velirapay 0.1.1 → 0.2.1

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.
Files changed (117) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +700 -51
  3. package/dist/cjs/client.d.ts +1 -1
  4. package/dist/cjs/enums.d.ts +159 -27
  5. package/dist/cjs/enums.js +150 -25
  6. package/dist/cjs/errors.d.ts +10 -1
  7. package/dist/cjs/errors.js +12 -1
  8. package/dist/cjs/http/transport.js +18 -3
  9. package/dist/cjs/index.d.ts +3 -3
  10. package/dist/cjs/index.js +12 -2
  11. package/dist/cjs/page.d.ts +14 -2
  12. package/dist/cjs/page.js +19 -2
  13. package/dist/cjs/params.d.ts +21 -10
  14. package/dist/cjs/resources/account.d.ts +13 -13
  15. package/dist/cjs/resources/account.js +7 -7
  16. package/dist/cjs/resources/activity.d.ts +4 -3
  17. package/dist/cjs/resources/activity.js +1 -1
  18. package/dist/cjs/resources/api-key.d.ts +3 -2
  19. package/dist/cjs/resources/api-resource.d.ts +2 -0
  20. package/dist/cjs/resources/api-resource.js +5 -0
  21. package/dist/cjs/resources/charge.d.ts +7 -3
  22. package/dist/cjs/resources/charge.js +6 -0
  23. package/dist/cjs/resources/coupon.d.ts +2 -1
  24. package/dist/cjs/resources/event.d.ts +3 -3
  25. package/dist/cjs/resources/event.js +1 -1
  26. package/dist/cjs/resources/invoice.d.ts +8 -4
  27. package/dist/cjs/resources/invoice.js +6 -0
  28. package/dist/cjs/resources/member.d.ts +5 -4
  29. package/dist/cjs/resources/member.js +2 -2
  30. package/dist/cjs/resources/overview.d.ts +116 -4
  31. package/dist/cjs/resources/overview.js +76 -3
  32. package/dist/cjs/resources/payment-link.d.ts +3 -3
  33. package/dist/cjs/resources/payout.d.ts +5 -5
  34. package/dist/cjs/resources/payout.js +1 -1
  35. package/dist/cjs/resources/pro-payment.d.ts +3 -2
  36. package/dist/cjs/resources/supported-asset.d.ts +2 -2
  37. package/dist/cjs/resources/webhook-endpoint.d.ts +5 -4
  38. package/dist/cjs/resources/webhook-endpoint.js +3 -2
  39. package/dist/cjs/services/account.js +1 -1
  40. package/dist/cjs/services/api-keys.d.ts +7 -1
  41. package/dist/cjs/services/api-keys.js +7 -1
  42. package/dist/cjs/services/assets.d.ts +3 -4
  43. package/dist/cjs/services/assets.js +3 -2
  44. package/dist/cjs/services/charges.js +3 -3
  45. package/dist/cjs/services/coupons.js +1 -1
  46. package/dist/cjs/services/invoices.js +5 -1
  47. package/dist/cjs/services/members.d.ts +2 -2
  48. package/dist/cjs/services/members.js +2 -2
  49. package/dist/cjs/services/overview.d.ts +1 -1
  50. package/dist/cjs/services/overview.js +3 -2
  51. package/dist/cjs/services/payment-links.js +4 -2
  52. package/dist/cjs/services/payout-addresses.d.ts +9 -4
  53. package/dist/cjs/services/payout-addresses.js +6 -2
  54. package/dist/cjs/services/service.d.ts +8 -3
  55. package/dist/cjs/services/service.js +45 -10
  56. package/dist/cjs/services/webhook-endpoints.d.ts +15 -2
  57. package/dist/cjs/services/webhook-endpoints.js +15 -2
  58. package/dist/cjs/version.d.ts +1 -1
  59. package/dist/cjs/version.js +1 -1
  60. package/dist/esm/client.d.ts +1 -1
  61. package/dist/esm/enums.d.ts +159 -27
  62. package/dist/esm/enums.js +149 -24
  63. package/dist/esm/errors.d.ts +10 -1
  64. package/dist/esm/errors.js +12 -1
  65. package/dist/esm/http/transport.js +18 -3
  66. package/dist/esm/index.d.ts +3 -3
  67. package/dist/esm/index.js +3 -3
  68. package/dist/esm/page.d.ts +14 -2
  69. package/dist/esm/page.js +17 -1
  70. package/dist/esm/params.d.ts +21 -10
  71. package/dist/esm/resources/account.d.ts +13 -13
  72. package/dist/esm/resources/account.js +8 -8
  73. package/dist/esm/resources/activity.d.ts +4 -3
  74. package/dist/esm/resources/activity.js +1 -1
  75. package/dist/esm/resources/api-key.d.ts +3 -2
  76. package/dist/esm/resources/api-resource.d.ts +2 -0
  77. package/dist/esm/resources/api-resource.js +4 -0
  78. package/dist/esm/resources/charge.d.ts +7 -3
  79. package/dist/esm/resources/charge.js +6 -0
  80. package/dist/esm/resources/coupon.d.ts +2 -1
  81. package/dist/esm/resources/event.d.ts +3 -3
  82. package/dist/esm/resources/event.js +1 -1
  83. package/dist/esm/resources/invoice.d.ts +8 -4
  84. package/dist/esm/resources/invoice.js +6 -0
  85. package/dist/esm/resources/member.d.ts +5 -4
  86. package/dist/esm/resources/member.js +2 -2
  87. package/dist/esm/resources/overview.d.ts +116 -4
  88. package/dist/esm/resources/overview.js +77 -4
  89. package/dist/esm/resources/payment-link.d.ts +3 -3
  90. package/dist/esm/resources/payout.d.ts +5 -5
  91. package/dist/esm/resources/payout.js +1 -1
  92. package/dist/esm/resources/pro-payment.d.ts +3 -2
  93. package/dist/esm/resources/supported-asset.d.ts +2 -2
  94. package/dist/esm/resources/webhook-endpoint.d.ts +5 -4
  95. package/dist/esm/resources/webhook-endpoint.js +3 -2
  96. package/dist/esm/services/account.js +2 -2
  97. package/dist/esm/services/api-keys.d.ts +7 -1
  98. package/dist/esm/services/api-keys.js +7 -1
  99. package/dist/esm/services/assets.d.ts +3 -4
  100. package/dist/esm/services/assets.js +3 -2
  101. package/dist/esm/services/charges.js +4 -4
  102. package/dist/esm/services/coupons.js +2 -2
  103. package/dist/esm/services/invoices.js +6 -2
  104. package/dist/esm/services/members.d.ts +2 -2
  105. package/dist/esm/services/members.js +2 -2
  106. package/dist/esm/services/overview.d.ts +1 -1
  107. package/dist/esm/services/overview.js +4 -3
  108. package/dist/esm/services/payment-links.js +5 -3
  109. package/dist/esm/services/payout-addresses.d.ts +9 -4
  110. package/dist/esm/services/payout-addresses.js +6 -2
  111. package/dist/esm/services/service.d.ts +8 -3
  112. package/dist/esm/services/service.js +44 -10
  113. package/dist/esm/services/webhook-endpoints.d.ts +15 -2
  114. package/dist/esm/services/webhook-endpoints.js +15 -2
  115. package/dist/esm/version.d.ts +1 -1
  116. package/dist/esm/version.js +1 -1
  117. package/package.json +12 -2
