@easypayment/medusa-paypal 0.6.1 โ 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -144
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,53 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<h1>๐
ฟ medusa-paypal-backend</h1>
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
- PayPal Wallet (Smart Buttons)
|
|
10
|
-
- PayPal Advanced Card Payments
|
|
11
|
-
- Admin configuration UI for PayPal settings
|
|
12
|
-
- Store API support for storefront integrations
|
|
13
|
-
- Configurable checkout behavior
|
|
5
|
+
<p><strong>Production-ready PayPal payment plugin for Medusa v2</strong></p>
|
|
14
6
|
|
|
15
|
-
|
|
7
|
+
<p>
|
|
8
|
+
<a href="https://www.npmjs.com/package/@easypayment/medusa-paypal-backend"><img src="https://img.shields.io/npm/v/@easypayment/medusa-paypal-backend?color=blue&label=npm" alt="npm version" /></a>
|
|
9
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License: MIT" /></a>
|
|
10
|
+
<a href="https://medusajs.com"><img src="https://img.shields.io/badge/Medusa-v2-9b59b6" alt="Medusa v2" /></a>
|
|
11
|
+
<a href="https://developer.paypal.com"><img src="https://img.shields.io/badge/PayPal-PPCP-003087" alt="PayPal PPCP" /></a>
|
|
12
|
+
</p>
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
<p>Smart Buttons ยท Advanced Card Fields ยท Webhooks</p>
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
|-----------|---------|
|
|
21
|
-
| Medusa | `^2.12.0` |
|
|
22
|
-
| Node.js | `>=20` |
|
|
16
|
+
</div>
|
|
23
17
|
|
|
24
18
|
---
|
|
25
19
|
|
|
26
|
-
##
|
|
20
|
+
## Requirements
|
|
27
21
|
|
|
28
|
-
|
|
22
|
+
- Medusa v2
|
|
23
|
+
- Node.js 18+
|
|
24
|
+
- PostgreSQL
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
npm install @easypayment/medusa-paypal
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Or with pnpm:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
pnpm add @easypayment/medusa-paypal
|
|
38
|
-
```
|
|
26
|
+
---
|
|
39
27
|
|
|
40
|
-
|
|
28
|
+
## Step 1 โ Install
|
|
41
29
|
|
|
42
30
|
```bash
|
|
43
|
-
|
|
31
|
+
npm install @easypayment/medusa-paypal-backend
|
|
44
32
|
```
|
|
45
33
|
|
|
46
34
|
---
|
|
47
35
|
|
|
48
|
-
##
|
|
36
|
+
## Step 2 โ Configure medusa-config.ts
|
|
49
37
|
|
|
50
|
-
|
|
38
|
+
Add the plugin and both payment providers to your existing `medusa-config.ts`:
|
|
51
39
|
|
|
52
40
|
```ts
|
|
53
41
|
import { loadEnv, defineConfig } from "@medusajs/framework/utils"
|
|
@@ -79,13 +67,17 @@ export default defineConfig({
|
|
|
79
67
|
options: {
|
|
80
68
|
providers: [
|
|
81
69
|
{
|
|
70
|
+
// PayPal Smart Buttons (wallet checkout)
|
|
82
71
|
resolve: "@easypayment/medusa-paypal/providers/paypal",
|
|
83
72
|
id: "paypal",
|
|
73
|
+
options: {},
|
|
84
74
|
dependencies: ["paypal_onboarding"],
|
|
85
75
|
},
|
|
86
76
|
{
|
|
77
|
+
// Advanced Card Fields (hosted card inputs)
|
|
87
78
|
resolve: "@easypayment/medusa-paypal/providers/paypal_card",
|
|
88
79
|
id: "paypal_card",
|
|
80
|
+
options: {},
|
|
89
81
|
dependencies: ["paypal_onboarding"],
|
|
90
82
|
},
|
|
91
83
|
],
|
|
@@ -97,146 +89,65 @@ export default defineConfig({
|
|
|
97
89
|
|
|
98
90
|
---
|
|
99
91
|
|
|
100
|
-
##
|
|
92
|
+
## Step 3 โ Set environment variables
|
|
101
93
|
|
|
102
|
-
Add
|
|
94
|
+
Add these to your Medusa server `.env`:
|
|
103
95
|
|
|
104
96
|
```env
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
AUTH_CORS=http://localhost:5173,http://localhost:9000,http://localhost:8000,https://docs.medusajs.com
|
|
108
|
-
|
|
109
|
-
REDIS_URL=redis://localhost:6379
|
|
110
|
-
JWT_SECRET=supersecret
|
|
111
|
-
COOKIE_SECRET=supersecret
|
|
112
|
-
DATABASE_URL=postgres://postgres:root@localhost/medusa-medusa-backend
|
|
113
|
-
|
|
114
|
-
MEDUSA_ADMIN_ONBOARDING_TYPE=nextjs
|
|
115
|
-
MEDUSA_ADMIN_ONBOARDING_NEXTJS_DIRECTORY=medusa-backend-storefront
|
|
116
|
-
|
|
117
|
-
PAYPAL_CURRENCY=EUR
|
|
97
|
+
# Required
|
|
98
|
+
MEDUSA_BACKEND_URL=https://your-medusa-server.com
|
|
118
99
|
```
|
|
119
100
|
|
|
120
101
|
---
|
|
121
102
|
|
|
122
|
-
##
|
|
123
|
-
|
|
124
|
-
Run your Medusa backend:
|
|
103
|
+
## Step 4 โ Run database migrations
|
|
125
104
|
|
|
126
105
|
```bash
|
|
127
|
-
|
|
106
|
+
npx medusa db:migrate
|
|
128
107
|
```
|
|
129
108
|
|
|
130
|
-
Then open Medusa Admin.
|
|
131
|
-
|
|
132
109
|
---
|
|
133
110
|
|
|
134
|
-
##
|
|
135
|
-
|
|
136
|
-
After installation, configure PayPal from the Medusa Admin PayPal settings pages.
|
|
137
|
-
|
|
138
|
-
### PayPal Wallet
|
|
139
|
-
|
|
140
|
-
Available settings include:
|
|
141
|
-
|
|
142
|
-
- `enabled`
|
|
143
|
-
- `title`
|
|
144
|
-
- `disableButtons`
|
|
145
|
-
- `buttonColor`
|
|
146
|
-
- `buttonShape`
|
|
147
|
-
- `buttonWidth`
|
|
148
|
-
- `buttonHeight`
|
|
149
|
-
- `buttonLabel`
|
|
150
|
-
|
|
151
|
-
### Advanced Card Payments
|
|
152
|
-
|
|
153
|
-
Available settings include:
|
|
111
|
+
## Step 5 โ Connect your PayPal account
|
|
154
112
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
113
|
+
1. Start your Medusa server
|
|
114
|
+
2. Open Medusa Admin โ **Settings โ PayPal โ PayPal Connection**
|
|
115
|
+
3. Choose **Sandbox** (testing) or **Live** (production)
|
|
116
|
+
4. Click **Connect to PayPal** and complete the PayPal onboarding flow
|
|
158
117
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
Available settings include:
|
|
162
|
-
|
|
163
|
-
- `paymentAction` (`capture` or `authorize`)
|
|
164
|
-
- `brandName`
|
|
165
|
-
- `landingPage`
|
|
166
|
-
- `requireInstantPayment`
|
|
167
|
-
- `sendItemDetails`
|
|
168
|
-
- `invoicePrefix`
|
|
169
|
-
- `creditCardStatementName`
|
|
118
|
+
Credentials are saved automatically. To connect manually instead, click **Insert credentials manually** and paste your Client ID and Secret from [developer.paypal.com](https://developer.paypal.com).
|
|
170
119
|
|
|
171
120
|
---
|
|
172
121
|
|
|
173
|
-
##
|
|
174
|
-
|
|
175
|
-
With the default configuration shown above, the generated Medusa provider IDs are:
|
|
122
|
+
## Step 6 โ Enable providers in your region
|
|
176
123
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
Use these exact provider IDs in your storefront unless you change the provider `id` values in `medusa-config.ts`.
|
|
124
|
+
1. Medusa Admin โ **Settings โ Regions โ [your region]**
|
|
125
|
+
2. Under **Payment Providers**, enable:
|
|
126
|
+
- `pp_paypal_paypal` โ Paypal (CARD)
|
|
127
|
+
- `pp_paypal_card_paypal_card` โ Paypal (PAYPAL)
|
|
183
128
|
|
|
184
129
|
---
|
|
185
130
|
|
|
186
|
-
##
|
|
187
|
-
|
|
188
|
-
When creating a payment session, use one of the generated provider IDs.
|
|
131
|
+
## Step 7 โ Configure settings (optional)
|
|
189
132
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
```json
|
|
193
|
-
{
|
|
194
|
-
"provider_id": "pp_paypal_paypal"
|
|
195
|
-
}
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
Example for PayPal Card:
|
|
199
|
-
|
|
200
|
-
```json
|
|
201
|
-
{
|
|
202
|
-
"provider_id": "pp_paypal_card_paypal_card"
|
|
203
|
-
}
|
|
204
|
-
```
|
|
133
|
+
All settings are in Medusa Admin โ **Settings โ PayPal** and take effect immediately with no server restart.
|
|
205
134
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
Example endpoint:
|
|
213
|
-
|
|
214
|
-
```http
|
|
215
|
-
POST /store/payment-collections/{id}/payment-sessions
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
Example body:
|
|
219
|
-
|
|
220
|
-
```json
|
|
221
|
-
{
|
|
222
|
-
"provider_id": "pp_paypal_paypal"
|
|
223
|
-
}
|
|
224
|
-
```
|
|
135
|
+
| Tab | What you can configure |
|
|
136
|
+
|---|---|
|
|
137
|
+
| **PayPal Settings** | Enable/disable, button color, shape, label |
|
|
138
|
+
| **Advanced Card Payments** | Enable/disable, 3D Secure mode |
|
|
139
|
+
| **Additional Settings** | Payment action (capture / authorize), brand name, invoice prefix |
|
|
225
140
|
|
|
226
141
|
---
|
|
227
142
|
|
|
228
|
-
##
|
|
143
|
+
## Step 8 โ Connect the frontend package
|
|
229
144
|
|
|
230
|
-
|
|
231
|
-
- Register the plugin in `medusa-config.ts`
|
|
232
|
-
- Register both payment providers
|
|
233
|
-
- Add required environment variables
|
|
234
|
-
- Start the Medusa backend
|
|
235
|
-
- Configure PayPal in Admin
|
|
236
|
-
- Use the correct provider IDs in the storefront
|
|
145
|
+
Install the storefront UI package to render PayPal at checkout:
|
|
237
146
|
|
|
238
|
-
|
|
147
|
+
```bash
|
|
148
|
+
npm install @easypayment/medusa-paypal-ui
|
|
149
|
+
```
|
|
239
150
|
|
|
240
|
-
|
|
151
|
+
See the [medusa-paypal-frontend README](../medusa-paypal-frontend/README.md) for integration steps.
|
|
241
152
|
|
|
242
|
-
|
|
153
|
+
---
|