@easypayment/medusa-paypal 0.6.1 โ 0.6.2
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 +60 -142
- 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 ยท Reconciliation ยท Credential Encryption</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,72 @@ 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
|
-
|
|
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
|
|
97
|
+
# Required
|
|
98
|
+
MEDUSA_BACKEND_URL=https://your-medusa-server.com
|
|
99
|
+
STOREFRONT_URL=https://your-storefront.com
|
|
116
100
|
|
|
101
|
+
# Recommended for production
|
|
102
|
+
PAYPAL_CREDENTIALS_ENCRYPTION_KEY=your-64-char-hex-key
|
|
117
103
|
PAYPAL_CURRENCY=EUR
|
|
118
104
|
```
|
|
119
105
|
|
|
120
|
-
|
|
106
|
+
> Generate an encryption key with: `openssl rand -hex 32`
|
|
121
107
|
|
|
122
|
-
|
|
108
|
+
---
|
|
123
109
|
|
|
124
|
-
Run
|
|
110
|
+
## Step 4 โ Run database migrations
|
|
125
111
|
|
|
126
112
|
```bash
|
|
127
|
-
|
|
113
|
+
npx medusa db:migrate
|
|
128
114
|
```
|
|
129
115
|
|
|
130
|
-
Then open Medusa Admin.
|
|
131
|
-
|
|
132
116
|
---
|
|
133
117
|
|
|
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:
|
|
118
|
+
## Step 5 โ Connect your PayPal account
|
|
154
119
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
120
|
+
1. Start your Medusa server
|
|
121
|
+
2. Open Medusa Admin โ **Settings โ PayPal โ PayPal Connection**
|
|
122
|
+
3. Choose **Sandbox** (testing) or **Live** (production)
|
|
123
|
+
4. Click **Connect to PayPal** and complete the PayPal onboarding flow
|
|
158
124
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
Available settings include:
|
|
162
|
-
|
|
163
|
-
- `paymentAction` (`capture` or `authorize`)
|
|
164
|
-
- `brandName`
|
|
165
|
-
- `landingPage`
|
|
166
|
-
- `requireInstantPayment`
|
|
167
|
-
- `sendItemDetails`
|
|
168
|
-
- `invoicePrefix`
|
|
169
|
-
- `creditCardStatementName`
|
|
125
|
+
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
126
|
|
|
171
127
|
---
|
|
172
128
|
|
|
173
|
-
##
|
|
174
|
-
|
|
175
|
-
With the default configuration shown above, the generated Medusa provider IDs are:
|
|
129
|
+
## Step 6 โ Enable providers in your region
|
|
176
130
|
|
|
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`.
|
|
131
|
+
1. Medusa Admin โ **Settings โ Regions โ [your region]**
|
|
132
|
+
2. Under **Payment Providers**, enable:
|
|
133
|
+
- `pp_paypal_paypal` โ PayPal Smart Buttons
|
|
134
|
+
- `pp_paypal_card_paypal_card` โ Advanced Card Fields
|
|
183
135
|
|
|
184
136
|
---
|
|
185
137
|
|
|
186
|
-
##
|
|
187
|
-
|
|
188
|
-
When creating a payment session, use one of the generated provider IDs.
|
|
138
|
+
## Step 7 โ Configure settings (optional)
|
|
189
139
|
|
|
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
|
-
```
|
|
140
|
+
All settings are in Medusa Admin โ **Settings โ PayPal** and take effect immediately with no server restart.
|
|
205
141
|
|
|
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
|
-
```
|
|
142
|
+
| Tab | What you can configure |
|
|
143
|
+
|---|---|
|
|
144
|
+
| **PayPal Settings** | Enable/disable, button color, shape, label |
|
|
145
|
+
| **Advanced Card Payments** | Enable/disable, 3D Secure mode |
|
|
146
|
+
| **Additional Settings** | Payment action (capture / authorize), brand name, invoice prefix |
|
|
225
147
|
|
|
226
148
|
---
|
|
227
149
|
|
|
228
|
-
##
|
|
150
|
+
## Step 8 โ Connect the frontend package
|
|
229
151
|
|
|
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
|
|
152
|
+
Install the storefront UI package to render PayPal at checkout:
|
|
237
153
|
|
|
238
|
-
|
|
154
|
+
```bash
|
|
155
|
+
npm install @easypayment/medusa-paypal-ui
|
|
156
|
+
```
|
|
239
157
|
|
|
240
|
-
|
|
158
|
+
See the [medusa-paypal-frontend README](../medusa-paypal-frontend/README.md) for integration steps.
|
|
241
159
|
|
|
242
|
-
|
|
160
|
+
---
|