package/dist/cjs/index.js CHANGED
@@ -1,24 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PayoutAddress = exports.Payout = exports.PaymentLink = exports.Overview = exports.Member = exports.Invitation = exports.InvoiceItem = exports.Invoice = exports.Event = exports.Coupon = exports.Transaction = exports.Refund = exports.Customer = exports.Charge = exports.ApiResource = exports.ApiKey = exports.Activity = exports.Address = exports.AccountBusiness = exports.Account = exports.Page = exports.ApiResponse = exports.VeliraPayError = exports.ValidationError = exports.UnexpectedResponseError = exports.SignatureVerificationError = exports.ServerError = exports.RateLimitError = exports.PermissionError = exports.NotFoundError = exports.InvalidRequestError = exports.InvalidArgumentError = exports.ConnectionError = exports.ConflictError = exports.AuthenticationError = exports.ApiError = exports.PricingType = exports.PayoutStatus = exports.PaymentLinkStatus = exports.MonthlyVolume = exports.Mode = exports.InvoiceStatus = exports.Industry = exports.EventType = exports.ChargeStatus = exports.BusinessType = exports.Asset = exports.ApiKeyPermission = exports.VERSION = exports.VeliraPayClient = void 0;
4
- exports.WebhookEvent = exports.Webhook = exports.WebhookEndpointService = exports.Service = exports.PayoutService = exports.PayoutAddressService = exports.PaymentLinkService = exports.OverviewService = exports.MemberService = exports.InvitationService = exports.InvoiceService = exports.EventService = exports.CouponService = exports.ChargeService = exports.BillingService = exports.AssetService = exports.ApiKeyService = exports.ActivityService = exports.AccountService = exports.WebhookEndpoint = exports.WebhookDeliveryAttempt = exports.WebhookDelivery = exports.SupportedAsset = exports.ProPayment = exports.PayoutSummary = void 0;
3
+ exports.Transaction = exports.Refund = exports.Customer = exports.Charge = exports.ApiResource = exports.ApiKey = exports.Activity = exports.Address = exports.AccountBusiness = exports.Account = exports.Page = exports.AssetPage = exports.ApiResponse = exports.VeliraPayError = exports.ValidationError = exports.UnexpectedResponseError = exports.SignatureVerificationError = exports.ServerError = exports.RateLimitError = exports.PermissionError = exports.NotFoundError = exports.InvalidRequestError = exports.InvalidArgumentError = exports.ConnectionError = exports.ConflictError = exports.AuthenticationError = exports.ApiError = exports.WebhookDeliveryStatus = exports.PricingType = exports.PlanName = exports.PayoutStatus = exports.PaymentLinkStatus = exports.MonthlyVolume = exports.Mode = exports.MemberRole = exports.InvoiceStatus = exports.Industry = exports.EventType = exports.Currency = exports.CheckoutLocale = exports.CheckoutAppearance = exports.ChargeStatus = exports.BusinessType = exports.Asset = exports.ApiKeyPermission = exports.AddressNetwork = exports.ActivityAction = exports.AccountType = exports.VERSION = exports.VeliraPayClient = void 0;
4
+ exports.WebhookEvent = exports.Webhook = exports.WebhookEndpointService = exports.Service = exports.PayoutService = exports.PayoutAddressService = exports.PaymentLinkService = exports.OverviewService = exports.MemberService = exports.InvitationService = exports.InvoiceService = exports.EventService = exports.CouponService = exports.ChargeService = exports.BillingService = exports.AssetService = exports.ApiKeyService = exports.ActivityService = exports.AccountService = exports.WebhookEndpoint = exports.WebhookDeliveryAttempt = exports.WebhookDelivery = exports.SupportedAsset = exports.ProPayment = exports.PayoutSummary = exports.PayoutAddress = exports.Payout = exports.PaymentLink = exports.Overview = exports.Member = exports.Invitation = exports.InvoiceItem = exports.Invoice = exports.Event = exports.Coupon = void 0;
5
5
  var client_ts_1 = require("./client.js");
6
6
  Object.defineProperty(exports, "VeliraPayClient", { enumerable: true, get: function () { return client_ts_1.VeliraPayClient; } });
7
7
  var version_ts_1 = require("./version.js");
8
8
  Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_ts_1.VERSION; } });
9
9
  var enums_ts_1 = require("./enums.js");
10
+ Object.defineProperty(exports, "AccountType", { enumerable: true, get: function () { return enums_ts_1.AccountType; } });
11
+ Object.defineProperty(exports, "ActivityAction", { enumerable: true, get: function () { return enums_ts_1.ActivityAction; } });
12
+ Object.defineProperty(exports, "AddressNetwork", { enumerable: true, get: function () { return enums_ts_1.AddressNetwork; } });
10
13
  Object.defineProperty(exports, "ApiKeyPermission", { enumerable: true, get: function () { return enums_ts_1.ApiKeyPermission; } });
