@easypayment/medusa-paypal 0.5.0 → 0.5.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 CHANGED
@@ -1,39 +1,71 @@
1
- # @easypayment/medusa-paypal
1
+ # EasyPayment PayPal for Medusa
2
2
 
3
- Production-ready PayPal integration for **Medusa v2** with:
3
+ PayPal Wallet and Advanced Card Payments integration for Medusa v2.
4
4
 
5
- - PayPal Wallet provider
6
- - PayPal Advanced Card provider
7
- - Admin settings pages (connection, wallet settings, advanced card settings, additional checkout behavior)
8
- - Store API routes used by storefront integrations
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
9
14
 
10
15
  ---
11
16
 
12
17
  ## Compatibility
13
18
 
14
- - Medusa: `^2.12.0`
15
- - Node.js: `>=20`
19
+ | Component | Version |
20
+ |-----------|---------|
21
+ | Medusa | `^2.12.0` |
22
+ | Node.js | `>=20` |
16
23
 
17
24
  ---
18
25
 
19
- ## Step-by-step setup (GitHub style)
26
+ ## Installation
20
27
 
21
- ### 1) Install the package
28
+ Install the package in your Medusa backend:
22
29
 
23
30
  ```bash
24
31
  npm install @easypayment/medusa-paypal
25
- # or
32
+ ```
33
+
34
+ Or with pnpm:
35
+
36
+ ```bash
26
37
  pnpm add @easypayment/medusa-paypal
27
- # or
38
+ ```
39
+
40
+ Or with yarn:
41
+
42
+ ```bash
28
43
  yarn add @easypayment/medusa-paypal
29
44
  ```
30
45
 
31
- ### 2) Register plugin + providers in `medusa-config.ts`
46
+ ---
47
+
48
+ ## Medusa Configuration
32
49
 
33
- Add the plugin and both payment providers:
50
+ Register the plugin and both payment providers in `medusa-config.ts`:
34
51
 
35
52
  ```ts
36
- module.exports = defineConfig({
53
+ import { loadEnv, defineConfig } from "@medusajs/framework/utils"
54
+
55
+ loadEnv(process.env.NODE_ENV || "development", process.cwd())
56
+
57
+ export default defineConfig({
58
+ projectConfig: {
59
+ databaseUrl: process.env.DATABASE_URL,
60
+ http: {
61
+ storeCors: process.env.STORE_CORS!,
62
+ adminCors: process.env.ADMIN_CORS!,
63
+ authCors: process.env.AUTH_CORS!,
64
+ jwtSecret: process.env.JWT_SECRET || "supersecret",
65
+ cookieSecret: process.env.COOKIE_SECRET || "supersecret",
66
+ },
67
+ },
68
+
37
69
  plugins: [
38
70
  {
39
71
  resolve: "@easypayment/medusa-paypal",
@@ -49,10 +81,12 @@ module.exports = defineConfig({
49
81
  {
50
82
  resolve: "@easypayment/medusa-paypal/providers/paypal",
51
83
  id: "paypal",
84
+ dependencies: ["paypal_onboarding"],
52
85
  },
53
86
  {
54
87
  resolve: "@easypayment/medusa-paypal/providers/paypal_card",
55
88
  id: "paypal_card",
89
+ dependencies: ["paypal_onboarding"],
56
90
  },
57
91
  ],
58
92
  },
@@ -61,80 +95,146 @@ module.exports = defineConfig({
61
95
  })
62
96
  ```
63
97
 
64
- ### 3) Add backend environment variables
98
+ ---
65
99
 
66
- Set these in your backend `.env`:
100
+ ## Environment Variables
101
+
102
+ Add the required variables to your backend `.env` file:
103
+
104
+ ```env
105
+ STORE_CORS=http://localhost:8000,https://docs.medusajs.com
106
+ ADMIN_CORS=http://localhost:5173,http://localhost:9000,https://docs.medusajs.com
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
67
116
 
68
- ```bash
69
- # required for API + onboarding defaults
70
- PAYPAL_ENV=sandbox
71
117
  PAYPAL_CURRENCY=EUR
