fix(stripe): Wrong container type (#10223)
RESOLVES SUP-238 **What** wrong container type withing payment providers
This commit is contained in:
1 parent
9d5b0412ec
commit
b964b45fb2
4 files changed
+16
-16
No files matched your search
@@ -1,8 +1,4 @@
|
|||||||
import {
|
import { EventBusTypes, InternalModuleDeclaration } from "@medusajs/types"
|
||||||
EventBusTypes,
|
|
||||||
InternalModuleDeclaration,
|
|
||||||
MedusaContainer,
|
|
||||||
} from "@medusajs/types"
|
|
||||||
import { ulid } from "ulid"
|
import { ulid } from "ulid"
|
||||||
|
|
||||||
export abstract class AbstractEventBusModuleService
|
export abstract class AbstractEventBusModuleService
|
||||||
@@ -23,7 +19,7 @@ export abstract class AbstractEventBusModuleService
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected constructor(
|
protected constructor(
|
||||||
container: MedusaContainer,
|
cradle: Record<string, unknown>,
|
||||||
moduleOptions = {},
|
moduleOptions = {},
|
||||||
moduleDeclaration: InternalModuleDeclaration
|
moduleDeclaration: InternalModuleDeclaration
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
CreatePaymentProviderSession,
|
CreatePaymentProviderSession,
|
||||||
IPaymentProvider,
|
IPaymentProvider,
|
||||||
MedusaContainer,
|
|
||||||
PaymentProviderError,
|
PaymentProviderError,
|
||||||
PaymentProviderSessionResponse,
|
PaymentProviderSessionResponse,
|
||||||
PaymentSessionStatus,
|
PaymentSessionStatus,
|
||||||
@@ -13,6 +12,7 @@ import {
|
|||||||
export abstract class AbstractPaymentProvider<TConfig = Record<string, unknown>>
|
export abstract class AbstractPaymentProvider<TConfig = Record<string, unknown>>
|
||||||
implements IPaymentProvider
|
implements IPaymentProvider
|
||||||
{
|
{
|
||||||
|
protected readonly container: Record<string, unknown>
|
||||||
/**
|
/**
|
||||||
* This method validates the options of the provider set in `medusa-config.ts`.
|
* This method validates the options of the provider set in `medusa-config.ts`.
|
||||||
* Implementing this method is optional. It's useful if your provider requires custom validation.
|
* Implementing this method is optional. It's useful if your provider requires custom validation.
|
||||||
@@ -43,7 +43,7 @@ export abstract class AbstractPaymentProvider<TConfig = Record<string, unknown>>
|
|||||||
*
|
*
|
||||||
* The provider can also access the module's options as a second parameter.
|
* The provider can also access the module's options as a second parameter.
|
||||||
*
|
*
|
||||||
* @param {MedusaContainer} container - The module's container used to resolve resources.
|
* @param {Record<string, unknown>} cradle - The module's container cradle used to resolve resources.
|
||||||
* @param {Record<string, unknown>} config - The options passed to the payment module provider.
|
* @param {Record<string, unknown>} config - The options passed to the payment module provider.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
@@ -92,9 +92,11 @@ export abstract class AbstractPaymentProvider<TConfig = Record<string, unknown>>
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
protected constructor(
|
protected constructor(
|
||||||
protected readonly container: MedusaContainer,
|
cradle: Record<string, unknown>,
|
||||||
protected readonly config: TConfig = {} as TConfig // eslint-disable-next-line @typescript-eslint/no-empty-function
|
protected readonly config: TConfig = {} as TConfig // eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
) {}
|
) {
|
||||||
|
this.container = cradle
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ export abstract class AbstractSearchService
|
|||||||
* Additionally, if you’re creating your search service as an external plugin to be installed on any Medusa backend and you want to access the options added for the plugin,
|
* Additionally, if you’re creating your search service as an external plugin to be installed on any Medusa backend and you want to access the options added for the plugin,
|
||||||
* you can access them in the constructor. The default constructor already sets the value of the class proeprty `options_` to the passed options.
|
* you can access them in the constructor. The default constructor already sets the value of the class proeprty `options_` to the passed options.
|
||||||
*
|
*
|
||||||
* @param {MedusaContainer} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend.
|
* @param {Record<string, unknown>} cradle - An container cradle that allows you to access other resources, such as services, in your Medusa backend.
|
||||||
* @param {Record<string, unknown>} options - If this search service is created in a plugin, the plugin's options are passed in this parameter.
|
* @param {Record<string, unknown>} options - If this search service is created in a plugin, the plugin's options are passed in this parameter.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
@@ -144,7 +144,7 @@ export abstract class AbstractSearchService
|
|||||||
* // ...
|
* // ...
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
protected constructor(container, options) {
|
protected constructor(cradle, options) {
|
||||||
this.options_ = options
|
this.options_ = options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import Stripe from "stripe"
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
CreatePaymentProviderSession,
|
CreatePaymentProviderSession,
|
||||||
MedusaContainer,
|
|
||||||
PaymentProviderError,
|
PaymentProviderError,
|
||||||
PaymentProviderSessionResponse,
|
PaymentProviderSessionResponse,
|
||||||
ProviderWebhookPayload,
|
ProviderWebhookPayload,
|
||||||
@@ -34,7 +33,7 @@ import {
|
|||||||
abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
|
abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
|
||||||
protected readonly options_: StripeOptions
|
protected readonly options_: StripeOptions
|
||||||
protected stripe_: Stripe
|
protected stripe_: Stripe
|
||||||
protected container_: MedusaContainer
|
protected container_: Record<string, unknown>
|
||||||
|
|
||||||
static validateOptions(options: StripeOptions): void {
|
static validateOptions(options: StripeOptions): void {
|
||||||
if (!isDefined(options.apiKey)) {
|
if (!isDefined(options.apiKey)) {
|
||||||
@@ -42,11 +41,14 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected constructor(container: MedusaContainer, options: StripeOptions) {
|
protected constructor(
|
||||||
|
cradle: Record<string, unknown>,
|
||||||
|
options: StripeOptions
|
||||||
|
) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
super(...arguments)
|
super(...arguments)
|
||||||
|
|
||||||
this.container_ = container
|
this.container_ = cradle
|
||||||
this.options_ = options
|
this.options_ = options
|
||||||
|
|
||||||
this.stripe_ = new Stripe(options.apiKey)
|
this.stripe_ = new Stripe(options.apiKey)
|
||||||
|
|||||||
Reference in new issue
Block a user