@hectasquare/medusa-payment-paypal 1.0.0
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/CHANGELOG.md +83 -0
- package/LICENSE +22 -0
- package/README.md +214 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/service.d.ts +104 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +405 -0
- package/dist/service.js.map +1 -0
- package/package.json +57 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.0.0] - 2024-10-13
|
|
9
|
+
|
|
10
|
+
### ⚠️ BREAKING CHANGES
|
|
11
|
+
- **SDK Migration**: Migrated from `@paypal/checkout-server-sdk` (deprecated) to `@paypal/paypal-server-sdk` (latest)
|
|
12
|
+
- Removed hybrid SDK approach in favor of unified SDK implementation
|
|
13
|
+
- All functionality now uses the latest PayPal Server SDK
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- 🔄 **Unified SDK**: Replaced hybrid SDK architecture with single `@paypal/paypal-server-sdk`
|
|
17
|
+
- ✨ **Core Payments**: All Orders and Payments API calls now use new SDK controllers
|
|
18
|
+
- `OrdersController.createOrder()` for order creation
|
|
19
|
+
- `OrdersController.captureOrder()` for payment capture
|
|
20
|
+
- `OrdersController.getOrder()` for status retrieval
|
|
21
|
+
- `PaymentsController.refundCapturedPayment()` for refunds
|
|
22
|
+
- 🎯 **Vault API**: Vault functionality continues to use same SDK (no changes)
|
|
23
|
+
- 📝 **TypeScript**: Improved type safety with latest SDK type definitions
|
|
24
|
+
|
|
25
|
+
### Removed
|
|
26
|
+
- ❌ `@paypal/checkout-server-sdk` dependency (deprecated by PayPal)
|
|
27
|
+
- ❌ `@types/paypal__checkout-server-sdk` dev dependency
|
|
28
|
+
|
|
29
|
+
### Why This Update?
|
|
30
|
+
PayPal's `@paypal/checkout-server-sdk` is no longer maintained. The new `@paypal/paypal-server-sdk` provides:
|
|
31
|
+
- ✅ Continued maintenance and security updates
|
|
32
|
+
- ✅ Complete feature parity for Orders and Payments APIs
|
|
33
|
+
- ✅ Better TypeScript support
|
|
34
|
+
- ✅ Unified API design across all PayPal services
|
|
35
|
+
|
|
36
|
+
### Migration Guide
|
|
37
|
+
No changes required for most users! The provider interface remains the same. Simply update the package:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install @rd1988/medusa-payment-paypal@^2.0.0
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The payment flow, Vault API, and all configuration remain unchanged.
|
|
44
|
+
|
|
45
|
+
## [1.0.0] - 2024-10-13
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
- 🎉 Initial release
|
|
49
|
+
- ✅ Complete PayPal payment integration for Medusa v2.10+
|
|
50
|
+
- ✅ Core payment functionality
|
|
51
|
+
- Create orders
|
|
52
|
+
- Authorize and capture payments
|
|
53
|
+
- Refund handling
|
|
54
|
+
- Webhook integration
|
|
55
|
+
- ✅ Vault API support (US only)
|
|
56
|
+
- Save payment methods using Setup Tokens
|
|
57
|
+
- List saved payment methods
|
|
58
|
+
- ✅ Account holder management
|
|
59
|
+
- Create customer accounts
|
|
60
|
+
- Update customer information
|
|
61
|
+
- Delete customer accounts
|
|
62
|
+
- ✅ Hybrid SDK approach
|
|
63
|
+
- `@paypal/checkout-server-sdk` for core payments
|
|
64
|
+
- `@paypal/paypal-server-sdk` for Vault API
|
|
65
|
+
- ✅ Proper status mapping (PayPal COMPLETED → Medusa CAPTURED)
|
|
66
|
+
- ✅ Automatic amount conversion (cents ↔ dollars)
|
|
67
|
+
- ✅ TypeScript support
|
|
68
|
+
- ✅ Sandbox and production environment support
|
|
69
|
+
|
|
70
|
+
### Technical Details
|
|
71
|
+
- Based on official @medusajs/payment-stripe implementation pattern
|
|
72
|
+
- Full TypeScript type definitions
|
|
73
|
+
- Comprehensive error handling
|
|
74
|
+
- Follows Medusa v2 payment provider specification
|
|
75
|
+
|
|
76
|
+
### Documentation
|
|
77
|
+
- Complete README with setup instructions
|
|
78
|
+
- API reference
|
|
79
|
+
- Frontend integration guide
|
|
80
|
+
- Troubleshooting section
|
|
81
|
+
|
|
82
|
+
[1.0.0]: https://github.com/yourusername/medusa-payment-paypal/releases/tag/v1.0.0
|
|
83
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Medusa Payment PayPal
|
|
2
|
+
|
|
3
|
+
Complete PayPal Payment Provider for Medusa v2.10+ with full Vault API support.
|
|
4
|
+
|
|
5
|
+
## ✨ Features
|
|
6
|
+
|
|
7
|
+
### Core Payment Capabilities
|
|
8
|
+
- ✅ Order creation (Orders API)
|
|
9
|
+
- ✅ Payment authorization and capture
|
|
10
|
+
- ✅ Refund processing
|
|
11
|
+
- ✅ Webhook integration
|
|
12
|
+
- ✅ Sandbox and production environment support
|
|
13
|
+
|
|
14
|
+
### Advanced Features (Vault API)
|
|
15
|
+
- ✅ **Save Payment Methods** - Customers can save credit cards for faster checkout
|
|
16
|
+
- ✅ **List Payment Methods** - View saved payment methods
|
|
17
|
+
- ✅ **Customer Account Management** - Create, update, delete customer accounts
|
|
18
|
+
- ✅ **Setup Tokens** - Securely collect and store payment information
|
|
19
|
+
|
|
20
|
+
### Technical Highlights
|
|
21
|
+
- ✨ **Unified SDK** - Implements all features using the latest `@paypal/paypal-server-sdk`
|
|
22
|
+
- 📝 **Full TypeScript support**
|
|
23
|
+
- 🛡️ **Error handling and validation**
|
|
24
|
+
- 🎯 **Based on official Stripe provider implementation pattern**
|
|
25
|
+
- 🚀 **Actively maintained** - Follows PayPal's latest SDK updates
|
|
26
|
+
|
|
27
|
+
## 📦 Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @rd1988/medusa-payment-paypal
|
|
31
|
+
# or
|
|
32
|
+
yarn add @rd1988/medusa-payment-paypal
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 🚀 Usage
|
|
36
|
+
|
|
37
|
+
### 1. Configure Medusa
|
|
38
|
+
|
|
39
|
+
Add the provider in `medusa-config.ts`:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { defineConfig } from "@medusajs/framework/utils"
|
|
43
|
+
|
|
44
|
+
export default defineConfig({
|
|
45
|
+
// ...
|
|
46
|
+
modules: [
|
|
47
|
+
{
|
|
48
|
+
resolve: "@medusajs/medusa/payment",
|
|
49
|
+
options: {
|
|
50
|
+
providers: [
|
|
51
|
+
{
|
|
52
|
+
resolve: "@rd1988/medusa-payment-paypal",
|
|
53
|
+
id: "paypal",
|
|
54
|
+
options: {
|
|
55
|
+
clientId: process.env.PAYPAL_CLIENT_ID,
|
|
56
|
+
clientSecret: process.env.PAYPAL_CLIENT_SECRET,
|
|
57
|
+
isSandbox: process.env.PAYPAL_IS_SANDBOX === "true",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 2. Environment Variables
|
|
68
|
+
|
|
69
|
+
Create a `.env` file:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# PayPal Sandbox Environment
|
|
73
|
+
PAYPAL_CLIENT_ID=your_sandbox_client_id
|
|
74
|
+
PAYPAL_CLIENT_SECRET=your_sandbox_client_secret
|
|
75
|
+
PAYPAL_IS_SANDBOX=true
|
|
76
|
+
|
|
77
|
+
# PayPal Production Environment
|
|
78
|
+
# PAYPAL_CLIENT_ID=your_production_client_id
|
|
79
|
+
# PAYPAL_CLIENT_SECRET=your_production_client_secret
|
|
80
|
+
# PAYPAL_IS_SANDBOX=false
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 3. Get PayPal Credentials
|
|
84
|
+
|
|
85
|
+
1. Visit [PayPal Developer Dashboard](https://developer.paypal.com/dashboard/)
|
|
86
|
+
2. Create an app to get Client ID and Secret
|
|
87
|
+
3. Configure sandbox test accounts
|
|
88
|
+
|
|
89
|
+
### 4. Enable in Admin
|
|
90
|
+
|
|
91
|
+
1. Log in to Medusa Admin
|
|
92
|
+
2. Go to Settings → Regions
|
|
93
|
+
3. Enable PayPal payment provider for your region
|
|
94
|
+
|
|
95
|
+
## 🔧 Configuration Options
|
|
96
|
+
|
|
97
|
+
| Option | Type | Required | Description |
|
|
98
|
+
|--------|------|----------|-------------|
|
|
99
|
+
| `clientId` | string | ✅ | PayPal Client ID |
|
|
100
|
+
| `clientSecret` | string | ✅ | PayPal Client Secret |
|
|
101
|
+
| `isSandbox` | boolean | ❌ | Use sandbox environment (default `false`) |
|
|
102
|
+
|
|
103
|
+
## 📝 Supported Methods
|
|
104
|
+
|
|
105
|
+
### Core Payment
|
|
106
|
+
- `initiatePayment` - Create PayPal order
|
|
107
|
+
- `authorizePayment` - Authorize and capture payment
|
|
108
|
+
- `capturePayment` - Capture authorized payment
|
|
109
|
+
- `cancelPayment` - Cancel payment
|
|
110
|
+
- `refundPayment` - Process refund
|
|
111
|
+
- `retrievePayment` - Get payment status
|
|
112
|
+
- `updatePayment` - Update payment (recreate order)
|
|
113
|
+
- `getWebhookActionAndData` - Handle PayPal webhooks
|
|
114
|
+
|
|
115
|
+
### Account Management
|
|
116
|
+
- `createAccountHolder` - Create customer account
|
|
117
|
+
- `updateAccountHolder` - Update customer information
|
|
118
|
+
- `deleteAccountHolder` - Delete customer account
|
|
119
|
+
|
|
120
|
+
### Payment Method Management (Vault API)
|
|
121
|
+
- `savePaymentMethod` - Save customer payment method
|
|
122
|
+
- `listPaymentMethods` - List saved payment methods
|
|
123
|
+
|
|
124
|
+
## 🎨 Frontend Integration
|
|
125
|
+
|
|
126
|
+
### Basic Payment Flow
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
// In checkout page
|
|
130
|
+
import { sdk } from "@/lib/medusa"
|
|
131
|
+
|
|
132
|
+
// 1. Initialize PayPal payment session
|
|
133
|
+
const paymentSession = await sdk.store.payment.initiatePaymentSession(cartId, {
|
|
134
|
+
provider_id: "pp_payment_paypal", // pp_{module_id}_{identifier}
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
// 2. Load PayPal SDK
|
|
138
|
+
const script = document.createElement('script')
|
|
139
|
+
script.src = `https://www.paypal.com/sdk/js?client-id=${PAYPAL_CLIENT_ID}¤cy=USD&intent=capture`
|
|
140
|
+
script.onload = () => {
|
|
141
|
+
window.paypal.Buttons({
|
|
142
|
+
createOrder: () => paymentSession.data.id, // Use Medusa-created order ID
|
|
143
|
+
onApprove: async () => {
|
|
144
|
+
// 3. Complete order
|
|
145
|
+
const order = await sdk.store.cart.complete(cartId)
|
|
146
|
+
// Redirect to order confirmation page
|
|
147
|
+
}
|
|
148
|
+
}).render('#paypal-button-container')
|
|
149
|
+
}
|
|
150
|
+
document.body.appendChild(script)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Save Payment Method (Optional)
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
// Save customer payment method
|
|
157
|
+
const paymentMethod = await sdk.store.payment.savePaymentMethod({
|
|
158
|
+
provider_id: "pp_payment_paypal",
|
|
159
|
+
data: {
|
|
160
|
+
card: {
|
|
161
|
+
// Card information
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
// List saved payment methods
|
|
167
|
+
const paymentMethods = await sdk.store.payment.listPaymentMethods()
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## 🔍 Status Mapping
|
|
171
|
+
|
|
172
|
+
| PayPal Status | Medusa Status | Description |
|
|
173
|
+
|--------------|--------------|-------------|
|
|
174
|
+
| `CREATED` | `PENDING` | Order created |
|
|
175
|
+
| `SAVED` | `PENDING` | Order saved |
|
|
176
|
+
| `APPROVED` | `PENDING` | Buyer approved |
|
|
177
|
+
| `COMPLETED` | `CAPTURED` | 🔑 Payment completed |
|
|
178
|
+
| `VOIDED` | `CANCELED` | Payment voided |
|
|
179
|
+
| `PAYER_ACTION_REQUIRED` | `REQUIRES_MORE` | Requires buyer action |
|
|
180
|
+
|
|
181
|
+
## 🐛 Troubleshooting
|
|
182
|
+
|
|
183
|
+
### Payment status not updating
|
|
184
|
+
|
|
185
|
+
Ensure PayPal status is correctly mapped to Medusa's `CAPTURED` status. This provider handles this correctly.
|
|
186
|
+
|
|
187
|
+
### Amount format errors
|
|
188
|
+
|
|
189
|
+
PayPal uses dollars, Medusa uses cents. This provider handles conversion automatically:
|
|
190
|
+
- Sending to PayPal: `3299 cents → $32.99`
|
|
191
|
+
- Receiving from PayPal: `$32.99 → 3299 cents`
|
|
192
|
+
|
|
193
|
+
### Vault API unavailable
|
|
194
|
+
|
|
195
|
+
PayPal Vault API is currently **only available in the United States**. Ensure your PayPal account supports this feature.
|
|
196
|
+
|
|
197
|
+
## 📚 Reference Documentation
|
|
198
|
+
|
|
199
|
+
- [PayPal Orders API](https://developer.paypal.com/docs/api/orders/v2/)
|
|
200
|
+
- [PayPal Payments API](https://developer.paypal.com/docs/api/payments/v2/)
|
|
201
|
+
- [PayPal Vault API](https://developer.paypal.com/docs/api/payment-tokens/v3/)
|
|
202
|
+
- [Medusa Payment Provider](https://docs.medusajs.com/resources/references/payment/provider)
|
|
203
|
+
|
|
204
|
+
## 🤝 Contributing
|
|
205
|
+
|
|
206
|
+
Issues and Pull Requests are welcome!
|
|
207
|
+
|
|
208
|
+
## 📄 License
|
|
209
|
+
|
|
210
|
+
MIT License
|
|
211
|
+
|
|
212
|
+
## 🙏 Acknowledgments
|
|
213
|
+
|
|
214
|
+
Based on the implementation pattern of the official [@medusajs/payment-stripe](https://github.com/medusajs/medusa/tree/develop/packages/modules/providers/payment-stripe).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,wBAEE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
7
|
+
const service_1 = __importDefault(require("./service"));
|
|
8
|
+
exports.default = (0, utils_1.ModuleProvider)(utils_1.Modules.PAYMENT, {
|
|
9
|
+
services: [service_1.default],
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,qDAAmE;AACnE,wDAA6C;AAE7C,kBAAe,IAAA,sBAAc,EAAC,eAAO,CAAC,OAAO,EAAE;IAC7C,QAAQ,EAAE,CAAC,iBAAqB,CAAC;CAClC,CAAC,CAAA"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PayPal Payment Provider for Medusa 2.10+
|
|
3
|
+
*
|
|
4
|
+
* Using the latest @paypal/paypal-server-sdk for unified functionality:
|
|
5
|
+
* - Orders API: Create orders, capture, query
|
|
6
|
+
* - Payments API: Refund processing
|
|
7
|
+
* - Vault API: Save payment methods, account management
|
|
8
|
+
*
|
|
9
|
+
* Based on official @medusajs/payment-stripe implementation pattern
|
|
10
|
+
* Reference: https://github.com/medusajs/medusa/tree/develop/packages/modules/providers/payment-stripe
|
|
11
|
+
* Documentation: https://docs.medusajs.com/resources/references/payment/provider
|
|
12
|
+
*/
|
|
13
|
+
import { AuthorizePaymentInput, AuthorizePaymentOutput, CancelPaymentInput, CancelPaymentOutput, CapturePaymentInput, CapturePaymentOutput, CreateAccountHolderInput, CreateAccountHolderOutput, DeleteAccountHolderInput, DeleteAccountHolderOutput, DeletePaymentInput, DeletePaymentOutput, GetPaymentStatusInput, GetPaymentStatusOutput, InitiatePaymentInput, InitiatePaymentOutput, ListPaymentMethodsInput, ListPaymentMethodsOutput, ProviderWebhookPayload, RefundPaymentInput, RefundPaymentOutput, RetrievePaymentInput, RetrievePaymentOutput, SavePaymentMethodInput, SavePaymentMethodOutput, UpdateAccountHolderInput, UpdateAccountHolderOutput, UpdatePaymentInput, UpdatePaymentOutput, WebhookActionResult } from "@medusajs/framework/types";
|
|
14
|
+
import { AbstractPaymentProvider } from "@medusajs/framework/utils";
|
|
15
|
+
import { Client } from "@paypal/paypal-server-sdk";
|
|
16
|
+
interface PayPalOptions {
|
|
17
|
+
clientId: string;
|
|
18
|
+
clientSecret: string;
|
|
19
|
+
isSandbox?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export default class PayPalProviderService extends AbstractPaymentProvider<PayPalOptions> {
|
|
22
|
+
static identifier: string;
|
|
23
|
+
protected readonly options_: PayPalOptions;
|
|
24
|
+
protected readonly client_: Client;
|
|
25
|
+
static validateOptions(options: PayPalOptions): void;
|
|
26
|
+
constructor(container: any, options: PayPalOptions);
|
|
27
|
+
/**
|
|
28
|
+
* Create PayPal order
|
|
29
|
+
*
|
|
30
|
+
* Key:
|
|
31
|
+
* - intent: CAPTURE (PayPal default)
|
|
32
|
+
* - Amount conversion: cents -> dollars
|
|
33
|
+
*/
|
|
34
|
+
initiatePayment(input: InitiatePaymentInput): Promise<InitiatePaymentOutput>;
|
|
35
|
+
/**
|
|
36
|
+
* Authorize/Capture payment
|
|
37
|
+
*
|
|
38
|
+
* Key:
|
|
39
|
+
* - PayPal CAPTURE intent: authorize = capture
|
|
40
|
+
* - Execute capture and return correct CAPTURED status
|
|
41
|
+
*/
|
|
42
|
+
authorizePayment(input: AuthorizePaymentInput): Promise<AuthorizePaymentOutput>;
|
|
43
|
+
/**
|
|
44
|
+
* Capture payment
|
|
45
|
+
*
|
|
46
|
+
* PayPal already completes capture in authorizePayment
|
|
47
|
+
* Just return current status
|
|
48
|
+
*/
|
|
49
|
+
capturePayment(input: CapturePaymentInput): Promise<CapturePaymentOutput>;
|
|
50
|
+
/**
|
|
51
|
+
* Cancel payment
|
|
52
|
+
*/
|
|
53
|
+
cancelPayment(input: CancelPaymentInput): Promise<CancelPaymentOutput>;
|
|
54
|
+
/**
|
|
55
|
+
* Delete payment
|
|
56
|
+
*/
|
|
57
|
+
deletePayment(input: DeletePaymentInput): Promise<DeletePaymentOutput>;
|
|
58
|
+
/**
|
|
59
|
+
* Get payment status
|
|
60
|
+
*/
|
|
61
|
+
getPaymentStatus(input: GetPaymentStatusInput): Promise<GetPaymentStatusOutput>;
|
|
62
|
+
/**
|
|
63
|
+
* Refund payment
|
|
64
|
+
*/
|
|
65
|
+
refundPayment(input: RefundPaymentInput): Promise<RefundPaymentOutput>;
|
|
66
|
+
/**
|
|
67
|
+
* Retrieve payment
|
|
68
|
+
*/
|
|
69
|
+
retrievePayment(input: RetrievePaymentInput): Promise<RetrievePaymentOutput>;
|
|
70
|
+
/**
|
|
71
|
+
* Update payment
|
|
72
|
+
*/
|
|
73
|
+
updatePayment(input: UpdatePaymentInput): Promise<UpdatePaymentOutput>;
|
|
74
|
+
/**
|
|
75
|
+
* Handle webhook
|
|
76
|
+
*/
|
|
77
|
+
getWebhookActionAndData(webhookData: ProviderWebhookPayload["payload"]): Promise<WebhookActionResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Map PayPal status to Medusa PaymentSessionStatus
|
|
80
|
+
*/
|
|
81
|
+
private getStatus;
|
|
82
|
+
/**
|
|
83
|
+
* Create account holder (customer)
|
|
84
|
+
*/
|
|
85
|
+
createAccountHolder({ context, }: CreateAccountHolderInput): Promise<CreateAccountHolderOutput>;
|
|
86
|
+
/**
|
|
87
|
+
* Update account holder
|
|
88
|
+
*/
|
|
89
|
+
updateAccountHolder({ context, data, }: UpdateAccountHolderInput): Promise<UpdateAccountHolderOutput>;
|
|
90
|
+
/**
|
|
91
|
+
* Delete account holder
|
|
92
|
+
*/
|
|
93
|
+
deleteAccountHolder({ context, }: DeleteAccountHolderInput): Promise<DeleteAccountHolderOutput>;
|
|
94
|
+
/**
|
|
95
|
+
* Save payment method - PayPal Vault API
|
|
96
|
+
*/
|
|
97
|
+
savePaymentMethod({ context, data, }: SavePaymentMethodInput): Promise<SavePaymentMethodOutput>;
|
|
98
|
+
/**
|
|
99
|
+
* List saved payment methods - PayPal Vault API
|
|
100
|
+
*/
|
|
101
|
+
listPaymentMethods({ context, }: ListPaymentMethodsInput): Promise<ListPaymentMethodsOutput>;
|
|
102
|
+
}
|
|
103
|
+
export {};
|
|
104
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,uBAAuB,EAIxB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,MAAM,EAMP,MAAM,2BAA2B,CAAA;AAElC,UAAU,aAAa;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,uBAAuB,CAAC,aAAa,CAAC;IACvF,MAAM,CAAC,UAAU,SAAW;IAE5B,SAAS,CAAC,QAAQ,CAAC,Q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ACG,mBAAmB,CAAC,EACxB,OAAO,EACP,IAAI,GACL,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAyBhE;;OAEG;IACG,mBAAmB,CAAC,EACxB,OAAO,GACR,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAahE;;OAEG;IACG,iBAAiB,CAAC,EACtB,OAAO,EACP,IAAI,GACL,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAuC5D;;OAEG;IACG,kBAAkB,CAAC,EACvB,OAAO,GACR,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CA8B/D"}
|
package/dist/service.js
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PayPal Payment Provider for Medusa 2.10+
|
|
4
|
+
*
|
|
5
|
+
* Using the latest @paypal/paypal-server-sdk for unified functionality:
|
|
6
|
+
* - Orders API: Create orders, capture, query
|
|
7
|
+
* - Payments API: Refund processing
|
|
8
|
+
* - Vault API: Save payment methods, account management
|
|
9
|
+
*
|
|
10
|
+
* Based on official @medusajs/payment-stripe implementation pattern
|
|
11
|
+
* Reference: https://github.com/medusajs/medusa/tree/develop/packages/modules/providers/payment-stripe
|
|
12
|
+
* Documentation: https://docs.medusajs.com/resources/references/payment/provider
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
16
|
+
const paypal_server_sdk_1 = require("@paypal/paypal-server-sdk");
|
|
17
|
+
class PayPalProviderService extends utils_1.AbstractPaymentProvider {
|
|
18
|
+
static validateOptions(options) {
|
|
19
|
+
if (!options.clientId) {
|
|
20
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Required option `clientId` is missing in PayPal provider");
|
|
21
|
+
}
|
|
22
|
+
if (!options.clientSecret) {
|
|
23
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Required option `clientSecret` is missing in PayPal provider");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
constructor(container, options) {
|
|
27
|
+
super(container, options);
|
|
28
|
+
this.options_ = options;
|
|
29
|
+
// Initialize PayPal client
|
|
30
|
+
this.client_ = new paypal_server_sdk_1.Client({
|
|
31
|
+
clientCredentialsAuthCredentials: {
|
|
32
|
+
oAuthClientId: options.clientId,
|
|
33
|
+
oAuthClientSecret: options.clientSecret,
|
|
34
|
+
},
|
|
35
|
+
environment: options.isSandbox
|
|
36
|
+
? paypal_server_sdk_1.Environment.Sandbox
|
|
37
|
+
: paypal_server_sdk_1.Environment.Production,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create PayPal order
|
|
42
|
+
*
|
|
43
|
+
* Key:
|
|
44
|
+
* - intent: CAPTURE (PayPal default)
|
|
45
|
+
* - Amount conversion: cents -> dollars
|
|
46
|
+
*/
|
|
47
|
+
async initiatePayment(input) {
|
|
48
|
+
const { currency_code, amount, data, context } = input;
|
|
49
|
+
const ordersController = new paypal_server_sdk_1.OrdersController(this.client_);
|
|
50
|
+
try {
|
|
51
|
+
const response = await ordersController.createOrder({
|
|
52
|
+
body: {
|
|
53
|
+
intent: paypal_server_sdk_1.CheckoutPaymentIntent.Capture,
|
|
54
|
+
purchaseUnits: [
|
|
55
|
+
{
|
|
56
|
+
amount: {
|
|
57
|
+
currencyCode: currency_code.toUpperCase(),
|
|
58
|
+
value: (amount / 100).toFixed(2), // cents to dollars
|
|
59
|
+
},
|
|
60
|
+
customId: data?.session_id || undefined,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
applicationContext: {
|
|
64
|
+
userAction: "PAY_NOW",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
prefer: "return=representation",
|
|
68
|
+
});
|
|
69
|
+
const order = response.result;
|
|
70
|
+
return {
|
|
71
|
+
id: order.id,
|
|
72
|
+
...this.getStatus(order),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.PAYMENT_AUTHORIZATION_ERROR, `PayPal initiatePayment failed: ${error.message || error}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Authorize/Capture payment
|
|
81
|
+
*
|
|
82
|
+
* Key:
|
|
83
|
+
* - PayPal CAPTURE intent: authorize = capture
|
|
84
|
+
* - Execute capture and return correct CAPTURED status
|
|
85
|
+
*/
|
|
86
|
+
async authorizePayment(input) {
|
|
87
|
+
const { data } = input;
|
|
88
|
+
const orderId = data?.id;
|
|
89
|
+
if (!orderId) {
|
|
90
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "No PayPal order ID found for authorizePayment");
|
|
91
|
+
}
|
|
92
|
+
const ordersController = new paypal_server_sdk_1.OrdersController(this.client_);
|
|
93
|
+
try {
|
|
94
|
+
// PayPal CAPTURE intent: execute capture on authorize
|
|
95
|
+
const response = await ordersController.captureOrder({
|
|
96
|
+
id: orderId,
|
|
97
|
+
prefer: "return=representation",
|
|
98
|
+
});
|
|
99
|
+
// Return CAPTURED status
|
|
100
|
+
return this.getStatus(response.result);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
// If already captured (422 error), get status
|
|
104
|
+
if (error.statusCode === 422) {
|
|
105
|
+
return await this.getPaymentStatus(input);
|
|
106
|
+
}
|
|
107
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.PAYMENT_AUTHORIZATION_ERROR, `PayPal authorizePayment failed: ${error.message || error}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Capture payment
|
|
112
|
+
*
|
|
113
|
+
* PayPal already completes capture in authorizePayment
|
|
114
|
+
* Just return current status
|
|
115
|
+
*/
|
|
116
|
+
async capturePayment(input) {
|
|
117
|
+
return await this.getPaymentStatus(input);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Cancel payment
|
|
121
|
+
*/
|
|
122
|
+
async cancelPayment(input) {
|
|
123
|
+
return {
|
|
124
|
+
data: input.data,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Delete payment
|
|
129
|
+
*/
|
|
130
|
+
async deletePayment(input) {
|
|
131
|
+
return await this.cancelPayment(input);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get payment status
|
|
135
|
+
*/
|
|
136
|
+
async getPaymentStatus(input) {
|
|
137
|
+
const { data } = input;
|
|
138
|
+
const orderId = data?.id;
|
|
139
|
+
if (!orderId) {
|
|
140
|
+
return {
|
|
141
|
+
status: utils_1.PaymentSessionStatus.PENDING,
|
|
142
|
+
data: data || {},
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const ordersController = new paypal_server_sdk_1.OrdersController(this.client_);
|
|
146
|
+
try {
|
|
147
|
+
const response = await ordersController.getOrder({
|
|
148
|
+
id: orderId,
|
|
149
|
+
});
|
|
150
|
+
return this.getStatus(response.result);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
return {
|
|
154
|
+
status: utils_1.PaymentSessionStatus.ERROR,
|
|
155
|
+
data: data || {},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Refund payment
|
|
161
|
+
*/
|
|
162
|
+
async refundPayment(input) {
|
|
163
|
+
const { data, amount } = input;
|
|
164
|
+
// Extract capture ID from data
|
|
165
|
+
const captureId = data?.purchase_units?.[0]?.payments?.captures?.[0]?.id;
|
|
166
|
+
if (!captureId) {
|
|
167
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "No capture ID found for refund");
|
|
168
|
+
}
|
|
169
|
+
const paymentsController = new paypal_server_sdk_1.PaymentsController(this.client_);
|
|
170
|
+
try {
|
|
171
|
+
const refundRequest = {};
|
|
172
|
+
if (amount && typeof amount === "number") {
|
|
173
|
+
const currencyCode = data?.purchase_units?.[0]?.amount?.currency_code || "USD";
|
|
174
|
+
refundRequest.amount = {
|
|
175
|
+
currencyCode: currencyCode.toUpperCase(),
|
|
176
|
+
value: (amount / 100).toFixed(2),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const response = await paymentsController.refundCapturedPayment({
|
|
180
|
+
captureId: captureId,
|
|
181
|
+
body: refundRequest,
|
|
182
|
+
prefer: "return=representation",
|
|
183
|
+
});
|
|
184
|
+
return { data: response.result };
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.PAYMENT_AUTHORIZATION_ERROR, `PayPal refundPayment failed: ${error.message || error}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Retrieve payment
|
|
192
|
+
*/
|
|
193
|
+
async retrievePayment(input) {
|
|
194
|
+
return await this.getPaymentStatus(input);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Update payment
|
|
198
|
+
*/
|
|
199
|
+
async updatePayment(input) {
|
|
200
|
+
return await this.initiatePayment(input);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Handle webhook
|
|
204
|
+
*/
|
|
205
|
+
async getWebhookActionAndData(webhookData) {
|
|
206
|
+
const { resource, event_type } = webhookData;
|
|
207
|
+
switch (event_type) {
|
|
208
|
+
case "PAYMENT.CAPTURE.COMPLETED":
|
|
209
|
+
return {
|
|
210
|
+
action: utils_1.PaymentActions.SUCCESSFUL,
|
|
211
|
+
data: {
|
|
212
|
+
session_id: resource?.custom_id,
|
|
213
|
+
amount: parseFloat(resource?.amount?.value || "0") * 100,
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
case "PAYMENT.CAPTURE.DENIED":
|
|
217
|
+
case "PAYMENT.CAPTURE.DECLINED":
|
|
218
|
+
return {
|
|
219
|
+
action: utils_1.PaymentActions.FAILED,
|
|
220
|
+
data: {
|
|
221
|
+
session_id: resource?.custom_id,
|
|
222
|
+
amount: parseFloat(resource?.amount?.value || "0") * 100,
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
case "CHECKOUT.ORDER.APPROVED":
|
|
226
|
+
return {
|
|
227
|
+
action: utils_1.PaymentActions.AUTHORIZED,
|
|
228
|
+
data: {
|
|
229
|
+
session_id: resource?.purchase_units?.[0]?.custom_id,
|
|
230
|
+
amount: parseFloat(resource?.purchase_units?.[0]?.amount?.value || "0") * 100,
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
case "PAYMENT.CAPTURE.REFUNDED":
|
|
234
|
+
return {
|
|
235
|
+
action: utils_1.PaymentActions.SUCCESSFUL,
|
|
236
|
+
data: {
|
|
237
|
+
session_id: resource?.custom_id,
|
|
238
|
+
amount: parseFloat(resource?.amount?.value || "0") * 100,
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
default:
|
|
242
|
+
return {
|
|
243
|
+
action: utils_1.PaymentActions.NOT_SUPPORTED,
|
|
244
|
+
data: {
|
|
245
|
+
session_id: "",
|
|
246
|
+
amount: 0,
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Map PayPal status to Medusa PaymentSessionStatus
|
|
253
|
+
*/
|
|
254
|
+
getStatus(paypalOrder) {
|
|
255
|
+
const status = paypalOrder.status;
|
|
256
|
+
const data = paypalOrder;
|
|
257
|
+
switch (status) {
|
|
258
|
+
case "CREATED":
|
|
259
|
+
case "SAVED":
|
|
260
|
+
return {
|
|
261
|
+
status: utils_1.PaymentSessionStatus.PENDING,
|
|
262
|
+
data,
|
|
263
|
+
};
|
|
264
|
+
case "APPROVED":
|
|
265
|
+
return {
|
|
266
|
+
status: utils_1.PaymentSessionStatus.PENDING,
|
|
267
|
+
data,
|
|
268
|
+
};
|
|
269
|
+
case "PAYER_ACTION_REQUIRED":
|
|
270
|
+
return {
|
|
271
|
+
status: utils_1.PaymentSessionStatus.REQUIRES_MORE,
|
|
272
|
+
data,
|
|
273
|
+
};
|
|
274
|
+
case "COMPLETED":
|
|
275
|
+
return {
|
|
276
|
+
status: utils_1.PaymentSessionStatus.CAPTURED,
|
|
277
|
+
data,
|
|
278
|
+
};
|
|
279
|
+
case "VOIDED":
|
|
280
|
+
return {
|
|
281
|
+
status: utils_1.PaymentSessionStatus.CANCELED,
|
|
282
|
+
data,
|
|
283
|
+
};
|
|
284
|
+
default:
|
|
285
|
+
return {
|
|
286
|
+
status: utils_1.PaymentSessionStatus.PENDING,
|
|
287
|
+
data,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Create account holder (customer)
|
|
293
|
+
*/
|
|
294
|
+
async createAccountHolder({ context, }) {
|
|
295
|
+
const { account_holder, customer } = context;
|
|
296
|
+
if (account_holder?.data?.id) {
|
|
297
|
+
return { id: account_holder.data.id };
|
|
298
|
+
}
|
|
299
|
+
if (!customer) {
|
|
300
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "No customer provided while creating account holder");
|
|
301
|
+
}
|
|
302
|
+
const paypalCustomerId = `paypal_${customer.id}`;
|
|
303
|
+
return {
|
|
304
|
+
id: paypalCustomerId,
|
|
305
|
+
data: {
|
|
306
|
+
id: paypalCustomerId,
|
|
307
|
+
email: customer.email,
|
|
308
|
+
name: customer.company_name ||
|
|
309
|
+
`${customer.first_name ?? ""} ${customer.last_name ?? ""}`.trim() ||
|
|
310
|
+
undefined,
|
|
311
|
+
phone: customer.phone,
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Update account holder
|
|
317
|
+
*/
|
|
318
|
+
async updateAccountHolder({ context, data, }) {
|
|
319
|
+
const { account_holder, customer } = context;
|
|
320
|
+
if (!account_holder?.data?.id) {
|
|
321
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Missing account holder ID");
|
|
322
|
+
}
|
|
323
|
+
const updatedData = {
|
|
324
|
+
...account_holder.data,
|
|
325
|
+
...data,
|
|
326
|
+
email: customer?.email || account_holder.data.email,
|
|
327
|
+
name: customer?.company_name ||
|
|
328
|
+
`${customer?.first_name ?? ""} ${customer?.last_name ?? ""}`.trim() ||
|
|
329
|
+
account_holder.data.name,
|
|
330
|
+
};
|
|
331
|
+
return {
|
|
332
|
+
data: updatedData,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Delete account holder
|
|
337
|
+
*/
|
|
338
|
+
async deleteAccountHolder({ context, }) {
|
|
339
|
+
const { account_holder } = context;
|
|
340
|
+
if (!account_holder?.data?.id) {
|
|
341
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Missing account holder ID");
|
|
342
|
+
}
|
|
343
|
+
return {};
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Save payment method - PayPal Vault API
|
|
347
|
+
*/
|
|
348
|
+
async savePaymentMethod({ context, data, }) {
|
|
349
|
+
const accountHolderId = context?.account_holder?.data?.id;
|
|
350
|
+
if (!accountHolderId) {
|
|
351
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Missing account holder ID for saving payment method");
|
|
352
|
+
}
|
|
353
|
+
const vaultController = new paypal_server_sdk_1.VaultController(this.client_);
|
|
354
|
+
try {
|
|
355
|
+
const setupTokenRequest = {
|
|
356
|
+
payment_source: {
|
|
357
|
+
card: data?.card || {},
|
|
358
|
+
},
|
|
359
|
+
customer: {
|
|
360
|
+
id: accountHolderId,
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
const response = await vaultController.createSetupToken({
|
|
364
|
+
body: setupTokenRequest,
|
|
365
|
+
paypalRequestId: context?.idempotency_key,
|
|
366
|
+
});
|
|
367
|
+
return {
|
|
368
|
+
id: response.result.id || "",
|
|
369
|
+
data: response.result,
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.PAYMENT_AUTHORIZATION_ERROR, `PayPal savePaymentMethod failed: ${error.message || error}`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* List saved payment methods - PayPal Vault API
|
|
378
|
+
*/
|
|
379
|
+
async listPaymentMethods({ context, }) {
|
|
380
|
+
const accountHolderId = context?.account_holder?.data?.id;
|
|
381
|
+
if (!accountHolderId) {
|
|
382
|
+
return [];
|
|
383
|
+
}
|
|
384
|
+
const vaultController = new paypal_server_sdk_1.VaultController(this.client_);
|
|
385
|
+
try {
|
|
386
|
+
const response = await vaultController.listCustomerPaymentTokens({
|
|
387
|
+
customerId: accountHolderId,
|
|
388
|
+
pageSize: 100,
|
|
389
|
+
});
|
|
390
|
+
return (response.result.paymentTokens || []).map((token) => ({
|
|
391
|
+
id: token.id,
|
|
392
|
+
data: token,
|
|
393
|
+
}));
|
|
394
|
+
}
|
|
395
|
+
catch (error) {
|
|
396
|
+
if (error.statusCode === 404) {
|
|
397
|
+
return [];
|
|
398
|
+
}
|
|
399
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `PayPal listPaymentMethods failed: ${error.message || error}`);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
PayPalProviderService.identifier = "paypal";
|
|
404
|
+
exports.default = PayPalProviderService;
|
|
405
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAmCH,qDAKkC;AAElC,iEAOkC;AAQlC,MAAqB,qBAAsB,SAAQ,+BAAsC;IAMvF,MAAM,CAAC,eAAe,CAAC,OAAs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YAED,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,qCAAqC,KAAK,CAAC,OAAO,IAAI,KAAK,EAAE,CAC9D,CAAA;QACH,CAAC;IACH,CAAC;;AA7fM,gCAAU,GAAG,QAAQ,CAAA;kBADT,qBAAqB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hectasquare/medusa-payment-paypal",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "PayPal Payment Provider for Medusa v2.10+ using the latest PayPal Server SDK with full Vault API support - Hecta Square Edition",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"medusa",
|
|
13
|
+
"medusa-plugin",
|
|
14
|
+
"medusa-payment",
|
|
15
|
+
"medusa-v2",
|
|
16
|
+
"medusa-2.0",
|
|
17
|
+
"medusa-2.10",
|
|
18
|
+
"paypal",
|
|
19
|
+
"payment-provider",
|
|
20
|
+
"vault-api",
|
|
21
|
+
"e-commerce",
|
|
22
|
+
"paypal-server-sdk",
|
|
23
|
+
"headless-commerce",
|
|
24
|
+
"hectasquare"
|
|
25
|
+
],
|
|
26
|
+
"author": "HectaSquare",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/HectaSquareUK/medusa-payment-paypal"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@medusajs/framework": "^2.10.0",
|
|
37
|
+
"@medusajs/utils": "^2.10.0"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@paypal/paypal-server-sdk": "^1.1.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@medusajs/framework": "^2.10.3",
|
|
44
|
+
"@medusajs/utils": "^2.10.3",
|
|
45
|
+
"@types/node": "^20.0.0",
|
|
46
|
+
"typescript": "^5.3.0"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"README.md",
|
|
51
|
+
"LICENSE",
|
|
52
|
+
"CHANGELOG.md"
|
|
53
|
+
],
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=18.0.0"
|
|
56
|
+
}
|
|
57
|
+
}
|