fix: Update stripe options input (#7919)

This commit is contained in:
Stevche Radevski
2024-07-03 12:51:38 +02:00
committed by GitHub
parent da645e4073
commit 19d7d01805
6 changed files with 53 additions and 49 deletions
@@ -23,7 +23,6 @@ import {
ErrorCodes,
ErrorIntentStatus,
PaymentIntentOptions,
StripeCredentials,
StripeOptions,
} from "../types"
import {
@@ -31,7 +30,7 @@ import {
getSmallestUnit,
} from "../utils/get-smallest-unit"
abstract class StripeBase extends AbstractPaymentProvider<StripeCredentials> {
abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
protected readonly options_: StripeOptions
protected stripe_: Stripe
protected container_: MedusaContainer
@@ -54,7 +53,7 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeCredentials> {
abstract get paymentIntentOptions(): PaymentIntentOptions
private validateOptions(options: StripeCredentials): void {
private validateOptions(options: StripeOptions): void {
if (!isDefined(options.apiKey)) {
throw new Error("Required option `apiKey` is missing in Stripe plugin")
}
@@ -114,7 +113,7 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeCredentials> {
const { currency_code, amount } = input
const description = (extra?.payment_description ??
this.options_?.payment_description) as string
this.options_?.paymentDescription) as string
const intentRequest: Stripe.PaymentIntentCreateParams = {
description,
@@ -125,7 +124,7 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeCredentials> {
...intentRequestData,
}
if (this.options_?.automatic_payment_methods) {
if (this.options_?.automaticPaymentMethods) {
intentRequest.automatic_payment_methods = { enabled: true }
}
@@ -1,22 +1,24 @@
export interface StripeCredentials {
apiKey: string
webhookSecret: string
}
export interface StripeOptions {
credentials: Record<string, StripeCredentials>
/**
* The API key for the Stripe account
*/
apiKey: string
/**
* The webhook secret used to verify webhooks
*/
webhookSecret: string
/**
* Use this flag to capture payment immediately (default is false)
*/
capture?: boolean
/**
* set `automatic_payment_methods` to `{ enabled: true }`
* set `automatic_payment_methods` on the intent request to `{ enabled: true }`
*/
automatic_payment_methods?: boolean
automaticPaymentMethods?: boolean
/**
* Set a default description on the intent if the context does not provide one
*/
payment_description?: string
paymentDescription?: string
}
export interface PaymentIntentOptions {