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/CHANGELOG.md CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  All notable changes to this library are documented here. It follows [Semantic Versioning](https://semver.org).
4
4
 
5
+ ## 0.2.1 - 2026-11-12
6
+
7
+ - `invoices.create()` takes `success_url` and `cancel_url`, public https:// addresses the invoice's page and its charges' checkout offer the customer a way back to: a button once they have paid, and a link while it is open. `invoice.successUrl` and `invoice.cancelUrl` read them back, and are `null` in webhooks, which leave them out.
8
+
9
+ ## 0.2.0 - 2026-11-12
10
+
11
+ ### Breaking
12
+
13
+ - `MemberRole` now has `owner` too, which members can be: a `switch` over it that covers every role needs a case for it. Invitations and role changes take the new `AssignableMemberRole`, which leaves owner out. Nothing changes at runtime.
14
+ - An `idempotencyKey` that is empty or only whitespace throws an `InvalidArgumentError` before anything is sent. It used to go out as an empty header, which the API reads as no key, so a retried write could be carried out twice.
15
+
16
+ ### Added
17
+
18
+ - Constants for the API's other value sets, each an object with a type of the same name: `Currency`, `MemberRole`, `AddressNetwork` (the networks payout addresses are for), `CheckoutAppearance`, `WebhookDeliveryStatus`, `PlanName`, `AccountType`, `CheckoutLocale` and `ActivityAction`, every action the activity log records. Methods take them or plain strings.
19
+ - Fields that hold one of these, a coin, a currency, a mode, a permission or an event type are typed with it, such as `payoutAddress.network`, `account.plan`, `member.role`, `activity.action`, `apiKey.permissions`, `invoice.charges[].status` and `webhookEndpoint.events`. They stay strings, so a value the API adds later still reads, and nothing breaks.
20
+ - Every constant, the existing ones too, is frozen, so no code can change one by mistake.
21
+ - The overview's other figures, which only `get()` could read before: `overview.period`, `funnel`, `attention`, `assets`, `topPaymentLinks`, `setup` and `daily`, typed `OverviewPeriod`, `OverviewFunnel` (with `OverviewFunnelAsset`), `OverviewAttention` (with `OverviewChargeAmount` and `OverviewWaitingPayouts`), `OverviewAsset`, `OverviewPaymentLink`, `OverviewSetup` and `OverviewDay`. Amounts stay strings, and days are `Date`s at midnight UTC.
22
+ - What answers carry besides their objects: every `Page` has the `meta` the API sent and the `mode` of the lists that say it, the coins on offer and the activity log; `assets.list()` answers with an `AssetPage`, whose `currencies` are those prices can be asked in; and the overview has its `mode`. `payoutAddresses.list()` and `payouts.summary()` stay plain arrays: their mode is `velirapay.mode()`, and whether an owner lets API keys change payout addresses is `account.apiPayoutAddressChanges`.
23
+ - `ConflictError.wasReplayed()`, true for the 409 the API gives a repeat of `apiKeys.create()`, `webhookEndpoints.create()` or `rotateSecret()` whose first answer carried the new key or secret, which it never keeps. That includes the library's own retry after an answer was lost: the write was carried out, but the key or secret cannot be shown again. The three methods' docs say how to recover, and `idempotencyKey`'s no longer promises the first answer to every repeat.
24
+ - `charge.paymentLinkTitle` and `charge.invoiceNumber`: the title of the payment link and the number of the invoice a charge in a webhook names. The API's answers only give their codes, so both are null there; `paymentLink` and `invoice` keep giving the codes everywhere.
25
+ - The README covers the whole library, as the PHP library's does: the lowest prices and minimums, network surcharges, Lightning, short and late payments, payouts and payout addresses, webhook endpoints and what to do when the answer carrying a secret is lost, the account and its payment settings, the overview, the activity log, members, API keys, Pro, the constants, the `baseUrl` option, the retry of a 409 that is still being processed and `UnexpectedResponseError`. Every example type-checks under TypeScript's `strict`; the webhook example no longer reads `event.charge.id` without checking that there is a charge.
26
+
27
+ ### Fixed
28
+
29
+ - The charges events carry are typed `ApiCharge`, since the API always sends their checkout page: `event.charge?.checkoutUrl` is a `string`, where 0.1.1 said events left it out. Only charges in webhooks lack it. Nothing changes at runtime.
30
+ - A network failure from a `fetch` you pass, such as node-fetch's `FetchError` of the `system` type or an error with a code such as `ECONNRESET`, is retried with the same idempotency key and then thrown as a `ConnectionError` whose `cause` is the original, as the built-in fetch's are. Before, it escaped as it was after one attempt. An error a `fetch` throws for any other reason still passes straight through.
31
+ - Amounts given as numbers are sent as decimal strings without an exponent. The API reads a JSON number below 0.0001, such as a refund of `0.00005` BTC, in exponent notation and refused it. A number is rounded first to the 14 significant digits the API read it with, so `0.1 + 0.2` still reaches it as `0.3`, and `0.00005` now goes out as `'0.00005'`. This covers charge, refund and simulated amounts, invoice totals, quantities and unit prices, payment link prices and limits, coupon discounts and minimums, and the payment tolerances; other numbers, such as `max_redemptions` and metadata values, stay numbers. A number that is not finite, or one with a fraction and 15 or more digits before its point, both of which the API refused, is refused before anything is sent. Strings go out as given, and `velirapay.request()` sends its body as it is.
32
+ - Cloudflare's 520 to 524, its answers when it gets nothing from VeliraPay, are retried like 502, 503 and 504, reads and writes alike, since a retried write carries the same idempotency key.
33
+ - The README's charge examples and the docs of `idempotencyKey` no longer use the bare order number as the idempotency key, which would send a customer coming back after the charge expired to that expired charge for a day. They use keys such as `order-1042-attempt-1`, and say to reuse a key only to retry the same request and to give a new attempt, such as a charge replacing an expired one, a new key.
34
+
5
35
  ## 0.1.1 - 2026-11-12
6
36
 
7
37
  - The charges that `charges.create()`, `retrieve()`, `list()`, `iterator()`, `cancel()`, `recordRefund()`, `send()`, `accept()` and `simulate()` answer with are typed `ApiCharge`, whose `checkoutUrl` is a `string`, so `res.redirect(303, charge.checkoutUrl)` compiles under TypeScript's `strict`. Charges in webhooks and events keep `checkoutUrl: string | null`, since webhooks leave it out. Nothing changes at runtime.