Skip to content

Commit

Permalink
fix(payment-stripe): expand payment method object
Browse files Browse the repository at this point in the history
  • Loading branch information
silenaker committed Nov 12, 2024
1 parent 29e896f commit 21997c7
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/modules/providers/payment-stripe/src/core/stripe-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
: undefined,
metadata: metadata as Stripe.MetadataParam,
capture_method: this.options_.capture ? "automatic" : "manual",
expand: ["latest_charge"],
expand: ["latest_charge", "payment_method"],
...intentRequestData,
}

Expand Down Expand Up @@ -164,7 +164,7 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
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)),
Expand All @@ -185,7 +185,7 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
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)),
Expand Down Expand Up @@ -218,7 +218,7 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
? getSmallestUnit(captureAmount, currency)
: undefined,
final_capture: false,
expand: ["latest_charge"],
expand: ["latest_charge", "payment_method"],
})
return {
...(await this.buildResponse(intent)),
Expand Down Expand Up @@ -262,7 +262,7 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
: undefined,
})
const intent = await this.stripe_.paymentIntents.retrieve(id, {
expand: ["latest_charge"],
expand: ["latest_charge", "payment_method"],
})
return {
...(await this.buildResponse(intent)),
Expand All @@ -280,7 +280,7 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
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)),
Expand Down Expand Up @@ -351,7 +351,7 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
}
const intent = await this.stripe_.paymentIntents.update(id, {
...updateParams,
expand: ["latest_charge"],
expand: ["latest_charge", "payment_method"],
})
return {
...(await this.buildResponse(intent)),
Expand All @@ -370,7 +370,10 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
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(
Expand All @@ -379,7 +382,7 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
}
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
Expand Down

0 comments on commit 21997c7

Please sign in to comment.