@vexpay/node 0.13.0 → 0.15.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 +8 -4
- package/dist/index.cjs +48 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +824 -101
- package/dist/index.d.ts +824 -101
- package/dist/index.js +48 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# VEXPay Node.js SDK
|
|
2
2
|
|
|
3
|
-
The official Node.js / TypeScript library for the [VEXPay](https://
|
|
3
|
+
The official Node.js / TypeScript library for the [VEXPay](https://vexpay.app) API: accept Venezuelan payments (Pago Móvil C2P, cards, débito inmediato), pay out to merchants, create checkout sessions, and verify signed webhooks.
|
|
4
4
|
|
|
5
5
|
- Fully typed from the VEXPay OpenAPI contract
|
|
6
6
|
- Safe retries: every `POST` carries an `Idempotency-Key`, so a retried charge never charges twice
|
|
@@ -109,6 +109,9 @@ const session = await vexpay.checkout.sessions.create({
|
|
|
109
109
|
// Or a static deposit address per customer — every deposit fires payment.completed with this customerRef.
|
|
110
110
|
const address = await vexpay.crypto.depositAddresses.create({ customerRef: 'user_123', network: 'BEP20' });
|
|
111
111
|
|
|
112
|
+
// Test key only: make a deposit "arrive" at that address (same payment, fee and webhook, livemode: false).
|
|
113
|
+
await vexpay.crypto.simulateDeposit({ customerRef: 'user_123', network: 'BEP20', amount: '40.00' });
|
|
114
|
+
|
|
112
115
|
const balance = await vexpay.crypto.balance.retrieve();
|
|
113
116
|
const networks = await vexpay.crypto.networks.list({ amountUsdt: '50.00' });
|
|
114
117
|
|
|
@@ -275,7 +278,7 @@ await vexpay.subscriptions.update(subscription.id, { cancelAtPeriodEnd: true });
|
|
|
275
278
|
|
|
276
279
|
## Testing card payments
|
|
277
280
|
|
|
278
|
-
With a test API key, VPOS test cards return a fixed outcome without reaching the bank: `4242424242424242` succeeds, `4000000000009995` is declined with `G51` (insufficient funds), `4000000000000259` completes and is then charged back, and more. A decline fails exactly like a live one (422, the bank code in `code` and `failureCode`, a `payment.failed` webhook). With a live key these numbers are refused with 400 `test_card_in_live_mode`. Full list: [test cards](https://docs.
|
|
281
|
+
With a test API key, VPOS test cards return a fixed outcome without reaching the bank: `4242424242424242` succeeds, `4000000000009995` is declined with `G51` (insufficient funds), `4000000000000259` completes and is then charged back, and more. A decline fails exactly like a live one (422, the bank code in `code` and `failureCode`, a `payment.failed` webhook). With a live key these numbers are refused with 400 `test_card_in_live_mode`. Full list: [test cards](https://docs.vexpay.app/vpos#test-card).
|
|
279
282
|
|
|
280
283
|
## Webhooks
|
|
281
284
|
|
|
@@ -472,7 +475,7 @@ console.log(recentPayouts.length);
|
|
|
472
475
|
import VexPay from '@vexpay/node';
|
|
473
476
|
|
|
474
477
|
const vexpay = new VexPay(process.env.VEXPAY_API_KEY!, {
|
|
475
|
-
baseUrl: 'http://localhost:3010', // default: https://api.
|
|
478
|
+
baseUrl: 'http://localhost:3010', // default: https://api.vexpay.app
|
|
476
479
|
timeoutMs: 30_000,
|
|
477
480
|
maxNetworkRetries: 2,
|
|
478
481
|
});
|
|
@@ -510,6 +513,7 @@ console.log(describe, {} as NewPayout, {} as Session);
|
|
|
510
513
|
| `payments.pagoMovil` | `verify` |
|
|
511
514
|
| `payments.debit` · `credit` · `operations` · `dispersals` · `change` | débito/crédito inmediato and disbursements (advanced payments) |
|
|
512
515
|
| `checkout.sessions` | `create`, `retrieve` |
|
|
516
|
+
| `crypto` | `simulateDeposit` (Test mode only) |
|
|
513
517
|
| `crypto.balance` | `retrieve` |
|
|
514
518
|
| `crypto.balances` | `list` |
|
|
515
519
|
| `crypto.depositAddresses` | `create` |
|
|
@@ -537,7 +541,7 @@ console.log(describe, {} as NewPayout, {} as Session);
|
|
|
537
541
|
| `paymentMethods` | `retrieve`, `detach` |
|
|
538
542
|
| `webhooks` | `constructEvent`, `generateTestHeader` (offline) |
|
|
539
543
|
|
|
540
|
-
Full API reference: [docs](https://
|
|
544
|
+
Full API reference: [docs](https://docs.vexpay.app) · OpenAPI: `/openapi.json`.
|
|
541
545
|
|
|
542
546
|
## License
|
|
543
547
|
|
package/dist/index.cjs
CHANGED
|
@@ -107,7 +107,7 @@ function errorFromResponse(status, body, requestId) {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
// src/version.ts
|
|
110
|
-
var VERSION = "0.
|
|
110
|
+
var VERSION = "0.15.0";
|
|
111
111
|
|
|
112
112
|
// src/core.ts
|
|
113
113
|
var INITIAL_RETRY_DELAY_MS = 500;
|
|
@@ -281,6 +281,7 @@ var ROUTES = {
|
|
|
281
281
|
Crypto_getBalances: { method: "GET", path: "/v1/crypto/balances" },
|
|
282
282
|
Crypto_getPayout: { method: "GET", path: "/v1/crypto/payouts/{id}" },
|
|
283
283
|
Crypto_listNetworks: { method: "GET", path: "/v1/crypto/networks" },
|
|
284
|
+
Crypto_simulateDeposit: { method: "POST", path: "/v1/crypto/deposit-addresses/simulate" },
|
|
284
285
|
Customers_create: { method: "POST", path: "/v1/customers" },
|
|
285
286
|
Customers_list: { method: "GET", path: "/v1/customers" },
|
|
286
287
|
Customers_remove: { method: "DELETE", path: "/v1/customers/{id}" },
|
|
@@ -365,6 +366,11 @@ var ROUTES = {
|
|
|
365
366
|
TenantPayoutAccount_startVerify: { method: "POST", path: "/v1/tenant/payout-account/verify/start" },
|
|
366
367
|
TenantPayoutAccount_upsert: { method: "PUT", path: "/v1/tenant/payout-account" },
|
|
367
368
|
TenantPayoutAccount_upsertPost: { method: "POST", path: "/v1/tenant/payout-account" },
|
|
369
|
+
TestClocks_advance: { method: "POST", path: "/v1/test-clocks/{id}/advance" },
|
|
370
|
+
TestClocks_create: { method: "POST", path: "/v1/test-clocks" },
|
|
371
|
+
TestClocks_list: { method: "GET", path: "/v1/test-clocks" },
|
|
372
|
+
TestClocks_remove: { method: "DELETE", path: "/v1/test-clocks/{id}" },
|
|
373
|
+
TestClocks_retrieve: { method: "GET", path: "/v1/test-clocks/{id}" },
|
|
368
374
|
Topups_create: { method: "POST", path: "/v1/balance/topups" },
|
|
369
375
|
Topups_get: { method: "GET", path: "/v1/balance/topups/{id}" },
|
|
370
376
|
Topups_instant: { method: "POST", path: "/v1/balance/topups/{id}/instant" },
|
|
@@ -632,6 +638,33 @@ var PaymentMethods = class extends APIResource {
|
|
|
632
638
|
return this.call("PaymentMethods_detach", { path: { id } }, options);
|
|
633
639
|
}
|
|
634
640
|
};
|
|
641
|
+
var TestClocks = class extends APIResource {
|
|
642
|
+
/** `frozenTime` is an ISO 8601 time. */
|
|
643
|
+
create(params, options) {
|
|
644
|
+
return this.call("TestClocks_create", { body: params }, options);
|
|
645
|
+
}
|
|
646
|
+
/** Await for one page, or `for await` over every clock (newest first). */
|
|
647
|
+
list(params = {}, options) {
|
|
648
|
+
return new PagePromise(
|
|
649
|
+
(cursor) => this.call("TestClocks_list", { query: { ...params, cursor } }, options),
|
|
650
|
+
params.cursor
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
retrieve(id, options) {
|
|
654
|
+
return this.call("TestClocks_retrieve", { path: { id } }, options);
|
|
655
|
+
}
|
|
656
|
+
/** Deletes the clock with its customers, subscriptions, invoices and payment methods. */
|
|
657
|
+
delete(id, options) {
|
|
658
|
+
return this.call("TestClocks_remove", { path: { id } }, options);
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Move the clock forward (at most two intervals of its shortest subscription). It returns at
|
|
662
|
+
* once with `status: "advancing"`; poll `retrieve` or wait for `test_clock.ready`.
|
|
663
|
+
*/
|
|
664
|
+
advance(id, params, options) {
|
|
665
|
+
return this.call("TestClocks_advance", { path: { id }, body: params }, options);
|
|
666
|
+
}
|
|
667
|
+
};
|
|
635
668
|
|
|
636
669
|
// src/resources/commerce.ts
|
|
637
670
|
var CheckoutSessions = class extends APIResource {
|
|
@@ -809,6 +842,14 @@ var Crypto = class extends APIResource {
|
|
|
809
842
|
depositAddresses = new DepositAddresses(this.http);
|
|
810
843
|
networks = new CryptoNetworks(this.http);
|
|
811
844
|
payouts = new CryptoPayouts(this.http);
|
|
845
|
+
/**
|
|
846
|
+
* Test mode only: credit a deposit to one of your deposit addresses (`customerRef` + `currency` +
|
|
847
|
+
* `network`, requested before) as if it had arrived on chain. Sends `payment.completed` with
|
|
848
|
+
* `livemode: false`. A Live key gets 403 `test_mode_only`; an unknown address 404.
|
|
849
|
+
*/
|
|
850
|
+
simulateDeposit(params, options) {
|
|
851
|
+
return this.call("Crypto_simulateDeposit", { body: params }, options);
|
|
852
|
+
}
|
|
812
853
|
};
|
|
813
854
|
|
|
814
855
|
// src/resources/merchants.ts
|
|
@@ -1054,6 +1095,8 @@ var WEBHOOK_EVENT_NAMES = [
|
|
|
1054
1095
|
"payment_method.attached",
|
|
1055
1096
|
"payment_method.updated",
|
|
1056
1097
|
"payment_method.detached",
|
|
1098
|
+
"test_clock.advancing",
|
|
1099
|
+
"test_clock.ready",
|
|
1057
1100
|
"notification.test"
|
|
1058
1101
|
];
|
|
1059
1102
|
var SIGNATURE_HEADER = "VexPay-Signature";
|
|
@@ -1134,7 +1177,7 @@ var Webhooks = class {
|
|
|
1134
1177
|
};
|
|
1135
1178
|
|
|
1136
1179
|
// src/client.ts
|
|
1137
|
-
var DEFAULT_BASE_URL = "https://api.
|
|
1180
|
+
var DEFAULT_BASE_URL = "https://api.vexpay.app";
|
|
1138
1181
|
var VexPay = class {
|
|
1139
1182
|
/** @internal */
|
|
1140
1183
|
http;
|
|
@@ -1166,6 +1209,8 @@ var VexPay = class {
|
|
|
1166
1209
|
setupSessions;
|
|
1167
1210
|
/** Billing: domiciliación payment methods (bolívar methods your account takes: `payments.methods()`). */
|
|
1168
1211
|
paymentMethods;
|
|
1212
|
+
/** Billing, test mode only: simulated time for trials, renewals and dunning. */
|
|
1213
|
+
testClocks;
|
|
1169
1214
|
/** Offline helpers: `constructEvent` verifies deliveries; no API calls. */
|
|
1170
1215
|
webhooks = new Webhooks();
|
|
1171
1216
|
constructor(apiKey, options = {}) {
|
|
@@ -1206,6 +1251,7 @@ var VexPay = class {
|
|
|
1206
1251
|
this.invoices = new Invoices(this.http);
|
|
1207
1252
|
this.setupSessions = new SetupSessions(this.http);
|
|
1208
1253
|
this.paymentMethods = new PaymentMethods(this.http);
|
|
1254
|
+
this.testClocks = new TestClocks(this.http);
|
|
1209
1255
|
}
|
|
1210
1256
|
};
|
|
1211
1257
|
// Annotate the CommonJS export names for ESM import in node:
|