@vexpay/node 0.11.0 → 0.13.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/dist/index.js CHANGED
@@ -62,7 +62,7 @@ function errorFromResponse(status, body, requestId) {
62
62
  }
63
63
 
64
64
  // src/version.ts
65
- var VERSION = "0.11.0";
65
+ var VERSION = "0.13.0";
66
66
 
67
67
  // src/core.ts
68
68
  var INITIAL_RETRY_DELAY_MS = 500;
@@ -225,6 +225,7 @@ var ROUTES = {
225
225
  ConversionSettings_update: { method: "PATCH", path: "/v1/conversions/settings" },
226
226
  CopPayments_balance: { method: "GET", path: "/v1/cop/balance" },
227
227
  CopPayments_cancel: { method: "POST", path: "/v1/cop/payments/{id}/cancel" },
228
+ CopPayments_channels: { method: "GET", path: "/v1/cop/channels" },
228
229
  CopPayments_create: { method: "POST", path: "/v1/cop/payments" },
229
230
  CopPayments_get: { method: "GET", path: "/v1/cop/payments/{id}" },
230
231
  CopPayments_refund: { method: "POST", path: "/v1/cop/payments/{id}/refund" },
@@ -235,6 +236,16 @@ var ROUTES = {
235
236
  Crypto_getBalances: { method: "GET", path: "/v1/crypto/balances" },
236
237
  Crypto_getPayout: { method: "GET", path: "/v1/crypto/payouts/{id}" },
237
238
  Crypto_listNetworks: { method: "GET", path: "/v1/crypto/networks" },
239
+ Customers_create: { method: "POST", path: "/v1/customers" },
240
+ Customers_list: { method: "GET", path: "/v1/customers" },
241
+ Customers_remove: { method: "DELETE", path: "/v1/customers/{id}" },
242
+ Customers_retrieve: { method: "GET", path: "/v1/customers/{id}" },
243
+ Customers_update: { method: "POST", path: "/v1/customers/{id}" },
244
+ Invoices_list: { method: "GET", path: "/v1/invoices" },
245
+ Invoices_markUncollectible: { method: "POST", path: "/v1/invoices/{id}/mark-uncollectible" },
246
+ Invoices_pay: { method: "POST", path: "/v1/invoices/{id}/pay" },
247
+ Invoices_retrieve: { method: "GET", path: "/v1/invoices/{id}" },
248
+ Invoices_void: { method: "POST", path: "/v1/invoices/{id}/void" },
238
249
  Merchants_addPayoutMethod: { method: "POST", path: "/v1/merchants/{id}/payout-methods" },
239
250
  Merchants_confirmVerify: { method: "POST", path: "/v1/merchants/{id}/verify" },
240
251
  Merchants_confirmVerifyMethod: { method: "POST", path: "/v1/merchants/{id}/payout-methods/{methodId}/verify" },
@@ -245,16 +256,21 @@ var ROUTES = {
245
256
  Merchants_listAuditEvents: { method: "GET", path: "/v1/merchants/{id}/audit-events" },
246
257
  Merchants_listOrGetByRef: { method: "GET", path: "/v1/merchants" },
247
258
  Merchants_listPayoutMethods: { method: "GET", path: "/v1/merchants/{id}/payout-methods" },
259
+ Merchants_listTransactions: { method: "GET", path: "/v1/merchants/{id}/transactions" },
248
260
  Merchants_remove: { method: "DELETE", path: "/v1/merchants/{id}" },
249
261
  Merchants_setDefaultPayoutMethod: { method: "POST", path: "/v1/merchants/{id}/payout-methods/{methodId}/default" },
250
262
  Merchants_startVerify: { method: "POST", path: "/v1/merchants/{id}/verify/start" },
251
263
  Merchants_startVerifyMethod: { method: "POST", path: "/v1/merchants/{id}/payout-methods/{methodId}/verify/start" },
264
+ Merchants_statement: { method: "GET", path: "/v1/merchants/{id}/statement" },
252
265
  Merchants_transfer: { method: "POST", path: "/v1/merchants/{id}/transfers" },
253
266
  Merchants_update: { method: "PATCH", path: "/v1/merchants/{id}" },
254
267
  Notifications_sendTest: { method: "POST", path: "/v1/notifications/test" },
255
268
  PaymentLinks_get: { method: "GET", path: "/v1/payment-links/{id}" },
256
269
  PaymentLinks_remove: { method: "DELETE", path: "/v1/payment-links/{id}" },
257
270
  PaymentLinks_update: { method: "PATCH", path: "/v1/payment-links/{id}" },
271
+ PaymentMethods_detach: { method: "DELETE", path: "/v1/payment-methods/{id}" },
272
+ PaymentMethods_list: { method: "GET", path: "/v1/customers/{id}/payment-methods" },
273
+ PaymentMethods_retrieve: { method: "GET", path: "/v1/payment-methods/{id}" },
258
274
  Payments_executeC2p: { method: "POST", path: "/v1/payments/c2p" },
259
275
  Payments_executeVpos: { method: "POST", path: "/v1/payments/vpos" },
260
276
  Payments_getBanks: { method: "GET", path: "/v1/banks" },
@@ -272,6 +288,10 @@ var ROUTES = {
272
288
  Payouts_getById: { method: "GET", path: "/v1/payouts/{id}" },
273
289
  Payouts_getByRef: { method: "GET", path: "/v1/payouts/by-ref/{externalRef}" },
274
290
  Payouts_list: { method: "GET", path: "/v1/payouts" },
291
+ Prices_create: { method: "POST", path: "/v1/prices" },
292
+ Prices_list: { method: "GET", path: "/v1/prices" },
293
+ Prices_retrieve: { method: "GET", path: "/v1/prices/{id}" },
294
+ Prices_update: { method: "POST", path: "/v1/prices/{id}" },
275
295
  Products_create: { method: "POST", path: "/v1/products" },
276
296
  Products_createLink: { method: "POST", path: "/v1/products/{id}/links" },
277
297
  Products_get: { method: "GET", path: "/v1/products/{id}" },
@@ -288,11 +308,23 @@ var ROUTES = {
288
308
  R4Operations_ejecutarVuelto: { method: "POST", path: "/v1/payments/change" },
289
309
  R4Operations_generarOtp: { method: "POST", path: "/v1/payments/debit/otp" },
290
310
  R4Operations_pollOperation: { method: "POST", path: "/v1/payments/operations/poll" },
311
+ SetupSessions_create: { method: "POST", path: "/v1/setup-sessions" },
312
+ SetupSessions_retrieve: { method: "GET", path: "/v1/setup-sessions/{id}" },
313
+ Subscriptions_cancel: { method: "DELETE", path: "/v1/subscriptions/{id}" },
314
+ Subscriptions_create: { method: "POST", path: "/v1/subscriptions" },
315
+ Subscriptions_list: { method: "GET", path: "/v1/subscriptions" },
316
+ Subscriptions_retrieve: { method: "GET", path: "/v1/subscriptions/{id}" },
317
+ Subscriptions_update: { method: "POST", path: "/v1/subscriptions/{id}" },
291
318
  TenantPayoutAccount_confirmVerify: { method: "POST", path: "/v1/tenant/payout-account/verify" },
292
319
  TenantPayoutAccount_get: { method: "GET", path: "/v1/tenant/payout-account" },
293
320
  TenantPayoutAccount_startVerify: { method: "POST", path: "/v1/tenant/payout-account/verify/start" },
294
321
  TenantPayoutAccount_upsert: { method: "PUT", path: "/v1/tenant/payout-account" },
295
322
  TenantPayoutAccount_upsertPost: { method: "POST", path: "/v1/tenant/payout-account" },
323
+ Topups_create: { method: "POST", path: "/v1/balance/topups" },
324
+ Topups_get: { method: "GET", path: "/v1/balance/topups/{id}" },
325
+ Topups_instant: { method: "POST", path: "/v1/balance/topups/{id}/instant" },
326
+ Topups_list: { method: "GET", path: "/v1/balance/topups" },
327
+ Topups_simulate: { method: "POST", path: "/v1/balance/topups/{id}/simulate" },
296
328
  Webhooks_createWebhook: { method: "POST", path: "/v1/webhooks" },
297
329
  Webhooks_deleteWebhook: { method: "DELETE", path: "/v1/webhooks/{id}" },
298
330
  Webhooks_listWebhooks: { method: "GET", path: "/v1/webhooks" },
@@ -343,8 +375,30 @@ var BalanceTransactions = class extends APIResource {
343
375
  );
344
376
  }
345
377
  };
378
+ var BalanceTopups = class extends APIResource {
379
+ /** Start a top-up. Over the monthly limit fails with `topup_cap_exceeded` (422). */
380
+ create(params, options) {
381
+ return this.call("Topups_create", { body: params }, options);
382
+ }
383
+ /** Your latest top-ups (newest first, `limit` 1–100) plus this month's limit usage. */
384
+ list(params = {}, options) {
385
+ return this.call("Topups_list", { query: params }, options);
386
+ }
387
+ retrieve(id, options) {
388
+ return this.call("Topups_get", { path: { id } }, options);
389
+ }
390
+ /** Release the still-held part of a completed top-up now, for `instantFeeVes`. Idempotent; `not_held` (409) if nothing is held. */
391
+ instant(id, options) {
392
+ return this.call("Topups_instant", { path: { id } }, options);
393
+ }
394
+ /** Test mode only: complete the top-up as if the Pago Móvil arrived. */
395
+ simulate(id, options) {
396
+ return this.call("Topups_simulate", { path: { id } }, options);
397
+ }
398
+ };
346
399
  var Balance = class extends APIResource {
347
400
  transactions = new BalanceTransactions(this.http);
401
+ topups = new BalanceTopups(this.http);
348
402
  retrieve(options) {
349
403
  return this.call("Balance_getBalance", {}, options);
350
404
  }
@@ -414,6 +468,126 @@ var WebhookEndpoints = class extends APIResource {
414
468
  }
415
469
  };
416
470
 
471
+ // src/resources/billing.ts
472
+ var CustomerPaymentMethods = class extends APIResource {
473
+ /** Await for one page, or `for await` over every attached method (newest first). */
474
+ list(customerId, params = {}, options) {
475
+ return new PagePromise(
476
+ (cursor) => this.call("PaymentMethods_list", { path: { id: customerId }, query: { ...params, cursor } }, options),
477
+ params.cursor
478
+ );
479
+ }
480
+ };
481
+ var Customers = class extends APIResource {
482
+ paymentMethods = new CustomerPaymentMethods(this.http);
483
+ /** Pass `idempotencyKey` in options to retry safely. */
484
+ create(params = {}, options) {
485
+ return this.call("Customers_create", { body: params }, options);
486
+ }
487
+ /** Await for one page, or `for await` over every customer (newest first). Filter with `email`. */
488
+ list(params = {}, options) {
489
+ return new PagePromise(
490
+ (cursor) => this.call("Customers_list", { query: { ...params, cursor } }, options),
491
+ params.cursor
492
+ );
493
+ }
494
+ retrieve(id, options) {
495
+ return this.call("Customers_retrieve", { path: { id } }, options);
496
+ }
497
+ update(id, params, options) {
498
+ return this.call("Customers_update", { path: { id }, body: params }, options);
499
+ }
500
+ /** Refused with 409 while the customer has a live subscription. */
501
+ delete(id, options) {
502
+ return this.call("Customers_remove", { path: { id } }, options);
503
+ }
504
+ };
505
+ var Prices = class extends APIResource {
506
+ create(params, options) {
507
+ return this.call("Prices_create", { body: params }, options);
508
+ }
509
+ /** Await for one page, or `for await` over every price. Filter with `product` and `active`. */
510
+ list(params = {}, options) {
511
+ return new PagePromise(
512
+ (cursor) => this.call("Prices_list", { query: { ...params, cursor } }, options),
513
+ params.cursor
514
+ );
515
+ }
516
+ retrieve(id, options) {
517
+ return this.call("Prices_retrieve", { path: { id } }, options);
518
+ }
519
+ /** Only `active`, `nickname` and `metadata` can change; create a new price for a new amount. */
520
+ update(id, params, options) {
521
+ return this.call("Prices_update", { path: { id }, body: params }, options);
522
+ }
523
+ };
524
+ var Subscriptions = class extends APIResource {
525
+ /** Pass `idempotencyKey` in options to retry safely. */
526
+ create(params, options) {
527
+ return this.call("Subscriptions_create", { body: params }, options);
528
+ }
529
+ /** Await for one page, or `for await` over every subscription (newest first). Filter with `customer`, `price`, `status`. */
530
+ list(params = {}, options) {
531
+ return new PagePromise(
532
+ (cursor) => this.call("Subscriptions_list", { query: { ...params, cursor } }, options),
533
+ params.cursor
534
+ );
535
+ }
536
+ retrieve(id, options) {
537
+ return this.call("Subscriptions_retrieve", { path: { id } }, options);
538
+ }
539
+ /** Changes apply from the next invoice. Set `cancelAtPeriodEnd` to cancel when the period ends. */
540
+ update(id, params, options) {
541
+ return this.call("Subscriptions_update", { path: { id }, body: params }, options);
542
+ }
543
+ /** Cancel now; its open invoices are voided. */
544
+ cancel(id, options) {
545
+ return this.call("Subscriptions_cancel", { path: { id } }, options);
546
+ }
547
+ };
548
+ var Invoices = class extends APIResource {
549
+ /** Await for one page, or `for await` over every invoice (newest first). Filter with `customer`, `subscription`, `status`. */
550
+ list(params = {}, options) {
551
+ return new PagePromise(
552
+ (cursor) => this.call("Invoices_list", { query: { ...params, cursor } }, options),
553
+ params.cursor
554
+ );
555
+ }
556
+ retrieve(id, options) {
557
+ return this.call("Invoices_retrieve", { path: { id } }, options);
558
+ }
559
+ /** Void an open invoice. */
560
+ void(id, options) {
561
+ return this.call("Invoices_void", { path: { id } }, options);
562
+ }
563
+ /** Stop chasing an open invoice; it can still be paid. */
564
+ markUncollectible(id, options) {
565
+ return this.call("Invoices_markUncollectible", { path: { id } }, options);
566
+ }
567
+ /** Record an open invoice as paid outside VEXPay (`paidOutOfBand: true`); no money moves. */
568
+ pay(id, params, options) {
569
+ return this.call("Invoices_pay", { path: { id }, body: params }, options);
570
+ }
571
+ };
572
+ var SetupSessions = class extends APIResource {
573
+ /** `url` is returned only here — send it to the customer. */
574
+ create(params, options) {
575
+ return this.call("SetupSessions_create", { body: params }, options);
576
+ }
577
+ retrieve(id, options) {
578
+ return this.call("SetupSessions_retrieve", { path: { id } }, options);
579
+ }
580
+ };
581
+ var PaymentMethods = class extends APIResource {
582
+ retrieve(id, options) {
583
+ return this.call("PaymentMethods_retrieve", { path: { id } }, options);
584
+ }
585
+ /** The method is never charged again. */
586
+ detach(id, options) {
587
+ return this.call("PaymentMethods_detach", { path: { id } }, options);
588
+ }
589
+ };
590
+
417
591
  // src/resources/commerce.ts
418
592
  var CheckoutSessions = class extends APIResource {
419
593
  /** `clientSecret` is returned only here — hand it to the browser, never store or log it. */
@@ -512,8 +686,10 @@ var Conversions = class extends APIResource {
512
686
  // src/resources/cop.ts
513
687
  var CopPayments = class extends APIResource {
514
688
  /**
515
- * Create a payment in whole pesos. `buyer` is required for `nequi` and `daviplata`. The response
516
- * `next` says what the buyer does: `show_qr`, `approve_in_app` or `submit_otp`.
689
+ * Create a payment in whole pesos. `buyer` is required for every channel except `breb`, with
690
+ * `termsAccepted: true` when {@link Cop.channels} says `needsTermsAcceptance`; `pse` also needs
691
+ * `pse.bankCode`. The response `next` says what the buyer does: `show_qr`, `approve_in_app`,
692
+ * `submit_otp`, `redirect` (send them to `next.url`) or `redirect_pending` (retrieve again shortly).
517
693
  * Pass `idempotencyKey` in options to retry safely.
518
694
  */
519
695
  create(params, options) {
@@ -522,7 +698,7 @@ var CopPayments = class extends APIResource {
522
698
  retrieve(id, options) {
523
699
  return this.call("CopPayments_get", { path: { id } }, options);
524
700
  }
525
- /** Daviplata: submit the code the buyer received by SMS. A wrong code fails with `invalid_otp`. */
701
+ /** Daviplata with `next.type: "submit_otp"`: submit the code the buyer received by SMS. A wrong code fails with `invalid_otp`. */
526
702
  submitOtp(id, params, options) {
527
703
  return this.call("CopPayments_submitOtp", { path: { id }, body: params }, options);
528
704
  }
@@ -530,7 +706,10 @@ var CopPayments = class extends APIResource {
530
706
  cancel(id, options) {
531
707
  return this.call("CopPayments_cancel", { path: { id } }, options);
532
708
  }
533
- /** Full refund of a completed payment, within 96 hours. */
709
+ /**
710
+ * Full refund of a completed payment, within the channel's window (card 24 h, Bre-B 96 h).
711
+ * Channels that cannot be refunded through the API fail with `refund_not_supported`.
712
+ */
534
713
  refund(id, options) {
535
714
  return this.call("CopPayments_refund", { path: { id } }, options);
536
715
  }
@@ -543,6 +722,10 @@ var CopBalance = class extends APIResource {
543
722
  var Cop = class extends APIResource {
544
723
  payments = new CopPayments(this.http);
545
724
  balance = new CopBalance(this.http);
725
+ /** Channels you can use right now, with what each needs, plus the PSE banks and terms links. */
726
+ channels(options) {
727
+ return this.call("CopPayments_channels", {}, options);
728
+ }
546
729
  };
547
730
 
548
731
  // src/resources/crypto.ts
@@ -639,10 +822,34 @@ var Merchants = class extends APIResource {
639
822
  retrieveBalance(id, options) {
640
823
  return this.call("Merchants_getBalance", { path: { id } }, options);
641
824
  }
642
- /** Move VES between this merchant's balance and another. */
825
+ /**
826
+ * Credit this seller's pending balance from your platform balance. Send `amountVes`, or
827
+ * `amountUsd` to convert at the official BCV rate; `transferKey` makes it idempotent.
828
+ * The response is the seller balance plus `transfer` (amounts and rate used).
829
+ */
643
830
  transfer(id, params, options) {
644
831
  return this.call("Merchants_transfer", { path: { id }, body: params }, options);
645
832
  }
833
+ /** Seller balance movements, newest first. Await for one page, or `for await` over every movement. */
834
+ listTransactions(id, params = {}, options) {
835
+ return new PagePromise(
836
+ (cursor) => this.call("Merchants_listTransactions", { path: { id }, query: { ...params, cursor } }, options),
837
+ params.cursor
838
+ );
839
+ }
840
+ /** Monthly statement (`month: 'YYYY-MM'`, America/Caracas): opening, movements, closing. */
841
+ retrieveStatement(id, params, options) {
842
+ return this.call("Merchants_statement", { path: { id }, query: { ...params, format: "json" } }, options);
843
+ }
844
+ /** The same monthly statement as CSV (with a running balance column), returned as a string. */
845
+ async retrieveStatementCsv(id, params, options) {
846
+ const body = await this.call(
847
+ "Merchants_statement",
848
+ { path: { id }, query: { ...params, format: "csv" } },
849
+ options
850
+ );
851
+ return typeof body === "string" ? body : "";
852
+ }
646
853
  listAuditEvents(id, options) {
647
854
  return this.call("Merchants_listAuditEvents", { path: { id } }, options);
648
855
  }
@@ -783,6 +990,25 @@ var WEBHOOK_EVENT_NAMES = [
783
990
  "tenant.api_key.rotated",
784
991
  "tenant.api_key.revoked",
785
992
  "tenant.live_status_changed",
993
+ "customer.created",
994
+ "customer.updated",
995
+ "customer.deleted",
996
+ "customer.subscription.created",
997
+ "customer.subscription.updated",
998
+ "customer.subscription.deleted",
999
+ "customer.subscription.trial_will_end",
1000
+ "customer.subscription.reactivated",
1001
+ "invoice.created",
1002
+ "invoice.upcoming",
1003
+ "invoice.paid",
1004
+ "invoice.payment_attempt",
1005
+ "invoice.payment_failed",
1006
+ "invoice.overdue",
1007
+ "invoice.voided",
1008
+ "invoice.marked_uncollectible",
1009
+ "payment_method.attached",
1010
+ "payment_method.updated",
1011
+ "payment_method.detached",
786
1012
  "notification.test"
787
1013
  ];
788
1014
  var SIGNATURE_HEADER = "VexPay-Signature";
@@ -884,6 +1110,17 @@ var VexPay = class {
884
1110
  paymentLinks;
885
1111
  tenantPayoutAccount;
886
1112
  webhookEndpoints;
1113
+ /** Billing: who you bill. */
1114
+ customers;
1115
+ /** Billing: recurring prices on products. */
1116
+ prices;
1117
+ /** Billing: bill a customer on a price every interval. */
1118
+ subscriptions;
1119
+ invoices;
1120
+ /** Billing: hosted links where a customer authorizes domiciliación. */
1121
+ setupSessions;
1122
+ /** Billing: domiciliación payment methods (bolívar methods your account takes: `payments.methods()`). */
1123
+ paymentMethods;
887
1124
  /** Offline helpers: `constructEvent` verifies deliveries; no API calls. */
888
1125
  webhooks = new Webhooks();
889
1126
  constructor(apiKey, options = {}) {
@@ -918,6 +1155,12 @@ var VexPay = class {
918
1155
  this.paymentLinks = new PaymentLinks(this.http);
919
1156
  this.tenantPayoutAccount = new TenantPayoutAccount(this.http);
920
1157
  this.webhookEndpoints = new WebhookEndpoints(this.http);
1158
+ this.customers = new Customers(this.http);
1159
+ this.prices = new Prices(this.http);
1160
+ this.subscriptions = new Subscriptions(this.http);
1161
+ this.invoices = new Invoices(this.http);
1162
+ this.setupSessions = new SetupSessions(this.http);
1163
+ this.paymentMethods = new PaymentMethods(this.http);
921
1164
  }
922
1165
  };
923
1166
  export {