|
1
|
import { CardList } from "docs-ui" |
|
2
|
|
|
3
|
export const metadata = { |
|
4
|
title: `Payment Module Provider`, |
|
5
|
} |
|
6
|
|
|
7
|
# {metadata.title} |
|
8
|
|
|
9
|
In this guide, you’ll learn about the Payment Module Provider and how it's used. |
|
10
|
|
|
11
|
<Note title="Looking for no-code docs?"> |
|
12
|
|
|
13
|
Refer to this [Medusa Admin User Guide](!user-guide!/settings/regions) to learn how to manage the payment providers available in a region using the dashboard. |
|
14
|
|
|
15
|
</Note> |
|
16
|
|
|
17
|
--- |
|
18
|
|
|
19
|
## What is a Payment Module Provider? |
|
20
|
|
|
21
|
The Payment Module Provider handles payment processing in the Medusa application. It integrates third-party payment services, such as [Stripe](./stripe/page.mdx). |
|
22
|
|
|
23
|
To authorize a payment amount with a payment provider, a payment session is created and associated with that payment provider. The payment provider is then used to handle the authorization. |
|
24
|
|
|
25
|
After the payment session is authorized, the payment provider is associated with the resulting payment and handles its payment processing, such as to capture or refund payment. |
|
26
|
|
|
27
|
 |
|
28
|
|
|
29
|
### List of Payment Module Providers |
|
30
|
|
|
31
|
<CardList |
|
32
|
items={[ |
|
33
|
{ |
|
34
|
href: "/commerce-modules/payment/payment-provider/stripe", |
|
35
|
title: "Stripe" |
|
36
|
} |
|
37
|
]} |
|
38
|
/> |
|
39
|
|
|
40
|
### Default Payment Provider |
|
41
|
|
|
42
|
The Payment Module provides a `system` payment provider that acts as a placeholder payment provider. |
|
43
|
|
|
44
|
It doesn’t handle payment processing and delegates that to the merchant. It acts similarly to a cash-on-delivery (COD) payment method. |
|
45
|
|
|
46
|
<Note title="Tip"> |
|
47
|
|
|
48
|
The identifier of the system payment provider is `pp_system`. |
|
49
|
|
|
50
|
</Note> |
|
51
|
|
|
52
|
--- |
|
53
|
|
|
54
|
## How to Create a Custom Payment Provider? |
|
55
|
|
|
56
|
A payment provider is a module whose main service extends the `AbstractPaymentProvider` imported from `@medusajs/framework/utils`. |
|
57
|
|
|
58
|
The module can have multiple payment provider services, where each is registered as a separate payment provider. |
|
59
|
|
|
60
|
Refer to [this guide](/references/payment/provider) on how to create a payment provider for the Payment Module. |
|
61
|
|
|
62
|
After you create a payment provider, you can enable it as a payment provider in a region using the [Medusa Admin dashboard](!user-guide!/settings/regions). |
|
63
|
|
|
64
|
--- |
|
65
|
|
|
66
|
## How are Payment Providers Registered? |
|
67
|
|
|
68
|
### Configure Payment Module's Providers |
|
69
|
|
|
70
|
The Payment Module accepts a `providers` option that allows you to configure the providers registered in your application. |
|
71
|
|
|
72
|
Learn more about this option in the [Module Options](../module-options/page.mdx) guide. |
|
73
|
|
|
74
|
### Registration on Application Start |
|
75
|
|
|
76
|
When the Medusa application starts, it registers the Payment Module Providers defined in the `providers` option of the Payment Module. |
|
77
|
|
|
78
|
For each Payment Module Provider, the Medusa application finds all payment provider services defined in them to register. |
|
79
|
|
|
80
|
### PaymentProvider Data Model |
|
81
|
|
|
82
|
A registered payment provider is represented by the [PaymentProvider data model](/references/payment/models/PaymentProvider) in the Medusa application. |
|
83
|
|
|
84
|
 |
|
85
|
|
|
86
|
This data model is used to reference a service in the Payment Module Provider and determine whether it's installed in the application. |
|
87
|
|
|
88
|
The `PaymentProvider` data model has the following properties: |
|
89
|
|
|
90
|
- `id`: The unique identifier of the Payment Module Provider. The ID's format is `pp_{identifier}_{id}`, where: |
|
91
|
- `identifier` is the value of the `identifier` property in the Payment Module Provider's service. |
|
92
|
- `id` is the value of the `id` property of the Payment Module Provider in `medusa-config.ts`. |
|
93
|
- `is_enabled`: A boolean indicating whether the payment provider is enabled. |
|
94
|
|
|
95
|
### How to Remove a Payment Provider? |
|
96
|
|
|
97
|
If you remove a payment provider from the `providers` option, the Medusa application will not remove the associated `PaymentProvider` data model record. |
|
98
|
|
|
99
|
Instead, the Medusa application will set the `is_enabled` property of the `PaymentProvider`'s record to `false`. This allows you to re-enable the payment provider later if needed by adding it back to the `providers` option. |