118
+ ```
119
+
120
+ ---
121
+
122
+ ## Start the Backend
123
+
124
+ Run your Medusa backend:
72
125
 
73
- # optional but recommended
74
- STOREFRONT_URL=https://your-storefront.example.com
75
- PAYPAL_CREDENTIALS_ENCRYPTION_KEY=your-32-byte-or-strong-secret
126
+ ```bash
127
+ npm run dev
76
128
  ```
77
129
 
78
- > Tip: PayPal API credentials are managed from the Medusa Admin PayPal settings UI.
130
+ Then open Medusa Admin.
131
+
132
+ ---
133
+
134
+ ## Admin Setup
79
135
 
80
- ### 4) Start backend and open Admin
136
+ After installation, configure PayPal from the Medusa Admin PayPal settings pages.
81
137
 
82
- - Run your Medusa backend.
83
- - Open Medusa Admin.
84
- - Go to the PayPal settings pages.
138
+ ### PayPal Wallet
85
139
 
86
- ### 5) Connect PayPal and configure checkout behavior
140
+ Available settings include:
87
141
 
88
- Use the Admin UI to set credentials and runtime behavior.
142
+ - `enabled`
143
+ - `title`
144
+ - `disableButtons`
145
+ - `buttonColor`
146
+ - `buttonShape`
147
+ - `buttonWidth`
148
+ - `buttonHeight`
149
+ - `buttonLabel`
89
150
 
90
- Runtime-relevant settings include:
151
+ ### Advanced Card Payments
91
152
 
92
- - **PayPal Settings**
93
- - `enabled`
94
- - `title`
95
- - `disableButtons`
96
- - `buttonColor`, `buttonShape`, `buttonWidth`, `buttonHeight`, `buttonLabel`
97
- - **Advanced Card Payments**
98
- - `enabled`
99
- - `title`
100
- - `threeDS`
101
- - **Additional Settings**
102
- - `paymentAction` (`capture` or `authorize`)
103
- - `brandName`
104
- - `landingPage`
105
- - `requireInstantPayment`
106
- - `sendItemDetails`
107
- - `invoicePrefix`
108
- - `creditCardStatementName`
153
+ Available settings include:
109
154
 
110
- ### 6) Use the generated provider IDs in your storefront
155
+ - `enabled`
156
+ - `title`
157
+ - `threeDS`
111
158
 
112
- With the sample config above, Medusa provider IDs are:
159
+ ### Additional Checkout Settings
113
160
 
114
- - `pp_paypal_paypal`
115
- - `pp_paypal_card_paypal_card`
161
+ Available settings include:
116
162
 
117
- Your storefront package should use these exact IDs unless you customize provider IDs.
163
+ - `paymentAction` (`capture` or `authorize`)
164
+ - `brandName`
165
+ - `landingPage`
166
+ - `requireInstantPayment`
167
+ - `sendItemDetails`
168
+ - `invoicePrefix`
169
+ - `creditCardStatementName`
118
170
 
119
171
  ---
120
172
 
121
- ## Quick checklist
173
+ ## Provider IDs
174
+
175
+ With the default configuration shown above, the generated Medusa provider IDs are:
176
+
177
+ ```txt
178
+ pp_paypal_paypal
179
+ pp_paypal_card_paypal_card
180
+ ```
122
181
 
123
- - [ ] Package installed
124
- - [ ] `medusa-config.ts` updated (plugin + both providers)
125
- - [ ] Required env vars set
126
- - [ ] PayPal credentials configured in Admin
127
- - [ ] Storefront uses correct provider IDs
182
+ Use these exact provider IDs in your storefront unless you change the provider `id` values in `medusa-config.ts`.
128
183
 
129
184
  ---
130
185
 
131
- ## Build and publish
186
+ ## Storefront Usage
132
187
 
133
- ```bash
134
- npm run build
135
- npm publish --access public
188
+ When creating a payment session, use one of the generated provider IDs.
189
+
190
+ Example for PayPal Wallet:
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
+ }
136
204
  ```
137
205
 
206
+ Typical flow:
207
+
208
+ 1. Create cart
209
+ 2. Create payment collection
210
+ 3. Create payment session with the selected provider ID
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
+ ```
225
+
226
+ ---
227
+
228
+ ## Quick Setup Checklist
229
+
230
+ - Install `@easypayment/medusa-paypal`
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
237
+
138
238
  ---
139
239
 
140
240
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easypayment/medusa-paypal",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Industry-standard PayPal integration for Medusa v2",
5
5
  "license": "MIT",
6
6
  "main": "./.medusa/server/src/index.js",
@@ -0,0 +1,11 @@
1
+ import { Migration } from "@mikro-orm/migrations"
2
+
3
+ export class Migration20270102090000 extends Migration {
4
+ override async up(): Promise<void> {
5
+ this.addSql(`alter table if exists "paypal_connection" add column if not exists "seller_email" text null;`)
6
+ }
7
+
8
+ override async down(): Promise<void> {
9
+ this.addSql(`alter table if exists "paypal_connection" drop column if exists "seller_email";`)
10
+ }
11
+ }
@@ -1,21 +1,22 @@
1
- import { model } from "@medusajs/framework/utils"
2
-
3
- const PayPalConnection = model.define("paypal_connection", {
4
- id: model.id().primaryKey(),
5
-
6
- environment: model.text(), // sandbox|live
7
- status: model.text(), // disconnected|pending|pending_credentials|connected|revoked
8
-
9
- shared_id: model.text().nullable(),
10
- auth_code: model.text().nullable(),
11
-
12
- seller_client_id: model.text().nullable(),
13
- seller_client_secret: model.text().nullable(),
14
-
15
- app_access_token: model.text().nullable(),
16
- app_access_token_expires_at: model.dateTime().nullable(),
17
-
18
- metadata: model.json().nullable(),
19
- })
20
-
21
- export default PayPalConnection
1
+ import { model } from "@medusajs/framework/utils"
2
+
3
+ const PayPalConnection = model.define("paypal_connection", {
4
+ id: model.id().primaryKey(),
5
+
6
+ environment: model.text(), // sandbox|live
7
+ status: model.text(), // disconnected|pending|pending_credentials|connected|revoked
8
+
9
+ shared_id: model.text().nullable(),
10
+ auth_code: model.text().nullable(),
11
+
12
+ seller_client_id: model.text().nullable(),
13
+ seller_client_secret: model.text().nullable(),
14
+ seller_email: model.text().nullable(),
15
+
16
+ app_access_token: model.text().nullable(),
17
+ app_access_token_expires_at: model.dateTime().nullable(),
18
+
19
+ metadata: model.json().nullable(),
20
+ })
21
+
22
+ export default PayPalConnection