@vexpay/node 0.15.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 CHANGED
@@ -1,8 +1,8 @@
1
- # VEXPay Node.js SDK
1
+ # VEX Pay Node.js SDK
2
2
 
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.
3
+ The official Node.js / TypeScript library for the [VEX Pay](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
- - Fully typed from the VEXPay OpenAPI contract
5
+ - Fully typed from the VEX Pay OpenAPI contract
6
6
  - Safe retries: every `POST` carries an `Idempotency-Key`, so a retried charge never charges twice
7
7
  - Auto-pagination with `for await`
8
8
  - Webhook signature verification with replay protection
@@ -61,7 +61,7 @@ console.log(payment.status); // "COMPLETED" or "PENDING" — confirm with the pa
61
61
 
62
62
  ## Checkout sessions (hosted or embedded)
63
63
 
64
- Let VEXPay collect the payment details. Redirect the buyer to `url`, or embed the checkout on your own site with [`@vexpay/js`](https://www.npmjs.com/package/@vexpay/js) and the one-time `clientSecret`.
64
+ Let VEX Pay collect the payment details. Redirect the buyer to `url`, or embed the checkout on your own site with [`@vexpay/js`](https://www.npmjs.com/package/@vexpay/js) and the one-time `clientSecret`.
65
65
 
66
66
  ```ts
67
67
  import VexPay from '@vexpay/node';
@@ -91,7 +91,7 @@ The hosted page lets the buyer pick the currency — bolívares, stablecoins or
91
91
 
92
92
  ## USDT
93
93
 
94
- USDT settles in USDT, into your VEXPay USDT balance (never converted to VES). It must be enabled on your account — otherwise these calls fail with `method_not_allowed` (403). Pay-ins cost 2.5 % + 0.50 USDT; payouts cost the network fee listed by `crypto.networks.list()`.
94
+ USDT settles in USDT, into your VEX Pay USDT balance (never converted to VES). It must be enabled on your account — otherwise these calls fail with `method_not_allowed` (403). Pay-ins cost 2.5 % + 0.50 USDT; payouts cost the network fee listed by `crypto.networks.list()`.
95
95
 
96
96
  ```ts
97
97
  import VexPay from '@vexpay/node';
@@ -151,7 +151,7 @@ Responses and events include `currency`, `amount` and `fee` for both coins (`amo
151
151
 
152
152
  ## Convert VES or COP to USDT
153
153
 
154
- Turn available VES or Colombian pesos into your USDT balance. A quote locks the rate (market USDT rate in that currency plus your spread) for 60 seconds; accepting it debits the source at once (`conversion.created`) and returns a `PENDING` conversion. VEXPay then delivers the USDT and sends `conversion.completed` (or `conversion.canceled`, with the VES or COP returned). Conversions are on for every account that has USDT enabled (COP also needs COP enabled) — otherwise the calls fail with `conversions_not_enabled` (403). In test mode they complete immediately. COP amounts are whole pesos.
154
+ Turn available VES or Colombian pesos into your USDT balance. A quote locks the rate (market USDT rate in that currency plus your spread) for 60 seconds; accepting it debits the source at once (`conversion.created`) and returns a `PENDING` conversion. VEX Pay then delivers the USDT and sends `conversion.completed` (or `conversion.canceled`, with the VES or COP returned). Conversions are on for every account that has USDT enabled (COP also needs COP enabled) — otherwise the calls fail with `conversions_not_enabled` (403). In test mode they complete immediately. COP amounts are whole pesos.
155
155
 
156
156
  ```ts
157
157
  import VexPay from '@vexpay/node';
@@ -241,7 +241,7 @@ const { availableCop } = await vexpay.cop.balance.retrieve();
241
241
 
242
242
  ## Subscriptions
243
243
 
244
- Bill a customer on a recurring USD price. Each period VEXPay issues an invoice; with `send_invoice` (default) the customer pays it on a hosted page (`hostedInvoiceUrl`), with `charge_automatically` VEXPay charges their domiciliación. Listen for `invoice.paid`, `invoice.payment_failed` and `customer.subscription.*` webhooks.
244
+ Bill a customer on a recurring USD price. Each period VEX Pay issues an invoice; with `send_invoice` (default) the customer pays it on a hosted page (`hostedInvoiceUrl`), with `charge_automatically` VEX Pay charges their domiciliación. Listen for `invoice.paid`, `invoice.payment_failed` and `customer.subscription.*` webhooks.
245
245
 
246
246
  ```ts
247
247
  import VexPay from '@vexpay/node';
@@ -274,7 +274,7 @@ for await (const method of vexpay.customers.paymentMethods.list(customer.id)) {
274
274
  await vexpay.subscriptions.update(subscription.id, { cancelAtPeriodEnd: true });
275
275
  ```
276
276
 
277
- `subscriptions.cancel(id)` cancels at once and voids its open invoices. On an open invoice, `invoices.void(id)`, `invoices.markUncollectible(id)` (stays payable) and `invoices.pay(id, { paidOutOfBand: true })` (paid outside VEXPay; no money moves). `paymentMethods.detach(id)` stops a domiciliación from being charged again.
277
+ `subscriptions.cancel(id)` cancels at once and voids its open invoices. On an open invoice, `invoices.void(id)`, `invoices.markUncollectible(id)` (stays payable) and `invoices.pay(id, { paidOutOfBand: true })` (paid outside VEX Pay; no money moves). `paymentMethods.detach(id)` stops a domiciliación from being charged again.
278
278
 
279
279
  ## Testing card payments
280
280
 
@@ -282,7 +282,7 @@ With a test API key, VPOS test cards return a fixed outcome without reaching the
282
282
 
283
283
  ## Webhooks
284
284
 
285
- VEXPay signs every delivery with a `VexPay-Signature` header. Verify it with the **raw** request body — parsing and re-serializing JSON changes the bytes and breaks the signature.
285
+ VEX Pay signs every delivery with a `VexPay-Signature` header. Verify it with the **raw** request body — parsing and re-serializing JSON changes the bytes and breaks the signature.
286
286
 
287
287
  ```ts
288
288
  import VexPay from '@vexpay/node';
@@ -403,7 +403,7 @@ try {
403
403
 
404
404
  ## Retries and idempotency
405
405
 
406
- The SDK retries connection errors, timeouts, `429`, `5xx`, and `409 idempotency_request_in_progress` up to `maxNetworkRetries` times (default 2) with exponential backoff, honouring `Retry-After`. Every `POST` gets a random `Idempotency-Key` that stays the same across its retries, so VEXPay executes it at most once. Supply your own key to make retries safe across process restarts too:
406
+ The SDK retries connection errors, timeouts, `429`, `5xx`, and `409 idempotency_request_in_progress` up to `maxNetworkRetries` times (default 2) with exponential backoff, honouring `Retry-After`. Every `POST` gets a random `Idempotency-Key` that stays the same across its retries, so VEX Pay executes it at most once. Supply your own key to make retries safe across process restarts too:
407
407
 
408
408
  ```ts
409
409
  import VexPay from '@vexpay/node';
package/dist/index.cjs CHANGED
@@ -91,7 +91,7 @@ function messageFrom(body, status) {
91
91
  if (typeof error === "string" && error) return error;
92
92
  }
93
93
  if (typeof body === "string" && body) return body;
94
- return `VEXPay API responded with HTTP ${status}`;
94
+ return `VEX Pay API responded with HTTP ${status}`;
95
95
  }
96
96
  function errorFromResponse(status, body, requestId) {
97
97
  const rawCode = body && typeof body === "object" ? body.error : void 0;
@@ -107,7 +107,7 @@ function errorFromResponse(status, body, requestId) {
107
107
  }
108
108
 
109
109
  // src/version.ts
110
- var VERSION = "0.15.0";
110
+ var VERSION = "0.17.0";
111
111
 
112
112
  // src/core.ts
113
113
  var INITIAL_RETRY_DELAY_MS = 500;
@@ -202,11 +202,11 @@ var HttpClient = class {
202
202
  return await this.config.fetch(url, { ...init, signal: controller.signal });
203
203
  } catch (caught) {
204
204
  if (timedOut) {
205
- throw new VexPayTimeoutError(`Request to VEXPay timed out after ${timeoutMs}ms`);
205
+ throw new VexPayTimeoutError(`Request to VEX Pay timed out after ${timeoutMs}ms`);
206
206
  }
207
207
  if (signal?.aborted) throw caught;
208
208
  const reason = caught instanceof Error ? caught.message : String(caught);
209
- throw new VexPayConnectionError(`Could not reach VEXPay: ${reason}`);
209
+ throw new VexPayConnectionError(`Could not reach VEX Pay: ${reason}`);
210
210
  } finally {
211
211
  clearTimeout(timer);
212
212
  signal?.removeEventListener("abort", onAbort);
@@ -292,6 +292,8 @@ var ROUTES = {
292
292
  Invoices_pay: { method: "POST", path: "/v1/invoices/{id}/pay" },
293
293
  Invoices_retrieve: { method: "GET", path: "/v1/invoices/{id}" },
294
294
  Invoices_void: { method: "POST", path: "/v1/invoices/{id}/void" },
295
+ MarketplaceSettings_get: { method: "GET", path: "/v1/marketplace/settings" },
296
+ MarketplaceSettings_update: { method: "PATCH", path: "/v1/marketplace/settings" },
295
297
  Merchants_addPayoutMethod: { method: "POST", path: "/v1/merchants/{id}/payout-methods" },
296
298
  Merchants_confirmVerify: { method: "POST", path: "/v1/merchants/{id}/verify" },
297
299
  Merchants_confirmVerifyMethod: { method: "POST", path: "/v1/merchants/{id}/payout-methods/{methodId}/verify" },
@@ -615,7 +617,7 @@ var Invoices = class extends APIResource {
615
617
  markUncollectible(id, options) {
616
618
  return this.call("Invoices_markUncollectible", { path: { id } }, options);
617
619
  }
618
- /** Record an open invoice as paid outside VEXPay (`paidOutOfBand: true`); no money moves. */
620
+ /** Record an open invoice as paid outside VEX Pay (`paidOutOfBand: true`); no money moves. */
619
621
  pay(id, params, options) {
620
622
  return this.call("Invoices_pay", { path: { id }, body: params }, options);
621
623
  }
@@ -879,8 +881,18 @@ var PayoutMethods = class extends APIResource {
879
881
  );
880
882
  }
881
883
  };
884
+ var MarketplaceSettings = class extends APIResource {
885
+ retrieve(options) {
886
+ return this.call("MarketplaceSettings_get", {}, options);
887
+ }
888
+ /** `merchantAutoPayoutDefault` and/or `merchantAutoPayoutMinUsd` (USD; null clears it). */
889
+ update(params, options) {
890
+ return this.call("MarketplaceSettings_update", { body: params }, options);
891
+ }
892
+ };
882
893
  var Merchants = class extends APIResource {
883
894
  payoutMethods = new PayoutMethods(this.http);
895
+ marketplaceSettings = new MarketplaceSettings(this.http);
884
896
  /** `externalRef` is required and is the idempotency key for merchant creation. */
885
897
  create(params, options) {
886
898
  return this.call("Merchants_create", { body: params }, options);
@@ -1216,7 +1228,7 @@ var VexPay = class {
1216
1228
  constructor(apiKey, options = {}) {
1217
1229
  if (typeof apiKey !== "string" || apiKey.trim() === "") {
1218
1230
  throw new VexPayConfigurationError(
1219
- "A VEXPay API key is required: new VexPay(process.env.VEXPAY_API_KEY)."
1231
+ "A VEX Pay API key is required: new VexPay(process.env.VEXPAY_API_KEY)."
1220
1232
  );
1221
1233
  }
1222
1234
  const fetchImpl = options.fetch ?? globalThis.fetch;