feat: Improvements to payment module and Stripe provider (#10980)

* fix: Correctly parse Stripe error, remove unused method

* fix: Isolate the payment provider error check function

* fix: Allow passing few extra parameters to Stripe

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Stevche Radevski
2025-01-16 08:12:53 +01:00
committed by GitHub
parent 44cd0224af
commit f5235862c0
4 changed files with 62 additions and 96 deletions

View File

@@ -39,13 +39,13 @@ export abstract class AbstractPaymentProvider<TConfig = Record<string, unknown>>
static validateOptions(options: Record<any, any>): void | never {}
/**
* The constructor allows you to access resources from the [module's container](https://docs.medusajs.com/learn/fundamentals/modules/container)
* The constructor allows you to access resources from the [module's container](https://docs.medusajs.com/learn/fundamentals/modules/container)
* using the first parameter, and the module's options using the second parameter.
*
*
* :::note
*
*
* A module's options are passed when you register it in the Medusa application.
*
*
* :::
*
* @param {Record<string, unknown>} cradle - The module's container cradle used to resolve resources.
@@ -55,35 +55,35 @@ export abstract class AbstractPaymentProvider<TConfig = Record<string, unknown>>
* @example
* import { AbstractPaymentProvider } from "@medusajs/framework/utils"
* import { Logger } from "@medusajs/framework/types"
*
*
* type Options = {
* apiKey: string
* }
*
*
* type InjectedDependencies = {
* logger: Logger
* }
*
*
* class MyPaymentProviderService extends AbstractPaymentProvider<Options> {
* protected logger_: Logger
* protected options_: Options
* // assuming you're initializing a client
* protected client
*
*
* constructor(
* container: InjectedDependencies,
* options: Options
* ) {
* super(container, options)
*
*
* this.logger_ = container.logger
* this.options_ = options
*
*
* // TODO initialize your client
* }
* // ...
* }
*
*
* export default MyPaymentProviderService
*/
protected constructor(
@@ -697,16 +697,3 @@ export abstract class AbstractPaymentProvider<TConfig = Record<string, unknown>>
data: ProviderWebhookPayload["payload"]
): Promise<WebhookActionResult>
}
/**
* @ignore
*/
export function isPaymentProviderError(obj: any): obj is PaymentProviderError {
return (
obj &&
typeof obj === "object" &&
"error" in obj &&
"code" in obj &&
"detail" in obj
)
}