paybridge 0.4.0 → 0.6.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/README.md +117 -1
- package/dist/crypto/index.d.ts +3 -1
- package/dist/crypto/index.js +23 -0
- package/dist/crypto/ramp.d.ts +36 -0
- package/dist/crypto/ramp.js +179 -0
- package/dist/crypto/transak.d.ts +32 -0
- package/dist/crypto/transak.js +212 -0
- package/dist/index.js +68 -0
- package/dist/providers/adyen.d.ts +46 -0
- package/dist/providers/adyen.js +289 -0
- package/dist/providers/mercadopago.d.ts +36 -0
- package/dist/providers/mercadopago.js +297 -0
- package/dist/providers/mollie.d.ts +39 -0
- package/dist/providers/mollie.js +178 -0
- package/dist/providers/pesapal.d.ts +47 -0
- package/dist/providers/pesapal.js +236 -0
- package/dist/providers/razorpay.d.ts +37 -0
- package/dist/providers/razorpay.js +328 -0
- package/dist/providers/square.d.ts +41 -0
- package/dist/providers/square.js +278 -0
- package/dist/types.d.ts +1 -1
- package/package.json +13 -2
package/dist/index.js
CHANGED
|
@@ -29,6 +29,12 @@ const stripe_1 = require("./providers/stripe");
|
|
|
29
29
|
const payfast_1 = require("./providers/payfast");
|
|
30
30
|
const paystack_1 = require("./providers/paystack");
|
|
31
31
|
const flutterwave_1 = require("./providers/flutterwave");
|
|
32
|
+
const adyen_1 = require("./providers/adyen");
|
|
33
|
+
const mercadopago_1 = require("./providers/mercadopago");
|
|
34
|
+
const razorpay_1 = require("./providers/razorpay");
|
|
35
|
+
const mollie_1 = require("./providers/mollie");
|
|
36
|
+
const square_1 = require("./providers/square");
|
|
37
|
+
const pesapal_1 = require("./providers/pesapal");
|
|
32
38
|
__exportStar(require("./types"), exports);
|
|
33
39
|
__exportStar(require("./utils/currency"), exports);
|
|
34
40
|
__exportStar(require("./utils/fetch"), exports);
|
|
@@ -135,6 +141,68 @@ class PayBridge {
|
|
|
135
141
|
sandbox,
|
|
136
142
|
webhookSecret,
|
|
137
143
|
});
|
|
144
|
+
case 'adyen':
|
|
145
|
+
if (!credentials.apiKey || !credentials.merchantAccount) {
|
|
146
|
+
throw new Error('Adyen requires apiKey and merchantAccount');
|
|
147
|
+
}
|
|
148
|
+
return new adyen_1.AdyenProvider({
|
|
149
|
+
apiKey: credentials.apiKey,
|
|
150
|
+
merchantAccount: credentials.merchantAccount,
|
|
151
|
+
liveUrlPrefix: credentials.liveUrlPrefix,
|
|
152
|
+
sandbox,
|
|
153
|
+
webhookSecret,
|
|
154
|
+
});
|
|
155
|
+
case 'mercadopago':
|
|
156
|
+
if (!credentials.apiKey) {
|
|
157
|
+
throw new Error('Mercado Pago requires apiKey (access token TEST-* or APP_USR-*)');
|
|
158
|
+
}
|
|
159
|
+
return new mercadopago_1.MercadoPagoProvider({
|
|
160
|
+
accessToken: credentials.apiKey,
|
|
161
|
+
sandbox,
|
|
162
|
+
webhookSecret,
|
|
163
|
+
});
|
|
164
|
+
case 'razorpay':
|
|
165
|
+
if (!credentials.apiKey || !credentials.secretKey) {
|
|
166
|
+
throw new Error('Razorpay requires apiKey (key_id rzp_test_* or rzp_live_*) and secretKey (key_secret)');
|
|
167
|
+
}
|
|
168
|
+
return new razorpay_1.RazorpayProvider({
|
|
169
|
+
keyId: credentials.apiKey,
|
|
170
|
+
keySecret: credentials.secretKey,
|
|
171
|
+
sandbox,
|
|
172
|
+
webhookSecret,
|
|
173
|
+
});
|
|
174
|
+
case 'mollie':
|
|
175
|
+
if (!credentials.apiKey) {
|
|
176
|
+
throw new Error('Mollie requires apiKey (test_* or live_*)');
|
|
177
|
+
}
|
|
178
|
+
return new mollie_1.MollieProvider({
|
|
179
|
+
apiKey: credentials.apiKey,
|
|
180
|
+
sandbox,
|
|
181
|
+
webhookSecret,
|
|
182
|
+
});
|
|
183
|
+
case 'square':
|
|
184
|
+
if (!credentials.apiKey || !credentials.locationId) {
|
|
185
|
+
throw new Error('Square requires apiKey (access token) and locationId');
|
|
186
|
+
}
|
|
187
|
+
return new square_1.SquareProvider({
|
|
188
|
+
accessToken: credentials.apiKey,
|
|
189
|
+
locationId: credentials.locationId,
|
|
190
|
+
notificationUrl: credentials.notificationUrl,
|
|
191
|
+
sandbox,
|
|
192
|
+
webhookSecret,
|
|
193
|
+
});
|
|
194
|
+
case 'pesapal':
|
|
195
|
+
if (!credentials.apiKey || !credentials.secretKey) {
|
|
196
|
+
throw new Error('Pesapal requires apiKey (consumer_key) and secretKey (consumer_secret)');
|
|
197
|
+
}
|
|
198
|
+
return new pesapal_1.PesapalProvider({
|
|
199
|
+
consumerKey: credentials.apiKey,
|
|
200
|
+
consumerSecret: credentials.secretKey,
|
|
201
|
+
notificationId: credentials.notificationId,
|
|
202
|
+
username: credentials.username,
|
|
203
|
+
sandbox,
|
|
204
|
+
webhookSecret,
|
|
205
|
+
});
|
|
138
206
|
default:
|
|
139
207
|
throw new Error(`Unknown provider: ${provider}`);
|
|
140
208
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adyen payment provider
|
|
3
|
+
* Global payment platform supporting 150+ countries
|
|
4
|
+
* @see https://docs.adyen.com/api-explorer/Checkout/71/overview
|
|
5
|
+
*/
|
|
6
|
+
import { PaymentProvider } from './base';
|
|
7
|
+
import { CreatePaymentParams, PaymentResult, CreateSubscriptionParams, SubscriptionResult, RefundParams, RefundResult, WebhookEvent } from '../types';
|
|
8
|
+
import { ProviderCapabilities } from '../routing-types';
|
|
9
|
+
interface AdyenConfig {
|
|
10
|
+
apiKey: string;
|
|
11
|
+
merchantAccount: string;
|
|
12
|
+
liveUrlPrefix?: string;
|
|
13
|
+
webhookSecret?: string;
|
|
14
|
+
sandbox?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class AdyenProvider extends PaymentProvider {
|
|
17
|
+
readonly name = "adyen";
|
|
18
|
+
readonly supportedCurrencies: string[];
|
|
19
|
+
private apiKey;
|
|
20
|
+
private merchantAccount;
|
|
21
|
+
private liveUrlPrefix?;
|
|
22
|
+
private webhookSecret?;
|
|
23
|
+
private sandbox;
|
|
24
|
+
private baseUrl;
|
|
25
|
+
constructor(config: AdyenConfig);
|
|
26
|
+
private apiRequest;
|
|
27
|
+
createPayment(params: CreatePaymentParams): Promise<PaymentResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Adyen subscriptions require recurring tokenization flow (shopperReference + recurring contract).
|
|
30
|
+
* This is not yet supported by paybridge's simple checkout URL model.
|
|
31
|
+
* Use Stripe or PayFast for subscriptions.
|
|
32
|
+
*/
|
|
33
|
+
createSubscription(_params: CreateSubscriptionParams): Promise<SubscriptionResult>;
|
|
34
|
+
getPayment(id: string): Promise<PaymentResult>;
|
|
35
|
+
refund(params: RefundParams): Promise<RefundResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Parse Adyen webhook notification.
|
|
38
|
+
* Note: Adyen webhooks contain multiple notificationItems in a batch.
|
|
39
|
+
* This method returns only the FIRST item (paybridge webhook interface is single-event).
|
|
40
|
+
* Multi-event batches require custom handling outside paybridge.
|
|
41
|
+
*/
|
|
42
|
+
parseWebhook(body: any, _headers?: any): WebhookEvent;
|
|
43
|
+
verifyWebhook(body: string | Buffer, _headers?: any): boolean;
|
|
44
|
+
getCapabilities(): ProviderCapabilities;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Adyen payment provider
|
|
4
|
+
* Global payment platform supporting 150+ countries
|
|
5
|
+
* @see https://docs.adyen.com/api-explorer/Checkout/71/overview
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.AdyenProvider = void 0;
|
|
42
|
+
const crypto = __importStar(require("crypto"));
|
|
43
|
+
const base_1 = require("./base");
|
|
44
|
+
const currency_1 = require("../utils/currency");
|
|
45
|
+
const fetch_1 = require("../utils/fetch");
|
|
46
|
+
class AdyenProvider extends base_1.PaymentProvider {
|
|
47
|
+
constructor(config) {
|
|
48
|
+
super();
|
|
49
|
+
this.name = 'adyen';
|
|
50
|
+
this.supportedCurrencies = ['ZAR', 'EUR', 'USD', 'GBP', 'AUD', 'BRL', 'INR', 'NGN'];
|
|
51
|
+
this.apiKey = config.apiKey;
|
|
52
|
+
this.merchantAccount = config.merchantAccount;
|
|
53
|
+
this.liveUrlPrefix = config.liveUrlPrefix;
|
|
54
|
+
this.webhookSecret = config.webhookSecret;
|
|
55
|
+
this.sandbox = config.sandbox ?? true;
|
|
56
|
+
if (this.sandbox) {
|
|
57
|
+
this.baseUrl = 'https://checkout-test.adyen.com/v71';
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
if (!this.liveUrlPrefix) {
|
|
61
|
+
throw new Error('Adyen live mode requires liveUrlPrefix');
|
|
62
|
+
}
|
|
63
|
+
this.baseUrl = `https://checkout-${this.liveUrlPrefix}.adyenpayments.com/v71`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async apiRequest(method, path, data) {
|
|
67
|
+
const url = `${this.baseUrl}${path}`;
|
|
68
|
+
const response = await (0, fetch_1.timedFetchOrThrow)(url, {
|
|
69
|
+
method,
|
|
70
|
+
headers: {
|
|
71
|
+
'x-API-key': this.apiKey,
|
|
72
|
+
'Content-Type': 'application/json',
|
|
73
|
+
},
|
|
74
|
+
body: data ? JSON.stringify(data) : undefined,
|
|
75
|
+
});
|
|
76
|
+
return (await response.json());
|
|
77
|
+
}
|
|
78
|
+
async createPayment(params) {
|
|
79
|
+
this.validateCurrency(params.currency);
|
|
80
|
+
const amountInMinorUnits = (0, currency_1.toMinorUnit)(params.amount, params.currency);
|
|
81
|
+
const [firstName, ...lastNameParts] = params.customer.name.split(' ');
|
|
82
|
+
const lastName = lastNameParts.join(' ') || firstName;
|
|
83
|
+
const sessionData = {
|
|
84
|
+
amount: {
|
|
85
|
+
value: amountInMinorUnits,
|
|
86
|
+
currency: params.currency,
|
|
87
|
+
},
|
|
88
|
+
merchantAccount: this.merchantAccount,
|
|
89
|
+
reference: params.reference,
|
|
90
|
+
returnUrl: params.urls.success,
|
|
91
|
+
shopperEmail: params.customer.email,
|
|
92
|
+
shopperName: {
|
|
93
|
+
firstName,
|
|
94
|
+
lastName,
|
|
95
|
+
},
|
|
96
|
+
countryCode: 'ZA',
|
|
97
|
+
metadata: {
|
|
98
|
+
reference: params.reference,
|
|
99
|
+
...(params.metadata || {}),
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
const response = await this.apiRequest('POST', '/sessions', sessionData);
|
|
103
|
+
return {
|
|
104
|
+
id: response.id,
|
|
105
|
+
checkoutUrl: response.url,
|
|
106
|
+
status: 'pending',
|
|
107
|
+
amount: (0, currency_1.toMajorUnit)(response.amount.value, params.currency),
|
|
108
|
+
currency: response.amount.currency,
|
|
109
|
+
reference: params.reference,
|
|
110
|
+
provider: 'adyen',
|
|
111
|
+
createdAt: new Date().toISOString(),
|
|
112
|
+
raw: response,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Adyen subscriptions require recurring tokenization flow (shopperReference + recurring contract).
|
|
117
|
+
* This is not yet supported by paybridge's simple checkout URL model.
|
|
118
|
+
* Use Stripe or PayFast for subscriptions.
|
|
119
|
+
*/
|
|
120
|
+
async createSubscription(_params) {
|
|
121
|
+
throw new Error('Adyen subscriptions require recurring tokenization flow; not yet supported by paybridge. Use Stripe or PayFast for subscriptions.');
|
|
122
|
+
}
|
|
123
|
+
async getPayment(id) {
|
|
124
|
+
const session = await this.apiRequest('GET', `/sessions/${id}`);
|
|
125
|
+
let status = 'pending';
|
|
126
|
+
if (session.status === 'completed') {
|
|
127
|
+
status = 'completed';
|
|
128
|
+
}
|
|
129
|
+
else if (session.status === 'paymentPending' || session.status === 'pending') {
|
|
130
|
+
status = 'pending';
|
|
131
|
+
}
|
|
132
|
+
else if (session.status === 'expired') {
|
|
133
|
+
status = 'cancelled';
|
|
134
|
+
}
|
|
135
|
+
else if (session.status === 'refused' || session.status === 'error') {
|
|
136
|
+
status = 'failed';
|
|
137
|
+
}
|
|
138
|
+
const currency = session.amount?.currency || 'EUR';
|
|
139
|
+
return {
|
|
140
|
+
id: session.id,
|
|
141
|
+
checkoutUrl: session.url || '',
|
|
142
|
+
status,
|
|
143
|
+
amount: (0, currency_1.toMajorUnit)(session.amount?.value || 0, currency),
|
|
144
|
+
currency,
|
|
145
|
+
reference: session.reference || session.id,
|
|
146
|
+
provider: 'adyen',
|
|
147
|
+
createdAt: new Date().toISOString(),
|
|
148
|
+
raw: session,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async refund(params) {
|
|
152
|
+
const refundData = {
|
|
153
|
+
merchantAccount: this.merchantAccount,
|
|
154
|
+
reference: `refund-${params.paymentId}-${Date.now()}`,
|
|
155
|
+
};
|
|
156
|
+
if (params.amount !== undefined) {
|
|
157
|
+
refundData.amount = {
|
|
158
|
+
value: (0, currency_1.toMinorUnit)(params.amount, 'EUR'),
|
|
159
|
+
currency: 'EUR',
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const response = await this.apiRequest('POST', `/payments/${params.paymentId}/refunds`, refundData);
|
|
163
|
+
const currency = response.amount?.currency || 'EUR';
|
|
164
|
+
return {
|
|
165
|
+
id: response.pspReference,
|
|
166
|
+
status: response.status === 'received' ? 'pending' : 'completed',
|
|
167
|
+
amount: (0, currency_1.toMajorUnit)(response.amount?.value || 0, currency),
|
|
168
|
+
currency,
|
|
169
|
+
paymentId: params.paymentId,
|
|
170
|
+
createdAt: new Date().toISOString(),
|
|
171
|
+
raw: response,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Parse Adyen webhook notification.
|
|
176
|
+
* Note: Adyen webhooks contain multiple notificationItems in a batch.
|
|
177
|
+
* This method returns only the FIRST item (paybridge webhook interface is single-event).
|
|
178
|
+
* Multi-event batches require custom handling outside paybridge.
|
|
179
|
+
*/
|
|
180
|
+
parseWebhook(body, _headers) {
|
|
181
|
+
const event = typeof body === 'string' ? JSON.parse(body) : body;
|
|
182
|
+
const notificationItems = event.notificationItems || [];
|
|
183
|
+
if (notificationItems.length === 0) {
|
|
184
|
+
throw new Error('Adyen webhook contains no notificationItems');
|
|
185
|
+
}
|
|
186
|
+
const item = notificationItems[0].NotificationRequestItem;
|
|
187
|
+
const typeMap = {
|
|
188
|
+
AUTHORISATION: item.success === 'true' ? 'payment.completed' : 'payment.failed',
|
|
189
|
+
CANCELLATION: 'payment.cancelled',
|
|
190
|
+
REFUND: item.success === 'true' ? 'refund.completed' : 'payment.failed',
|
|
191
|
+
};
|
|
192
|
+
const eventType = typeMap[item.eventCode] || 'payment.pending';
|
|
193
|
+
const currency = item.amount?.currency || 'EUR';
|
|
194
|
+
let payment;
|
|
195
|
+
let refund;
|
|
196
|
+
if (item.eventCode === 'AUTHORISATION') {
|
|
197
|
+
payment = {
|
|
198
|
+
id: item.pspReference,
|
|
199
|
+
checkoutUrl: '',
|
|
200
|
+
status: item.success === 'true' ? 'completed' : 'failed',
|
|
201
|
+
amount: (0, currency_1.toMajorUnit)(item.amount?.value || 0, currency),
|
|
202
|
+
currency,
|
|
203
|
+
reference: item.merchantReference,
|
|
204
|
+
provider: 'adyen',
|
|
205
|
+
createdAt: new Date().toISOString(),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
else if (item.eventCode === 'REFUND') {
|
|
209
|
+
refund = {
|
|
210
|
+
id: item.pspReference,
|
|
211
|
+
status: item.success === 'true' ? 'completed' : 'failed',
|
|
212
|
+
amount: (0, currency_1.toMajorUnit)(item.amount?.value || 0, currency),
|
|
213
|
+
currency,
|
|
214
|
+
paymentId: item.originalReference || item.pspReference,
|
|
215
|
+
createdAt: new Date().toISOString(),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
else if (item.eventCode === 'CANCELLATION') {
|
|
219
|
+
payment = {
|
|
220
|
+
id: item.pspReference,
|
|
221
|
+
checkoutUrl: '',
|
|
222
|
+
status: 'cancelled',
|
|
223
|
+
amount: (0, currency_1.toMajorUnit)(item.amount?.value || 0, currency),
|
|
224
|
+
currency,
|
|
225
|
+
reference: item.merchantReference,
|
|
226
|
+
provider: 'adyen',
|
|
227
|
+
createdAt: new Date().toISOString(),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
type: eventType,
|
|
232
|
+
payment,
|
|
233
|
+
refund,
|
|
234
|
+
raw: event,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
verifyWebhook(body, _headers) {
|
|
238
|
+
if (!this.webhookSecret) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
const event = typeof body === 'string' ? JSON.parse(body) : JSON.parse(body.toString('utf8'));
|
|
242
|
+
const notificationItems = event.notificationItems || [];
|
|
243
|
+
if (notificationItems.length === 0) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
const item = notificationItems[0].NotificationRequestItem;
|
|
247
|
+
const hmacSignature = item.additionalData?.hmacSignature;
|
|
248
|
+
if (!hmacSignature) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
const signedFields = [
|
|
252
|
+
item.pspReference || '',
|
|
253
|
+
item.originalReference || '',
|
|
254
|
+
item.merchantAccountCode || this.merchantAccount,
|
|
255
|
+
item.merchantReference || '',
|
|
256
|
+
String(item.amount?.value || ''),
|
|
257
|
+
item.amount?.currency || '',
|
|
258
|
+
item.eventCode || '',
|
|
259
|
+
item.success || '',
|
|
260
|
+
];
|
|
261
|
+
const signedString = signedFields.join('|');
|
|
262
|
+
const hmacKey = Buffer.from(this.webhookSecret, 'hex');
|
|
263
|
+
const computedSig = crypto.createHmac('sha256', hmacKey).update(signedString, 'utf8').digest('base64');
|
|
264
|
+
try {
|
|
265
|
+
const computedBuffer = Buffer.from(computedSig, 'utf8');
|
|
266
|
+
const expectedBuffer = Buffer.from(hmacSignature, 'utf8');
|
|
267
|
+
if (computedBuffer.length !== expectedBuffer.length) {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
return crypto.timingSafeEqual(computedBuffer, expectedBuffer);
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
getCapabilities() {
|
|
277
|
+
return {
|
|
278
|
+
fees: {
|
|
279
|
+
fixed: 0.11,
|
|
280
|
+
percent: 0.6,
|
|
281
|
+
currency: 'EUR',
|
|
282
|
+
},
|
|
283
|
+
currencies: this.supportedCurrencies,
|
|
284
|
+
country: 'GLOBAL',
|
|
285
|
+
avgLatencyMs: 250,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
exports.AdyenProvider = AdyenProvider;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mercado Pago payment provider
|
|
3
|
+
* Leading payment platform for Latin America
|
|
4
|
+
* @see https://www.mercadopago.com/developers/en/reference
|
|
5
|
+
*/
|
|
6
|
+
import { PaymentProvider } from './base';
|
|
7
|
+
import { CreatePaymentParams, PaymentResult, CreateSubscriptionParams, SubscriptionResult, RefundParams, RefundResult, WebhookEvent } from '../types';
|
|
8
|
+
import { ProviderCapabilities } from '../routing-types';
|
|
9
|
+
interface MercadoPagoConfig {
|
|
10
|
+
accessToken: string;
|
|
11
|
+
webhookSecret?: string;
|
|
12
|
+
sandbox?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare class MercadoPagoProvider extends PaymentProvider {
|
|
15
|
+
readonly name = "mercadopago";
|
|
16
|
+
readonly supportedCurrencies: string[];
|
|
17
|
+
private accessToken;
|
|
18
|
+
private webhookSecret?;
|
|
19
|
+
private sandbox;
|
|
20
|
+
private baseUrl;
|
|
21
|
+
constructor(config: MercadoPagoConfig);
|
|
22
|
+
private apiRequest;
|
|
23
|
+
createPayment(params: CreatePaymentParams): Promise<PaymentResult>;
|
|
24
|
+
createSubscription(params: CreateSubscriptionParams): Promise<SubscriptionResult>;
|
|
25
|
+
getPayment(id: string): Promise<PaymentResult>;
|
|
26
|
+
refund(params: RefundParams): Promise<RefundResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Parse Mercado Pago webhook notification.
|
|
29
|
+
* Note: MP webhooks are notification events that require a follow-up API call to get full payment details.
|
|
30
|
+
* This method returns a pending event; caller should use getPayment(data.id) to fetch real status.
|
|
31
|
+
*/
|
|
32
|
+
parseWebhook(body: any, _headers?: any): WebhookEvent;
|
|
33
|
+
verifyWebhook(body: string | Buffer, headers?: any): boolean;
|
|
34
|
+
getCapabilities(): ProviderCapabilities;
|
|
35
|
+
}
|
|
36
|
+
export {};
|