@vexpay/node 0.10.0 → 0.12.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.10.0";
65
+ var VERSION = "0.12.0";
66
66
 
67
67
  // src/core.ts
68
68
  var INITIAL_RETRY_DELAY_MS = 500;
@@ -235,6 +235,16 @@ var ROUTES = {
235
235
  Crypto_getBalances: { method: "GET", path: "/v1/crypto/balances" },
236
236
  Crypto_getPayout: { method: "GET", path: "/v1/crypto/payouts/{id}" },
237
237
  Crypto_listNetworks: { method: "GET", path: "/v1/crypto/networks" },
238
+ Customers_create: { method: "POST", path: "/v1/customers" },
239
+ Customers_list: { method: "GET", path: "/v1/customers" },
240
+ Customers_remove: { method: "DELETE", path: "/v1/customers/{id}" },
241
+ Customers_retrieve: { method: "GET", path: "/v1/customers/{id}" },
242
+ Customers_update: { method: "POST", path: "/v1/customers/{id}" },
243
+ Invoices_list: { method: "GET", path: "/v1/invoices" },
244
+ Invoices_markUncollectible: { method: "POST", path: "/v1/invoices/{id}/mark-uncollectible" },
245
+ Invoices_pay: { method: "POST", path: "/v1/invoices/{id}/pay" },
246
+ Invoices_retrieve: { method: "GET", path: "/v1/invoices/{id}" },
247
+ Invoices_void: { method: "POST", path: "/v1/invoices/{id}/void" },
238
248
  Merchants_addPayoutMethod: { method: "POST", path: "/v1/merchants/{id}/payout-methods" },
239
249
  Merchants_confirmVerify: { method: "POST", path: "/v1/merchants/{id}/verify" },
240
250
  Merchants_confirmVerifyMethod: { method: "POST", path: "/v1/merchants/{id}/payout-methods/{methodId}/verify" },
@@ -255,6 +265,9 @@ var ROUTES = {
255
265
  PaymentLinks_get: { method: "GET", path: "/v1/payment-links/{id}" },
256
266
  PaymentLinks_remove: { method: "DELETE", path: "/v1/payment-links/{id}" },
257
267
  PaymentLinks_update: { method: "PATCH", path: "/v1/payment-links/{id}" },
268
+ PaymentMethods_detach: { method: "DELETE", path: "/v1/payment-methods/{id}" },
269
+ PaymentMethods_list: { method: "GET", path: "/v1/customers/{id}/payment-methods" },
270
+ PaymentMethods_retrieve: { method: "GET", path: "/v1/payment-methods/{id}" },
258
271
  Payments_executeC2p: { method: "POST", path: "/v1/payments/c2p" },
259
272
  Payments_executeVpos: { method: "POST", path: "/v1/payments/vpos" },
260
273
  Payments_getBanks: { method: "GET", path: "/v1/banks" },
@@ -272,6 +285,10 @@ var ROUTES = {
272
285
  Payouts_getById: { method: "GET", path: "/v1/payouts/{id}" },
273
286
  Payouts_getByRef: { method: "GET", path: "/v1/payouts/by-ref/{externalRef}" },
274
287
  Payouts_list: { method: "GET", path: "/v1/payouts" },
288
+ Prices_create: { method: "POST", path: "/v1/prices" },
289
+ Prices_list: { method: "GET", path: "/v1/prices" },
290
+ Prices_retrieve: { method: "GET", path: "/v1/prices/{id}" },
291
+ Prices_update: { method: "POST", path: "/v1/prices/{id}" },
275
292
  Products_create: { method: "POST", path: "/v1/products" },
276
293
  Products_createLink: { method: "POST", path: "/v1/products/{id}/links" },
277
294
  Products_get: { method: "GET", path: "/v1/products/{id}" },
@@ -288,6 +305,13 @@ var ROUTES = {
288
305
  R4Operations_ejecutarVuelto: { method: "POST", path: "/v1/payments/change" },
289
306
  R4Operations_generarOtp: { method: "POST", path: "/v1/payments/debit/otp" },
290
307
  R4Operations_pollOperation: { method: "POST", path: "/v1/payments/operations/poll" },
308
+ SetupSessions_create: { method: "POST", path: "/v1/setup-sessions" },
309
+ SetupSessions_retrieve: { method: "GET", path: "/v1/setup-sessions/{id}" },
310
+ Subscriptions_cancel: { method: "DELETE", path: "/v1/subscriptions/{id}" },
311
+ Subscriptions_create: { method: "POST", path: "/v1/subscriptions" },
312
+ Subscriptions_list: { method: "GET", path: "/v1/subscriptions" },
313
+ Subscriptions_retrieve: { method: "GET", path: "/v1/subscriptions/{id}" },
314
+ Subscriptions_update: { method: "POST", path: "/v1/subscriptions/{id}" },
291
315
  TenantPayoutAccount_confirmVerify: { method: "POST", path: "/v1/tenant/payout-account/verify" },
292
316
  TenantPayoutAccount_get: { method: "GET", path: "/v1/tenant/payout-account" },
293
317
  TenantPayoutAccount_startVerify: { method: "POST", path: "/v1/tenant/payout-account/verify/start" },
@@ -414,6 +438,126 @@ var WebhookEndpoints = class extends APIResource {
414
438
  }
415
439
  };
416
440
 
441
+ // src/resources/billing.ts
442
+ var CustomerPaymentMethods = class extends APIResource {
443
+ /** Await for one page, or `for await` over every attached method (newest first). */
444
+ list(customerId, params = {}, options) {
445
+ return new PagePromise(
446
+ (cursor) => this.call("PaymentMethods_list", { path: { id: customerId }, query: { ...params, cursor } }, options),
447
+ params.cursor
448
+ );
449
+ }
450
+ };
451
+ var Customers = class extends APIResource {
452
+ paymentMethods = new CustomerPaymentMethods(this.http);
453
+ /** Pass `idempotencyKey` in options to retry safely. */
454
+ create(params = {}, options) {
455
+ return this.call("Customers_create", { body: params }, options);
456
+ }
457
+ /** Await for one page, or `for await` over every customer (newest first). Filter with `email`. */
458
+ list(params = {}, options) {
459
+ return new PagePromise(
460
+ (cursor) => this.call("Customers_list", { query: { ...params, cursor } }, options),
461
+ params.cursor
462
+ );
463
+ }
464
+ retrieve(id, options) {
465
+ return this.call("Customers_retrieve", { path: { id } }, options);
466
+ }
467
+ update(id, params, options) {
468
+ return this.call("Customers_update", { path: { id }, body: params }, options);
469
+ }
470
+ /** Refused with 409 while the customer has a live subscription. */
471
+ delete(id, options) {
472
+ return this.call("Customers_remove", { path: { id } }, options);
473
+ }
474
+ };
475
+ var Prices = class extends APIResource {
476
+ create(params, options) {
477
+ return this.call("Prices_create", { body: params }, options);
478
+ }
479
+ /** Await for one page, or `for await` over every price. Filter with `product` and `active`. */
480
+ list(params = {}, options) {
481
+ return new PagePromise(
482
+ (cursor) => this.call("Prices_list", { query: { ...params, cursor } }, options),
483
+ params.cursor
484
+ );
485
+ }
486
+ retrieve(id, options) {
487
+ return this.call("Prices_retrieve", { path: { id } }, options);
488
+ }
489
+ /** Only `active`, `nickname` and `metadata` can change; create a new price for a new amount. */
490
+ update(id, params, options) {
491
+ return this.call("Prices_update", { path: { id }, body: params }, options);
492
+ }
493
+ };
494
+ var Subscriptions = class extends APIResource {
495
+ /** Pass `idempotencyKey` in options to retry safely. */
496
+ create(params, options) {
497
+ return this.call("Subscriptions_create", { body: params }, options);
498
+ }
499
+ /** Await for one page, or `for await` over every subscription (newest first). Filter with `customer`, `price`, `status`. */
500
+ list(params = {}, options) {
501
+ return new PagePromise(
502
+ (cursor) => this.call("Subscriptions_list", { query: { ...params, cursor } }, options),
503
+ params.cursor
504
+ );
505
+ }
506
+ retrieve(id, options) {
507
+ return this.call("Subscriptions_retrieve", { path: { id } }, options);
508
+ }
509
+ /** Changes apply from the next invoice. Set `cancelAtPeriodEnd` to cancel when the period ends. */
510
+ update(id, params, options) {
511
+ return this.call("Subscriptions_update", { path: { id }, body: params }, options);
512
+ }
513
+ /** Cancel now; its open invoices are voided. */
514
+ cancel(id, options) {
515
+ return this.call("Subscriptions_cancel", { path: { id } }, options);
516
+ }
517
+ };
518
+ var Invoices = class extends APIResource {
519
+ /** Await for one page, or `for await` over every invoice (newest first). Filter with `customer`, `subscription`, `status`. */
520
+ list(params = {}, options) {
521
+ return new PagePromise(
522
+ (cursor) => this.call("Invoices_list", { query: { ...params, cursor } }, options),
523
+ params.cursor
524
+ );
525
+ }
526
+ retrieve(id, options) {
527
+ return this.call("Invoices_retrieve", { path: { id } }, options);
528
+ }
529
+ /** Void an open invoice. */
530
+ void(id, options) {
531
+ return this.call("Invoices_void", { path: { id } }, options);
532
+ }
533
+ /** Stop chasing an open invoice; it can still be paid. */
534
+ markUncollectible(id, options) {
535
+ return this.call("Invoices_markUncollectible", { path: { id } }, options);
536
+ }
537
+ /** Record an open invoice as paid outside VEXPay (`paidOutOfBand: true`); no money moves. */
538
+ pay(id, params, options) {
539
+ return this.call("Invoices_pay", { path: { id }, body: params }, options);
540
+ }
541
+ };
542
+ var SetupSessions = class extends APIResource {
543
+ /** `url` is returned only here — send it to the customer. */
544
+ create(params, options) {
545
+ return this.call("SetupSessions_create", { body: params }, options);
546
+ }
547
+ retrieve(id, options) {
548
+ return this.call("SetupSessions_retrieve", { path: { id } }, options);
549
+ }
550
+ };
551
+ var PaymentMethods = class extends APIResource {
552
+ retrieve(id, options) {
553
+ return this.call("PaymentMethods_retrieve", { path: { id } }, options);
554
+ }
555
+ /** The method is never charged again. */
556
+ detach(id, options) {
557
+ return this.call("PaymentMethods_detach", { path: { id } }, options);
558
+ }
559
+ };
560
+
417
561
  // src/resources/commerce.ts
418
562
  var CheckoutSessions = class extends APIResource {
419
563
  /** `clientSecret` is returned only here — hand it to the browser, never store or log it. */
@@ -783,6 +927,25 @@ var WEBHOOK_EVENT_NAMES = [
783
927
  "tenant.api_key.rotated",
784
928
  "tenant.api_key.revoked",
785
929
  "tenant.live_status_changed",
930
+ "customer.created",
931
+ "customer.updated",
932
+ "customer.deleted",
933
+ "customer.subscription.created",
934
+ "customer.subscription.updated",
935
+ "customer.subscription.deleted",
936
+ "customer.subscription.trial_will_end",
937
+ "customer.subscription.reactivated",
938
+ "invoice.created",
939
+ "invoice.upcoming",
940
+ "invoice.paid",
941
+ "invoice.payment_attempt",
942
+ "invoice.payment_failed",
943
+ "invoice.overdue",
944
+ "invoice.voided",
945
+ "invoice.marked_uncollectible",
946
+ "payment_method.attached",
947
+ "payment_method.updated",
948
+ "payment_method.detached",
786
949
  "notification.test"
787
950
  ];
788
951
  var SIGNATURE_HEADER = "VexPay-Signature";
@@ -884,6 +1047,17 @@ var VexPay = class {
884
1047
  paymentLinks;
885
1048
  tenantPayoutAccount;
886
1049
  webhookEndpoints;
1050
+ /** Billing: who you bill. */
1051
+ customers;
1052
+ /** Billing: recurring prices on products. */
1053
+ prices;
1054
+ /** Billing: bill a customer on a price every interval. */
1055
+ subscriptions;
1056
+ invoices;
1057
+ /** Billing: hosted links where a customer authorizes domiciliación. */
1058
+ setupSessions;
1059
+ /** Billing: domiciliación payment methods (bolívar methods your account takes: `payments.methods()`). */
1060
+ paymentMethods;
887
1061
  /** Offline helpers: `constructEvent` verifies deliveries; no API calls. */
888
1062
  webhooks = new Webhooks();
889
1063
  constructor(apiKey, options = {}) {
@@ -918,6 +1092,12 @@ var VexPay = class {
918
1092
  this.paymentLinks = new PaymentLinks(this.http);
919
1093
  this.tenantPayoutAccount = new TenantPayoutAccount(this.http);
920
1094
  this.webhookEndpoints = new WebhookEndpoints(this.http);
1095
+ this.customers = new Customers(this.http);
1096
+ this.prices = new Prices(this.http);
1097
+ this.subscriptions = new Subscriptions(this.http);
1098
+ this.invoices = new Invoices(this.http);
1099
+ this.setupSessions = new SetupSessions(this.http);
1100
+ this.paymentMethods = new PaymentMethods(this.http);
921
1101
  }
922
1102
  };
923
1103
  export {