@vexpay/node 0.15.0 → 0.18.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 +17 -31
- package/dist/index.cjs +23 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +694 -462
- package/dist/index.d.ts +694 -462
- package/dist/index.js +23 -13
- 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.18.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" },
|
|
@@ -570,7 +572,7 @@ var Invoices = class extends APIResource {
|
|
|
570
572
|
markUncollectible(id, options) {
|
|
571
573
|
return this.call("Invoices_markUncollectible", { path: { id } }, options);
|
|
572
574
|
}
|
|
573
|
-
/** Record an open invoice as paid outside
|
|
575
|
+
/** Record an open invoice as paid outside VEX Pay (`paidOutOfBand: true`); no money moves. */
|
|
574
576
|
pay(id, params, options) {
|
|
575
577
|
return this.call("Invoices_pay", { path: { id }, body: params }, options);
|
|
576
578
|
}
|
|
@@ -719,10 +721,8 @@ var Conversions = class extends APIResource {
|
|
|
719
721
|
// src/resources/cop.ts
|
|
720
722
|
var CopPayments = class extends APIResource {
|
|
721
723
|
/**
|
|
722
|
-
* Create a payment in whole pesos. `buyer` is required for every channel except `breb
|
|
723
|
-
*
|
|
724
|
-
* `pse.bankCode`. The response `next` says what the buyer does: `show_qr`, `approve_in_app`,
|
|
725
|
-
* `submit_otp`, `redirect` (send them to `next.url`) or `redirect_pending` (retrieve again shortly).
|
|
724
|
+
* Create a payment in whole pesos. `buyer` is required for every channel except `breb`. The
|
|
725
|
+
* response `next` says what the buyer does: `show_qr`, `approve_in_app` or `submit_otp`.
|
|
726
726
|
* Pass `idempotencyKey` in options to retry safely.
|
|
727
727
|
*/
|
|
728
728
|
create(params, options) {
|
|
@@ -740,8 +740,8 @@ var CopPayments = class extends APIResource {
|
|
|
740
740
|
return this.call("CopPayments_cancel", { path: { id } }, options);
|
|
741
741
|
}
|
|
742
742
|
/**
|
|
743
|
-
* Full refund of a completed payment, within
|
|
744
|
-
*
|
|
743
|
+
* Full refund of a completed payment, within 96 hours of completion. A payment that can no
|
|
744
|
+
* longer be refunded through the API fails with `refund_not_supported`.
|
|
745
745
|
*/
|
|
746
746
|
refund(id, options) {
|
|
747
747
|
return this.call("CopPayments_refund", { path: { id } }, options);
|
|
@@ -755,7 +755,7 @@ var CopBalance = class extends APIResource {
|
|
|
755
755
|
var Cop = class extends APIResource {
|
|
756
756
|
payments = new CopPayments(this.http);
|
|
757
757
|
balance = new CopBalance(this.http);
|
|
758
|
-
/** Channels you can use right now, with what each needs
|
|
758
|
+
/** Channels you can use right now, with what each needs. */
|
|
759
759
|
channels(options) {
|
|
760
760
|
return this.call("CopPayments_channels", {}, options);
|
|
761
761
|
}
|
|
@@ -834,8 +834,18 @@ var PayoutMethods = class extends APIResource {
|
|
|
834
834
|
);
|
|
835
835
|
}
|
|
836
836
|
};
|
|
837
|
+
var MarketplaceSettings = class extends APIResource {
|
|
838
|
+
retrieve(options) {
|
|
839
|
+
return this.call("MarketplaceSettings_get", {}, options);
|
|
840
|
+
}
|
|
841
|
+
/** `merchantAutoPayoutDefault` and/or `merchantAutoPayoutMinUsd` (USD; null clears it). */
|
|
842
|
+
update(params, options) {
|
|
843
|
+
return this.call("MarketplaceSettings_update", { body: params }, options);
|
|
844
|
+
}
|
|
845
|
+
};
|
|
837
846
|
var Merchants = class extends APIResource {
|
|
838
847
|
payoutMethods = new PayoutMethods(this.http);
|
|
848
|
+
marketplaceSettings = new MarketplaceSettings(this.http);
|
|
839
849
|
/** `externalRef` is required and is the idempotency key for merchant creation. */
|
|
840
850
|
create(params, options) {
|
|
841
851
|
return this.call("Merchants_create", { body: params }, options);
|
|
@@ -1171,7 +1181,7 @@ var VexPay = class {
|
|
|
1171
1181
|
constructor(apiKey, options = {}) {
|
|
1172
1182
|
if (typeof apiKey !== "string" || apiKey.trim() === "") {
|
|
1173
1183
|
throw new VexPayConfigurationError(
|
|
1174
|
-
"A
|
|
1184
|
+
"A VEX Pay API key is required: new VexPay(process.env.VEXPAY_API_KEY)."
|
|
1175
1185
|
);
|
|
1176
1186
|
}
|
|
1177
1187
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|