From d5f4d542fd1c22372d967ff8dc589d8b424be3f7 Mon Sep 17 00:00:00 2001 From: Phil Bennett Date: Fri, 30 Jan 2026 10:05:54 -0600 Subject: [PATCH 1/3] use full tax and discount data for confirm checkout --- .../utils/use-get-price-adjustments.ts | 10 +- .../checkout-buttons/express/godaddy.tsx | 99 ++-- .../checkout/taxes/utils/use-get-taxes.ts | 2 +- .../react/src/lib/godaddy/checkout-env.ts | 426 +++++++++++++++++- .../react/src/lib/godaddy/checkout-queries.ts | 176 +++----- packages/react/src/types.ts | 8 + 6 files changed, 545 insertions(+), 176 deletions(-) diff --git a/packages/react/src/components/checkout/discount/utils/use-get-price-adjustments.ts b/packages/react/src/components/checkout/discount/utils/use-get-price-adjustments.ts index eebfdf1a..94554048 100644 --- a/packages/react/src/components/checkout/discount/utils/use-get-price-adjustments.ts +++ b/packages/react/src/components/checkout/discount/utils/use-get-price-adjustments.ts @@ -3,7 +3,10 @@ import { useMutation } from '@tanstack/react-query'; import { useCheckoutContext } from '@/components/checkout/checkout'; import { useGoDaddyContext } from '@/godaddy-provider'; import { getDraftOrderPriceAdjustments } from '@/lib/godaddy/godaddy'; -import type { DraftOrderPriceAdjustmentsQueryInput } from '@/types'; +import type { + CalculatedAdjustments, + DraftOrderPriceAdjustmentsQueryInput, +} from '@/types'; type Vars = { discountCodes: DraftOrderPriceAdjustmentsQueryInput['discountCodes']; @@ -14,7 +17,7 @@ export function useGetPriceAdjustments() { const { session, jwt } = useCheckoutContext(); const { apiHost } = useGoDaddyContext(); - return useMutation({ + return useMutation({ mutationKey: [ 'get-price-adjustments-by-discount-code', session?.id ?? 'no-session', @@ -34,8 +37,7 @@ export function useGetPriceAdjustments() { apiHost ); - return data.checkoutSession?.draftOrder?.calculatedAdjustments - ?.totalDiscountAmount?.value; + return data.checkoutSession?.draftOrder?.calculatedAdjustments; }, }); } diff --git a/packages/react/src/components/checkout/payment/checkout-buttons/express/godaddy.tsx b/packages/react/src/components/checkout/payment/checkout-buttons/express/godaddy.tsx index 9f2c15e1..a8b6a9c6 100644 --- a/packages/react/src/components/checkout/payment/checkout-buttons/express/godaddy.tsx +++ b/packages/react/src/components/checkout/payment/checkout-buttons/express/godaddy.tsx @@ -47,6 +47,7 @@ import { TrackingEventType, track, } from '@/tracking/track'; +import type { CalculatedAdjustments, CalculatedTaxes } from '@/types'; export function ExpressCheckoutButton() { const formatCurrency = useFormatCurrency(); @@ -60,7 +61,10 @@ export function ExpressCheckoutButton() { undefined ); const [error, setError] = useState(''); - const [priceAdjustment, setPriceAdjustment] = useState(null); + const [calculatedAdjustments, setCalculatedAdjustments] = + useState(null); + const [calculatedTaxes, setCalculatedTaxes] = + useState(null); const [appliedCouponCode, setAppliedCouponCode] = useState( null ); @@ -177,7 +181,7 @@ export function ExpressCheckoutButton() { let expressRequest = { ...poyntExpressRequest }; // If there's an applied coupon code and price adjustment, add it to the request - if (appliedCouponCode && priceAdjustment !== null) { + if (appliedCouponCode && calculatedAdjustments?.totalDiscountAmount) { // console.log("[poynt collect] Adding discount to express request", { // appliedCouponCode, // priceAdjustment, @@ -189,7 +193,7 @@ export function ExpressCheckoutButton() { updatedLineItems.push({ label: t.totals.discount, amount: formatCurrency({ - amount: -priceAdjustment, + amount: -(calculatedAdjustments?.totalDiscountAmount?.value || 0), currencyCode, inputInMinorUnits: true, returnRaw: true, @@ -199,7 +203,8 @@ export function ExpressCheckoutButton() { // Calculate the correct total in minor units const totalInMinorUnits = - (totals?.subTotal?.value || 0) - priceAdjustment; + (totals?.subTotal?.value || 0) - + (calculatedAdjustments?.totalDiscountAmount?.value || 0); const totalAmount = formatCurrency({ amount: totalInMinorUnits, @@ -220,7 +225,7 @@ export function ExpressCheckoutButton() { code: appliedCouponCode, label: t.totals.discount, amount: formatCurrency({ - amount: -priceAdjustment, + amount: -(calculatedAdjustments?.totalDiscountAmount?.value || 0), currencyCode, inputInMinorUnits: true, returnRaw: true, @@ -270,7 +275,7 @@ export function ExpressCheckoutButton() { [ poyntExpressRequest, appliedCouponCode, - priceAdjustment, + calculatedAdjustments, t, setCheckoutErrors, ] @@ -322,7 +327,7 @@ export function ExpressCheckoutButton() { if (result) { setAppliedCouponCode(discountCodes?.[0]); - setPriceAdjustment(result); + setCalculatedAdjustments(result); } } // Mark the fetch as complete regardless of whether there were discounts @@ -355,12 +360,12 @@ export function ExpressCheckoutButton() { let couponConfig: | { code: string; label: string; amount: string } | undefined; - if (priceAdjustment && appliedCouponCode) { + if (calculatedAdjustments?.totalDiscountAmount && appliedCouponCode) { couponConfig = { code: appliedCouponCode, label: t.totals.discount, amount: formatCurrency({ - amount: priceAdjustment, + amount: calculatedAdjustments?.totalDiscountAmount?.value || 0, currencyCode, inputInMinorUnits: true, returnRaw: true, @@ -392,7 +397,7 @@ export function ExpressCheckoutButton() { session, isPoyntLoaded, isCollectLoading, - priceAdjustment, + calculatedAdjustments, appliedCouponCode, draftOrder, couponFetchStatus, @@ -550,7 +555,7 @@ export function ExpressCheckoutButton() { if (!couponCode) { // User removed the coupon code setAppliedCouponCode(null); - setPriceAdjustment(null); + setCalculatedAdjustments(null); // Add shipping and taxes if they exist const finalLineItems = [...baseLineItems]; @@ -621,14 +626,16 @@ export function ExpressCheckoutButton() { } // Call the price adjustments mutation with the new coupon code - const adjustment = await getPriceAdjustments.mutateAsync({ + const adjustments = await getPriceAdjustments.mutateAsync({ discountCodes: [couponCode], shippingLines, }); - if (adjustment) { + if (adjustments?.totalDiscountAmount?.value) { setAppliedCouponCode(couponCode); - setPriceAdjustment(adjustment); + setCalculatedAdjustments(adjustments); + + const adjustmentValue = adjustments.totalDiscountAmount.value; // Build line items with shipping, taxes, and the new discount const finalLineItems = [...baseLineItems]; @@ -661,7 +668,7 @@ export function ExpressCheckoutButton() { finalLineItems.push({ label: t.totals.discount, amount: formatCurrency({ - amount: -adjustment, + amount: -adjustmentValue, currencyCode, inputInMinorUnits: true, returnRaw: true, @@ -673,7 +680,7 @@ export function ExpressCheckoutButton() { (totals?.subTotal?.value || 0) + godaddyTotals.shipping.value + godaddyTotals.taxes.value - - adjustment; + adjustmentValue; const totalAmount = formatCurrency({ amount: totalInMinorUnits, @@ -692,7 +699,7 @@ export function ExpressCheckoutButton() { code: couponCode, label: t.totals.discount, amount: formatCurrency({ - amount: -adjustment, + amount: -adjustmentValue, currencyCode, inputInMinorUnits: true, returnRaw: true, @@ -766,14 +773,8 @@ export function ExpressCheckoutButton() { shippingTotal: godaddyTotals.shipping, } : {}), - ...(godaddyTotals.taxes - ? { - taxTotal: { - value: godaddyTotals.taxes.value, - currencyCode: godaddyTotals.taxes.currencyCode, - }, - } - : {}), + ...(calculatedTaxes ? { calculatedTaxes } : {}), + ...(calculatedAdjustments ? { calculatedAdjustments } : {}), ...(event?.billingAddress ? { billing: { @@ -958,10 +959,10 @@ export function ExpressCheckoutButton() { shippingLines, }); - if (newAdjustments) { - setPriceAdjustment(newAdjustments); + if (newAdjustments?.totalDiscountAmount) { + setCalculatedAdjustments(newAdjustments); } else { - setPriceAdjustment(null); + setCalculatedAdjustments(null); setAppliedCouponCode(''); } } catch (err) { @@ -988,11 +989,14 @@ export function ExpressCheckoutButton() { shippingAmount || '0' ); - if (taxesResult?.value) { + if (taxesResult?.totalTaxAmount?.value) { + // Store the full tax calculation response + setCalculatedTaxes(taxesResult); + poyntLineItems.push({ label: t.totals.estimatedTaxes, amount: formatCurrency({ - amount: taxesResult.value, + amount: taxesResult.totalTaxAmount.value, currencyCode, inputInMinorUnits: true, returnRaw: true, @@ -1003,7 +1007,7 @@ export function ExpressCheckoutButton() { ...value, taxes: { currencyCode: currencyCode, - value: taxesResult.value || 0, + value: taxesResult.totalTaxAmount.value || 0, }, })); } @@ -1024,11 +1028,11 @@ export function ExpressCheckoutButton() { } // Add discount line if a coupon is applied - if (priceAdjustment && appliedCouponCode) { + if (calculatedAdjustments?.totalDiscountAmount && appliedCouponCode) { poyntLineItems.push({ label: t.totals.discount, amount: formatCurrency({ - amount: -priceAdjustment, + amount: -(calculatedAdjustments?.totalDiscountAmount?.value || 0), currencyCode, inputInMinorUnits: true, returnRaw: true, @@ -1057,12 +1061,12 @@ export function ExpressCheckoutButton() { }; // Add coupon code to the request if one is applied - if (appliedCouponCode && priceAdjustment !== null) { + if (appliedCouponCode && calculatedAdjustments?.totalDiscountAmount) { updatedOrder.couponCode = { code: appliedCouponCode, label: t.totals.discount, amount: formatCurrency({ - amount: -priceAdjustment, + amount: -(calculatedAdjustments?.totalDiscountAmount?.value || 0), currencyCode, inputInMinorUnits: true, returnRaw: true, @@ -1126,10 +1130,10 @@ export function ExpressCheckoutButton() { shippingLines, }); - if (newAdjustments) { - setPriceAdjustment(newAdjustments); + if (newAdjustments?.totalDiscountAmount) { + setCalculatedAdjustments(newAdjustments); } else { - setPriceAdjustment(null); + setCalculatedAdjustments(null); setAppliedCouponCode(''); } } catch (err) { @@ -1174,11 +1178,14 @@ export function ExpressCheckoutButton() { // console.log("[poynt collect] Taxes result", { taxesResult }); - if (taxesResult?.value) { + if (taxesResult?.totalTaxAmount?.value) { + // Store the full tax calculation response + setCalculatedTaxes(taxesResult); + poyntLineItems.push({ label: t.totals.estimatedTaxes, amount: formatCurrency({ - amount: taxesResult.value, + amount: taxesResult.totalTaxAmount.value, currencyCode, inputInMinorUnits: true, returnRaw: true, @@ -1189,7 +1196,7 @@ export function ExpressCheckoutButton() { ...value, taxes: { currencyCode: currencyCode, - value: taxesResult.value || 0, + value: taxesResult.totalTaxAmount.value || 0, }, })); } @@ -1213,11 +1220,11 @@ export function ExpressCheckoutButton() { } // Add discount line if a coupon is applied - if (priceAdjustment && appliedCouponCode) { + if (calculatedAdjustments?.totalDiscountAmount && appliedCouponCode) { poyntLineItems.push({ label: t.totals.discount, amount: formatCurrency({ - amount: -priceAdjustment, + amount: -(calculatedAdjustments?.totalDiscountAmount?.value || 0), currencyCode, inputInMinorUnits: true, returnRaw: true, @@ -1247,12 +1254,12 @@ export function ExpressCheckoutButton() { }; // Add coupon code to the request if one is applied - if (appliedCouponCode && priceAdjustment !== null) { + if (appliedCouponCode && calculatedAdjustments?.totalDiscountAmount) { updatedOrder.couponCode = { code: appliedCouponCode, label: appliedCouponCode || 'Discount', amount: formatCurrency({ - amount: -priceAdjustment, + amount: -(calculatedAdjustments?.totalDiscountAmount?.value || 0), currencyCode, inputInMinorUnits: true, returnRaw: true, @@ -1296,7 +1303,7 @@ export function ExpressCheckoutButton() { getSortedShippingMethods, convertAddressToShippingLines, getPriceAdjustments.mutateAsync, - priceAdjustment, + calculatedAdjustments, appliedCouponCode, t, form, diff --git a/packages/react/src/components/checkout/taxes/utils/use-get-taxes.ts b/packages/react/src/components/checkout/taxes/utils/use-get-taxes.ts index 5870cb1e..a784fe5a 100644 --- a/packages/react/src/components/checkout/taxes/utils/use-get-taxes.ts +++ b/packages/react/src/components/checkout/taxes/utils/use-get-taxes.ts @@ -29,7 +29,7 @@ export function useGetTaxes() { ) : await getDraftOrderTaxes(session, { destination, lines }, apiHost); - return data.checkoutSession?.draftOrder?.calculatedTaxes?.totalTaxAmount; + return data.checkoutSession?.draftOrder?.calculatedTaxes; }, }); } diff --git a/packages/react/src/lib/godaddy/checkout-env.ts b/packages/react/src/lib/godaddy/checkout-env.ts index 2221205f..8a248eb9 100644 --- a/packages/react/src/lib/godaddy/checkout-env.ts +++ b/packages/react/src/lib/godaddy/checkout-env.ts @@ -900,6 +900,71 @@ const introspection = { }, ], }, + { + kind: 'INPUT_OBJECT', + name: 'CalculatedAdjustmentDetailsInput', + inputFields: [ + { + name: 'description', + type: { + kind: 'SCALAR', + name: 'String', + }, + }, + { + name: 'id', + type: { + kind: 'SCALAR', + name: 'String', + }, + }, + { + name: 'label', + type: { + kind: 'SCALAR', + name: 'String', + }, + }, + { + name: 'name', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'SCALAR', + name: 'String', + }, + }, + }, + ], + isOneOf: false, + }, + { + kind: 'INPUT_OBJECT', + name: 'CalculatedAdjustmentInput', + inputFields: [ + { + name: 'adjustment', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'CalculatedAdjustmentDetailsInput', + }, + }, + }, + { + name: 'totalAmount', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'MoneyInput', + }, + }, + }, + ], + isOneOf: false, + }, { kind: 'OBJECT', name: 'CalculatedAdjustmentOutput', @@ -925,6 +990,59 @@ const introspection = { ], interfaces: [], }, + { + kind: 'INPUT_OBJECT', + name: 'CalculatedAdjustmentsInput', + inputFields: [ + { + name: 'adjustments', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'LIST', + ofType: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'CalculatedAdjustmentInput', + }, + }, + }, + }, + }, + { + name: 'lines', + type: { + kind: 'LIST', + ofType: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'CalculatedLineInput', + }, + }, + }, + }, + { + name: 'totalDiscountAmount', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'MoneyInput', + }, + }, + }, + { + name: 'totalFeeAmount', + type: { + kind: 'INPUT_OBJECT', + name: 'MoneyInput', + }, + }, + ], + isOneOf: false, + }, { kind: 'OBJECT', name: 'CalculatedDiscount', @@ -1029,6 +1147,53 @@ const introspection = { ], interfaces: [], }, + { + kind: 'INPUT_OBJECT', + name: 'CalculatedLineInput', + inputFields: [ + { + name: 'adjustments', + type: { + kind: 'LIST', + ofType: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'CalculatedAdjustmentInput', + }, + }, + }, + }, + { + name: 'calculationLine', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'CalculationLineInput', + }, + }, + }, + { + name: 'totalDiscountAmount', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'MoneyInput', + }, + }, + }, + { + name: 'totalFeeAmount', + type: { + kind: 'INPUT_OBJECT', + name: 'MoneyInput', + }, + }, + ], + isOneOf: false, + }, { kind: 'OBJECT', name: 'CalculatedLineOutput', @@ -1078,6 +1243,79 @@ const introspection = { ], interfaces: [], }, + { + kind: 'INPUT_OBJECT', + name: 'CalculatedTaxesInput', + inputFields: [ + { + name: 'lines', + type: { + kind: 'LIST', + ofType: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'TaxCalculatedLineInput', + }, + }, + }, + }, + { + name: 'taxAmounts', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'LIST', + ofType: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'TaxAmountInput', + }, + }, + }, + }, + }, + { + name: 'totalTaxAmount', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'MoneyInput', + }, + }, + }, + ], + isOneOf: false, + }, + { + kind: 'INPUT_OBJECT', + name: 'CalculationLineInput', + inputFields: [ + { + name: 'id', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'SCALAR', + name: 'String', + }, + }, + }, + { + name: 'type', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'SCALAR', + name: 'String', + }, + }, + }, + ], + isOneOf: false, + }, { kind: 'OBJECT', name: 'CalculationLineOutput', @@ -6823,6 +7061,20 @@ const introspection = { name: 'ConfirmCheckoutBillingInfoInput', }, }, + { + name: 'calculatedAdjustments', + type: { + kind: 'INPUT_OBJECT', + name: 'CalculatedAdjustmentsInput', + }, + }, + { + name: 'calculatedTaxes', + type: { + kind: 'INPUT_OBJECT', + name: 'CalculatedTaxesInput', + }, + }, { name: 'fulfillmentEndAt', type: { @@ -6908,13 +7160,6 @@ const introspection = { name: 'MoneyInput', }, }, - { - name: 'taxTotal', - type: { - kind: 'INPUT_OBJECT', - name: 'MoneyInput', - }, - }, ], isOneOf: false, }, @@ -9421,6 +9666,93 @@ const introspection = { kind: 'SCALAR', name: 'String', }, + { + kind: 'INPUT_OBJECT', + name: 'TaxAmountInput', + inputFields: [ + { + name: 'rate', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'TaxRateInput', + }, + }, + }, + { + name: 'totalTaxAmount', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'MoneyInput', + }, + }, + }, + ], + isOneOf: false, + }, + { + kind: 'INPUT_OBJECT', + name: 'TaxCalculatedLineInput', + inputFields: [ + { + name: 'calculationLine', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'TaxCalculationLineInput', + }, + }, + }, + { + name: 'taxAmounts', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'LIST', + ofType: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'TaxAmountInput', + }, + }, + }, + }, + }, + { + name: 'totalTaxAmount', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'INPUT_OBJECT', + name: 'MoneyInput', + }, + }, + }, + ], + isOneOf: false, + }, + { + kind: 'INPUT_OBJECT', + name: 'TaxCalculationLineInput', + inputFields: [ + { + name: 'id', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'SCALAR', + name: 'String', + }, + }, + }, + ], + isOneOf: false, + }, { kind: 'INPUT_OBJECT', name: 'TaxDestinationAddressInput', @@ -9645,6 +9977,86 @@ const introspection = { ], isOneOf: false, }, + { + kind: 'INPUT_OBJECT', + name: 'TaxRateInput', + inputFields: [ + { + name: 'calculationMethod', + type: { + kind: 'NON_NULL', + ofType: { + kind: 'SCALAR', + name: 'String', + }, + }, + }, + { + name: 'id', + type: { + kind: 'SCALAR', + name: 'String', + }, + }, + { + name: 'label', + type: { + kind: 'SCALAR', + name: 'String', + }, + }, + { + name: 'name', + type: { + kind: 'SCALAR', + name: 'String', + }, + }, + { + name: 'value', + type: { + kind: 'INPUT_OBJECT', + name: 'TaxRateValueInput', + }, + }, + ], + isOneOf: false, + }, + { + kind: 'INPUT_OBJECT', + name: 'TaxRateValueInput', + inputFields: [ + { + name: 'amount', + type: { + kind: 'INPUT_OBJECT', + name: 'MoneyInput', + }, + }, + { + name: 'appliedAmount', + type: { + kind: 'INPUT_OBJECT', + name: 'MoneyInput', + }, + }, + { + name: 'appliedPercentage', + type: { + kind: 'SCALAR', + name: 'Float', + }, + }, + { + name: 'percentage', + type: { + kind: 'SCALAR', + name: 'String', + }, + }, + ], + isOneOf: false, + }, { kind: 'UNION', name: 'Transaction', diff --git a/packages/react/src/lib/godaddy/checkout-queries.ts b/packages/react/src/lib/godaddy/checkout-queries.ts index 2bc09620..5b9d6465 100644 --- a/packages/react/src/lib/godaddy/checkout-queries.ts +++ b/packages/react/src/lib/godaddy/checkout-queries.ts @@ -584,128 +584,68 @@ export const DraftOrderPriceAdjustmentsQuery = graphql(` draftOrder { id calculatedAdjustments(discountCodes: $discountCodes, shippingLines: $shippingLines) { -# adjustments { -# adjustment { -# ... on CalculatedDiscount { -# description -# id -# label -# name -# value { -# ... on AdjustmentAmount { -# amount { -# currencyCode -# value -# } -# } -# ... on AdjustmentPercentage { -# maximumAmount { -# currencyCode -# value -# } -# percentage -# } -# } -# } -# ... on CalculatedFee { -# description -# id -# label -# name -# value { -# ... on AdjustmentAmount { -# amount { -# currencyCode -# value -# } -# } -# ... on AdjustmentPercentage { -# maximumAmount { -# currencyCode -# value -# } -# percentage -# } -# } -# } -# } -# totalAmount { -# currencyCode -# value -# } -# } -# lines { -# adjustments { -# adjustment { -# ... on CalculatedDiscount { -# description -# id -# label -# name -# value { -# ... on AdjustmentAmount { -# amount { -# currencyCode -# value -# } -# } -# ... on AdjustmentPercentage { -# maximumAmount { -# currencyCode -# value -# } -# percentage -# } -# } -# } -# ... on CalculatedFee { -# description -# id -# label -# name -# value { -# ... on AdjustmentAmount { -# amount { -# currencyCode -# value -# } -# } -# ... on AdjustmentPercentage { -# maximumAmount { -# currencyCode -# value -# } -# percentage -# } -# } -# } -# } -# totalAmount { -# currencyCode -# value -# } -# } -# calculationLine { -# id -# type -# } -# totalDiscountAmount { -# currencyCode -# value -# } -# totalFeeAmount { -# currencyCode -# value -# } -# } + adjustments { + adjustment { + ... on CalculatedDiscount { + description + id + label + name + } + ... on CalculatedFee { + description + id + label + name + } + } + totalAmount { + currencyCode + value + } + } + lines { + calculationLine { + id + type + } + adjustments { + adjustment { + ... on CalculatedDiscount { + description + id + label + name + } + ... on CalculatedFee { + description + id + label + name + } + } + totalAmount { + currencyCode + value + } + } + totalDiscountAmount { + currencyCode + value + } + totalFeeAmount { + currencyCode + value + } + } totalDiscountAmount { currencyCode value } -# totalFeeAmount { -# currencyCode -# value -# } + totalFeeAmount { + currencyCode + value + } } } } diff --git a/packages/react/src/types.ts b/packages/react/src/types.ts index 2cfc2edd..920c95b8 100644 --- a/packages/react/src/types.ts +++ b/packages/react/src/types.ts @@ -173,6 +173,14 @@ export type DraftOrderPriceAdjustmentsQueryInput = VariablesOf< typeof DraftOrderPriceAdjustmentsQuery >; +export type CalculatedAdjustments = NonNullable< + ConfirmCheckoutMutationInput['input']['calculatedAdjustments'] +>; + +export type CalculatedTaxes = NonNullable< + ConfirmCheckoutMutationInput['input']['calculatedTaxes'] +>; + export type GetCheckoutSessionTaxesInput = VariablesOf< typeof DraftOrderTaxesQuery >; From 971c3abdbbd247cbed6b2eb55e0248e9e7f281d7 Mon Sep 17 00:00:00 2001 From: Phil Bennett Date: Mon, 2 Feb 2026 16:09:32 -0600 Subject: [PATCH 2/3] fix tax and discount input types --- .../checkout-buttons/express/godaddy.tsx | 6 +- .../react/src/lib/godaddy/checkout-env.ts | 146 ++++++------------ 2 files changed, 49 insertions(+), 103 deletions(-) diff --git a/packages/react/src/components/checkout/payment/checkout-buttons/express/godaddy.tsx b/packages/react/src/components/checkout/payment/checkout-buttons/express/godaddy.tsx index a8b6a9c6..2db20949 100644 --- a/packages/react/src/components/checkout/payment/checkout-buttons/express/godaddy.tsx +++ b/packages/react/src/components/checkout/payment/checkout-buttons/express/godaddy.tsx @@ -996,7 +996,7 @@ export function ExpressCheckoutButton() { poyntLineItems.push({ label: t.totals.estimatedTaxes, amount: formatCurrency({ - amount: taxesResult.totalTaxAmount.value, + amount: taxesResult?.totalTaxAmount?.value, currencyCode, inputInMinorUnits: true, returnRaw: true, @@ -1007,7 +1007,7 @@ export function ExpressCheckoutButton() { ...value, taxes: { currencyCode: currencyCode, - value: taxesResult.totalTaxAmount.value || 0, + value: taxesResult?.totalTaxAmount?.value || 0, }, })); } @@ -1196,7 +1196,7 @@ export function ExpressCheckoutButton() { ...value, taxes: { currencyCode: currencyCode, - value: taxesResult.totalTaxAmount.value || 0, + value: taxesResult?.totalTaxAmount?.value || 0, }, })); } diff --git a/packages/react/src/lib/godaddy/checkout-env.ts b/packages/react/src/lib/godaddy/checkout-env.ts index 8a248eb9..ec35cfb2 100644 --- a/packages/react/src/lib/godaddy/checkout-env.ts +++ b/packages/react/src/lib/godaddy/checkout-env.ts @@ -928,11 +928,8 @@ const introspection = { { name: 'name', type: { - kind: 'NON_NULL', - ofType: { - kind: 'SCALAR', - name: 'String', - }, + kind: 'SCALAR', + name: 'String', }, }, ], @@ -945,21 +942,15 @@ const introspection = { { name: 'adjustment', type: { - kind: 'NON_NULL', - ofType: { - kind: 'INPUT_OBJECT', - name: 'CalculatedAdjustmentDetailsInput', - }, + kind: 'INPUT_OBJECT', + name: 'CalculatedAdjustmentDetailsInput', }, }, { name: 'totalAmount', type: { - kind: 'NON_NULL', - ofType: { - kind: 'INPUT_OBJECT', - name: 'MoneyInput', - }, + kind: 'INPUT_OBJECT', + name: 'UpdateMoneyInput', }, }, ], @@ -997,15 +988,12 @@ const introspection = { { name: 'adjustments', type: { - kind: 'NON_NULL', + kind: 'LIST', ofType: { - kind: 'LIST', + kind: 'NON_NULL', ofType: { - kind: 'NON_NULL', - ofType: { - kind: 'INPUT_OBJECT', - name: 'CalculatedAdjustmentInput', - }, + kind: 'INPUT_OBJECT', + name: 'CalculatedAdjustmentInput', }, }, }, @@ -1026,18 +1014,15 @@ const introspection = { { name: 'totalDiscountAmount', type: { - kind: 'NON_NULL', - ofType: { - kind: 'INPUT_OBJECT', - name: 'MoneyInput', - }, + kind: 'INPUT_OBJECT', + name: 'UpdateMoneyInput', }, }, { name: 'totalFeeAmount', type: { kind: 'INPUT_OBJECT', - name: 'MoneyInput', + name: 'UpdateMoneyInput', }, }, ], @@ -1167,28 +1152,22 @@ const introspection = { { name: 'calculationLine', type: { - kind: 'NON_NULL', - ofType: { - kind: 'INPUT_OBJECT', - name: 'CalculationLineInput', - }, + kind: 'INPUT_OBJECT', + name: 'CalculationLineInput', }, }, { name: 'totalDiscountAmount', type: { - kind: 'NON_NULL', - ofType: { - kind: 'INPUT_OBJECT', - name: 'MoneyInput', - }, + kind: 'INPUT_OBJECT', + name: 'UpdateMoneyInput', }, }, { name: 'totalFeeAmount', type: { kind: 'INPUT_OBJECT', - name: 'MoneyInput', + name: 'UpdateMoneyInput', }, }, ], @@ -1263,15 +1242,12 @@ const introspection = { { name: 'taxAmounts', type: { - kind: 'NON_NULL', + kind: 'LIST', ofType: { - kind: 'LIST', + kind: 'NON_NULL', ofType: { - kind: 'NON_NULL', - ofType: { - kind: 'INPUT_OBJECT', - name: 'TaxAmountInput', - }, + kind: 'INPUT_OBJECT', + name: 'TaxAmountInput', }, }, }, @@ -1279,11 +1255,8 @@ const introspection = { { name: 'totalTaxAmount', type: { - kind: 'NON_NULL', - ofType: { - kind: 'INPUT_OBJECT', - name: 'MoneyInput', - }, + kind: 'INPUT_OBJECT', + name: 'UpdateMoneyInput', }, }, ], @@ -1296,21 +1269,15 @@ const introspection = { { name: 'id', type: { - kind: 'NON_NULL', - ofType: { - kind: 'SCALAR', - name: 'String', - }, + kind: 'SCALAR', + name: 'String', }, }, { name: 'type', type: { - kind: 'NON_NULL', - ofType: { - kind: 'SCALAR', - name: 'String', - }, + kind: 'SCALAR', + name: 'String', }, }, ], @@ -9673,21 +9640,15 @@ const introspection = { { name: 'rate', type: { - kind: 'NON_NULL', - ofType: { - kind: 'INPUT_OBJECT', - name: 'TaxRateInput', - }, + kind: 'INPUT_OBJECT', + name: 'TaxRateInput', }, }, { name: 'totalTaxAmount', type: { - kind: 'NON_NULL', - ofType: { - kind: 'INPUT_OBJECT', - name: 'MoneyInput', - }, + kind: 'INPUT_OBJECT', + name: 'UpdateMoneyInput', }, }, ], @@ -9700,25 +9661,19 @@ const introspection = { { name: 'calculationLine', type: { - kind: 'NON_NULL', - ofType: { - kind: 'INPUT_OBJECT', - name: 'TaxCalculationLineInput', - }, + kind: 'INPUT_OBJECT', + name: 'TaxCalculationLineInput', }, }, { name: 'taxAmounts', type: { - kind: 'NON_NULL', + kind: 'LIST', ofType: { - kind: 'LIST', + kind: 'NON_NULL', ofType: { - kind: 'NON_NULL', - ofType: { - kind: 'INPUT_OBJECT', - name: 'TaxAmountInput', - }, + kind: 'INPUT_OBJECT', + name: 'TaxAmountInput', }, }, }, @@ -9726,11 +9681,8 @@ const introspection = { { name: 'totalTaxAmount', type: { - kind: 'NON_NULL', - ofType: { - kind: 'INPUT_OBJECT', - name: 'MoneyInput', - }, + kind: 'INPUT_OBJECT', + name: 'UpdateMoneyInput', }, }, ], @@ -9743,11 +9695,8 @@ const introspection = { { name: 'id', type: { - kind: 'NON_NULL', - ofType: { - kind: 'SCALAR', - name: 'String', - }, + kind: 'SCALAR', + name: 'String', }, }, ], @@ -9984,11 +9933,8 @@ const introspection = { { name: 'calculationMethod', type: { - kind: 'NON_NULL', - ofType: { - kind: 'SCALAR', - name: 'String', - }, + kind: 'SCALAR', + name: 'String', }, }, { @@ -10030,14 +9976,14 @@ const introspection = { name: 'amount', type: { kind: 'INPUT_OBJECT', - name: 'MoneyInput', + name: 'UpdateMoneyInput', }, }, { name: 'appliedAmount', type: { kind: 'INPUT_OBJECT', - name: 'MoneyInput', + name: 'UpdateMoneyInput', }, }, { From e979691148bb1f711c87516e80c74db806c84c7a Mon Sep 17 00:00:00 2001 From: Phil Bennett Date: Tue, 3 Feb 2026 10:50:57 -0600 Subject: [PATCH 3/3] add changeset --- .changeset/two-ducks-enter.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/two-ducks-enter.md diff --git a/.changeset/two-ducks-enter.md b/.changeset/two-ducks-enter.md new file mode 100644 index 00000000..74b5259f --- /dev/null +++ b/.changeset/two-ducks-enter.md @@ -0,0 +1,5 @@ +--- +"@godaddy/react": patch +--- + +Send new tax, price adjustment, and shipping data to express checkout confirmation