diff --git a/packages/core/utils/src/fulfillment/provider.ts b/packages/core/utils/src/fulfillment/provider.ts index 22582d2ccb98a..1e5e326457f16 100644 --- a/packages/core/utils/src/fulfillment/provider.ts +++ b/packages/core/utils/src/fulfillment/provider.ts @@ -48,6 +48,8 @@ import { * * this.logger_ = logger * this.options_ = options + * + * // TODO initialize your client * } * } * diff --git a/packages/core/utils/src/payment/abstract-payment-provider.ts b/packages/core/utils/src/payment/abstract-payment-provider.ts index 7709e2ea4fa6e..56f995fdda33c 100644 --- a/packages/core/utils/src/payment/abstract-payment-provider.ts +++ b/packages/core/utils/src/payment/abstract-payment-provider.ts @@ -39,60 +39,52 @@ export abstract class AbstractPaymentProvider> static validateOptions(options: Record): void | never {} /** - * You can use the `constructor` of the provider's service to access resources in your module's container. - * - * You can also use the constructor to initialize your integration with the third-party provider. For example, if you use a client to connect to the third-party provider’s APIs, - * you can initialize it in the constructor and use it in other methods in the service. - * - * The provider can also access the module's options as a second parameter. + * 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} cradle - The module's container cradle used to resolve resources. * @param {Record} config - The options passed to the Payment Module provider. + * @typeParam TConfig - The type of the provider's options passed as a second parameter. * * @example - * ```ts - * import { - * AbstractPaymentProvider - * } from "@medusajs/framework/utils" + * import { AbstractPaymentProvider } from "@medusajs/framework/utils" * import { Logger } from "@medusajs/framework/types" - * - * type InjectedDependencies = { - * logger: Logger - * } - * + * * type Options = { * apiKey: string * } - * - * class MyPaymentProviderService extends AbstractPaymentProvider< - * Options - * > { - * static identifier = "my-payment" + * + * type InjectedDependencies = { + * logger: Logger + * } + * + * class MyPaymentProviderService extends AbstractPaymentProvider { * protected logger_: Logger * protected options_: Options - * // Assuming you're using a client to integrate - * // with a third-party service + * // assuming you're initializing a client * protected client - * + * * constructor( - * { logger }: InjectedDependencies, + * container: InjectedDependencies, * options: Options * ) { - * // @ts-ignore - * super(...arguments) - * - * this.logger_ = logger + * super(container, options) + * + * this.logger_ = container.logger * this.options_ = options - * - * // Assuming you're initializing a client - * this.client = new Client(options) + * + * // TODO initialize your client * } - * * // ... * } - * + * * export default MyPaymentProviderService - * ``` */ protected constructor( cradle: Record, @@ -175,6 +167,7 @@ export abstract class AbstractPaymentProvider> * const externalId = paymentData.id * * try { + * // assuming you have a client that captures the payment * const newData = await this.client.capturePayment(externalId) * * return { @@ -237,6 +230,7 @@ export abstract class AbstractPaymentProvider> * const externalId = paymentSessionData.id * * try { + * // assuming you have a client that authorizes the payment * const paymentData = await this.client.authorizePayment(externalId) * * return { @@ -299,6 +293,7 @@ export abstract class AbstractPaymentProvider> * const externalId = paymentData.id * * try { + * // assuming you have a client that cancels the payment * const paymentData = await this.client.cancelPayment(externalId) * } catch (e) { * return { @@ -345,6 +340,7 @@ export abstract class AbstractPaymentProvider> * } = context * * try { + * // assuming you have a client that initializes the payment * const response = await this.client.init( * amount, currency_code, customerDetails * ) @@ -399,6 +395,7 @@ export abstract class AbstractPaymentProvider> * const externalId = paymentSessionData.id * * try { + * // assuming you have a client that cancels the payment * await this.client.cancelPayment(externalId) * } catch (e) { * return { @@ -439,6 +436,7 @@ export abstract class AbstractPaymentProvider> * const externalId = paymentSessionData.id * * try { + * // assuming you have a client that retrieves the payment status * const status = await this.client.getStatus(externalId) * * switch (status) { @@ -491,6 +489,7 @@ export abstract class AbstractPaymentProvider> * const externalId = paymentData.id * * try { + * // assuming you have a client that refunds the payment * const newData = await this.client.refund( * externalId, * refundAmount @@ -543,6 +542,7 @@ export abstract class AbstractPaymentProvider> * const externalId = paymentSessionData.id * * try { + * // assuming you have a client that retrieves the payment * return await this.client.retrieve(externalId) * } catch (e) { * return { @@ -591,6 +591,7 @@ export abstract class AbstractPaymentProvider> * const externalId = data.id * * try { + * // assuming you have a client that updates the payment * const response = await this.client.update( * externalId, * { diff --git a/www/apps/resources/generated/edit-dates.mjs b/www/apps/resources/generated/edit-dates.mjs index 2088a7f2b2942..820468f631e28 100644 --- a/www/apps/resources/generated/edit-dates.mjs +++ b/www/apps/resources/generated/edit-dates.mjs @@ -1389,7 +1389,7 @@ export const generatedEditDates = { "references/payment/interfaces/payment.JoinerServiceConfig/page.mdx": "2024-12-09T13:22:02.312Z", "references/payment/interfaces/payment.JoinerServiceConfigAlias/page.mdx": "2024-12-09T13:22:02.308Z", "references/payment/types/payment.JoinerRelationship/page.mdx": "2024-12-09T13:22:02.304Z", - "references/payment_provider/classes/payment_provider.AbstractPaymentProvider/page.mdx": "2024-12-09T13:22:02.268Z", + "references/payment_provider/classes/payment_provider.AbstractPaymentProvider/page.mdx": "2024-12-26T11:35:43.318Z", "references/pricing/IPricingModuleService/methods/pricing.IPricingModuleService.addPriceListPrices/page.mdx": "2024-12-09T13:22:02.928Z", "references/pricing/IPricingModuleService/methods/pricing.IPricingModuleService.addPrices/page.mdx": "2024-12-09T13:22:02.868Z", "references/pricing/IPricingModuleService/methods/pricing.IPricingModuleService.calculatePrices/page.mdx": "2024-12-09T13:22:02.832Z", @@ -2203,47 +2203,47 @@ export const generatedEditDates = { "app/examples/page.mdx": "2024-12-11T09:07:47.589Z", "app/medusa-cli/commands/build/page.mdx": "2024-11-11T11:00:49.665Z", "app/js-sdk/page.mdx": "2024-12-12T11:41:51.152Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.apiKey/page.mdx": "2024-12-26T08:56:54.626Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.campaign/page.mdx": "2024-12-26T08:56:58.139Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.claim/page.mdx": "2024-12-26T08:56:57.938Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.currency/page.mdx": "2024-12-26T08:56:56.810Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.customer/page.mdx": "2024-12-26T08:56:56.636Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.customerGroup/page.mdx": "2024-12-26T08:56:57.456Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.exchange/page.mdx": "2024-12-26T08:56:56.991Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.fulfillment/page.mdx": "2024-12-26T08:56:56.893Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.fulfillmentProvider/page.mdx": "2024-12-26T08:56:55.073Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.fulfillmentSet/page.mdx": "2024-12-26T08:56:55.842Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.inventoryItem/page.mdx": "2024-12-26T08:56:55.548Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.notification/page.mdx": "2024-12-26T08:56:57.247Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.invite/page.mdx": "2024-12-26T08:56:57.660Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.order/page.mdx": "2024-12-26T08:56:55.109Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.orderEdit/page.mdx": "2024-12-26T08:56:57.350Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.payment/page.mdx": "2024-12-26T08:56:57.122Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.paymentCollection/page.mdx": "2024-12-26T08:56:54.632Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.priceList/page.mdx": "2024-12-26T08:56:55.929Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.pricePreference/page.mdx": "2024-12-26T08:56:56.726Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.product/page.mdx": "2024-12-26T08:56:57.844Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.productCategory/page.mdx": "2024-12-26T08:56:55.361Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.productCollection/page.mdx": "2024-12-26T08:56:54.834Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.productTag/page.mdx": "2024-12-26T08:56:56.438Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.productType/page.mdx": "2024-12-26T08:56:54.685Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.productVariant/page.mdx": "2024-12-26T08:56:57.752Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.promotion/page.mdx": "2024-12-26T08:56:55.276Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.refundReason/page.mdx": "2024-12-26T08:56:57.560Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.region/page.mdx": "2024-12-26T08:56:58.038Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.reservation/page.mdx": "2024-12-26T08:56:56.189Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.return/page.mdx": "2024-12-26T08:56:54.626Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.returnReason/page.mdx": "2024-12-26T08:56:54.760Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.salesChannel/page.mdx": "2024-12-26T08:56:55.660Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.shippingOption/page.mdx": "2024-12-26T08:56:56.031Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.shippingProfile/page.mdx": "2024-12-26T08:56:56.541Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.stockLocation/page.mdx": "2024-12-26T08:56:55.202Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.store/page.mdx": "2024-12-26T08:56:54.626Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.taxRate/page.mdx": "2024-12-26T08:56:54.626Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.taxRegion/page.mdx": "2024-12-26T08:56:55.458Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.upload/page.mdx": "2024-12-26T08:56:55.760Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.user/page.mdx": "2024-12-26T08:56:54.924Z", - "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.workflowExecution/page.mdx": "2024-12-26T08:56:56.322Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.apiKey/page.mdx": "2024-12-26T11:37:18.120Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.campaign/page.mdx": "2024-12-26T11:37:18.121Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.claim/page.mdx": "2024-12-26T11:37:18.121Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.currency/page.mdx": "2024-12-26T11:37:18.121Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.customer/page.mdx": "2024-12-26T11:37:18.121Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.customerGroup/page.mdx": "2024-12-26T11:37:18.121Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.exchange/page.mdx": "2024-12-26T11:37:18.122Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.fulfillment/page.mdx": "2024-12-26T11:37:18.122Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.fulfillmentProvider/page.mdx": "2024-12-26T11:37:18.122Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.fulfillmentSet/page.mdx": "2024-12-26T11:37:18.122Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.inventoryItem/page.mdx": "2024-12-26T11:37:18.122Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.notification/page.mdx": "2024-12-26T11:37:18.123Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.invite/page.mdx": "2024-12-26T11:37:18.122Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.order/page.mdx": "2024-12-26T11:37:18.123Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.orderEdit/page.mdx": "2024-12-26T11:37:18.123Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.payment/page.mdx": "2024-12-26T11:37:18.123Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.paymentCollection/page.mdx": "2024-12-26T11:37:18.123Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.priceList/page.mdx": "2024-12-26T11:37:18.123Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.pricePreference/page.mdx": "2024-12-26T11:37:18.124Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.product/page.mdx": "2024-12-26T11:37:18.124Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.productCategory/page.mdx": "2024-12-26T11:37:18.124Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.productCollection/page.mdx": "2024-12-26T11:37:18.124Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.productTag/page.mdx": "2024-12-26T11:37:18.124Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.productType/page.mdx": "2024-12-26T11:37:18.125Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.productVariant/page.mdx": "2024-12-26T11:37:18.125Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.promotion/page.mdx": "2024-12-26T11:37:18.125Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.refundReason/page.mdx": "2024-12-26T11:37:18.125Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.region/page.mdx": "2024-12-26T11:37:18.125Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.reservation/page.mdx": "2024-12-26T11:37:18.125Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.return/page.mdx": "2024-12-26T11:37:18.125Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.returnReason/page.mdx": "2024-12-26T11:37:18.126Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.salesChannel/page.mdx": "2024-12-26T11:37:18.126Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.shippingOption/page.mdx": "2024-12-26T11:37:18.126Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.shippingProfile/page.mdx": "2024-12-26T11:37:18.126Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.stockLocation/page.mdx": "2024-12-26T11:37:18.126Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.store/page.mdx": "2024-12-26T11:37:18.127Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.taxRate/page.mdx": "2024-12-26T11:37:18.127Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.taxRegion/page.mdx": "2024-12-26T11:37:18.127Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.upload/page.mdx": "2024-12-26T11:37:18.127Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.user/page.mdx": "2024-12-26T11:37:18.127Z", + "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.workflowExecution/page.mdx": "2024-12-26T11:37:18.128Z", "references/js_sdk/admin/ApiKey/methods/js_sdk.admin.ApiKey.batchSalesChannels/page.mdx": "2024-12-09T13:21:56.916Z", "references/js_sdk/admin/ApiKey/methods/js_sdk.admin.ApiKey.create/page.mdx": "2024-12-09T13:21:56.900Z", "references/js_sdk/admin/ApiKey/methods/js_sdk.admin.ApiKey.delete/page.mdx": "2024-12-09T13:21:56.912Z", @@ -2631,27 +2631,27 @@ export const generatedEditDates = { "references/js_sdk/admin/types/js_sdk.admin.FetchInput/page.mdx": "2024-10-22T15:09:53.767Z", "references/js_sdk/admin/types/js_sdk.admin.ClientFetch/page.mdx": "2024-12-09T13:22:00.128Z", "references/js_sdk/admin/types/js_sdk.admin.FetchParams/page.mdx": "2024-10-22T15:09:53.766Z", - "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.callback/page.mdx": "2024-12-26T08:56:59.595Z", - "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.login/page.mdx": "2024-12-26T08:56:59.394Z", + "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.callback/page.mdx": "2024-12-26T11:37:18.128Z", + "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.login/page.mdx": "2024-12-26T11:37:18.128Z", "references/js_sdk/admin/types/js_sdk.admin.Logger/page.mdx": "2024-12-09T13:22:00.088Z", - "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.logout/page.mdx": "2024-12-26T08:56:59.509Z", - "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.refresh/page.mdx": "2024-12-26T08:56:59.671Z", - "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.resetPassword/page.mdx": "2024-12-26T08:56:54.627Z", - "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.register/page.mdx": "2024-12-26T08:56:54.624Z", - "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.updateProvider/page.mdx": "2024-12-26T08:56:59.752Z", - "references/js_sdk/auth/classes/js_sdk.auth.Auth/page.mdx": "2024-12-26T08:56:59.269Z", + "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.logout/page.mdx": "2024-12-26T11:37:18.128Z", + "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.refresh/page.mdx": "2024-12-26T11:37:18.128Z", + "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.resetPassword/page.mdx": "2024-12-26T11:37:18.128Z", + "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.register/page.mdx": "2024-12-26T11:37:18.128Z", + "references/js_sdk/auth/Auth/methods/js_sdk.auth.Auth.updateProvider/page.mdx": "2024-12-26T11:37:18.128Z", + "references/js_sdk/auth/classes/js_sdk.auth.Auth/page.mdx": "2024-12-26T11:37:18.128Z", "references/js_sdk/modules/js_sdk.admin/page.mdx": "2024-11-25T17:49:51.856Z", - "references/js_sdk/store/Store/properties/js_sdk.store.Store.category/page.mdx": "2024-12-26T08:56:58.696Z", + "references/js_sdk/store/Store/properties/js_sdk.store.Store.category/page.mdx": "2024-12-26T11:37:18.129Z", "references/js_sdk/modules/js_sdk.store/page.mdx": "2024-10-22T15:09:53.787Z", "references/js_sdk/modules/js_sdk.auth/page.mdx": "2024-10-22T15:09:53.779Z", - "references/js_sdk/store/Store/properties/js_sdk.store.Store.collection/page.mdx": "2024-12-26T08:56:58.441Z", - "references/js_sdk/store/Store/properties/js_sdk.store.Store.cart/page.mdx": "2024-12-26T08:56:58.566Z", - "references/js_sdk/store/Store/properties/js_sdk.store.Store.customer/page.mdx": "2024-12-26T08:56:58.840Z", - "references/js_sdk/store/Store/properties/js_sdk.store.Store.fulfillment/page.mdx": "2024-12-26T08:56:58.294Z", - "references/js_sdk/store/Store/properties/js_sdk.store.Store.order/page.mdx": "2024-12-26T08:56:59.105Z", - "references/js_sdk/store/Store/properties/js_sdk.store.Store.payment/page.mdx": "2024-12-26T08:56:58.958Z", - "references/js_sdk/store/Store/properties/js_sdk.store.Store.product/page.mdx": "2024-12-26T08:56:54.620Z", - "references/js_sdk/store/Store/properties/js_sdk.store.Store.region/page.mdx": "2024-12-26T08:56:54.620Z", + "references/js_sdk/store/Store/properties/js_sdk.store.Store.collection/page.mdx": "2024-12-26T11:37:18.129Z", + "references/js_sdk/store/Store/properties/js_sdk.store.Store.cart/page.mdx": "2024-12-26T11:37:18.129Z", + "references/js_sdk/store/Store/properties/js_sdk.store.Store.customer/page.mdx": "2024-12-26T11:37:18.129Z", + "references/js_sdk/store/Store/properties/js_sdk.store.Store.fulfillment/page.mdx": "2024-12-26T11:37:18.129Z", + "references/js_sdk/store/Store/properties/js_sdk.store.Store.order/page.mdx": "2024-12-26T11:37:18.129Z", + "references/js_sdk/store/Store/properties/js_sdk.store.Store.payment/page.mdx": "2024-12-26T11:37:18.130Z", + "references/js_sdk/store/Store/properties/js_sdk.store.Store.product/page.mdx": "2024-12-26T11:37:18.130Z", + "references/js_sdk/store/Store/properties/js_sdk.store.Store.region/page.mdx": "2024-12-26T11:37:18.130Z", "references/js_sdk/store/classes/js_sdk.store.Store/page.mdx": "2024-11-25T17:49:55.112Z", "references/modules/js_sdk/page.mdx": "2024-10-22T15:09:52.263Z", "references/core_flows/Inventory/Steps_Inventory/functions/core_flows.Inventory.Steps_Inventory.validateInventoryDeleteStep/page.mdx": "2024-12-25T08:43:13.769Z", diff --git a/www/apps/resources/references/payment_provider/classes/payment_provider.AbstractPaymentProvider/page.mdx b/www/apps/resources/references/payment_provider/classes/payment_provider.AbstractPaymentProvider/page.mdx index a683021907e44..b5a5a81f4ef0f 100644 --- a/www/apps/resources/references/payment_provider/classes/payment_provider.AbstractPaymentProvider/page.mdx +++ b/www/apps/resources/references/payment_provider/classes/payment_provider.AbstractPaymentProvider/page.mdx @@ -36,6 +36,62 @@ class MyPaymentProviderService extends AbstractPaymentProvider< export default MyPaymentProviderService ``` +### constructor + +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. + +::: + +#### Example + +```ts +import { AbstractPaymentProvider } from "@medusajs/framework/utils" +import { Logger } from "@medusajs/framework/types" + +type Options = { + apiKey: string +} + +type InjectedDependencies = { + logger: Logger +} + +class MyPaymentProviderService extends AbstractPaymentProvider { + 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 +``` + +#### Type Parameters + + + +#### Parameters + +`","description":"The module's container cradle used to resolve resources.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="AbstractPaymentProvider"/> + ### identifier Each payment provider has a unique identifier defined in its class. The provider's ID @@ -111,6 +167,7 @@ class MyPaymentProviderService extends AbstractPaymentProvider< const externalId = paymentData.id try { + // assuming you have a client that captures the payment const newData = await this.client.capturePayment(externalId) return { @@ -173,6 +230,7 @@ class MyPaymentProviderService extends AbstractPaymentProvider< const externalId = paymentSessionData.id try { + // assuming you have a client that authorizes the payment const paymentData = await this.client.authorizePayment(externalId) return { @@ -225,6 +283,7 @@ class MyPaymentProviderService extends AbstractPaymentProvider< const externalId = paymentData.id try { + // assuming you have a client that cancels the payment const paymentData = await this.client.cancelPayment(externalId) } catch (e) { return { @@ -274,6 +333,7 @@ class MyPaymentProviderService extends AbstractPaymentProvider< } = context try { + // assuming you have a client that initializes the payment const response = await this.client.init( amount, currency_code, customerDetails ) @@ -331,6 +391,7 @@ class MyPaymentProviderService extends AbstractPaymentProvider< const externalId = paymentSessionData.id try { + // assuming you have a client that cancels the payment await this.client.cancelPayment(externalId) } catch (e) { return { @@ -374,6 +435,7 @@ class MyPaymentProviderService extends AbstractPaymentProvider< const externalId = paymentSessionData.id try { + // assuming you have a client that retrieves the payment status const status = await this.client.getStatus(externalId) switch (status) { @@ -428,6 +490,7 @@ class MyPaymentProviderService extends AbstractPaymentProvider< const externalId = paymentData.id try { + // assuming you have a client that refunds the payment const newData = await this.client.refund( externalId, refundAmount @@ -482,6 +545,7 @@ class MyPaymentProviderService extends AbstractPaymentProvider< const externalId = paymentSessionData.id try { + // assuming you have a client that retrieves the payment return await this.client.retrieve(externalId) } catch (e) { return { @@ -533,6 +597,7 @@ class MyPaymentProviderService extends AbstractPaymentProvider< const externalId = data.id try { + // assuming you have a client that updates the payment const response = await this.client.update( externalId, { @@ -707,4 +772,4 @@ Then, go through checkout to place an order. Your payment provider is used to au ## Useful Guides -- [Storefront Guide: how to implement UI for your payment provider during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/payment) +- [Storefront Guide: how to implement UI for your payment provider during checkout](https://docs.medusajs.com/resources/storefront-development/checkout/payment) diff --git a/www/packages/tags/src/tags/index.ts b/www/packages/tags/src/tags/index.ts index 9dd34b992738b..374a5310832c4 100644 --- a/www/packages/tags/src/tags/index.ts +++ b/www/packages/tags/src/tags/index.ts @@ -1,36 +1,36 @@ export * from "./product.js" -export * from "./tax.js" +export * from "./pricing.js" export * from "./storefront.js" export * from "./payment.js" export * from "./order.js" export * from "./cart.js" -export * from "./fulfillment.js" -export * from "./server.js" export * from "./stripe.js" -export * from "./pricing.js" -export * from "./product-collection.js" +export * from "./server.js" +export * from "./product-category.js" +export * from "./auth.js" +export * from "./tax.js" +export * from "./inventory.js" export * from "./customer.js" -export * from "./publishable-api-key.js" +export * from "./product-collection.js" +export * from "./fulfillment.js" +export * from "./region.js" +export * from "./api-key.js" export * from "./query.js" -export * from "./inventory.js" export * from "./sales-channel.js" export * from "./remote-link.js" +export * from "./publishable-api-key.js" export * from "./step.js" -export * from "./region.js" -export * from "./store.js" -export * from "./remote-query.js" export * from "./workflow.js" -export * from "./event-bus.js" -export * from "./promotion.js" -export * from "./user.js" +export * from "./file.js" export * from "./locking.js" -export * from "./api-key.js" +export * from "./stock-location.js" +export * from "./store.js" +export * from "./user.js" +export * from "./event-bus.js" export * from "./logger.js" -export * from "./currency.js" export * from "./js-sdk.js" -export * from "./stock-location.js" export * from "./admin.js" -export * from "./auth.js" +export * from "./promotion.js" +export * from "./remote-query.js" export * from "./notification.js" -export * from "./file.js" -export * from "./product-category.js" +export * from "./currency.js" diff --git a/www/utils/generated/typedoc-json-output/payment-provider.json b/www/utils/generated/typedoc-json-output/payment-provider.json index ffbc9f7e7acdc..7e291370bf1d6 100644 --- a/www/utils/generated/typedoc-json-output/payment-provider.json +++ b/www/utils/generated/typedoc-json-output/payment-provider.json @@ -1,12 +1,12 @@ { - "id": 41499, + "id": 0, "name": "payment-provider", "variant": "project", "kind": 1, "flags": {}, "children": [ { - "id": 41503, + "id": 4, "name": "AbstractPaymentProvider", "variant": "declaration", "kind": 128, @@ -15,7 +15,7 @@ }, "children": [ { - "id": 41504, + "id": 5, "name": "validateOptions", "variant": "declaration", "kind": 2048, @@ -24,7 +24,7 @@ }, "signatures": [ { - "id": 41505, + "id": 6, "name": "validateOptions", "variant": "signature", "kind": 4096, @@ -58,7 +58,7 @@ }, "parameters": [ { - "id": 41506, + "id": 7, "name": "options", "variant": "param", "kind": 32768, @@ -100,7 +100,7 @@ ] }, { - "id": 41512, + "id": 13, "name": "constructor", "variant": "declaration", "kind": 512, @@ -109,7 +109,7 @@ }, "signatures": [ { - "id": 41513, + "id": 14, "name": "AbstractPaymentProvider", "variant": "signature", "kind": 16384, @@ -118,15 +118,7 @@ "summary": [ { "kind": "text", - "text": "You can use the " - }, - { - "kind": "code", - "text": "`constructor`" - }, - { - "kind": "text", - "text": " of the provider's service to access resources in your module's container.\n\nYou can also use the constructor to initialize your integration with the third-party provider. For example, if you use a client to connect to the third-party provider’s APIs,\nyou can initialize it in the constructor and use it in other methods in the service.\n\nThe provider can also access the module's options as a second parameter." + "text": "The constructor allows you to access resources from the [module's container](https://docs.medusajs.com/learn/fundamentals/modules/container) \nusing the first parameter, and the module's options using the second parameter.\n\n:::note\n\nA module's options are passed when you register it in the Medusa application.\n\n:::" } ], "blockTags": [ @@ -135,7 +127,7 @@ "content": [ { "kind": "code", - "text": "```ts\nimport {\n AbstractPaymentProvider\n} from \"@medusajs/framework/utils\"\nimport { Logger } from \"@medusajs/framework/types\"\n\ntype InjectedDependencies = {\n logger: Logger\n}\n\ntype Options = {\n apiKey: string\n}\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n static identifier = \"my-payment\"\n protected logger_: Logger\n protected options_: Options\n // Assuming you're using a client to integrate\n // with a third-party service\n protected client\n\n constructor(\n { logger }: InjectedDependencies,\n options: Options\n ) {\n // @ts-ignore\n super(...arguments)\n\n this.logger_ = logger\n this.options_ = options\n\n // Assuming you're initializing a client\n this.client = new Client(options)\n }\n\n // ...\n}\n\nexport default MyPaymentProviderService\n```" + "text": "```ts\nimport { AbstractPaymentProvider } from \"@medusajs/framework/utils\"\nimport { Logger } from \"@medusajs/framework/types\"\n\ntype Options = {\n apiKey: string\n}\n\ntype InjectedDependencies = {\n logger: Logger\n}\n\nclass MyPaymentProviderService extends AbstractPaymentProvider {\n protected logger_: Logger\n protected options_: Options\n // assuming you're initializing a client\n protected client\n\n constructor(\n container: InjectedDependencies,\n options: Options\n ) {\n super(container, options)\n\n this.logger_ = container.logger\n this.options_ = options\n\n // TODO initialize your client\n }\n // ...\n}\n\nexport default MyPaymentProviderService\n```" } ] } @@ -143,11 +135,19 @@ }, "typeParameters": [ { - "id": 41514, + "id": 15, "name": "TConfig", "variant": "typeParam", "kind": 131072, "flags": {}, + "comment": { + "summary": [ + { + "kind": "text", + "text": "The type of the provider's options passed as a second parameter." + } + ] + }, "default": { "type": "reference", "target": { @@ -171,7 +171,7 @@ ], "parameters": [ { - "id": 41515, + "id": 16, "name": "cradle", "variant": "param", "kind": 32768, @@ -207,11 +207,11 @@ ], "type": { "type": "reference", - "target": 41503, + "target": 4, "typeArguments": [ { "type": "reference", - "target": 41514, + "target": 15, "name": "TConfig", "package": "@medusajs/utils", "qualifiedName": "AbstractPaymentProvider.TConfig", @@ -225,7 +225,7 @@ ] }, { - "id": 41511, + "id": 12, "name": "identifier", "variant": "declaration", "kind": 1024, @@ -290,7 +290,7 @@ } }, { - "id": 41521, + "id": 22, "name": "capturePayment", "variant": "declaration", "kind": 2048, @@ -299,7 +299,7 @@ }, "signatures": [ { - "id": 41522, + "id": 23, "name": "capturePayment", "variant": "signature", "kind": 4096, @@ -314,7 +314,7 @@ "kind": "inline-tag", "tag": "@link", "text": "authorizePayment", - "target": 41524 + "target": 25 }, { "kind": "text", @@ -352,7 +352,7 @@ "content": [ { "kind": "code", - "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async capturePayment(\n paymentData: Record\n ): Promise {\n const externalId = paymentData.id\n\n try {\n const newData = await this.client.capturePayment(externalId)\n\n return {\n ...newData,\n id: externalId\n }\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" + "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async capturePayment(\n paymentData: Record\n ): Promise {\n const externalId = paymentData.id\n\n try {\n // assuming you have a client that captures the payment\n const newData = await this.client.capturePayment(externalId)\n\n return {\n ...newData,\n id: externalId\n }\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" } ] } @@ -360,7 +360,7 @@ }, "parameters": [ { - "id": 41523, + "id": 24, "name": "paymentData", "variant": "param", "kind": 32768, @@ -460,7 +460,7 @@ } }, { - "id": 41524, + "id": 25, "name": "authorizePayment", "variant": "declaration", "kind": 2048, @@ -469,7 +469,7 @@ }, "signatures": [ { - "id": 41525, + "id": 26, "name": "authorizePayment", "variant": "signature", "kind": 4096, @@ -484,7 +484,7 @@ "kind": "inline-tag", "tag": "@link", "text": "capturePayment", - "target": 41521 + "target": 22 }, { "kind": "text", @@ -530,7 +530,7 @@ "content": [ { "kind": "code", - "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n PaymentSessionStatus\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async authorizePayment(\n paymentSessionData: Record,\n context: Record\n ): Promise<\n PaymentProviderError | {\n status: PaymentSessionStatus\n data: PaymentProviderSessionResponse[\"data\"]\n }\n > {\n const externalId = paymentSessionData.id\n\n try {\n const paymentData = await this.client.authorizePayment(externalId)\n\n return {\n data: {\n ...paymentData,\n id: externalId\n },\n status: \"authorized\"\n }\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" + "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n PaymentSessionStatus\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async authorizePayment(\n paymentSessionData: Record,\n context: Record\n ): Promise<\n PaymentProviderError | {\n status: PaymentSessionStatus\n data: PaymentProviderSessionResponse[\"data\"]\n }\n > {\n const externalId = paymentSessionData.id\n\n try {\n // assuming you have a client that authorizes the payment\n const paymentData = await this.client.authorizePayment(externalId)\n\n return {\n data: {\n ...paymentData,\n id: externalId\n },\n status: \"authorized\"\n }\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" } ] } @@ -538,7 +538,7 @@ }, "parameters": [ { - "id": 41526, + "id": 27, "name": "paymentSessionData", "variant": "param", "kind": 32768, @@ -580,7 +580,7 @@ } }, { - "id": 41527, + "id": 28, "name": "context", "variant": "param", "kind": 32768, @@ -644,14 +644,14 @@ { "type": "reflection", "declaration": { - "id": 41528, + "id": 29, "name": "__type", "variant": "declaration", "kind": 65536, "flags": {}, "children": [ { - "id": 41529, + "id": 30, "name": "status", "variant": "declaration", "kind": 1024, @@ -675,7 +675,7 @@ } }, { - "id": 41530, + "id": 31, "name": "data", "variant": "declaration", "kind": 1024, @@ -721,8 +721,8 @@ { "title": "Properties", "children": [ - 41529, - 41530 + 30, + 31 ] } ] @@ -748,7 +748,7 @@ } }, { - "id": 41531, + "id": 32, "name": "cancelPayment", "variant": "declaration", "kind": 2048, @@ -757,7 +757,7 @@ }, "signatures": [ { - "id": 41532, + "id": 33, "name": "cancelPayment", "variant": "signature", "kind": 4096, @@ -784,7 +784,7 @@ "content": [ { "kind": "code", - "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async cancelPayment(\n paymentData: Record\n ): Promise {\n const externalId = paymentData.id\n\n try {\n const paymentData = await this.client.cancelPayment(externalId)\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" + "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async cancelPayment(\n paymentData: Record\n ): Promise {\n const externalId = paymentData.id\n\n try {\n // assuming you have a client that cancels the payment\n const paymentData = await this.client.cancelPayment(externalId)\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" } ] } @@ -792,7 +792,7 @@ }, "parameters": [ { - "id": 41533, + "id": 34, "name": "paymentData", "variant": "param", "kind": 32768, @@ -892,7 +892,7 @@ } }, { - "id": 41534, + "id": 35, "name": "initiatePayment", "variant": "declaration", "kind": 2048, @@ -901,7 +901,7 @@ }, "signatures": [ { - "id": 41535, + "id": 36, "name": "initiatePayment", "variant": "signature", "kind": 4096, @@ -944,7 +944,7 @@ "content": [ { "kind": "code", - "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async initiatePayment(\n context: CreatePaymentProviderSession\n ): Promise {\n const {\n amount,\n currency_code,\n context: customerDetails\n } = context\n\n try {\n const response = await this.client.init(\n amount, currency_code, customerDetails\n )\n\n return {\n ...response,\n data: {\n id: response.id\n }\n }\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" + "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async initiatePayment(\n context: CreatePaymentProviderSession\n ): Promise {\n const {\n amount,\n currency_code,\n context: customerDetails\n } = context\n\n try {\n // assuming you have a client that initializes the payment\n const response = await this.client.init(\n amount, currency_code, customerDetails\n )\n\n return {\n ...response,\n data: {\n id: response.id\n }\n }\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" } ] } @@ -952,7 +952,7 @@ }, "parameters": [ { - "id": 41536, + "id": 37, "name": "context", "variant": "param", "kind": 32768, @@ -1024,7 +1024,7 @@ } }, { - "id": 41537, + "id": 38, "name": "deletePayment", "variant": "declaration", "kind": 2048, @@ -1033,7 +1033,7 @@ }, "signatures": [ { - "id": 41538, + "id": 39, "name": "deletePayment", "variant": "signature", "kind": 4096, @@ -1060,7 +1060,7 @@ "content": [ { "kind": "code", - "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async deletePayment(\n paymentSessionData: Record\n ): Promise<\n PaymentProviderError | PaymentProviderSessionResponse[\"data\"]\n > {\n const externalId = paymentSessionData.id\n\n try {\n await this.client.cancelPayment(externalId)\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" + "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async deletePayment(\n paymentSessionData: Record\n ): Promise<\n PaymentProviderError | PaymentProviderSessionResponse[\"data\"]\n > {\n const externalId = paymentSessionData.id\n\n try {\n // assuming you have a client that cancels the payment\n await this.client.cancelPayment(externalId)\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" } ] } @@ -1068,7 +1068,7 @@ }, "parameters": [ { - "id": 41539, + "id": 40, "name": "paymentSessionData", "variant": "param", "kind": 32768, @@ -1168,7 +1168,7 @@ } }, { - "id": 41540, + "id": 41, "name": "getPaymentStatus", "variant": "declaration", "kind": 2048, @@ -1177,7 +1177,7 @@ }, "signatures": [ { - "id": 41541, + "id": 42, "name": "getPaymentStatus", "variant": "signature", "kind": 4096, @@ -1204,7 +1204,7 @@ "content": [ { "kind": "code", - "text": "```ts\n// other imports...\nimport {\n PaymentSessionStatus\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async getPaymentStatus(\n paymentSessionData: Record\n ): Promise {\n const externalId = paymentSessionData.id\n\n try {\n const status = await this.client.getStatus(externalId)\n\n switch (status) {\n case \"requires_capture\":\n return \"authorized\"\n case \"success\":\n return \"captured\"\n case \"canceled\":\n return \"canceled\"\n default:\n return \"pending\"\n }\n } catch (e) {\n return \"error\"\n }\n }\n\n // ...\n}\n```" + "text": "```ts\n// other imports...\nimport {\n PaymentSessionStatus\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async getPaymentStatus(\n paymentSessionData: Record\n ): Promise {\n const externalId = paymentSessionData.id\n\n try {\n // assuming you have a client that retrieves the payment status\n const status = await this.client.getStatus(externalId)\n\n switch (status) {\n case \"requires_capture\":\n return \"authorized\"\n case \"success\":\n return \"captured\"\n case \"canceled\":\n return \"canceled\"\n default:\n return \"pending\"\n }\n } catch (e) {\n return \"error\"\n }\n }\n\n // ...\n}\n```" } ] } @@ -1212,7 +1212,7 @@ }, "parameters": [ { - "id": 41542, + "id": 43, "name": "paymentSessionData", "variant": "param", "kind": 32768, @@ -1288,7 +1288,7 @@ } }, { - "id": 41543, + "id": 44, "name": "refundPayment", "variant": "declaration", "kind": 2048, @@ -1297,7 +1297,7 @@ }, "signatures": [ { - "id": 41544, + "id": 45, "name": "refundPayment", "variant": "signature", "kind": 4096, @@ -1332,7 +1332,7 @@ "content": [ { "kind": "code", - "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async refundPayment(\n paymentData: Record,\n refundAmount: number\n ): Promise<\n PaymentProviderError | PaymentProviderSessionResponse[\"data\"]\n > {\n const externalId = paymentData.id\n\n try {\n const newData = await this.client.refund(\n externalId,\n refundAmount\n )\n\n return {\n ...newData,\n id: externalId\n }\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" + "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async refundPayment(\n paymentData: Record,\n refundAmount: number\n ): Promise<\n PaymentProviderError | PaymentProviderSessionResponse[\"data\"]\n > {\n const externalId = paymentData.id\n\n try {\n // assuming you have a client that refunds the payment\n const newData = await this.client.refund(\n externalId,\n refundAmount\n )\n\n return {\n ...newData,\n id: externalId\n }\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" } ] } @@ -1340,7 +1340,7 @@ }, "parameters": [ { - "id": 41545, + "id": 46, "name": "paymentData", "variant": "param", "kind": 32768, @@ -1382,7 +1382,7 @@ } }, { - "id": 41546, + "id": 47, "name": "refundAmount", "variant": "param", "kind": 32768, @@ -1459,7 +1459,7 @@ } }, { - "id": 41547, + "id": 48, "name": "retrievePayment", "variant": "declaration", "kind": 2048, @@ -1468,7 +1468,7 @@ }, "signatures": [ { - "id": 41548, + "id": 49, "name": "retrievePayment", "variant": "signature", "kind": 4096, @@ -1503,7 +1503,7 @@ "content": [ { "kind": "code", - "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async retrievePayment(\n paymentSessionData: Record\n ): Promise<\n PaymentProviderError | PaymentProviderSessionResponse[\"data\"]\n > {\n const externalId = paymentSessionData.id\n\n try {\n return await this.client.retrieve(externalId)\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" + "text": "```ts\n// other imports...\nimport {\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async retrievePayment(\n paymentSessionData: Record\n ): Promise<\n PaymentProviderError | PaymentProviderSessionResponse[\"data\"]\n > {\n const externalId = paymentSessionData.id\n\n try {\n // assuming you have a client that retrieves the payment\n return await this.client.retrieve(externalId)\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" } ] } @@ -1511,7 +1511,7 @@ }, "parameters": [ { - "id": 41549, + "id": 50, "name": "paymentSessionData", "variant": "param", "kind": 32768, @@ -1611,7 +1611,7 @@ } }, { - "id": 41550, + "id": 51, "name": "updatePayment", "variant": "declaration", "kind": 2048, @@ -1620,7 +1620,7 @@ }, "signatures": [ { - "id": 41551, + "id": 52, "name": "updatePayment", "variant": "signature", "kind": 4096, @@ -1635,7 +1635,7 @@ "kind": "inline-tag", "tag": "@link", "text": "initiatePayment", - "target": 41534 + "target": 35 }, { "kind": "text", @@ -1673,7 +1673,7 @@ "content": [ { "kind": "code", - "text": "```ts\n// other imports...\nimport {\n UpdatePaymentProviderSession,\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async updatePayment(\n context: UpdatePaymentProviderSession\n ): Promise {\n const {\n amount,\n currency_code,\n context: customerDetails,\n data\n } = context\n const externalId = data.id\n\n try {\n const response = await this.client.update(\n externalId,\n {\n amount,\n currency_code,\n customerDetails\n }\n )\n\n return {\n ...response,\n data: {\n id: response.id\n }\n }\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" + "text": "```ts\n// other imports...\nimport {\n UpdatePaymentProviderSession,\n PaymentProviderError,\n PaymentProviderSessionResponse,\n} from \"@medusajs/framework/types\"\n\n\nclass MyPaymentProviderService extends AbstractPaymentProvider<\n Options\n> {\n async updatePayment(\n context: UpdatePaymentProviderSession\n ): Promise {\n const {\n amount,\n currency_code,\n context: customerDetails,\n data\n } = context\n const externalId = data.id\n\n try {\n // assuming you have a client that updates the payment\n const response = await this.client.update(\n externalId,\n {\n amount,\n currency_code,\n customerDetails\n }\n )\n\n return {\n ...response,\n data: {\n id: response.id\n }\n }\n } catch (e) {\n return {\n error: e,\n code: \"unknown\",\n detail: e\n }\n }\n }\n\n // ...\n}\n```" } ] } @@ -1681,7 +1681,7 @@ }, "parameters": [ { - "id": 41552, + "id": 53, "name": "context", "variant": "param", "kind": 32768, @@ -1753,7 +1753,7 @@ } }, { - "id": 41553, + "id": 54, "name": "getWebhookActionAndData", "variant": "declaration", "kind": 2048, @@ -1762,7 +1762,7 @@ }, "signatures": [ { - "id": 41554, + "id": 55, "name": "getWebhookActionAndData", "variant": "signature", "kind": 4096, @@ -1829,7 +1829,7 @@ }, "parameters": [ { - "id": 41555, + "id": 56, "name": "data", "variant": "param", "kind": 32768, @@ -1845,14 +1845,14 @@ "type": { "type": "reflection", "declaration": { - "id": 41556, + "id": 57, "name": "__type", "variant": "declaration", "kind": 65536, "flags": {}, "children": [ { - "id": 41557, + "id": 58, "name": "data", "variant": "declaration", "kind": 1024, @@ -1886,7 +1886,7 @@ } }, { - "id": 41558, + "id": 59, "name": "rawData", "variant": "declaration", "kind": 1024, @@ -1920,7 +1920,7 @@ } }, { - "id": 41559, + "id": 60, "name": "headers", "variant": "declaration", "kind": 1024, @@ -1958,9 +1958,9 @@ { "title": "Properties", "children": [ - 41557, - 41558, - 41559 + 58, + 59, + 60 ] } ] @@ -2006,35 +2006,35 @@ { "title": "Constructors", "children": [ - 41512 + 13 ] }, { "title": "Properties", "children": [ - 41511 + 12 ] }, { "title": "Methods", "children": [ - 41504, - 41521, - 41524, - 41531, - 41534, - 41537, - 41540, - 41543, - 41547, - 41550, - 41553 + 5, + 22, + 25, + 32, + 35, + 38, + 41, + 44, + 48, + 51, + 54 ] } ], "typeParameters": [ { - "id": 41560, + "id": 61, "name": "TConfig", "variant": "typeParam", "kind": 131072, @@ -2077,209 +2077,209 @@ { "title": "Classes", "children": [ - 41503 + 4 ] } ], "packageName": "@medusajs/utils", "symbolIdMap": { - "41499": { + "0": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "" }, - "41503": { + "4": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider" }, - "41504": { + "5": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.validateOptions" }, - "41505": { + "6": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.validateOptions" }, - "41506": { + "7": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "options" }, - "41511": { + "12": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.identifier" }, - "41512": { + "13": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.__constructor" }, - "41513": { + "14": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider" }, - "41514": { + "15": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.TConfig" }, - "41515": { + "16": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "cradle" }, - "41521": { + "22": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.capturePayment" }, - "41522": { + "23": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.capturePayment" }, - "41523": { + "24": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "paymentData" }, - "41524": { + "25": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.authorizePayment" }, - "41525": { + "26": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.authorizePayment" }, - "41526": { + "27": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "paymentSessionData" }, - "41527": { + "28": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "context" }, - "41528": { + "29": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "__type" }, - "41529": { + "30": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "__type.status" }, - "41530": { + "31": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "__type.data" }, - "41531": { + "32": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.cancelPayment" }, - "41532": { + "33": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.cancelPayment" }, - "41533": { + "34": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "paymentData" }, - "41534": { + "35": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.initiatePayment" }, - "41535": { + "36": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.initiatePayment" }, - "41536": { + "37": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "context" }, - "41537": { + "38": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.deletePayment" }, - "41538": { + "39": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.deletePayment" }, - "41539": { + "40": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "paymentSessionData" }, - "41540": { + "41": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.getPaymentStatus" }, - "41541": { + "42": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.getPaymentStatus" }, - "41542": { + "43": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "paymentSessionData" }, - "41543": { + "44": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.refundPayment" }, - "41544": { + "45": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.refundPayment" }, - "41545": { + "46": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "paymentData" }, - "41546": { + "47": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "refundAmount" }, - "41547": { + "48": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.retrievePayment" }, - "41548": { + "49": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.retrievePayment" }, - "41549": { + "50": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "paymentSessionData" }, - "41550": { + "51": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.updatePayment" }, - "41551": { + "52": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.updatePayment" }, - "41552": { + "53": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "context" }, - "41553": { + "54": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.getWebhookActionAndData" }, - "41554": { + "55": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.getWebhookActionAndData" }, - "41555": { + "56": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "data" }, - "41556": { + "57": { "sourceFileName": "../../../../packages/core/types/src/payment/mutations.ts", "qualifiedName": "__type" }, - "41557": { + "58": { "sourceFileName": "../../../../packages/core/types/src/payment/mutations.ts", "qualifiedName": "__type.data" }, - "41558": { + "59": { "sourceFileName": "../../../../packages/core/types/src/payment/mutations.ts", "qualifiedName": "__type.rawData" }, - "41559": { + "60": { "sourceFileName": "../../../../packages/core/types/src/payment/mutations.ts", "qualifiedName": "__type.headers" }, - "41560": { + "61": { "sourceFileName": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts", "qualifiedName": "AbstractPaymentProvider.TConfig" } @@ -2289,7 +2289,7 @@ "1": "../../../../packages/core/utils/src/payment/abstract-payment-provider.ts" }, "reflections": { - "1": 41499 + "1": 0 } } } diff --git a/www/utils/packages/typedoc-generate-references/src/constants/merger-custom-options/payment-provider.ts b/www/utils/packages/typedoc-generate-references/src/constants/merger-custom-options/payment-provider.ts index 2d6227c828cbb..fb12b74c67078 100644 --- a/www/utils/packages/typedoc-generate-references/src/constants/merger-custom-options/payment-provider.ts +++ b/www/utils/packages/typedoc-generate-references/src/constants/merger-custom-options/payment-provider.ts @@ -13,9 +13,6 @@ const paymentProviderOptions: FormattingOptionsType = { reflectionTitle: { fullReplacement: "How to Create a Payment Provider", }, - reflectionGroups: { - Constructors: false, - }, shouldIncrementAfterStartSections: true, expandMembers: true, expandProperties: true, @@ -101,7 +98,7 @@ Then, go through checkout to place an order. Your payment provider is used to au `, `## Useful Guides -- [Storefront Guide: how to implement UI for your payment provider during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/payment) +- [Storefront Guide: how to implement UI for your payment provider during checkout](https://docs.medusajs.com/resources/storefront-development/checkout/payment) `, ], },