11
14
  Object.defineProperty(exports, "Asset", { enumerable: true, get: function () { return enums_ts_1.Asset; } });
12
15
  Object.defineProperty(exports, "BusinessType", { enumerable: true, get: function () { return enums_ts_1.BusinessType; } });
13
16
  Object.defineProperty(exports, "ChargeStatus", { enumerable: true, get: function () { return enums_ts_1.ChargeStatus; } });
17
+ Object.defineProperty(exports, "CheckoutAppearance", { enumerable: true, get: function () { return enums_ts_1.CheckoutAppearance; } });
18
+ Object.defineProperty(exports, "CheckoutLocale", { enumerable: true, get: function () { return enums_ts_1.CheckoutLocale; } });
19
+ Object.defineProperty(exports, "Currency", { enumerable: true, get: function () { return enums_ts_1.Currency; } });
14
20
  Object.defineProperty(exports, "EventType", { enumerable: true, get: function () { return enums_ts_1.EventType; } });
15
21
  Object.defineProperty(exports, "Industry", { enumerable: true, get: function () { return enums_ts_1.Industry; } });
16
22
  Object.defineProperty(exports, "InvoiceStatus", { enumerable: true, get: function () { return enums_ts_1.InvoiceStatus; } });
23
+ Object.defineProperty(exports, "MemberRole", { enumerable: true, get: function () { return enums_ts_1.MemberRole; } });
17
24
  Object.defineProperty(exports, "Mode", { enumerable: true, get: function () { return enums_ts_1.Mode; } });
18
25
  Object.defineProperty(exports, "MonthlyVolume", { enumerable: true, get: function () { return enums_ts_1.MonthlyVolume; } });
19
26
  Object.defineProperty(exports, "PaymentLinkStatus", { enumerable: true, get: function () { return enums_ts_1.PaymentLinkStatus; } });
20
27
  Object.defineProperty(exports, "PayoutStatus", { enumerable: true, get: function () { return enums_ts_1.PayoutStatus; } });
28
+ Object.defineProperty(exports, "PlanName", { enumerable: true, get: function () { return enums_ts_1.PlanName; } });
21
29
  Object.defineProperty(exports, "PricingType", { enumerable: true, get: function () { return enums_ts_1.PricingType; } });
30
+ Object.defineProperty(exports, "WebhookDeliveryStatus", { enumerable: true, get: function () { return enums_ts_1.WebhookDeliveryStatus; } });
22
31
  var errors_ts_1 = require("./errors.js");
23
32
  Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return errors_ts_1.ApiError; } });
24
33
  Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return errors_ts_1.AuthenticationError; } });
