@vexpay/node 0.14.0 → 0.17.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 +13 -13
- package/dist/index.cjs +56 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1320 -507
- package/dist/index.d.ts +1320 -507
- package/dist/index.js +56 -7
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
package/dist/index.js
CHANGED
|
@@ -46,7 +46,7 @@ function messageFrom(body, status) {
|
|
|
46
46
|
if (typeof error === "string" && error) return error;
|
|
47
47
|
}
|
|
48
48
|
if (typeof body === "string" && body) return body;
|
|
49
|
-
return `
|
|
49
|
+
return `VEX Pay API responded with HTTP ${status}`;
|
|
50
50
|
}
|
|
51
51
|
function errorFromResponse(status, body, requestId) {
|
|
52
52
|
const rawCode = body && typeof body === "object" ? body.error : void 0;
|
|
@@ -62,7 +62,7 @@ function errorFromResponse(status, body, requestId) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// src/version.ts
|
|
65
|
-
var VERSION = "0.
|
|
65
|
+
var VERSION = "0.17.0";
|
|
66
66
|
|
|
67
67
|
// src/core.ts
|
|
68
68
|
var INITIAL_RETRY_DELAY_MS = 500;
|
|
@@ -157,11 +157,11 @@ var HttpClient = class {
|
|
|
157
157
|
return await this.config.fetch(url, { ...init, signal: controller.signal });
|
|
158
158
|
} catch (caught) {
|
|
159
159
|
if (timedOut) {
|
|
160
|
-
throw new VexPayTimeoutError(`Request to
|
|
160
|
+
throw new VexPayTimeoutError(`Request to VEX Pay timed out after ${timeoutMs}ms`);
|
|
161
161
|
}
|
|
162
162
|
if (signal?.aborted) throw caught;
|
|
163
163
|
const reason = caught instanceof Error ? caught.message : String(caught);
|
|
164
|
-
throw new VexPayConnectionError(`Could not reach
|
|
164
|
+
throw new VexPayConnectionError(`Could not reach VEX Pay: ${reason}`);
|
|
165
165
|
} finally {
|
|
166
166
|
clearTimeout(timer);
|
|
167
167
|
signal?.removeEventListener("abort", onAbort);
|
|
@@ -247,6 +247,8 @@ var ROUTES = {
|
|
|
247
247
|
Invoices_pay: { method: "POST", path: "/v1/invoices/{id}/pay" },
|
|
248
248
|
Invoices_retrieve: { method: "GET", path: "/v1/invoices/{id}" },
|
|
249
249
|
Invoices_void: { method: "POST", path: "/v1/invoices/{id}/void" },
|
|
250
|
+
MarketplaceSettings_get: { method: "GET", path: "/v1/marketplace/settings" },
|
|
251
|
+
MarketplaceSettings_update: { method: "PATCH", path: "/v1/marketplace/settings" },
|
|
250
252
|
Merchants_addPayoutMethod: { method: "POST", path: "/v1/merchants/{id}/payout-methods" },
|
|
251
253
|
Merchants_confirmVerify: { method: "POST", path: "/v1/merchants/{id}/verify" },
|
|
252
254
|
Merchants_confirmVerifyMethod: { method: "POST", path: "/v1/merchants/{id}/payout-methods/{methodId}/verify" },
|
|
@@ -321,6 +323,11 @@ var ROUTES = {
|
|
|
321
323
|
TenantPayoutAccount_startVerify: { method: "POST", path: "/v1/tenant/payout-account/verify/start" },
|
|
322
324
|
TenantPayoutAccount_upsert: { method: "PUT", path: "/v1/tenant/payout-account" },
|
|
323
325
|
TenantPayoutAccount_upsertPost: { method: "POST", path: "/v1/tenant/payout-account" },
|
|
326
|
+
TestClocks_advance: { method: "POST", path: "/v1/test-clocks/{id}/advance" },
|
|
327
|
+
TestClocks_create: { method: "POST", path: "/v1/test-clocks" },
|
|
328
|
+
TestClocks_list: { method: "GET", path: "/v1/test-clocks" },
|
|
329
|
+
TestClocks_remove: { method: "DELETE", path: "/v1/test-clocks/{id}" },
|
|
330
|
+
TestClocks_retrieve: { method: "GET", path: "/v1/test-clocks/{id}" },
|
|
324
331
|
Topups_create: { method: "POST", path: "/v1/balance/topups" },
|
|
325
332
|
Topups_get: { method: "GET", path: "/v1/balance/topups/{id}" },
|
|
326
333
|
Topups_instant: { method: "POST", path: "/v1/balance/topups/{id}/instant" },
|
|
@@ -565,7 +572,7 @@ var Invoices = class extends APIResource {
|
|
|
565
572
|
markUncollectible(id, options) {
|
|
566
573
|
return this.call("Invoices_markUncollectible", { path: { id } }, options);
|
|
567
574
|
}
|
|
568
|
-
/** Record an open invoice as paid outside
|
|
575
|
+
/** Record an open invoice as paid outside VEX Pay (`paidOutOfBand: true`); no money moves. */
|
|
569
576
|
pay(id, params, options) {
|
|
570
577
|
return this.call("Invoices_pay", { path: { id }, body: params }, options);
|
|
571
578
|
}
|
|
@@ -588,6 +595,33 @@ var PaymentMethods = class extends APIResource {
|
|
|
588
595
|
return this.call("PaymentMethods_detach", { path: { id } }, options);
|
|
589
596
|
}
|
|
590
597
|
};
|
|
598
|
+
var TestClocks = class extends APIResource {
|
|
599
|
+
/** `frozenTime` is an ISO 8601 time. */
|
|
600
|
+
create(params, options) {
|
|
601
|
+
return this.call("TestClocks_create", { body: params }, options);
|
|
602
|
+
}
|
|
603
|
+
/** Await for one page, or `for await` over every clock (newest first). */
|
|
604
|
+
list(params = {}, options) {
|
|
605
|
+
return new PagePromise(
|
|
606
|
+
(cursor) => this.call("TestClocks_list", { query: { ...params, cursor } }, options),
|
|
607
|
+
params.cursor
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
retrieve(id, options) {
|
|
611
|
+
return this.call("TestClocks_retrieve", { path: { id } }, options);
|
|
612
|
+
}
|
|
613
|
+
/** Deletes the clock with its customers, subscriptions, invoices and payment methods. */
|
|
614
|
+
delete(id, options) {
|
|
615
|
+
return this.call("TestClocks_remove", { path: { id } }, options);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Move the clock forward (at most two intervals of its shortest subscription). It returns at
|
|
619
|
+
* once with `status: "advancing"`; poll `retrieve` or wait for `test_clock.ready`.
|
|
620
|
+
*/
|
|
621
|
+
advance(id, params, options) {
|
|
622
|
+
return this.call("TestClocks_advance", { path: { id }, body: params }, options);
|
|
623
|
+
}
|
|
624
|
+
};
|
|
591
625
|
|
|
592
626
|
// src/resources/commerce.ts
|
|
593
627
|
var CheckoutSessions = class extends APIResource {
|
|
@@ -802,8 +836,18 @@ var PayoutMethods = class extends APIResource {
|
|
|
802
836
|
);
|
|
803
837
|
}
|
|
804
838
|
};
|
|
839
|
+
var MarketplaceSettings = class extends APIResource {
|
|
840
|
+
retrieve(options) {
|
|
841
|
+
return this.call("MarketplaceSettings_get", {}, options);
|
|
842
|
+
}
|
|
843
|
+
/** `merchantAutoPayoutDefault` and/or `merchantAutoPayoutMinUsd` (USD; null clears it). */
|
|
844
|
+
update(params, options) {
|
|
845
|
+
return this.call("MarketplaceSettings_update", { body: params }, options);
|
|
846
|
+
}
|
|
847
|
+
};
|
|
805
848
|
var Merchants = class extends APIResource {
|
|
806
849
|
payoutMethods = new PayoutMethods(this.http);
|
|
850
|
+
marketplaceSettings = new MarketplaceSettings(this.http);
|
|
807
851
|
/** `externalRef` is required and is the idempotency key for merchant creation. */
|
|
808
852
|
create(params, options) {
|
|
809
853
|
return this.call("Merchants_create", { body: params }, options);
|
|
@@ -1018,6 +1062,8 @@ var WEBHOOK_EVENT_NAMES = [
|
|
|
1018
1062
|
"payment_method.attached",
|
|
1019
1063
|
"payment_method.updated",
|
|
1020
1064
|
"payment_method.detached",
|
|
1065
|
+
"test_clock.advancing",
|
|
1066
|
+
"test_clock.ready",
|
|
1021
1067
|
"notification.test"
|
|
1022
1068
|
];
|
|
1023
1069
|
var SIGNATURE_HEADER = "VexPay-Signature";
|
|
@@ -1098,7 +1144,7 @@ var Webhooks = class {
|
|
|
1098
1144
|
};
|
|
1099
1145
|
|
|
1100
1146
|
// src/client.ts
|
|
1101
|
-
var DEFAULT_BASE_URL = "https://api.
|
|
1147
|
+
var DEFAULT_BASE_URL = "https://api.vexpay.app";
|
|
1102
1148
|
var VexPay = class {
|
|
1103
1149
|
/** @internal */
|
|
1104
1150
|
http;
|
|
@@ -1130,12 +1176,14 @@ var VexPay = class {
|
|
|
1130
1176
|
setupSessions;
|
|
1131
1177
|
/** Billing: domiciliación payment methods (bolívar methods your account takes: `payments.methods()`). */
|
|
1132
1178
|
paymentMethods;
|
|
1179
|
+
/** Billing, test mode only: simulated time for trials, renewals and dunning. */
|
|
1180
|
+
testClocks;
|
|
1133
1181
|
/** Offline helpers: `constructEvent` verifies deliveries; no API calls. */
|
|
1134
1182
|
webhooks = new Webhooks();
|
|
1135
1183
|
constructor(apiKey, options = {}) {
|
|
1136
1184
|
if (typeof apiKey !== "string" || apiKey.trim() === "") {
|
|
1137
1185
|
throw new VexPayConfigurationError(
|
|
1138
|
-
"A
|
|
1186
|
+
"A VEX Pay API key is required: new VexPay(process.env.VEXPAY_API_KEY)."
|
|
1139
1187
|
);
|
|
1140
1188
|
}
|
|
1141
1189
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
@@ -1170,6 +1218,7 @@ var VexPay = class {
|
|
|
1170
1218
|
this.invoices = new Invoices(this.http);
|
|
1171
1219
|
this.setupSessions = new SetupSessions(this.http);
|
|
1172
1220
|
this.paymentMethods = new PaymentMethods(this.http);
|
|
1221
|
+
this.testClocks = new TestClocks(this.http);
|
|
1173
1222
|
}
|
|
1174
1223
|
};
|
|
1175
1224
|
export {
|