medusa-payment-monei 0.1.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/LICENSE +21 -0
- package/README.md +247 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/service.d.ts +31 -0
- package/dist/service.js +299 -0
- package/dist/service.js.map +1 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MONEI Digital Payments, S.L.
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# medusa-payment-monei
|
|
2
|
+
|
|
3
|
+
MONEI payment provider for **Medusa v2**. Accept Cards, Bizum, PayPal, Google Pay, Apple Pay, BNPL, MB Way, SEPA Direct Debit and more through [MONEI](https://monei.com) — a licensed European Payment Institution (Banco de España #6911).
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Full payment lifecycle**: initiate → authorize → capture → refund → cancel
|
|
8
|
+
- **Auth + Capture flow**: pre-authorize and capture when ready (default), or auto-capture on authorization
|
|
9
|
+
- **Webhook support**: real-time payment status updates with HMAC signature verification
|
|
10
|
+
- **Multi-payment methods**: all MONEI payment methods available automatically (Cards, Bizum, PayPal, Google Pay, Apple Pay, etc.)
|
|
11
|
+
- **Hosted Payment Page**: redirect customers to MONEI's secure PCI-compliant payment page
|
|
12
|
+
- **monei.js integration**: storefront can use MONEI JS SDK for embedded payment components
|
|
13
|
+
- **Partial capture & refund**: supported via MONEI API
|
|
14
|
+
|
|
15
|
+
## Prerequisites
|
|
16
|
+
|
|
17
|
+
- Medusa v2 application
|
|
18
|
+
- MONEI account ([sign up](https://dashboard.monei.com/signup))
|
|
19
|
+
- API Key from MONEI Dashboard → Settings → API Access
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install medusa-payment-monei
|
|
25
|
+
# or
|
|
26
|
+
yarn add medusa-payment-monei
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Configuration
|
|
30
|
+
|
|
31
|
+
### 1. Add to `medusa-config.ts`
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { defineConfig } from "@medusajs/framework/utils"
|
|
35
|
+
|
|
36
|
+
export default defineConfig({
|
|
37
|
+
// ...
|
|
38
|
+
modules: [
|
|
39
|
+
{
|
|
40
|
+
resolve: "@medusajs/medusa/payment",
|
|
41
|
+
options: {
|
|
42
|
+
providers: [
|
|
43
|
+
{
|
|
44
|
+
resolve: "medusa-payment-monei",
|
|
45
|
+
id: "monei",
|
|
46
|
+
options: {
|
|
47
|
+
apiKey: process.env.MONEI_API_KEY,
|
|
48
|
+
// Optional: auto-capture payments (default: false)
|
|
49
|
+
// When false, payments use AUTH + manual capture flow
|
|
50
|
+
// When true, payments use SALE flow (captured immediately)
|
|
51
|
+
capture: false,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
})
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 2. Set environment variables
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# .env
|
|
65
|
+
MONEI_API_KEY=pk_test_xxxxxxxxxxxxxxxxxxxxx
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 3. Enable in Medusa Admin
|
|
69
|
+
|
|
70
|
+
Go to **Settings → Regions** and enable the MONEI payment provider for your region(s).
|
|
71
|
+
|
|
72
|
+
The provider registers as `pp_monei_monei` (format: `pp_{identifier}_{id}`).
|
|
73
|
+
|
|
74
|
+
## Payment Flows
|
|
75
|
+
|
|
76
|
+
### Default: Auth + Capture (recommended)
|
|
77
|
+
|
|
78
|
+
1. **Customer selects MONEI** → `initiatePayment` creates a MONEI payment with `transactionType: AUTH`
|
|
79
|
+
2. **Customer completes payment** → redirected to MONEI hosted page or uses monei.js component, completes 3DS if needed
|
|
80
|
+
3. **MONEI webhook** → `getWebhookActionAndData` receives `AUTHORIZED` status, completes the cart
|
|
81
|
+
4. **Admin captures** → `capturePayment` calls MONEI capture API
|
|
82
|
+
|
|
83
|
+
> ⏰ **Capture window**: Card payments must be captured within **7 days**, Bizum within **30 days**.
|
|
84
|
+
|
|
85
|
+
### Auto-capture (set `capture: true`)
|
|
86
|
+
|
|
87
|
+
1. Customer selects MONEI → payment created with `transactionType: SALE`
|
|
88
|
+
2. Customer completes payment → funds are captured immediately
|
|
89
|
+
3. Webhook receives `SUCCEEDED` status → order is created
|
|
90
|
+
|
|
91
|
+
## Webhooks
|
|
92
|
+
|
|
93
|
+
MONEI sends asynchronous webhook notifications to your Medusa server. Medusa provides a built-in webhook endpoint:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
{your_server_url}/hooks/payment/monei_monei
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Setting up webhooks
|
|
100
|
+
|
|
101
|
+
Configure the callback URL in MONEI Dashboard → Settings → Webhooks, or pass it dynamically via `callbackUrl` in the payment creation.
|
|
102
|
+
|
|
103
|
+
The plugin verifies the `MONEI-Signature` header using the MONEI Node SDK's built-in signature verification.
|
|
104
|
+
|
|
105
|
+
## Storefront Integration
|
|
106
|
+
|
|
107
|
+
### Option A: Hosted Payment Page (simplest)
|
|
108
|
+
|
|
109
|
+
After `initiatePayment`, the session data contains `redirect_url`. Redirect the customer:
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
// In your checkout component
|
|
113
|
+
const paymentSession = cart.payment_collection?.payment_sessions?.[0]
|
|
114
|
+
|
|
115
|
+
if (paymentSession?.data?.redirect_url) {
|
|
116
|
+
window.location.href = paymentSession.data.redirect_url
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Option B: monei.js Embedded Components
|
|
121
|
+
|
|
122
|
+
Use the MONEI JS SDK to embed payment components directly in your checkout:
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
import monei from "@monei-js/components"
|
|
126
|
+
|
|
127
|
+
// The payment ID from the session data serves as the client reference
|
|
128
|
+
const paymentId = paymentSession.data.id
|
|
129
|
+
|
|
130
|
+
// Render card input
|
|
131
|
+
const cardInput = monei.CardInput({
|
|
132
|
+
paymentId,
|
|
133
|
+
onChange: (event) => {
|
|
134
|
+
// Handle validation
|
|
135
|
+
},
|
|
136
|
+
})
|
|
137
|
+
cardInput.render("#card-input")
|
|
138
|
+
|
|
139
|
+
// Confirm payment
|
|
140
|
+
const result = await monei.confirmPayment({
|
|
141
|
+
paymentId,
|
|
142
|
+
paymentToken: token, // from cardInput.getToken()
|
|
143
|
+
})
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Payment Methods
|
|
147
|
+
|
|
148
|
+
All payment methods enabled in your MONEI Dashboard are automatically available:
|
|
149
|
+
|
|
150
|
+
| Method | Description |
|
|
151
|
+
|--------|-------------|
|
|
152
|
+
| **Cards** | Visa, Mastercard, Amex via 3D Secure |
|
|
153
|
+
| **Bizum** | Spain's #1 mobile payment (direct acquiring) |
|
|
154
|
+
| **PayPal** | Global digital wallet |
|
|
155
|
+
| **Google Pay** | Android/Chrome payments |
|
|
156
|
+
| **Apple Pay** | iOS/Safari payments |
|
|
157
|
+
| **Click to Pay** | Visa/Mastercard secure remote commerce |
|
|
158
|
+
| **BNPL** | Buy now, pay later (Cofidis, Klarna) |
|
|
159
|
+
| **MB Way** | Portuguese mobile payments |
|
|
160
|
+
| **Multibanco** | Portuguese bank transfers |
|
|
161
|
+
| **SEPA DD** | Euro direct debit |
|
|
162
|
+
|
|
163
|
+
## API Reference
|
|
164
|
+
|
|
165
|
+
### Provider Options
|
|
166
|
+
|
|
167
|
+
| Option | Type | Default | Description |
|
|
168
|
+
|--------|------|---------|-------------|
|
|
169
|
+
| `apiKey` | `string` | *required* | MONEI API Key |
|
|
170
|
+
| `capture` | `boolean` | `false` | Auto-capture payments on authorization |
|
|
171
|
+
| `webhookSecret` | `string` | - | Optional webhook signing secret |
|
|
172
|
+
|
|
173
|
+
### Session Data
|
|
174
|
+
|
|
175
|
+
The `data` object stored in the payment session contains:
|
|
176
|
+
|
|
177
|
+
| Field | Description |
|
|
178
|
+
|-------|-------------|
|
|
179
|
+
| `id` | MONEI payment ID |
|
|
180
|
+
| `status` | Current MONEI payment status |
|
|
181
|
+
| `redirect_url` | URL for hosted payment page |
|
|
182
|
+
| `client_secret` | Reference for monei.js (same as payment ID) |
|
|
183
|
+
| `session_id` | Medusa session tracking ID |
|
|
184
|
+
|
|
185
|
+
## Testing
|
|
186
|
+
|
|
187
|
+
Use test mode credentials from MONEI Dashboard. Test card numbers and Bizum phone numbers are available in the [MONEI Testing documentation](https://docs.monei.com/testing/).
|
|
188
|
+
|
|
189
|
+
Common test cards:
|
|
190
|
+
- **Success**: `4111 1111 1111 1111`
|
|
191
|
+
- **3DS Required**: `4000 0000 0000 3220`
|
|
192
|
+
- **Declined**: `4000 0000 0000 0002`
|
|
193
|
+
|
|
194
|
+
## Development
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Clone and install
|
|
198
|
+
git clone https://github.com/MONEI/medusa-payment-monei.git
|
|
199
|
+
cd medusa-payment-monei
|
|
200
|
+
npm install
|
|
201
|
+
|
|
202
|
+
# Build
|
|
203
|
+
npm run build
|
|
204
|
+
|
|
205
|
+
# Watch mode
|
|
206
|
+
npm run watch
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Using as a local module in Medusa
|
|
210
|
+
|
|
211
|
+
During development, you can place the plugin source directly in your Medusa app:
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
your-medusa-app/
|
|
215
|
+
src/
|
|
216
|
+
modules/
|
|
217
|
+
monei-payment/
|
|
218
|
+
service.ts ← copy from src/service.ts
|
|
219
|
+
index.ts ← copy from src/index.ts
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Then in `medusa-config.ts`:
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
{
|
|
226
|
+
resolve: "@medusajs/medusa/payment",
|
|
227
|
+
options: {
|
|
228
|
+
providers: [
|
|
229
|
+
{
|
|
230
|
+
resolve: "./src/modules/monei-payment",
|
|
231
|
+
id: "monei",
|
|
232
|
+
options: {
|
|
233
|
+
apiKey: process.env.MONEI_API_KEY,
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## About MONEI
|
|
242
|
+
|
|
243
|
+
[MONEI](https://monei.com) is a licensed Payment Institution regulated by Banco de España (#6911) and a SWIFT member (BIC: MDIPES22). MONEI provides a unified payments platform for European merchants with direct acquiring for Bizum and multi-acquirer card processing.
|
|
244
|
+
|
|
245
|
+
## License
|
|
246
|
+
|
|
247
|
+
MIT
|
package/dist/index.d.ts
ADDED
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 service_1 = __importDefault(require("./service"));
|
|
7
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
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,wDAAmD;AACnD,qDAAmE;AAEnE,kBAAe,IAAA,sBAAc,EAAC,eAAO,CAAC,OAAO,EAAE;IAC7C,QAAQ,EAAE,CAAC,iBAA2B,CAAC;CACxC,CAAC,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AbstractPaymentProvider } from "@medusajs/framework/utils";
|
|
2
|
+
import type { AuthorizePaymentInput, AuthorizePaymentOutput, CancelPaymentInput, CancelPaymentOutput, CapturePaymentInput, CapturePaymentOutput, DeletePaymentInput, DeletePaymentOutput, GetPaymentStatusInput, GetPaymentStatusOutput, InitiatePaymentInput, InitiatePaymentOutput, RefundPaymentInput, RefundPaymentOutput, RetrievePaymentInput, RetrievePaymentOutput, UpdatePaymentInput, UpdatePaymentOutput, ProviderWebhookPayload, WebhookActionResult, Logger } from "@medusajs/framework/types";
|
|
3
|
+
export type MoneiOptions = {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
capture?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type InjectedDependencies = {
|
|
8
|
+
logger: Logger;
|
|
9
|
+
};
|
|
10
|
+
declare class MoneiPaymentProviderService extends AbstractPaymentProvider<MoneiOptions> {
|
|
11
|
+
static identifier: string;
|
|
12
|
+
protected logger_: Logger;
|
|
13
|
+
protected options_: MoneiOptions;
|
|
14
|
+
protected monei_: any;
|
|
15
|
+
constructor(container: InjectedDependencies, options: MoneiOptions);
|
|
16
|
+
static validateOptions(options: Record<any, any>): void;
|
|
17
|
+
private getStatus;
|
|
18
|
+
private toInt;
|
|
19
|
+
private api;
|
|
20
|
+
initiatePayment(input: InitiatePaymentInput): Promise<InitiatePaymentOutput>;
|
|
21
|
+
authorizePayment(input: AuthorizePaymentInput): Promise<AuthorizePaymentOutput>;
|
|
22
|
+
capturePayment(input: CapturePaymentInput): Promise<CapturePaymentOutput>;
|
|
23
|
+
cancelPayment(input: CancelPaymentInput): Promise<CancelPaymentOutput>;
|
|
24
|
+
refundPayment(input: RefundPaymentInput): Promise<RefundPaymentOutput>;
|
|
25
|
+
deletePayment(input: DeletePaymentInput): Promise<DeletePaymentOutput>;
|
|
26
|
+
getPaymentStatus(input: GetPaymentStatusInput): Promise<GetPaymentStatusOutput>;
|
|
27
|
+
retrievePayment(input: RetrievePaymentInput): Promise<RetrievePaymentOutput>;
|
|
28
|
+
updatePayment(input: UpdatePaymentInput): Promise<UpdatePaymentOutput>;
|
|
29
|
+
getWebhookActionAndData(payload: ProviderWebhookPayload["payload"]): Promise<WebhookActionResult>;
|
|
30
|
+
}
|
|
31
|
+
export default MoneiPaymentProviderService;
|
package/dist/service.js
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
4
|
+
const utils_2 = require("@medusajs/framework/utils");
|
|
5
|
+
const node_sdk_1 = require("@monei-js/node-sdk");
|
|
6
|
+
class MoneiPaymentProviderService extends utils_1.AbstractPaymentProvider {
|
|
7
|
+
static identifier = "monei";
|
|
8
|
+
logger_;
|
|
9
|
+
options_;
|
|
10
|
+
monei_;
|
|
11
|
+
constructor(container, options) {
|
|
12
|
+
super(container, options);
|
|
13
|
+
this.logger_ = container.logger;
|
|
14
|
+
this.options_ = options;
|
|
15
|
+
this.monei_ = new node_sdk_1.Monei(options.apiKey);
|
|
16
|
+
}
|
|
17
|
+
static validateOptions(options) {
|
|
18
|
+
if (!options.apiKey) {
|
|
19
|
+
throw new utils_2.MedusaError(utils_2.MedusaError.Types.INVALID_DATA, "MONEI API key is required. Get it from MONEI Dashboard → Settings → API Access.");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// -- Helpers ----------------------------------------------------------------
|
|
23
|
+
getStatus(s) {
|
|
24
|
+
switch (s) {
|
|
25
|
+
case "AUTHORIZED": return "authorized";
|
|
26
|
+
case "SUCCEEDED":
|
|
27
|
+
case "REFUNDED":
|
|
28
|
+
case "PARTIALLY_REFUNDED": return "captured";
|
|
29
|
+
case "CANCELED": return "canceled";
|
|
30
|
+
case "FAILED":
|
|
31
|
+
case "EXPIRED": return "error";
|
|
32
|
+
default: return "pending";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
toInt(amount) {
|
|
36
|
+
return Math.round(Number(amount));
|
|
37
|
+
}
|
|
38
|
+
async api(path, method = "POST", body) {
|
|
39
|
+
const res = await fetch(`https://api.monei.com/v1${path}`, {
|
|
40
|
+
method,
|
|
41
|
+
headers: {
|
|
42
|
+
Authorization: this.options_.apiKey,
|
|
43
|
+
"Content-Type": "application/json",
|
|
44
|
+
},
|
|
45
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
46
|
+
});
|
|
47
|
+
if (!res.ok) {
|
|
48
|
+
const err = await res.text();
|
|
49
|
+
throw new Error(`MONEI ${res.status}: ${err}`);
|
|
50
|
+
}
|
|
51
|
+
return res.json();
|
|
52
|
+
}
|
|
53
|
+
// -- Lifecycle --------------------------------------------------------------
|
|
54
|
+
async initiatePayment(input) {
|
|
55
|
+
const { amount, currency_code, context } = input;
|
|
56
|
+
const sessionId = input.data?.session_id ||
|
|
57
|
+
`medusa_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
|
|
58
|
+
try {
|
|
59
|
+
const body = {
|
|
60
|
+
amount: this.toInt(amount),
|
|
61
|
+
currency: currency_code.toUpperCase(),
|
|
62
|
+
orderId: sessionId,
|
|
63
|
+
description: `Medusa order ${sessionId}`,
|
|
64
|
+
transactionType: this.options_.capture ? "SALE" : "AUTH",
|
|
65
|
+
metadata: { session_id: sessionId, source: "medusa" },
|
|
66
|
+
};
|
|
67
|
+
if (context?.customer) {
|
|
68
|
+
const c = context.customer;
|
|
69
|
+
body.customer = {
|
|
70
|
+
email: c.email,
|
|
71
|
+
name: c.first_name ? `${c.first_name} ${c.last_name || ""}`.trim() : undefined,
|
|
72
|
+
phone: c.phone || undefined,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (context?.billing_address) {
|
|
76
|
+
const a = context.billing_address;
|
|
77
|
+
body.billingDetails = {
|
|
78
|
+
name: a.first_name ? `${a.first_name} ${a.last_name || ""}`.trim() : undefined,
|
|
79
|
+
email: context.customer?.email,
|
|
80
|
+
phone: a.phone || undefined,
|
|
81
|
+
address: {
|
|
82
|
+
country: a.country_code?.toUpperCase(),
|
|
83
|
+
city: a.city,
|
|
84
|
+
line1: a.address_1,
|
|
85
|
+
line2: a.address_2 || undefined,
|
|
86
|
+
zip: a.postal_code,
|
|
87
|
+
state: a.province || undefined,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if (context?.webhook_url) {
|
|
92
|
+
body.callbackUrl = context.webhook_url;
|
|
93
|
+
}
|
|
94
|
+
const payment = await this.api("/payments", "POST", body);
|
|
95
|
+
this.logger_.info(`MONEI: Created ${payment.id} (session: ${sessionId}, amount: ${payment.amount})`);
|
|
96
|
+
return {
|
|
97
|
+
id: payment.id,
|
|
98
|
+
data: {
|
|
99
|
+
id: payment.id,
|
|
100
|
+
status: payment.status,
|
|
101
|
+
amount: payment.amount,
|
|
102
|
+
currency: payment.currency,
|
|
103
|
+
session_id: sessionId,
|
|
104
|
+
redirect_url: payment.nextAction?.redirectUrl || null,
|
|
105
|
+
client_secret: payment.id,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
this.logger_.error(`MONEI: initiatePayment failed: ${error.message}`);
|
|
111
|
+
throw new utils_2.MedusaError(utils_2.MedusaError.Types.UNEXPECTED_STATE, `MONEI: ${error.message}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async authorizePayment(input) {
|
|
115
|
+
const paymentId = input.data?.id;
|
|
116
|
+
if (!paymentId) {
|
|
117
|
+
throw new utils_2.MedusaError(utils_2.MedusaError.Types.INVALID_DATA, "MONEI payment ID not found");
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
const payment = await this.api(`/payments/${paymentId}`, "GET");
|
|
121
|
+
this.logger_.info(`MONEI: authorize ${paymentId} → ${payment.status}`);
|
|
122
|
+
if (payment.status === "AUTHORIZED" ||
|
|
123
|
+
(this.options_.capture && payment.status === "SUCCEEDED")) {
|
|
124
|
+
return {
|
|
125
|
+
status: "authorized",
|
|
126
|
+
data: { ...input.data, id: payment.id, status: payment.status },
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
if (payment.status === "PENDING") {
|
|
130
|
+
return {
|
|
131
|
+
status: "requires_more",
|
|
132
|
+
data: { ...input.data, id: payment.id, status: payment.status },
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
status: this.getStatus(payment.status),
|
|
137
|
+
data: { ...input.data, id: payment.id, status: payment.status },
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
this.logger_.error(`MONEI: authorizePayment failed: ${error.message}`);
|
|
142
|
+
throw new utils_2.MedusaError(utils_2.MedusaError.Types.UNEXPECTED_STATE, `MONEI: ${error.message}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async capturePayment(input) {
|
|
146
|
+
const paymentId = input.data?.id;
|
|
147
|
+
if (!paymentId) {
|
|
148
|
+
throw new utils_2.MedusaError(utils_2.MedusaError.Types.INVALID_DATA, "MONEI payment ID not found");
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
if (this.options_.capture) {
|
|
152
|
+
const existing = await this.api(`/payments/${paymentId}`, "GET");
|
|
153
|
+
if (existing.status === "SUCCEEDED") {
|
|
154
|
+
return { data: { ...input.data, id: existing.id, status: existing.status, captured_at: new Date().toISOString() } };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const body = {};
|
|
158
|
+
if (input.amount)
|
|
159
|
+
body.amount = this.toInt(input.amount);
|
|
160
|
+
const payment = await this.api(`/payments/${paymentId}/capture`, "POST", Object.keys(body).length ? body : undefined);
|
|
161
|
+
this.logger_.info(`MONEI: Captured ${paymentId} → ${payment.status}`);
|
|
162
|
+
return { data: { ...input.data, id: payment.id, status: payment.status, captured_at: new Date().toISOString() } };
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
this.logger_.error(`MONEI: capturePayment failed: ${error.message}`);
|
|
166
|
+
throw new utils_2.MedusaError(utils_2.MedusaError.Types.UNEXPECTED_STATE, `MONEI: ${error.message}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
async cancelPayment(input) {
|
|
170
|
+
const paymentId = input.data?.id;
|
|
171
|
+
if (!paymentId)
|
|
172
|
+
return { data: input.data };
|
|
173
|
+
try {
|
|
174
|
+
const payment = await this.api(`/payments/${paymentId}/cancel`, "POST");
|
|
175
|
+
this.logger_.info(`MONEI: Canceled ${paymentId}`);
|
|
176
|
+
return { data: { ...input.data, id: payment.id, status: payment.status } };
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
this.logger_.warn(`MONEI: cancelPayment: ${error.message}`);
|
|
180
|
+
return { data: { ...input.data, cancel_error: error.message } };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async refundPayment(input) {
|
|
184
|
+
const paymentId = input.data?.id;
|
|
185
|
+
if (!paymentId) {
|
|
186
|
+
throw new utils_2.MedusaError(utils_2.MedusaError.Types.INVALID_DATA, "MONEI payment ID not found");
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
const body = {};
|
|
190
|
+
if (input.amount)
|
|
191
|
+
body.amount = this.toInt(input.amount);
|
|
192
|
+
const payment = await this.api(`/payments/${paymentId}/refund`, "POST", Object.keys(body).length ? body : undefined);
|
|
193
|
+
this.logger_.info(`MONEI: Refunded ${paymentId} (amount: ${body.amount || "full"})`);
|
|
194
|
+
return { data: { ...input.data, id: paymentId, status: payment.status, refunded_at: new Date().toISOString() } };
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
this.logger_.error(`MONEI: refundPayment failed: ${error.message}`);
|
|
198
|
+
throw new utils_2.MedusaError(utils_2.MedusaError.Types.UNEXPECTED_STATE, `MONEI: ${error.message}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
async deletePayment(input) {
|
|
202
|
+
const paymentId = input.data?.id;
|
|
203
|
+
if (paymentId) {
|
|
204
|
+
try {
|
|
205
|
+
await this.api(`/payments/${paymentId}/cancel`, "POST");
|
|
206
|
+
}
|
|
207
|
+
catch { }
|
|
208
|
+
}
|
|
209
|
+
return { data: input.data };
|
|
210
|
+
}
|
|
211
|
+
async getPaymentStatus(input) {
|
|
212
|
+
const paymentId = input.data?.id;
|
|
213
|
+
if (!paymentId)
|
|
214
|
+
return { status: "pending" };
|
|
215
|
+
try {
|
|
216
|
+
const payment = await this.api(`/payments/${paymentId}`, "GET");
|
|
217
|
+
return { status: this.getStatus(payment.status) };
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
return { status: "pending" };
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async retrievePayment(input) {
|
|
224
|
+
const paymentId = input.data?.id;
|
|
225
|
+
if (!paymentId) {
|
|
226
|
+
throw new utils_2.MedusaError(utils_2.MedusaError.Types.INVALID_DATA, "MONEI payment ID not found");
|
|
227
|
+
}
|
|
228
|
+
return await this.api(`/payments/${paymentId}`, "GET");
|
|
229
|
+
}
|
|
230
|
+
async updatePayment(input) {
|
|
231
|
+
const existingId = input.data?.id;
|
|
232
|
+
if (existingId && input.data?.amount === this.toInt(input.amount)) {
|
|
233
|
+
return input.data;
|
|
234
|
+
}
|
|
235
|
+
if (existingId) {
|
|
236
|
+
try {
|
|
237
|
+
await this.api(`/payments/${existingId}/cancel`, "POST");
|
|
238
|
+
}
|
|
239
|
+
catch { }
|
|
240
|
+
}
|
|
241
|
+
const result = await this.initiatePayment({
|
|
242
|
+
amount: input.amount,
|
|
243
|
+
currency_code: input.currency_code,
|
|
244
|
+
context: input.context,
|
|
245
|
+
data: input.data || {},
|
|
246
|
+
});
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
// -- Webhooks ---------------------------------------------------------------
|
|
250
|
+
async getWebhookActionAndData(payload) {
|
|
251
|
+
const { data, rawData, headers } = payload;
|
|
252
|
+
try {
|
|
253
|
+
let payment;
|
|
254
|
+
const sig = (headers?.["monei-signature"] || headers?.["MONEI-Signature"]);
|
|
255
|
+
if (sig) {
|
|
256
|
+
const body = typeof rawData === "string" ? rawData : rawData.toString();
|
|
257
|
+
try {
|
|
258
|
+
const verified = this.monei_.verifySignature(body, sig);
|
|
259
|
+
payment = verified?.object || verified;
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
payment = data;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
payment = data;
|
|
267
|
+
}
|
|
268
|
+
const sessionId = payment?.metadata?.session_id || payment?.orderId || "";
|
|
269
|
+
const amount = payment?.amount || 0;
|
|
270
|
+
this.logger_.info(`MONEI: Webhook → ${payment?.id}, status: ${payment?.status}, session: ${sessionId}`);
|
|
271
|
+
switch (payment?.status) {
|
|
272
|
+
case "AUTHORIZED":
|
|
273
|
+
return { action: "authorized", data: { session_id: sessionId, amount: new utils_1.BigNumber(amount) } };
|
|
274
|
+
case "SUCCEEDED":
|
|
275
|
+
return {
|
|
276
|
+
action: this.options_.capture ? "authorized" : "captured",
|
|
277
|
+
data: { session_id: sessionId, amount: new utils_1.BigNumber(amount) },
|
|
278
|
+
};
|
|
279
|
+
case "FAILED":
|
|
280
|
+
case "EXPIRED":
|
|
281
|
+
return { action: "failed", data: { session_id: sessionId, amount: new utils_1.BigNumber(amount) } };
|
|
282
|
+
default:
|
|
283
|
+
return { action: "not_supported", data: { session_id: sessionId, amount: new utils_1.BigNumber(0) } };
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
this.logger_.error(`MONEI: Webhook error: ${error.message}`);
|
|
288
|
+
return {
|
|
289
|
+
action: "failed",
|
|
290
|
+
data: {
|
|
291
|
+
session_id: data?.metadata?.session_id || data?.orderId || "",
|
|
292
|
+
amount: new utils_1.BigNumber(0),
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
exports.default = MoneiPaymentProviderService;
|
|
299
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;AAAA,qDAA8E;AAC9E,qDAAuD;AAyBvD,iDAA0C;AAW1C,MAAM,2BAA4B,SAAQ,+BAAqC;IAC7E,MAAM,CAAC,UAAU,GAAG,OAAO,CAAA;IAEjB,OAAO,CAAQ;IACf,QAAQ,CAAc;IACtB,MAAM,CAAK;IAErB,YAAY,SAA+B,EAAE,OAAqB;QAChE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package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "medusa-payment-monei",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MONEI payment provider for Medusa v2. Accept Cards, Bizum, PayPal, Google Pay, Apple Pay and more.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": ["dist"],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"watch": "tsc --watch",
|
|
11
|
+
"prepare": "npm run build"
|
|
12
|
+
},
|
|
13
|
+
"keywords": ["medusa", "medusa-payment", "monei", "bizum", "payment", "spain", "europe"],
|
|
14
|
+
"author": "MONEI <info@monei.com> (https://monei.com)",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/MONEI/medusa-payment-monei"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://docs.monei.com",
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@medusajs/framework": ">=2.0.0"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@monei-js/node-sdk": "^1.9.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "^5.0.0"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=20"
|
|
32
|
+
}
|
|
33
|
+
}
|