@@ -37,6 +46,7 @@ Object.defineProperty(exports, "VeliraPayError", { enumerable: true, get: functi
37
46
  var api_response_ts_1 = require("./http/api-response.js");
38
47
  Object.defineProperty(exports, "ApiResponse", { enumerable: true, get: function () { return api_response_ts_1.ApiResponse; } });
39
48
  var page_ts_1 = require("./page.js");
49
+ Object.defineProperty(exports, "AssetPage", { enumerable: true, get: function () { return page_ts_1.AssetPage; } });
40
50
  Object.defineProperty(exports, "Page", { enumerable: true, get: function () { return page_ts_1.Page; } });
41
51
  var account_ts_1 = require("./resources/account.js");
42
52
  Object.defineProperty(exports, "Account", { enumerable: true, get: function () { return account_ts_1.Account; } });
@@ -1,4 +1,6 @@
1
- import type { ApiResource } from './resources/api-resource.ts';
1
+ import type { Currency, Mode, OrString } from './enums.ts';
2
+ import { type ApiResource, type Attributes } from './resources/api-resource.ts';
3
+ import type { SupportedAsset } from './resources/supported-asset.ts';
2
4
  /** Where a page sits in its list. */
3
5
  export interface PagePosition {
4
6
  currentPage: number;
@@ -19,7 +21,11 @@ export declare class Page<T extends ApiResource> implements Iterable<T> {
19
21
  readonly perPage: number;
20
22
  /** How many objects the whole list holds. */
21
23
  readonly total: number;
22
- constructor(data: T[], position: PagePosition, fetch: (page: number) => Promise<Page<T>>);
24
+ /** What the answer said about the list besides its objects, as the API sent it: its position, and anything else, such as its mode. */
25
+ readonly meta: Attributes;
26
+ /** The mode the list is in, for the lists whose answer says it, such as the coins on offer and the activity log; null for the others. */
27
+ readonly mode: OrString<Mode> | null;
28
+ constructor(data: T[], position: PagePosition, fetch: (page: number) => Promise<Page<T>>, meta?: Attributes);
23
29
  /** Whether there are pages after this one. */
24
30
  hasMore(): boolean;
25
31
  /** Fetch the next page, or null when this is the last. */
@@ -31,3 +37,9 @@ export declare class Page<T extends ApiResource> implements Iterable<T> {
31
37
  /** Whether this page holds no objects. */
32
38
  isEmpty(): boolean;
33
39
  }
40
+ /** The coins on offer, which assets.list() answers with in a single page, with the currencies their prices can be asked in. */
41
+ export declare class AssetPage extends Page<SupportedAsset> {
42
+ /** The currencies assets.list() can give prices in, which its currency parameter takes. */
43
+ readonly currencies: OrString<Currency>[];
44
+ constructor(data: SupportedAsset[], position: PagePosition, fetch: (page: number) => Promise<Page<SupportedAsset>>, meta?: Attributes);
45
+ }
package/dist/cjs/page.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Page = void 0;
3
+ exports.AssetPage = exports.Page = void 0;
4
+ const api_resource_ts_1 = require("./resources/api-resource.js");
4
5
  /** One page of a list, able to fetch the pages after it. */
5
6
  class Page {
6
7
  /** The objects on this page. */
@@ -13,13 +14,19 @@ class Page {
13
14
  perPage;
14
15
  /** How many objects the whole list holds. */
15
16
  total;
17
+ /** What the answer said about the list besides its objects, as the API sent it: its position, and anything else, such as its mode. */
18
+ meta;
19
+ /** The mode the list is in, for the lists whose answer says it, such as the coins on offer and the activity log; null for the others. */
20
+ mode;
16
21
  #fetch;
17
- constructor(data, position, fetch) {
22
+ constructor(data, position, fetch, meta = {}) {
18
23
  this.data = data;
19
24
  this.currentPage = position.currentPage;
20
25
  this.lastPage = position.lastPage;
21
26
  this.perPage = position.perPage;
22
27
  this.total = position.total;
28
+ this.meta = meta;
29
+ this.mode = (0, api_resource_ts_1.nullableString)(meta, 'mode');
23
30
  this.#fetch = fetch;
24
31
  }
25
32
  /** Whether there are pages after this one. */
@@ -63,3 +70,13 @@ class Page {
63
70
  }
64
71
  }
65
72
  exports.Page = Page;
73
+ /** The coins on offer, which assets.list() answers with in a single page, with the currencies their prices can be asked in. */
74
+ class AssetPage extends Page {
75
+ /** The currencies assets.list() can give prices in, which its currency parameter takes. */
76
+ currencies;
77
+ constructor(data, position, fetch, meta = {}) {
78
+ super(data, position, fetch, meta);
79
+ this.currencies = (0, api_resource_ts_1.strings)(meta, 'currencies');
80
+ }
81
+ }
82
+ exports.AssetPage = AssetPage;
@@ -1,11 +1,18 @@
1
- import type { ApiKeyPermission, Asset, BusinessType, ChargeStatus, Currency, EventType, Industry, InvoiceStatus, MemberRole, Mode, MonthlyVolume, OrString, PaymentLinkStatus, PayoutStatus, PricingType } from './enums.ts';
2
- /** An amount of money or of a coin. Pass a string, such as "49.90", to keep every decimal. */
1
+ import type { ActivityAction, ApiKeyPermission, Asset, AssignableMemberRole, BusinessType, ChargeStatus, CheckoutAppearance, CheckoutLocale, Currency, EventType, Industry, InvoiceStatus, Mode, MonthlyVolume, OrString, PaymentLinkStatus, PayoutStatus, PricingType, WebhookDeliveryStatus } from './enums.ts';
2
+ /** An amount of money or of a coin. Pass a string, such as "49.90", to keep every decimal: a number is rounded to 14 significant digits. */
3
3
  export type Amount = string | number;
4
4
  /** Your own key-value data: up to 20 keys of at most 40 characters, each a string of at most 500 characters, a number, a boolean or null. */
5
5
  export type Metadata = Record<string, string | number | boolean | null>;
6
6
  /** Options for a request that changes something. */
7
7
  export interface RequestOptions {
8
- /** Up to 255 characters, such as an order number. For 24 hours, a repeat with the same key gets the first successful response instead of being carried out again. */
8
+ /**
9
+ * Up to 255 characters and not blank, such as "order-1042-attempt-1". For 24 hours, a repeat with the same key gets the first successful response
10
+ * instead of being carried out again. Reuse a key only to retry the same request: a new attempt, such as a charge replacing one
11
+ * that expired, needs a new key, or it gets the old charge back, and a different body under the same key throws a ConflictError.
12
+ * The answers that carry a new API key or webhook signing secret are the exception: they are never kept, so a repeat of
13
+ * apiKeys.create(), webhookEndpoints.create() or rotateSecret() throws a ConflictError whose wasReplayed() is true, meaning the
14
+ * first one succeeded.
15
+ */
9
16
  idempotencyKey?: string;
10
17
  }
11
18
  /** Which page of a list to fetch. */
@@ -86,6 +93,10 @@ export interface InvoiceCreateParams {
86
93
  memo?: string | null;
87
94
  /** The day it is due, as YYYY-MM-DD. */
88
95
  due_at?: string | null;
96
+ /** A public https:// address the customer is offered a button back to once they have paid. */
97
+ success_url?: string | null;
98
+ /** A public https:// address the customer can go back to from the invoice without paying. */
99
+ cancel_url?: string | null;
89
100
  send_email?: boolean;
90
101
  }
91
102
  export interface InvoiceListParams extends PageParams {
@@ -172,7 +183,7 @@ export interface WebhookEndpointCreateParams {
172
183
  }
173
184
  export type WebhookEndpointUpdateParams = Partial<WebhookEndpointCreateParams>;
174
185
  export interface WebhookDeliveryListParams extends PageParams {
175
- status?: OrString<'pending' | 'succeeded' | 'failed'>;
186
+ status?: OrString<WebhookDeliveryStatus>;
176
187
  event?: OrString<EventType>;
177
188
  }
178
189
  export interface ApiKeyCreateParams {
@@ -184,15 +195,15 @@ export interface ApiKeyCreateParams {
184
195
  }
185
196
  export type ApiKeyUpdateParams = Partial<ApiKeyCreateParams>;
186
197
  export interface MemberUpdateParams {
187
- role: OrString<MemberRole>;
198
+ role: OrString<AssignableMemberRole>;
188
199
  }
189
200
  export interface InvitationCreateParams {
190
201
  email: string;
191
- role: OrString<MemberRole>;
202
+ role: OrString<AssignableMemberRole>;
192
203
  }
193
204
  export interface ActivityListParams extends PageParams {
194
- /** An action, or "sensitive". */
195
- action?: string;
205
+ /** An action, or "sensitive" for those that touch money or access. */
206
+ action?: OrString<ActivityAction | 'sensitive'>;
196
207
  person?: string;
197
208
  /** A subject or the start of an IP address. */
198
209
  q?: string;
@@ -223,7 +234,7 @@ export interface AccountUpdateParams {
223
234
  refund_policy_url?: string | null;
224
235
  brand_color?: string | null;
225
236
  checkout?: {
226
- appearance?: OrString<'auto' | 'light' | 'dark'>;
237
+ appearance?: OrString<CheckoutAppearance>;
227
238
  coin_order?: OrString<Asset>[];
228
239
  default_coin?: OrString<Asset> | null;
229
240
  success_url?: string | null;
@@ -259,6 +270,6 @@ export interface PaymentSettingsUpdateParams {
259
270
  default_currency?: OrString<Currency>;
260
271
  underpayment_tolerance?: Amount;
261
272
  overpayment_threshold?: Amount;
262
- checkout_locale?: OrString<'en' | 'fr' | 'de' | 'es' | 'tr' | 'pt' | 'ru' | 'ar'> | null;
273
+ checkout_locale?: OrString<CheckoutLocale> | null;
263
274
  invoice_reminders?: boolean;
264
275
  }
@@ -1,13 +1,13 @@
1
- import { BusinessType, Industry, Mode, MonthlyVolume, type OrString } from '../enums.ts';
1
+ import { AccountType, BusinessType, CheckoutAppearance, Industry, Mode, MonthlyVolume, PlanName, type Asset, type CheckoutLocale, type Currency, type OrString } from '../enums.ts';
2
2
  import { ApiResource, type Attributes } from './api-resource.ts';
3
3
  /** How the account's checkout looks and what it falls back on. */
4
4
  export interface AccountCheckout {
5
- /** "auto", "light" or "dark". */
6
- appearance: string;
5
+ /** One of the CheckoutAppearance values: auto, light or dark. */
6
+ appearance: OrString<CheckoutAppearance>;
7
7
  /** The order coins are listed in. */
8
- coinOrder: string[];
8
+ coinOrder: OrString<Asset>[];
9
9
  /** The coin the checkout starts on, or null when the merchant has not picked one. */
10
- defaultCoin: string | null;
10
+ defaultCoin: OrString<Asset> | null;
11
11
  successUrl: string | null;
12
12
  cancelUrl: string | null;
13
13
  successMessage: string | null;
@@ -23,8 +23,8 @@ export interface AccountInvoices {
23
23
  export declare class Account extends ApiResource {
24
24
  /** The account's slug. */
25
25
  readonly id: string;
26
- /** Either "personal" or "organization". */
27
- readonly type: string;
26
+ /** One of the AccountType values: personal or organization. */
27
+ readonly type: OrString<AccountType>;
28
28
  /** The account's name. */
29
29
  readonly name: string;
30
30
  /** The name customers see. */
@@ -48,13 +48,13 @@ export declare class Account extends ApiResource {
48
48
  /** Who runs the account and what it sells; every field is null until it is filled in, and for a key without the sensitive account:write permission. */
49
49
  readonly business: AccountBusiness;
50
50
  /** The currency new links and reports default to. */
51
- readonly defaultCurrency: string;
51
+ readonly defaultCurrency: OrString<Currency>;
52
52
  /** How far short of the amount due, in percent, still counts as paid. */
53
53
  readonly underpaymentTolerance: string;
54
54
  /** How much surplus, in percent, is ignored before a charge is flagged as overpaid. */
55
55
  readonly overpaymentThreshold: string;
56
- /** "free" or "pro". */
57
- readonly plan: string;
56
+ /** One of the PlanName values: free or pro. */
57
+ readonly plan: OrString<PlanName>;
58
58
  /** The share of each payment kept as the platform's fee, in percent. */
59
59
  readonly feePercent: string;
60
60
  /** When Pro ends, or null while it renews, has no end or the account is on the free plan. */
@@ -63,8 +63,8 @@ export declare class Account extends ApiResource {
63
63
  readonly checkout: AccountCheckout | null;
64
64
  /** The invoice numbering, footer and business details settings. */
65
65
  readonly invoices: AccountInvoices | null;
66
- /** The fallback checkout language, or null for English. */
67
- readonly checkoutLocale: string | null;
66
+ /** The checkout's fallback language, one of the CheckoutLocale values, or null for English. */
67
+ readonly checkoutLocale: OrString<CheckoutLocale> | null;
68
68
  /** Whether automatic invoice reminders are enabled. */
69
69
  readonly invoiceReminders: boolean;
70
70
  /** Whether the owner allows API keys and AI apps to change payout addresses. */
@@ -74,7 +74,7 @@ export declare class Account extends ApiResource {
74
74
  /** The mode of the API key that fetched the account: "live" or "test". */
75
75
  readonly mode: OrString<Mode> | null;
76
76
  /** The coins the account can be paid in right now, in that mode. */
77
- readonly acceptedAssets: string[];
77
+ readonly acceptedAssets: OrString<Asset>[];
78
78
  constructor(attributes: Attributes, meta?: Attributes);
79
79
  /** Whether the account is on Pro, which keeps no fee. */
80
80
  isPro(): boolean;
@@ -7,7 +7,7 @@ const api_resource_ts_1 = require("./api-resource.js");
7
7
  class Account extends api_resource_ts_1.ApiResource {
8
8
  /** The account's slug. */
9
9
  id;
10
- /** Either "personal" or "organization". */
10
+ /** One of the AccountType values: personal or organization. */
11
11
  type;
12
12
  /** The account's name. */
13
13
  name;
@@ -37,7 +37,7 @@ class Account extends api_resource_ts_1.ApiResource {
37
37
  underpaymentTolerance;
38
38
  /** How much surplus, in percent, is ignored before a charge is flagged as overpaid. */
39
39
  overpaymentThreshold;
40
- /** "free" or "pro". */
40
+ /** One of the PlanName values: free or pro. */
41
41
  plan;
42
42
  /** The share of each payment kept as the platform's fee, in percent. */
43
43
  feePercent;
@@ -47,7 +47,7 @@ class Account extends api_resource_ts_1.ApiResource {
47
47
  checkout;
48
48
  /** The invoice numbering, footer and business details settings. */
49
49
  invoices;
50
- /** The fallback checkout language, or null for English. */
50
+ /** The checkout's fallback language, one of the CheckoutLocale values, or null for English. */
51
51
  checkoutLocale;
52
52
  /** Whether automatic invoice reminders are enabled. */
53
53
  invoiceReminders;
@@ -80,11 +80,11 @@ class Account extends api_resource_ts_1.ApiResource {
80
80
  this.defaultCurrency = (0, api_resource_ts_1.string)(attributes, 'default_currency');
81
81
  this.underpaymentTolerance = (0, api_resource_ts_1.string)(attributes, 'underpayment_tolerance', '0');
82
82
  this.overpaymentThreshold = (0, api_resource_ts_1.string)(attributes, 'overpayment_threshold', '0');
83
- this.plan = (0, api_resource_ts_1.string)(plan, 'name', 'free');
83
+ this.plan = (0, api_resource_ts_1.string)(plan, 'name', enums_ts_1.PlanName.Free);
84
84
  this.feePercent = (0, api_resource_ts_1.string)(plan, 'fee_percent', '0');
85
85
  this.proEndsAt = (0, api_resource_ts_1.date)(plan, 'pro_ends_at');
86
86
  this.checkout = (0, api_resource_ts_1.isRecord)(checkout) ? {
87
- appearance: (0, api_resource_ts_1.string)(checkout, 'appearance', 'auto'),
87
+ appearance: (0, api_resource_ts_1.string)(checkout, 'appearance', enums_ts_1.CheckoutAppearance.Auto),
88
88
  coinOrder: (0, api_resource_ts_1.strings)(checkout, 'coin_order'),
89
89
  defaultCoin: (0, api_resource_ts_1.nullableString)(checkout, 'default_coin'),
90
90
  successUrl: (0, api_resource_ts_1.nullableString)(checkout, 'success_url'),
@@ -106,11 +106,11 @@ class Account extends api_resource_ts_1.ApiResource {
106
106
  }
107
107
  /** Whether the account is on Pro, which keeps no fee. */
108
108
  isPro() {
109
- return this.plan === 'pro';
109
+ return this.plan === enums_ts_1.PlanName.Pro;
110
110
  }
111
111
  /** Whether this is an organization rather than a personal account. */
112
112
  isOrganization() {
113
- return this.type === 'organization';
113
+ return this.type === enums_ts_1.AccountType.Organization;
114
114
  }
115
115
  /** Whether the key that fetched the account works in test mode. */
116
116
  isTestMode() {
@@ -1,10 +1,11 @@
1
+ import type { ActivityAction, Mode, OrString } from '../enums.ts';
1
2
  import { ApiResource, type Attributes } from './api-resource.ts';
2
3
  /** One thing done in the account, from its activity log. */
3
4
  export declare class Activity extends ApiResource {
4
5
  /** The entry's id. */
5
6
  readonly id: string;
6
- /** What was done, such as "api_key.created". */
7
- readonly action: string;
7
+ /** One of the ActivityAction values, such as "api_key.created". */
8
+ readonly action: OrString<ActivityAction>;
8
9
  /** What was done, in words. */
9
10
  readonly description: string;
10
11
  /** Who did it: a member's name or an API key's. */
@@ -16,7 +17,7 @@ export declare class Activity extends ApiResource {
16
17
  /** The address it came from. */
17
18
  readonly ipAddress: string | null;
18
19
  /** "live" or "test", or null for what belongs to neither, such as a sign-in. */
19
- readonly mode: string | null;
20
+ readonly mode: OrString<Mode> | null;
20
21
  /** When it was done. */
21
22
  readonly createdAt: Date | null;
22
23
  constructor(attributes: Attributes);
@@ -6,7 +6,7 @@ const api_resource_ts_1 = require("./api-resource.js");
6
6
  class Activity extends api_resource_ts_1.ApiResource {
7
7
  /** The entry's id. */
8
8
  id;
9
- /** What was done, such as "api_key.created". */
9
+ /** One of the ActivityAction values, such as "api_key.created". */
10
10
  action;
11
11
  /** What was done, in words. */
12
12
  description;
@@ -1,3 +1,4 @@
1
+ import type { ApiKeyPermission, Mode, OrString } from '../enums.ts';
1
2
  import { ApiResource, type Attributes } from './api-resource.ts';
2
3
  /** An API key of the account. The key itself is only in the answer that creates it. */
3
4
  export declare class ApiKey extends ApiResource {
@@ -10,9 +11,9 @@ export declare class ApiKey extends ApiResource {
10
11
  /** The key itself, only in the answer that created it. */
11
12
  readonly key: string | null;
12
13
  /** "live" or "test". */
13
- readonly mode: string;
14
+ readonly mode: OrString<Mode>;
14
15
  /** The ApiKeyPermission values the key has, null for full access. */
15
- readonly permissions: string[] | null;
16
+ readonly permissions: OrString<ApiKeyPermission>[] | null;
16
17
  /** The addresses and ranges it may be used from, null for anywhere. */
17
18
  readonly allowedIps: string[] | null;
18
19
  /** The name of the member who made it. */
@@ -23,6 +23,8 @@ export declare function nullableBool(data: Attributes, key: string): boolean | n
23
23
  export declare function int(data: Attributes, key: string, fallback?: number): number;
24
24
  /** Read an integer attribute that may be null. */
25
25
  export declare function nullableInt(data: Attributes, key: string): number | null;
26
+ /** Read a number attribute. */
27
+ export declare function number(data: Attributes, key: string, fallback?: number): number;
26
28
  /** Read a number attribute that may be null. */
27
29
  export declare function nullableNumber(data: Attributes, key: string): number | null;
28
30
  /** Read a timestamp or a date, which is taken as midnight UTC. */
@@ -8,6 +8,7 @@ exports.bool = bool;
8
8
  exports.nullableBool = nullableBool;
9
9
  exports.int = int;
10
10
  exports.nullableInt = nullableInt;
11
+ exports.number = number;
11
12
  exports.nullableNumber = nullableNumber;
12
13
  exports.date = date;
13
14
  exports.strings = strings;
@@ -71,6 +72,10 @@ function nullableInt(data, key) {
71
72
  }
72
73
  return typeof value === 'string' && /^\d+$/.test(value) ? Number(value) : null;
73
74
  }
75
+ /** Read a number attribute. */
76
+ function number(data, key, fallback = 0) {
77
+ return nullableNumber(data, key) ?? fallback;
78
+ }
74
79
  /** Read a number attribute that may be null. */
75
80
  function nullableNumber(data, key) {
76
81
  const value = data[key];
@@ -1,4 +1,4 @@
1
- import { ChargeStatus, type Asset, type OrString } from '../enums.ts';
1
+ import { ChargeStatus, type Asset, type Currency, type OrString } from '../enums.ts';
2
2
  import { ApiResource, type Attributes } from './api-resource.ts';
3
3
  /** One entry of a charge's history. */
4
4
  export interface ChargeTimelineEntry {
@@ -18,14 +18,18 @@ export declare class Charge extends ApiResource {
18
18
  readonly status: OrString<ChargeStatus>;
19
19
  /** The code of the payment link the charge was made through. */
20
20
  readonly paymentLink: string | null;
21
+ /** The title of that payment link, in webhooks alone; null in the API's answers, which only give its code. */
22
+ readonly paymentLinkTitle: string | null;
21
23
  /** The code of the invoice the charge pays. */
22
24
  readonly invoice: string | null;
25
+ /** The number of that invoice, such as "INV-0042", in webhooks alone; null in the API's answers, which only give its code. */
26
+ readonly invoiceNumber: string | null;
23
27
  /** The merchant's description of the charge. */
24
28
  readonly description: string | null;
25
29
  /** What the customer owes, in fiat. */
26
30
  readonly fiatAmount: string;
27
31
  /** The fiat currency, such as "USD". */
28
- readonly fiatCurrency: string;
32
+ readonly fiatCurrency: OrString<Currency>;
29
33
  /** The coin and network paid with, such as "BTC" or "USDT". */
30
34
  readonly asset: OrString<Asset>;
31
35
  /** The exact amount of the coin to send. */
@@ -96,7 +100,7 @@ export declare class Charge extends ApiResource {
96
100
  /** Whether the charge can still be paid. */
97
101
  isOpen(): boolean;
98
102
  }
99
- /** A charge as the API answers with it, which always has its checkout page. Charges in webhooks and events stay plain charges, without one. */
103
+ /** A charge as the API answers with it, the charges events carry included, which always has its checkout page. Charges in webhooks stay plain charges, without one. */
100
104
  export type ApiCharge = Charge & {
101
105
  readonly checkoutUrl: string;
102
106
  };
@@ -11,8 +11,12 @@ class Charge extends api_resource_ts_1.ApiResource {
11
11
  status;
12
12
  /** The code of the payment link the charge was made through. */
13
13
  paymentLink;
14
+ /** The title of that payment link, in webhooks alone; null in the API's answers, which only give its code. */
15
+ paymentLinkTitle;
14
16
  /** The code of the invoice the charge pays. */
15
17
  invoice;
18
+ /** The number of that invoice, such as "INV-0042", in webhooks alone; null in the API's answers, which only give its code. */
19
+ invoiceNumber;
16
20
  /** The merchant's description of the charge. */
17
21
  description;
18
22
  /** What the customer owes, in fiat. */
@@ -80,7 +84,9 @@ class Charge extends api_resource_ts_1.ApiResource {
80
84
  this.id = (0, api_resource_ts_1.string)(attributes, 'id', (0, api_resource_ts_1.string)(attributes, 'code'));
81
85
  this.status = (0, api_resource_ts_1.string)(attributes, 'status');
82
86
  this.paymentLink = (0, api_resource_ts_1.reference)(attributes, 'payment_link');
87
+ this.paymentLinkTitle = (0, api_resource_ts_1.nullableString)((0, api_resource_ts_1.map)(attributes, 'payment_link'), 'title');
83
88
  this.invoice = (0, api_resource_ts_1.reference)(attributes, 'invoice');
89
+ this.invoiceNumber = (0, api_resource_ts_1.nullableString)((0, api_resource_ts_1.map)(attributes, 'invoice'), 'number');
84
90
  this.description = (0, api_resource_ts_1.nullableString)(attributes, 'description');
85
91
  this.fiatAmount = (0, api_resource_ts_1.string)(attributes, 'fiat_amount', '0');
86
92
  this.fiatCurrency = (0, api_resource_ts_1.string)(attributes, 'fiat_currency');
@@ -1,3 +1,4 @@
1
+ import type { Currency, OrString } from '../enums.ts';
1
2
  import { ApiResource, type Attributes } from './api-resource.ts';
2
3
  /** A discount code customers enter at checkout, or that is applied for them through a payment link's URL or the API. */
3
4
  export declare class Coupon extends ApiResource {
@@ -10,7 +11,7 @@ export declare class Coupon extends ApiResource {
10
11
  /** The amount taken off, or null for a percentage. */
11
12
  readonly amountOff: string | null;
12
13
  /** The only fiat currency the coupon works in, or null for a percentage that works in every one. */
13
- readonly currency: string | null;
14
+ readonly currency: OrString<Currency> | null;
14
15
  /** The least the price before the discount must be. */
15
16
  readonly minAmount: string | null;
16
17
  /** How many payments may use the coupon, or null for no limit. */
@@ -1,6 +1,6 @@
1
1
  import type { EventType, OrString } from '../enums.ts';
2
2
  import { ApiResource, type Attributes } from './api-resource.ts';
3
- import { Charge } from './charge.ts';
3
+ import { type ApiCharge } from './charge.ts';
4
4
  import { Invoice } from './invoice.ts';
5
5
  /** Something that happened to a charge or an invoice, as the events API lists it. */
6
6
  export declare class Event extends ApiResource {
@@ -12,8 +12,8 @@ export declare class Event extends ApiResource {
12
12
  readonly details: Record<string, unknown>;
13
13
  /** When it happened. */
14
14
  readonly createdAt: Date | null;
15
- /** The charge the event is about, as it is now, without its timeline. */
16
- readonly charge: Charge | null;
15
+ /** The charge the event is about, as it is now, with its checkout page but without its timeline. */
16
+ readonly charge: ApiCharge | null;
17
17
  /** The invoice the event is about. */
18
18
  readonly invoice: Invoice | null;
19
19
  constructor(attributes: Attributes);
@@ -14,7 +14,7 @@ class Event extends api_resource_ts_1.ApiResource {
14
14
  details;
15
15
  /** When it happened. */
16
16
  createdAt;
17
- /** The charge the event is about, as it is now, without its timeline. */
17
+ /** The charge the event is about, as it is now, with its checkout page but without its timeline. */
18
18
  charge;
19
19
  /** The invoice the event is about. */
20
20
  invoice;
@@ -1,10 +1,10 @@
1
- import { InvoiceStatus, type OrString } from '../enums.ts';
1
+ import { InvoiceStatus, type Asset, type ChargeStatus, type Currency, type OrString } from '../enums.ts';
2
2
  import { ApiResource, type Attributes } from './api-resource.ts';
3
3
  /** A charge made to pay an invoice, one per coin the customer tried. */
4
4
  export interface InvoiceCharge {
5
5
  id: string;
6
- status: string;
7
- asset: string;
6
+ status: OrString<ChargeStatus>;
7
+ asset: OrString<Asset>;
8
8
  }
9
9
  /** A bill sent to one customer, paid through a hosted page in the coin they choose. */
10
10
  export declare class Invoice extends ApiResource {
@@ -25,7 +25,7 @@ export declare class Invoice extends ApiResource {
25
25
  /** The total due. */
26
26
  readonly amount: string;
27
27
  /** The fiat currency, such as "USD". */
28
- readonly currency: string;
28
+ readonly currency: OrString<Currency>;
29
29
  /** The lines of an itemised invoice. */
30
30
  readonly items: InvoiceItem[];
31
31
  /** The day the invoice is due, at midnight UTC. */
@@ -46,6 +46,10 @@ export declare class Invoice extends ApiResource {
46
46
  readonly voidedAt: Date | null;
47
47
  /** When it was created. */
48
48
  readonly createdAt: Date | null;
49
+ /** The page the customer is offered a button back to once they have paid; absent from webhooks. */
50
+ readonly successUrl: string | null;
51
+ /** The page the customer can go back to from the invoice without paying; absent from webhooks. */
52
+ readonly cancelUrl: string | null;
49
53
  constructor(attributes: Attributes);
50
54
  /** Whether the invoice can still be paid. */
51
55
  isOpen(): boolean;
@@ -43,6 +43,10 @@ class Invoice extends api_resource_ts_1.ApiResource {
43
43
  voidedAt;
44
44
  /** When it was created. */
45
45
  createdAt;
46
+ /** The page the customer is offered a button back to once they have paid; absent from webhooks. */
47
+ successUrl;
48
+ /** The page the customer can go back to from the invoice without paying; absent from webhooks. */
49
+ cancelUrl;
46
50
  constructor(attributes) {
47
51
  super(attributes);
48
52
  this.id = (0, api_resource_ts_1.string)(attributes, 'id', (0, api_resource_ts_1.string)(attributes, 'code'));
@@ -68,6 +72,8 @@ class Invoice extends api_resource_ts_1.ApiResource {
68
72
  this.paidAt = (0, api_resource_ts_1.date)(attributes, 'paid_at');
69
73
  this.voidedAt = (0, api_resource_ts_1.date)(attributes, 'voided_at');
70
74
  this.createdAt = (0, api_resource_ts_1.date)(attributes, 'created_at');
75
+ this.successUrl = (0, api_resource_ts_1.nullableString)(attributes, 'success_url');
76
+ this.cancelUrl = (0, api_resource_ts_1.nullableString)(attributes, 'cancel_url');
71
77
  }
72
78
  /** Whether the invoice can still be paid. */
73
79
  isOpen() {
@@ -1,3 +1,4 @@
1
+ import type { MemberRole, OrString } from '../enums.ts';
1
2
  import { ApiResource, type Attributes } from './api-resource.ts';
2
3
  /** A person in the account, with their role. */
3
4
  export declare class Member extends ApiResource {
@@ -7,8 +8,8 @@ export declare class Member extends ApiResource {
7
8
  readonly name: string;
8
9
  /** The address they sign in with. */
9
10
  readonly email: string;
10
- /** "owner", "admin", "finance", "support" or "viewer". */
11
- readonly role: string | null;
11
+ /** One of the MemberRole values: owner, admin, finance, support or viewer. */
12
+ readonly role: OrString<MemberRole> | null;
12
13
  /** When they joined. */
13
14
  readonly joinedAt: Date | null;
14
15
  constructor(attributes: Attributes);
@@ -19,8 +20,8 @@ export declare class Invitation extends ApiResource {
19
20
  readonly id: string;
20
21
  /** Where it was sent. */
21
22
  readonly email: string;
22
- /** The role it gives once accepted: "admin", "finance", "support" or "viewer". */
23
- readonly role: string;
23
+ /** The role it gives once accepted: admin, finance, support or viewer. */
24
+ readonly role: OrString<MemberRole>;
24
25
  /** The name of the member who sent it. */
25
26
  readonly invitedBy: string | null;
26
27
  /** Whether it can no longer be accepted. */
@@ -10,7 +10,7 @@ class Member extends api_resource_ts_1.ApiResource {
10
10
  name;
11
11
  /** The address they sign in with. */
12
12
  email;
13
- /** "owner", "admin", "finance", "support" or "viewer". */
13
+ /** One of the MemberRole values: owner, admin, finance, support or viewer. */
14
14
  role;
15
15
  /** When they joined. */
16
16
  joinedAt;
@@ -30,7 +30,7 @@ class Invitation extends api_resource_ts_1.ApiResource {
30
30
  id;
31
31
  /** Where it was sent. */
32
32
  email;
33
- /** The role it gives once accepted: "admin", "finance", "support" or "viewer". */
33
+ /** The role it gives once accepted: admin, finance, support or viewer. */
34
34
  role;
35
35
  /** The name of the member who sent it. */
36
36
  invitedBy;