gembapay 1.5.0 → 1.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/CHANGELOG.md +6 -0
- package/README.md +18 -1
- package/package.json +1 -1
- package/src/index.d.ts +3 -1
- package/src/index.js +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog — `gembapay` (npm)
|
|
2
2
|
|
|
3
|
+
## 1.6.0 — 2026-12-04
|
|
4
|
+
|
|
5
|
+
**Added**
|
|
6
|
+
- `createPayment({ expiresInMinutes })` — how long the payment request can be paid (whole minutes, 5 … 1440;
|
|
7
|
+
default 24 hours, as before).
|
|
8
|
+
|
|
3
9
|
## 1.5.0 — 2026-11-30
|
|
4
10
|
|
|
5
11
|
Aligned with the GembaPay API as it runs today.
|
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ const payment = await gembapay.createPayment({
|
|
|
67
67
|
|
|
68
68
|
// payment → { success, orderId, paymentUrl, amountUsd: '49.99', amountOriginal: 49.99,
|
|
69
69
|
// currencyOriginal: 'USD', exchangeRate: 1, allowedMethods, expiresAt }
|
|
70
|
-
// exchangeRate = units of currencyOriginal per 1 USD (EUR ≈ 0.91); the request expires
|
|
70
|
+
// exchangeRate = units of currencyOriginal per 1 USD (EUR ≈ 0.91); the request expires at expiresAt (24 h by default).
|
|
71
71
|
|
|
72
72
|
// Send the customer to payment.paymentUrl as-is (unguessable token, not your orderId) —
|
|
73
73
|
// a redirect or a new tab; the checkout cannot be shown in an iframe.
|
|
@@ -76,6 +76,23 @@ const payment = await gembapay.createPayment({
|
|
|
76
76
|
res.redirect(payment.paymentUrl);
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
#### Payment with a shorter expiry
|
|
80
|
+
|
|
81
|
+
By default a payment request can be paid for 24 hours. `expiresInMinutes` (whole number, 5 … 1440) makes it
|
|
82
|
+
shorter — for tickets, seats or stock that you hold for the customer:
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
const payment = await gembapay.createPayment({
|
|
86
|
+
orderId: 'TICKET-1001',
|
|
87
|
+
amount: 25.00,
|
|
88
|
+
currency: 'EUR',
|
|
89
|
+
description: '2 tickets',
|
|
90
|
+
expiresInMinutes: 30
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
console.log(payment.expiresAt); // 30 minutes from now — after that it cannot be paid
|
|
94
|
+
```
|
|
95
|
+
|
|
79
96
|
After paying, the customer stays on GembaPay's confirmation page — there is no return URL. Mark the
|
|
80
97
|
order paid from the `payment.completed` webhook (below) or by polling `getPaymentStatus()`.
|
|
81
98
|
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ declare module 'gembapay' {
|
|
|
19
19
|
currency?: string;
|
|
20
20
|
/** Shown on the checkout */
|
|
21
21
|
description?: string;
|
|
22
|
+
/** How long the request can be paid: whole minutes, 5 … 1440 (default 1440 = 24 h) */
|
|
23
|
+
expiresInMinutes?: number;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
export type PaymentRequestStatus = 'pending' | 'completed' | 'expired' | 'refunded' | (string & {});
|
|
@@ -35,7 +37,7 @@ declare module 'gembapay' {
|
|
|
35
37
|
/** Units of currencyOriginal per 1 USD (amountUsd = amountOriginal / exchangeRate) */
|
|
36
38
|
exchangeRate: number;
|
|
37
39
|
allowedMethods: ('stripe' | 'paypal' | (string & {}))[];
|
|
38
|
-
/** 24 h
|
|
40
|
+
/** Creation + expiresInMinutes (24 h by default) */
|
|
39
41
|
expiresAt: string;
|
|
40
42
|
}
|
|
41
43
|
|
package/src/index.js
CHANGED
|
@@ -4,7 +4,7 @@ const https = require('https');
|
|
|
4
4
|
const crypto = require('crypto');
|
|
5
5
|
|
|
6
6
|
const BASE_URL = 'https://api.gembapay.com';
|
|
7
|
-
const VERSION = '1.
|
|
7
|
+
const VERSION = '1.6.0';
|
|
8
8
|
const SIGNATURE_TOLERANCE_SEC = 300;
|
|
9
9
|
|
|
10
10
|
class GembaPayError extends Error {
|
|
@@ -48,17 +48,24 @@ class GembaPay {
|
|
|
48
48
|
* @param {number} params.amount - Payment amount
|
|
49
49
|
* @param {string} [params.currency='USD'] - ISO 4217 code (70 supported)
|
|
50
50
|
* @param {string} [params.description] - Shown on the checkout
|
|
51
|
+
* @param {number} [params.expiresInMinutes=1440] - How long it can be paid: whole minutes, 5 … 1440
|
|
51
52
|
* @returns {Promise<Object>} { success, orderId, paymentUrl, amountUsd, amountOriginal, currencyOriginal,
|
|
52
53
|
* exchangeRate (units of currencyOriginal per 1 USD), allowedMethods, expiresAt }.
|
|
53
|
-
* The request expires
|
|
54
|
+
* The request expires at expiresAt (24 h by default). Only these fields are sent: the API has no return URL,
|
|
54
55
|
* customer email or metadata parameter.
|
|
55
56
|
*/
|
|
56
|
-
async createPayment({ orderId, amount, currency = 'USD', description } = {}) {
|
|
57
|
+
async createPayment({ orderId, amount, currency = 'USD', description, expiresInMinutes } = {}) {
|
|
57
58
|
if (!orderId) throw new GembaPayError('orderId is required', null, 'missing_param');
|
|
58
59
|
if (!amount || amount <= 0) throw new GembaPayError('amount must be greater than 0', null, 'invalid_param');
|
|
59
60
|
|
|
60
61
|
const body = { orderId, amount, currency };
|
|
61
62
|
if (description) body.description = description;
|
|
63
|
+
if (expiresInMinutes !== undefined && expiresInMinutes !== null) {
|
|
64
|
+
if (!Number.isInteger(expiresInMinutes) || expiresInMinutes < 5 || expiresInMinutes > 1440) {
|
|
65
|
+
throw new GembaPayError('expiresInMinutes must be a whole number between 5 and 1440', null, 'invalid_param');
|
|
66
|
+
}
|
|
67
|
+
body.expiresInMinutes = expiresInMinutes;
|
|
68
|
+
}
|
|
62
69
|
|
|
63
70
|
return this._request('POST', '/api/merchant/payment-request', body);
|
|
64
71
|
}
|