diff --git a/packages/keychain/src/components/purchasenew/checkout/stripe/index.tsx b/packages/keychain/src/components/purchasenew/checkout/stripe/index.tsx index 60976e4b9..45b8b5512 100644 --- a/packages/keychain/src/components/purchasenew/checkout/stripe/index.tsx +++ b/packages/keychain/src/components/purchasenew/checkout/stripe/index.tsx @@ -11,8 +11,12 @@ import { useEffect } from "react"; export function StripeCheckout() { const { clearError, starterpackDetails } = useStarterpackContext(); - const { stripePromise, clientSecret, costDetails } = - useCreditPurchaseContext(); + const { + stripePromise, + clientSecret, + customerSessionClientSecret, + costDetails, + } = useCreditPurchaseContext(); const { navigate, setOnBackCallback } = useNavigation(); const isOnchainStarterpackCheckout = !!starterpackDetails && isOnchainStarterpack(starterpackDetails); @@ -60,7 +64,14 @@ export function StripeCheckout() { return ( ; isStripeLoading: boolean; @@ -67,6 +68,8 @@ export const CreditPurchaseProvider = ({ const [usdAmount, setUsdAmount] = useState(USD_AMOUNTS[0]); const [stripePaymentId, setStripePaymentId] = useState(); const [clientSecret, setClientSecret] = useState(); + const [customerSessionClientSecret, setCustomerSessionClientSecret] = + useState(); const [costDetails, setCostDetails] = useState(); const { @@ -127,6 +130,9 @@ export const CreditPurchaseProvider = ({ setStripePaymentId(paymentIntent.id); setClientSecret(paymentIntent.clientSecret); + setCustomerSessionClientSecret( + paymentIntent.customerSessionClientSecret ?? undefined, + ); setCostDetails( starterpackDetails && isOnchainStarterpack(starterpackDetails) ? getStarterpackStripeCostDetails(starterpackDetails.quote!, quantity) @@ -153,6 +159,7 @@ export const CreditPurchaseProvider = ({ useEffect(() => { setStripePaymentId(undefined); setClientSecret(undefined); + setCustomerSessionClientSecret(undefined); setCostDetails(undefined); }, [starterpackId]); @@ -161,6 +168,7 @@ export const CreditPurchaseProvider = ({ setUsdAmount, stripePaymentId, clientSecret, + customerSessionClientSecret, costDetails, stripePromise, isStripeLoading, diff --git a/packages/keychain/src/utils/api/generated.ts b/packages/keychain/src/utils/api/generated.ts index fdb08c36e..0c0e2b433 100644 --- a/packages/keychain/src/utils/api/generated.ts +++ b/packages/keychain/src/utils/api/generated.ts @@ -6360,6 +6360,7 @@ export type StripePayment = { export type StripePaymentIntent = { __typename?: "StripePaymentIntent"; clientSecret: Scalars["String"]; + customerSessionClientSecret?: Maybe; id: Scalars["ID"]; pricing: StripePricingDetails; }; @@ -7236,6 +7237,7 @@ export type CreateStripePaymentIntentMutation = { __typename?: "StripePaymentIntent"; id: string; clientSecret: string; + customerSessionClientSecret?: string | null; pricing: { __typename?: "StripePricingDetails"; baseCostInCents: number; @@ -7255,6 +7257,7 @@ export type CreateStripeStarterpackIntentMutation = { __typename?: "StripePaymentIntent"; id: string; clientSecret: string; + customerSessionClientSecret?: string | null; pricing: { __typename?: "StripePricingDetails"; baseCostInCents: number; @@ -7964,6 +7967,7 @@ export const CreateStripePaymentIntentDocument = ` createStripePaymentIntent(input: $input) { id clientSecret + customerSessionClientSecret pricing { baseCostInCents processingFeeInCents @@ -8001,6 +8005,7 @@ export const CreateStripeStarterpackIntentDocument = ` createStripeStarterpackIntent(input: $input) { id clientSecret + customerSessionClientSecret pricing { baseCostInCents processingFeeInCents diff --git a/packages/keychain/src/utils/api/payment.graphql b/packages/keychain/src/utils/api/payment.graphql index acc042b24..f79982628 100644 --- a/packages/keychain/src/utils/api/payment.graphql +++ b/packages/keychain/src/utils/api/payment.graphql @@ -45,6 +45,7 @@ mutation CreateStripePaymentIntent($input: CreateStripePaymentIntentInput!) { createStripePaymentIntent(input: $input) { id clientSecret + customerSessionClientSecret pricing { baseCostInCents processingFeeInCents @@ -59,6 +60,7 @@ mutation CreateStripeStarterpackIntent( createStripeStarterpackIntent(input: $input) { id clientSecret + customerSessionClientSecret pricing { baseCostInCents processingFeeInCents