From 21997c7b648915a39b21edc944947362f1bee238 Mon Sep 17 00:00:00 2001 From: shij Date: Tue, 12 Nov 2024 09:32:04 +0800 Subject: [PATCH] fix(payment-stripe): expand payment method object --- .../payment-stripe/src/core/stripe-base.ts | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/modules/providers/payment-stripe/src/core/stripe-base.ts b/packages/modules/providers/payment-stripe/src/core/stripe-base.ts index 6bb034e104a2d..a210e4e9d1622 100644 --- a/packages/modules/providers/payment-stripe/src/core/stripe-base.ts +++ b/packages/modules/providers/payment-stripe/src/core/stripe-base.ts @@ -112,7 +112,7 @@ abstract class StripeBase extends AbstractPaymentProvider { : undefined, metadata: metadata as Stripe.MetadataParam, capture_method: this.options_.capture ? "automatic" : "manual", - expand: ["latest_charge"], + expand: ["latest_charge", "payment_method"], ...intentRequestData, } @@ -164,7 +164,7 @@ abstract class StripeBase extends AbstractPaymentProvider { try { const intent = await this.stripe_.paymentIntents.confirm(id, { payment_method: data.token, - expand: ["latest_charge"], + expand: ["latest_charge", "payment_method"], }) return { ...(await this.buildResponse(intent)), @@ -185,7 +185,7 @@ abstract class StripeBase extends AbstractPaymentProvider { const { id } = paymentSessionData as unknown as Stripe.PaymentIntent try { const intent = await this.stripe_.paymentIntents.cancel(id, { - expand: ["latest_charge"], + expand: ["latest_charge", "payment_method"], }) return { ...(await this.buildResponse(intent)), @@ -218,7 +218,7 @@ abstract class StripeBase extends AbstractPaymentProvider { ? getSmallestUnit(captureAmount, currency) : undefined, final_capture: false, - expand: ["latest_charge"], + expand: ["latest_charge", "payment_method"], }) return { ...(await this.buildResponse(intent)), @@ -262,7 +262,7 @@ abstract class StripeBase extends AbstractPaymentProvider { : undefined, }) const intent = await this.stripe_.paymentIntents.retrieve(id, { - expand: ["latest_charge"], + expand: ["latest_charge", "payment_method"], }) return { ...(await this.buildResponse(intent)), @@ -280,7 +280,7 @@ abstract class StripeBase extends AbstractPaymentProvider { const { id } = paymentSessionData as unknown as Stripe.PaymentIntent try { const intent = await this.stripe_.paymentIntents.retrieve(id, { - expand: ["latest_charge"], + expand: ["latest_charge", "payment_method"], }) return { ...(await this.buildResponse(intent)), @@ -351,7 +351,7 @@ abstract class StripeBase extends AbstractPaymentProvider { } const intent = await this.stripe_.paymentIntents.update(id, { ...updateParams, - expand: ["latest_charge"], + expand: ["latest_charge", "payment_method"], }) return { ...(await this.buildResponse(intent)), @@ -370,7 +370,10 @@ abstract class StripeBase extends AbstractPaymentProvider { let intent: Stripe.PaymentIntent if (event.data.object.object === "payment_intent") { - intent = event.data.object + intent = await this.stripe_.paymentIntents.retrieve( + event.data.object.id, + { expand: ["latest_charge", "payment_method"] } + ) } else if (event.data.object.object === "charge") { if (!event.data.object.payment_intent) { throw new Error( @@ -379,7 +382,7 @@ abstract class StripeBase extends AbstractPaymentProvider { } intent = await this.stripe_.paymentIntents.retrieve( event.data.object.payment_intent as string, - { expand: ["latest_charge"] } + { expand: ["latest_charge", "payment_method"] } ) } else if (event.data.object.object === "invoice") { // TODO