@phala/pay 0.2.0 → 0.4.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/CHANGELOG.md +53 -1
- package/README.md +46 -33
- package/dist/checkout.d.ts +2 -2
- package/dist/format.d.ts +6 -0
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +17 -2
- package/dist/format.js.map +1 -1
- package/dist/quote.d.ts +15 -4
- package/dist/quote.d.ts.map +1 -1
- package/dist/quote.js +7 -2
- package/dist/quote.js.map +1 -1
- package/dist/react/Checkout.d.ts +10 -2
- package/dist/react/Checkout.d.ts.map +1 -1
- package/dist/react/Checkout.js +34 -10
- package/dist/react/Checkout.js.map +1 -1
- package/dist/server/webhook.d.ts +6 -5
- package/dist/server/webhook.d.ts.map +1 -1
- package/dist/server/webhook.js +18 -16
- package/dist/server/webhook.js.map +1 -1
- package/dist/wallet.d.ts +5 -3
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +26 -2
- package/dist/wallet.js.map +1 -1
- package/package.json +1 -1
- package/src/checkout.ts +2 -2
- package/src/format.ts +20 -2
- package/src/quote.ts +22 -6
- package/src/react/Checkout.tsx +53 -6
- package/src/server/webhook.ts +21 -19
- package/src/wallet.ts +36 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,56 @@ All notable changes to `@phala/pay` are recorded here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.4.0] - 2026-10-01
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `payWithWallet` reads the account's token balance before sending and, when it is below the
|
|
14
|
+
quote's amount, sends nothing and throws `WalletError` with the new code
|
|
15
|
+
`insufficient_balance`: the transfer would revert and still cost gas. `<Checkout>` shows the
|
|
16
|
+
error's message (what the wallet holds and what the quote needs). A wallet that cannot read the
|
|
17
|
+
balance still pays.
|
|
18
|
+
- `<Checkout onWalletError>`: called with the `WalletError` and the wallet it tried (the chosen
|
|
19
|
+
browser wallet's provider, or `walletClient`) when the wallet tab could not send the payment, for
|
|
20
|
+
example to offer your own way to fund that wallet on `insufficient_balance`.
|
|
21
|
+
- `ClientQuote.amount_credited`, what a credited payment credited in cents (it differs from
|
|
22
|
+
`amount` for a payment of another amount or a late one), and `ClientQuote.typical_credit_seconds`,
|
|
23
|
+
the typical credit time at the quote's confirmation.
|
|
24
|
+
|
|
25
|
+
### Changed (breaking)
|
|
26
|
+
|
|
27
|
+
- `parseClientQuote`, and so `<Checkout>` and `createCheckout`, require `amount_credited` (an
|
|
28
|
+
integer or `null`) and `typical_credit_seconds`, which the service sends from v0.3.4: upgrade
|
|
29
|
+
the service before the SDK.
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- `<Checkout>` showed the quoted amount as credited ("Payment credited: $25.00" for a $25 quote
|
|
34
|
+
paid with $10). It now shows what was credited and, when that differs from the quote, says so
|
|
35
|
+
("Payment credited: $10.00 of $25.00"); `onSuccess(quote)` carries it as `amount_credited`.
|
|
36
|
+
- `<Checkout>` told a payer "crediting in about 30 seconds" on every chain. It now states the
|
|
37
|
+
quote's typical wait: about 5 minutes at Base's `safe` block, 15 minutes under a `finalized`
|
|
38
|
+
policy.
|
|
39
|
+
|
|
40
|
+
## [0.3.0] - 2026-10-01
|
|
41
|
+
|
|
42
|
+
### Changed (breaking)
|
|
43
|
+
|
|
44
|
+
- `constructEvent` takes webhook public keys only in Standard Webhooks' `whpk_` form (`whpk_` and
|
|
45
|
+
the standard base64 of the key), as `GET /v1/attestation` lists them; a hex or bare base64 key
|
|
46
|
+
is refused.
|
|
47
|
+
- `parseClientQuote` requires `confirmations`, an integer or `null`, as the service always sends
|
|
48
|
+
it.
|
|
49
|
+
- `constructEvent` requires the event's `actor` and `request` (`null` or the causing request), as
|
|
50
|
+
the service always sends them, and refuses an envelope without them; `WebhookEvent.actor` and
|
|
51
|
+
`request` are no longer optional.
|
|
52
|
+
|
|
53
|
+
### Fixed
|
|
54
|
+
|
|
55
|
+
- `constructEvent` returns the event's `request` (the causing API request's `id` and
|
|
56
|
+
`idempotency_key`, or `null`), as `WebhookEvent` declares; it was dropped. A malformed `request`
|
|
57
|
+
is refused like any malformed event.
|
|
58
|
+
|
|
9
59
|
## [0.2.0] - 2026-09-29
|
|
10
60
|
|
|
11
61
|
### Changed (breaking)
|
|
@@ -133,7 +183,9 @@ All notable changes to `@phala/pay` are recorded here. The format follows
|
|
|
133
183
|
without trailing zeros (`1,273.9185`); `tokenAmount(quote)` is the plain decimal a wallet
|
|
134
184
|
accepts, which `<Checkout>`'s "Exact amount" copies.
|
|
135
185
|
|
|
136
|
-
[unreleased]: https://github.com/Phala-Network/phala-pay/compare/sdk-js-v0.
|
|
186
|
+
[unreleased]: https://github.com/Phala-Network/phala-pay/compare/sdk-js-v0.4.0...HEAD
|
|
187
|
+
[0.4.0]: https://github.com/Phala-Network/phala-pay/compare/sdk-js-v0.3.0...sdk-js-v0.4.0
|
|
188
|
+
[0.3.0]: https://github.com/Phala-Network/phala-pay/compare/sdk-js-v0.2.0...sdk-js-v0.3.0
|
|
137
189
|
[0.2.0]: https://github.com/Phala-Network/phala-pay/compare/sdk-js-v0.1.2...sdk-js-v0.2.0
|
|
138
190
|
[0.1.2]: https://github.com/Phala-Network/phala-pay/compare/sdk-js-v0.1.1...sdk-js-v0.1.2
|
|
139
191
|
[0.1.1]: https://github.com/Phala-Network/phala-pay/compare/sdk-js-v0.1.0...sdk-js-v0.1.1
|
package/README.md
CHANGED
|
@@ -19,34 +19,34 @@ connects a wallet with wagmi, RainbowKit, ConnectKit, or AppKit, pass it in inst
|
|
|
19
19
|
|
|
20
20
|
## Quickstart
|
|
21
21
|
|
|
22
|
-
1. Your backend creates a quote (`POST /v1/quotes` with its
|
|
22
|
+
1. Your backend creates a quote (`POST /v1/quotes` with its API key, for example
|
|
23
23
|
`phala-pay`'s `pay.quotes.create`), recomputes its address from the pinned forwarder (the
|
|
24
24
|
Python SDK does it on every call), and returns only its `client_secret` and that address to
|
|
25
25
|
the signed-in user's browser.
|
|
26
26
|
2. Render the checkout with them:
|
|
27
27
|
|
|
28
|
-
```tsx
|
|
29
|
-
"use client";
|
|
30
|
-
import { Checkout } from "@phala/pay/react";
|
|
31
|
-
|
|
32
|
-
export function TopUp(props: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
```
|
|
28
|
+
```tsx
|
|
29
|
+
"use client";
|
|
30
|
+
import { Checkout } from "@phala/pay/react";
|
|
31
|
+
|
|
32
|
+
export function TopUp(props: {
|
|
33
|
+
clientSecret: string;
|
|
34
|
+
expectedAddress: string;
|
|
35
|
+
onPaid: () => void;
|
|
36
|
+
onRetry: () => void;
|
|
37
|
+
}) {
|
|
38
|
+
return (
|
|
39
|
+
<Checkout
|
|
40
|
+
clientSecret={props.clientSecret}
|
|
41
|
+
expectedAddress={props.expectedAddress}
|
|
42
|
+
apiBase="https://pay.example.com"
|
|
43
|
+
onSuccess={props.onPaid}
|
|
44
|
+
onExpire={props.onRetry}
|
|
45
|
+
buttonText="Pay with crypto"
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
50
|
|
|
51
51
|
3. Credit the account when your webhook endpoint receives `deposit.credited`. `onSuccess` is for the
|
|
52
52
|
UI only: the browser is not a trusted source of payment.
|
|
@@ -66,9 +66,9 @@ mode".
|
|
|
66
66
|
|---|---|
|
|
67
67
|
| `loading` | Loading payment details |
|
|
68
68
|
| `waiting` | Payment options, the exact amount, and the time left |
|
|
69
|
-
| `seen` | Payment in a block, with its confirmations (a reorg can still remove it) |
|
|
69
|
+
| `seen` | Payment in a block, with its confirmations and the typical wait for the credit (a reorg can still remove it) |
|
|
70
70
|
| `confirming` | Payment at the route's confirmation (two blocks on Ethereum), being valued and screened |
|
|
71
|
-
| `credited` |
|
|
71
|
+
| `credited` | What was credited, typically `typical_credit_seconds` after paying; `onSuccess(quote)` is called once |
|
|
72
72
|
| `rejected` | Will not be credited; the payer contacts support |
|
|
73
73
|
| `reversed` | Credited, then its transaction left the chain before finality: the payment did not happen |
|
|
74
74
|
| `expired`, `canceled` | The address is hidden; `onExpire` is called once |
|
|
@@ -78,17 +78,27 @@ mode".
|
|
|
78
78
|
Elements' `onChange`, for example to hide your own "new payment" control while a payment is
|
|
79
79
|
`seen` or `confirming`.
|
|
80
80
|
|
|
81
|
+
Before the wallet tab sends a payment, it reads the wallet's token balance; when the wallet holds
|
|
82
|
+
less than the quote, it sends nothing (the transfer would revert and still cost gas) and says how
|
|
83
|
+
much the wallet holds. `onWalletError(error, wallet)` is called with the `WalletError` and the
|
|
84
|
+
wallet it tried (the chosen browser wallet's EIP-1193 provider, or your `walletClient`) whenever the
|
|
85
|
+
wallet tab could not send (`code` `insufficient_balance`, `rejected`, `wrong_chain`, …), for example
|
|
86
|
+
to offer your own way to fund that wallet.
|
|
87
|
+
|
|
81
88
|
To resume after a reload, keep the client secret in the browser (for example `localStorage`, per
|
|
82
89
|
signed-in account) until the status is `credited`, `expired`, `canceled`, or `error`. Tell a
|
|
83
|
-
payer who is waiting that the payment is credited in about
|
|
84
|
-
|
|
90
|
+
payer who is waiting that the payment is credited in about the quote's `typical_credit_seconds`
|
|
91
|
+
(30 seconds on Ethereum, about 5 minutes on Base, 15 minutes under a `finalized` policy) and the
|
|
92
|
+
credit arrives on its own.
|
|
85
93
|
|
|
86
94
|
A credit is made before Ethereum finality (about 15 minutes). In the rare case that a reorg drops
|
|
87
95
|
the payment's transaction, your backend receives `deposit.reversed` and claws the credit back as
|
|
88
96
|
for `deposit.refunded`; the checkout itself only reflects the quote.
|
|
89
97
|
|
|
90
98
|
The payment options disappear once a payment is seen, and at `expires_at`. A payment of a different
|
|
91
|
-
amount, or after expiry, is still credited, at the market price instead of the quote's
|
|
99
|
+
amount, or after expiry, is still credited, at the market price instead of the quote's: the
|
|
100
|
+
checkout then says so ("Payment credited: $10.00 of $25.00"), and `onSuccess` receives the quote
|
|
101
|
+
with what was credited as `amount_credited`, beside the quoted `amount`.
|
|
92
102
|
|
|
93
103
|
### Your own wallet connection
|
|
94
104
|
|
|
@@ -102,12 +112,12 @@ ConnectKit, and AppKit, that is `useWalletClient()`:
|
|
|
102
112
|
import { Checkout } from "@phala/pay/react";
|
|
103
113
|
import { useWalletClient } from "wagmi";
|
|
104
114
|
|
|
105
|
-
export function TopUp({ clientSecret
|
|
115
|
+
export function TopUp(props: { clientSecret: string; expectedAddress: string }) {
|
|
106
116
|
const { data: walletClient } = useWalletClient();
|
|
107
117
|
return (
|
|
108
118
|
<Checkout
|
|
109
|
-
clientSecret={clientSecret}
|
|
110
|
-
expectedAddress={expectedAddress}
|
|
119
|
+
clientSecret={props.clientSecret}
|
|
120
|
+
expectedAddress={props.expectedAddress}
|
|
111
121
|
apiBase="https://pay.example.com"
|
|
112
122
|
walletClient={walletClient}
|
|
113
123
|
/>
|
|
@@ -121,7 +131,7 @@ as usual. The QR code and manual tabs do not change.
|
|
|
121
131
|
### A customer's deposit address
|
|
122
132
|
|
|
123
133
|
For top-ups of any amount, your backend creates the customer's persistent deposit address with
|
|
124
|
-
`POST /v1/deposit_addresses` (
|
|
134
|
+
`POST /v1/deposit_addresses` (its API key) and passes its `address` and `networks` to the page:
|
|
125
135
|
one address for all supported tokens and networks. `<DepositAddress>` lets the payer pick a
|
|
126
136
|
network and a token and shows a QR code of that token's transfer request, the token contract, and
|
|
127
137
|
the address to copy, with "send only supported tokens" and "credited at the market rate when it
|
|
@@ -214,7 +224,9 @@ checkout.destroy();
|
|
|
214
224
|
wagmi's `useWalletClient()` or `getWalletClient(config)`; its account is used without asking to
|
|
215
225
|
connect again). It connects, switches the wallet to the quote's chain (adding Ethereum, Sepolia,
|
|
216
226
|
Base, or Base Sepolia when the wallet lacks it), and sends the ERC-20 `transfer` stated by the
|
|
217
|
-
quote's `payment_uri`, after checking that it pays exactly `amount_atomic` to `address`.
|
|
227
|
+
quote's `payment_uri`, after checking that it pays exactly `amount_atomic` to `address`. A wallet
|
|
228
|
+
holding less of the token than that sends nothing: `WalletError` with `code`
|
|
229
|
+
`insufficient_balance`.
|
|
218
230
|
|
|
219
231
|
## Server helpers
|
|
220
232
|
|
|
@@ -232,6 +244,7 @@ const expectedAddress = verifyQuoteAddress(pins, quote); // pass it to <Checkout
|
|
|
232
244
|
|
|
233
245
|
// Standard Webhooks v1a (ed25519, WebCrypto: Node 20+, Deno, Bun, edge runtimes). Fails closed
|
|
234
246
|
// unless the signature verifies with a pinned key and the event is your account's in this mode.
|
|
247
|
+
// WEBHOOK_PUBLIC_KEYS: your account's keys in this mode, `whpk_…`, pinned from GET /v1/attestation.
|
|
235
248
|
const event = await constructEvent(rawBody, request.headers, WEBHOOK_PUBLIC_KEYS, {
|
|
236
249
|
expectedAccount: "acct_…",
|
|
237
250
|
expectedLivemode: false,
|
package/dist/checkout.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { type ClientQuote } from "./quote.js";
|
|
|
5
5
|
* - `waiting` for a payment, until `expires_at`;
|
|
6
6
|
* - `seen` once a transfer is in a block, `confirming` once it reaches the route's confirmation
|
|
7
7
|
* (two blocks on Ethereum) and is being valued;
|
|
8
|
-
* - `credited` (
|
|
9
|
-
* credited;
|
|
8
|
+
* - `credited` (typically the quote's `typical_credit_seconds` after paying), or `rejected` for a
|
|
9
|
+
* payment that will not be credited;
|
|
10
10
|
* - `reversed` when a credited payment's transaction left the chain before finality;
|
|
11
11
|
* - `expired` or `canceled` without a payment;
|
|
12
12
|
* - `error` when the client secret is not valid, or the quote's address is not the one your
|
package/dist/format.d.ts
CHANGED
|
@@ -4,10 +4,16 @@ import type { ClientQuote } from "./quote.js";
|
|
|
4
4
|
* `1,273.9185`. Every digit is kept: the service rounds a quote to a few decimals.
|
|
5
5
|
*/
|
|
6
6
|
export declare function formatTokenAmount(quote: ClientQuote, locale?: string): string;
|
|
7
|
+
/** An atomic token amount, grouped for `locale` and without trailing zeros, as `formatTokenAmount`. */
|
|
8
|
+
export declare function formatUnitsGrouped(atomic: bigint, decimals: number, locale?: string): string;
|
|
7
9
|
/** The exact token amount as a plain decimal, for copying into a wallet, for example `1273.9185`. */
|
|
8
10
|
export declare function tokenAmount(quote: ClientQuote): string;
|
|
9
11
|
/** The credit in the quote's currency, for example `$25.00`. */
|
|
10
12
|
export declare function formatAmount(quote: ClientQuote, locale?: string): string;
|
|
13
|
+
/** `minor` units of the quote's currency, for example `$10.00` for 1000. */
|
|
14
|
+
export declare function formatMinorAmount(quote: ClientQuote, minor: number, locale?: string): string;
|
|
15
|
+
/** A typical wait, for example `about 30 seconds` or `about 15 minutes`. */
|
|
16
|
+
export declare function formatWait(seconds: number): string;
|
|
11
17
|
/** `mm:ss` (or `h:mm:ss`) until `expiresAt` Unix seconds, never negative. */
|
|
12
18
|
export declare function formatCountdown(expiresAt: number, nowMs: number): string;
|
|
13
19
|
//# sourceMappingURL=format.d.ts.map
|
package/dist/format.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED,uGAAuG;AACvG,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAS5F;AAED,qGAAqG;AACrG,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAEtD;AAED,gEAAgE;AAChE,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAK5F;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKlD;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQxE"}
|
package/dist/format.js
CHANGED
|
@@ -4,7 +4,11 @@ import { formatUnits } from "viem";
|
|
|
4
4
|
* `1,273.9185`. Every digit is kept: the service rounds a quote to a few decimals.
|
|
5
5
|
*/
|
|
6
6
|
export function formatTokenAmount(quote, locale) {
|
|
7
|
-
|
|
7
|
+
return formatUnitsGrouped(BigInt(quote.amount_atomic), quote.decimals, locale);
|
|
8
|
+
}
|
|
9
|
+
/** An atomic token amount, grouped for `locale` and without trailing zeros, as `formatTokenAmount`. */
|
|
10
|
+
export function formatUnitsGrouped(atomic, decimals, locale) {
|
|
11
|
+
const [whole = "0", fraction] = formatUnits(atomic, decimals).split(".");
|
|
8
12
|
const format = new Intl.NumberFormat(locale);
|
|
9
13
|
const grouped = format.format(BigInt(whole));
|
|
10
14
|
if (fraction === undefined) {
|
|
@@ -19,10 +23,21 @@ export function tokenAmount(quote) {
|
|
|
19
23
|
}
|
|
20
24
|
/** The credit in the quote's currency, for example `$25.00`. */
|
|
21
25
|
export function formatAmount(quote, locale) {
|
|
26
|
+
return formatMinorAmount(quote, quote.amount, locale);
|
|
27
|
+
}
|
|
28
|
+
/** `minor` units of the quote's currency, for example `$10.00` for 1000. */
|
|
29
|
+
export function formatMinorAmount(quote, minor, locale) {
|
|
22
30
|
return new Intl.NumberFormat(locale, {
|
|
23
31
|
style: "currency",
|
|
24
32
|
currency: quote.currency.toUpperCase(),
|
|
25
|
-
}).format(
|
|
33
|
+
}).format(minor / 100);
|
|
34
|
+
}
|
|
35
|
+
/** A typical wait, for example `about 30 seconds` or `about 15 minutes`. */
|
|
36
|
+
export function formatWait(seconds) {
|
|
37
|
+
if (seconds < 90) {
|
|
38
|
+
return `about ${seconds} second${seconds === 1 ? "" : "s"}`;
|
|
39
|
+
}
|
|
40
|
+
return `about ${Math.round(seconds / 60)} minutes`;
|
|
26
41
|
}
|
|
27
42
|
/** `mm:ss` (or `h:mm:ss`) until `expiresAt` Unix seconds, never negative. */
|
|
28
43
|
export function formatCountdown(expiresAt, nowMs) {
|
package/dist/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAGnC;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAkB,EAAE,MAAe;IACnE,MAAM,CAAC,KAAK,GAAG,GAAG,EAAE,QAAQ,CAAC,GAAG,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAGnC;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAkB,EAAE,MAAe;IACnE,OAAO,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC,QAAQ,EAAE,M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chain time, or it is canceled. */
|
|
10
10
|
status: "open" | "complete" | "expired" | "canceled";
|
|
11
|
-
/**
|
|
11
|
+
/** The quoted credit in the currency's minor unit (US cents). */
|
|
12
12
|
amount: number;
|
|
13
13
|
currency: string;
|
|
14
14
|
/** The token's code, for example `pha`. */
|
|
@@ -25,13 +25,24 @@ export interface ClientQuote {
|
|
|
25
25
|
expires_at: number;
|
|
26
26
|
/**
|
|
27
27
|
* `seen` once in a block (a reorg can remove it), `confirming` while a payment at the route's
|
|
28
|
-
* confirmation is valued and screened, `credited` once it is credited (
|
|
29
|
-
* paying), `rejected` when it will not be, `reversed` when a
|
|
30
|
-
* left the chain before finality (the payment did not happen).
|
|
28
|
+
* confirmation is valued and screened, `credited` once it is credited (typically
|
|
29
|
+
* `typical_credit_seconds` after paying), `rejected` when it will not be, `reversed` when a
|
|
30
|
+
* credited payment's transaction left the chain before finality (the payment did not happen).
|
|
31
31
|
*/
|
|
32
32
|
payment_status: "none" | "seen" | "confirming" | "credited" | "rejected" | "reversed";
|
|
33
33
|
/** Block confirmations while `payment_status` is `seen`, otherwise `null`. */
|
|
34
34
|
confirmations: number | null;
|
|
35
|
+
/**
|
|
36
|
+
* While `payment_status` is `credited`: what was credited, in the currency's minor unit. It
|
|
37
|
+
* differs from `amount` for a payment valued at the market price (another amount, or paid late);
|
|
38
|
+
* otherwise `null`.
|
|
39
|
+
*/
|
|
40
|
+
amount_credited: number | null;
|
|
41
|
+
/**
|
|
42
|
+
* Typical seconds from paying to the credit at the confirmation this quote's payments need:
|
|
43
|
+
* 30 on Ethereum (two blocks), about 300 at an OP-stack chain's `safe` block, 900 at finality.
|
|
44
|
+
*/
|
|
45
|
+
typical_credit_seconds: number;
|
|
35
46
|
}
|
|
36
47
|
/** Returns the quote id a client secret belongs to (`qt_…_secret_…`), or throws. */
|
|
37
48
|
export declare function quoteIdFromClientSecret(clientSecret: string): string;
|
package/dist/quote.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;IAChB,0EAA0E;IAC1E,QAAQ,EAAE,OAAO,CAAC;IAClB,iGAAiG;IACjG,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;IACrD,
|
|
1
|
+
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;IAChB,0EAA0E;IAC1E,QAAQ,EAAE,OAAO,CAAC;IAClB,iGAAiG;IACjG,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;IACrD,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,aAAa,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;IACtF,8EAA8E;IAC9E,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;;OAIG;IACH,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAKD,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAMpE;AAED,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAiD5D"}
|
package/dist/quote.js
CHANGED
|
@@ -15,6 +15,7 @@ export function parseClientQuote(value) {
|
|
|
15
15
|
}
|
|
16
16
|
const v = value;
|
|
17
17
|
const confirmations = v["confirmations"];
|
|
18
|
+
const amountCredited = v["amount_credited"];
|
|
18
19
|
if (typeof v["id"] !== "string" ||
|
|
19
20
|
v["object"] !== "quote" ||
|
|
20
21
|
typeof v["livemode"] !== "boolean" ||
|
|
@@ -31,7 +32,9 @@ export function parseClientQuote(value) {
|
|
|
31
32
|
typeof v["payment_uri"] !== "string" ||
|
|
32
33
|
!isSafeInteger(v["expires_at"]) ||
|
|
33
34
|
!oneOf(v["payment_status"], PAYMENT_STATUSES) ||
|
|
34
|
-
!(confirmations === null ||
|
|
35
|
+
!(confirmations === null || isSafeInteger(confirmations)) ||
|
|
36
|
+
!(amountCredited === null || isSafeInteger(amountCredited)) ||
|
|
37
|
+
!isSafeInteger(v["typical_credit_seconds"])) {
|
|
35
38
|
throw new TypeError("quote response does not match the public quote view");
|
|
36
39
|
}
|
|
37
40
|
return {
|
|
@@ -49,7 +52,9 @@ export function parseClientQuote(value) {
|
|
|
49
52
|
payment_uri: v["payment_uri"],
|
|
50
53
|
expires_at: v["expires_at"],
|
|
51
54
|
payment_status: v["payment_status"],
|
|
52
|
-
confirmations
|
|
55
|
+
confirmations,
|
|
56
|
+
amount_credited: amountCredited,
|
|
57
|
+
typical_credit_seconds: v["typical_credit_seconds"],
|
|
53
58
|
};
|
|
54
59
|
}
|
|
55
60
|
function oneOf(value, allowed) {
|
package/dist/quote.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3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CAAC,eAAe,CAAC;QACjC,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC;QACrB,WAAW,EAAE,CAAC,CAAC,aAAa,CAAC;QAC7B,UAAU,EAAE,CAAC,CAAC,YAAY,CAAC;QAC3B,cAAc,EAAE,CAAC,CAAC,gBAAgB,CAAC;QACnC,aAAa;QACb,eAAe,EAAE,cAAc;QAC/B,sBAAsB,EAAE,CAAC,CAAC,wBAAwB,CAAC;KACpD,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAmB,KAAc,EAAE,OAAqB;IACpE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,OAA6B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACrF,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/react/Checkout.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { WalletClient } from "viem";
|
|
2
2
|
import type { CheckoutState } from "../checkout.js";
|
|
3
3
|
import type { ClientQuote } from "../quote.js";
|
|
4
|
+
import { WalletError, type EthereumProvider } from "../wallet.js";
|
|
4
5
|
import { type Appearance } from "./appearance.js";
|
|
5
6
|
export interface CheckoutProps {
|
|
6
7
|
/** The quote's `client_secret`, from your backend's `POST /v1/quotes`. */
|
|
@@ -13,13 +14,20 @@ export interface CheckoutProps {
|
|
|
13
14
|
expectedAddress: string;
|
|
14
15
|
/** The service origin, for example `https://topup.example.com`. */
|
|
15
16
|
apiBase: string;
|
|
16
|
-
/** Called once when the payment is credited
|
|
17
|
+
/** Called once when the payment is credited, with the quote: its `amount_credited` is what was
|
|
18
|
+
* credited, which differs from `amount` for a payment of another amount or a late one. Fulfil
|
|
19
|
+
* from the `deposit.credited` webhook, not here. */
|
|
17
20
|
onSuccess?: (quote: ClientQuote) => void;
|
|
18
21
|
/** Called once when the quote expires or is canceled without a payment. */
|
|
19
22
|
onExpire?: (quote: ClientQuote) => void;
|
|
20
23
|
/** Called whenever the checkout's status changes, like Stripe Elements' `onChange`: for example,
|
|
21
24
|
* to hide your own "new payment" control while a payment is `seen` or `confirming`. */
|
|
22
25
|
onChange?: (state: CheckoutState) => void;
|
|
26
|
+
/** Called when the wallet tab could not send the payment, with the `WalletError` and the wallet
|
|
27
|
+
* it tried (the chosen browser wallet's provider, or `walletClient`): for example on
|
|
28
|
+
* `insufficient_balance` (nothing was sent), to offer your own way to fund that wallet. The
|
|
29
|
+
* checkout shows the error's message itself. */
|
|
30
|
+
onWalletError?: (error: WalletError, wallet: WalletClient | EthereumProvider) => void;
|
|
23
31
|
appearance?: Appearance;
|
|
24
32
|
/** Milliseconds between status reads; default 3000. */
|
|
25
33
|
pollInterval?: number;
|
|
@@ -31,5 +39,5 @@ export interface CheckoutProps {
|
|
|
31
39
|
walletClient?: WalletClient | undefined;
|
|
32
40
|
}
|
|
33
41
|
/** A checkout for one quote: pay from a browser wallet, by QR code, or manually, with live status. */
|
|
34
|
-
export declare function Checkout({ clientSecret, expectedAddress, apiBase, onSuccess, onExpire, onChange, appearance, pollInterval, className, buttonText, walletClient, }: CheckoutProps): import("react").JSX.Element;
|
|
42
|
+
export declare function Checkout({ clientSecret, expectedAddress, apiBase, onSuccess, onExpire, onChange, onWalletError, appearance, pollInterval, className, buttonText, walletClient, }: CheckoutProps): import("react").JSX.Element;
|
|
35
43
|
//# sourceMappingURL=Checkout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources":["../../src/react/Checkout.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAQ,YAAY,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,KAAK,EAAqB,aAAa,EAAkB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources":["../../src/react/Checkout.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAQ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,EAAE,aAAa,+BAqEf"}
|
package/dist/react/Checkout.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useRef, useState } from "react";
|
|
4
4
|
import { networkName, transactionUrl } from "../chains.js";
|
|
5
|
-
import { formatAmount, formatCountdown, formatTokenAmount, tokenAmount } from "../format.js";
|
|
5
|
+
import { formatAmount, formatCountdown, formatMinorAmount, formatTokenAmount, formatWait, tokenAmount, } from "../format.js";
|
|
6
6
|
import { quoteTransfer } from "../payment.js";
|
|
7
7
|
import { WalletError, payWithWallet, watchWallets, } from "../wallet.js";
|
|
8
8
|
import { STYLES, appearanceStyle } from "./appearance.js";
|
|
@@ -15,7 +15,7 @@ const METHODS = [
|
|
|
15
15
|
{ id: "manual", label: "Send manually" },
|
|
16
16
|
];
|
|
17
17
|
/** A checkout for one quote: pay from a browser wallet, by QR code, or manually, with live status. */
|
|
18
|
-
export function Checkout({ clientSecret, expectedAddress, apiBase, onSuccess, onExpire, onChange, appearance, pollInterval, className, buttonText = "Pay with crypto", walletClient, }) {
|
|
18
|
+
export function Checkout({ clientSecret, expectedAddress, apiBase, onSuccess, onExpire, onChange, onWalletError, appearance, pollInterval, className, buttonText = "Pay with crypto", walletClient, }) {
|
|
19
19
|
const { status, quote, error, refresh } = useCheckout({
|
|
20
20
|
clientSecret,
|
|
21
21
|
expectedAddress,
|
|
@@ -51,7 +51,7 @@ export function Checkout({ clientSecret, expectedAddress, apiBase, onSuccess, on
|
|
|
51
51
|
return (_jsxs("div", { className: className === undefined ? "pp-root" : `pp-root ${className}`, "data-theme": appearance?.theme ?? "light", style: appearanceStyle(appearance), children: [_jsx("style", { children: STYLES }), quote !== null && (_jsxs(_Fragment, { children: [_jsxs("p", { className: "pp-amount", children: [formatTokenAmount(quote), " ", quote.asset.toUpperCase()] }), _jsxs("p", { className: "pp-subtitle", children: [formatAmount(quote), " top-up \u00B7 ", networkName(quote.chain_id), !quote.livemode && _jsx("span", { className: "pp-badge", children: " \u00B7 Test mode" })] })] })), _jsx(StatusLine, { status: status, quote: quote, now: now, error: error }), txHash !== null && quote !== null && _jsx(Transaction, { hash: txHash, chainId: quote.chain_id }), status === "waiting" && quote !== null && (_jsx(PaymentOptions, { quote: quote, buttonText: buttonText, walletClient: walletClient, now: now, onSent: (hash) => {
|
|
52
52
|
setTxHash(hash);
|
|
53
53
|
refresh();
|
|
54
|
-
} }))] }));
|
|
54
|
+
}, onWalletError: onWalletError }))] }));
|
|
55
55
|
}
|
|
56
56
|
function StatusLine({ status, quote, now, error, }) {
|
|
57
57
|
const tone = status === "credited"
|
|
@@ -68,13 +68,11 @@ function statusMessage(status, quote, code) {
|
|
|
68
68
|
case "waiting":
|
|
69
69
|
return "Waiting for your payment";
|
|
70
70
|
case "seen":
|
|
71
|
-
return quote
|
|
72
|
-
? "Payment received, crediting in about 30 seconds"
|
|
73
|
-
: `Payment received, ${quote.confirmations} confirmation${quote.confirmations === 1 ? "" : "s"}. Crediting in about 30 seconds`;
|
|
71
|
+
return seenMessage(quote);
|
|
74
72
|
case "confirming":
|
|
75
73
|
return "Payment confirmed on chain, crediting…";
|
|
76
74
|
case "credited":
|
|
77
|
-
return
|
|
75
|
+
return creditedMessage(quote);
|
|
78
76
|
case "rejected":
|
|
79
77
|
return "This payment cannot be credited. Contact support with your transaction.";
|
|
80
78
|
case "reversed":
|
|
@@ -89,11 +87,34 @@ function statusMessage(status, quote, code) {
|
|
|
89
87
|
: "This payment link is not valid. Start a new top-up.";
|
|
90
88
|
}
|
|
91
89
|
}
|
|
90
|
+
function seenMessage(quote) {
|
|
91
|
+
if (quote === null) {
|
|
92
|
+
return "Payment received, crediting once it is confirmed";
|
|
93
|
+
}
|
|
94
|
+
const wait = formatWait(quote.typical_credit_seconds);
|
|
95
|
+
return quote.confirmations === null
|
|
96
|
+
? `Payment received, crediting in ${wait}`
|
|
97
|
+
: `Payment received, ${quote.confirmations} confirmation${quote.confirmations === 1 ? "" : "s"}. Crediting in ${wait}`;
|
|
98
|
+
}
|
|
99
|
+
/** What was credited and, when the payment was valued at the market price, the quote it missed. */
|
|
100
|
+
function creditedMessage(quote) {
|
|
101
|
+
if (quote?.amount_credited == null) {
|
|
102
|
+
return "Payment credited";
|
|
103
|
+
}
|
|
104
|
+
const credited = formatMinorAmount(quote, quote.amount_credited);
|
|
105
|
+
if (quote.amount_credited < quote.amount) {
|
|
106
|
+
return `Payment credited: ${credited} of ${formatAmount(quote)}`;
|
|
107
|
+
}
|
|
108
|
+
if (quote.amount_credited > quote.amount) {
|
|
109
|
+
return `Payment credited: ${credited}, more than the ${formatAmount(quote)} quoted`;
|
|
110
|
+
}
|
|
111
|
+
return `Payment credited: ${credited}`;
|
|
112
|
+
}
|
|
92
113
|
function Transaction({ hash, chainId }) {
|
|
93
114
|
const url = transactionUrl(chainId, hash);
|
|
94
115
|
return (_jsxs("p", { className: "pp-tx", children: ["Transaction sent:", " ", url === undefined ? (_jsx("span", { className: "pp-value", children: hash })) : (_jsx("a", { className: "pp-value", href: url, target: "_blank", rel: "noreferrer", children: hash }))] }));
|
|
95
116
|
}
|
|
96
|
-
function PaymentOptions({ quote, now, buttonText, walletClient, onSent, }) {
|
|
117
|
+
function PaymentOptions({ quote, now, buttonText, walletClient, onSent, onWalletError, }) {
|
|
97
118
|
const [method, setMethod] = useState("wallet");
|
|
98
119
|
const id = useId();
|
|
99
120
|
const tabs = useRef([]);
|
|
@@ -118,9 +139,9 @@ function PaymentOptions({ quote, now, buttonText, walletClient, onSent, }) {
|
|
|
118
139
|
};
|
|
119
140
|
return (_jsxs(_Fragment, { children: [_jsxs("p", { className: "pp-notice", children: ["Send ", _jsxs("strong", { children: ["exactly ", amount] }), " on ", networkName(quote.chain_id), " in one transfer before the timer ends. A different amount, or a payment after expiry, is credited at the market price instead of this quote. Exchanges may deduct a withdrawal fee, so the amount that arrives must be exact."] }), _jsx("div", { className: "pp-tabs", role: "tablist", "aria-label": "Payment method", onKeyDown: onKeyDown, children: METHODS.map((m, index) => (_jsx("button", { ref: (element) => {
|
|
120
141
|
tabs.current[index] = element;
|
|
121
|
-
}, type: "button", role: "tab", className: "pp-tab", id: `${id}-tab-${m.id}`, "aria-selected": method === m.id, "aria-controls": `${id}-panel-${m.id}`, tabIndex: method === m.id ? 0 : -1, onClick: () => setMethod(m.id), children: m.label }, m.id))) }), _jsxs("div", { role: "tabpanel", id: `${id}-panel-${method}`, "aria-labelledby": `${id}-tab-${method}`, tabIndex: 0, children: [method === "wallet" && (_jsx(WalletPanel, { quote: quote, buttonText: buttonText, walletClient: walletClient, onSent: onSent })), method === "qr" && (_jsxs("div", { className: "pp-qr-panel", children: [_jsx(QrCode, { value: quote.payment_uri, label: `Payment request for ${amount}` }), _jsxs("p", { className: "pp-message", children: ["Scan with a wallet app that reads payment links, and check that it shows ", amount, " on", " ", networkName(quote.chain_id), " before you confirm."] })] })), method === "manual" && _jsx(ManualPanel, { quote: quote, now: now })] })] }));
|
|
142
|
+
}, type: "button", role: "tab", className: "pp-tab", id: `${id}-tab-${m.id}`, "aria-selected": method === m.id, "aria-controls": `${id}-panel-${m.id}`, tabIndex: method === m.id ? 0 : -1, onClick: () => setMethod(m.id), children: m.label }, m.id))) }), _jsxs("div", { role: "tabpanel", id: `${id}-panel-${method}`, "aria-labelledby": `${id}-tab-${method}`, tabIndex: 0, children: [method === "wallet" && (_jsx(WalletPanel, { quote: quote, buttonText: buttonText, walletClient: walletClient, onSent: onSent, onWalletError: onWalletError })), method === "qr" && (_jsxs("div", { className: "pp-qr-panel", children: [_jsx(QrCode, { value: quote.payment_uri, label: `Payment request for ${amount}` }), _jsxs("p", { className: "pp-message", children: ["Scan with a wallet app that reads payment links, and check that it shows ", amount, " on", " ", networkName(quote.chain_id), " before you confirm."] })] })), method === "manual" && _jsx(ManualPanel, { quote: quote, now: now })] })] }));
|
|
122
143
|
}
|
|
123
|
-
function WalletPanel({ quote, buttonText, walletClient, onSent, }) {
|
|
144
|
+
function WalletPanel({ quote, buttonText, walletClient, onSent, onWalletError, }) {
|
|
124
145
|
const [discovered, setDiscovered] = useState([]);
|
|
125
146
|
const [step, setStep] = useState({ kind: "idle" });
|
|
126
147
|
useEffect(() => (walletClient === undefined ? watchWallets(setDiscovered) : undefined), [walletClient]);
|
|
@@ -138,6 +159,9 @@ function WalletPanel({ quote, buttonText, walletClient, onSent, }) {
|
|
|
138
159
|
kind: "failed",
|
|
139
160
|
message: error instanceof WalletError ? error.message : "The payment could not be sent",
|
|
140
161
|
});
|
|
162
|
+
if (error instanceof WalletError) {
|
|
163
|
+
onWalletError?.(error, wallet);
|
|
164
|
+
}
|
|
141
165
|
}
|
|
142
166
|
};
|
|
143
167
|
if (wallets.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../../src/react/Checkout.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;AAG/E,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EACL,WAAW,EACX,aAAa,EACb,YAAY,GAGb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,eAAe,EAAmB,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAiC/C,MAAM,OAAO,GAAoC;IAC/C,EAAE,EAAE,EAAE,QAAQ,EAAE,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Y,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,SAAG,EACpF,KAAC,KAAK,IAAC,KAAK,EAAC,iBAAiB,EAAC,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,SAAG,EAC5D,KAAC,KAAK,IAAC,KAAK,EAAC,cAAc,EAAC,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,GAAI,EACzF,KAAC,KAAK,IAAC,KAAK,EAAC,WAAW,EAAC,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,GAAI,IACvE,CACN,CAAC;AACJ,CAAC;AAED,6EAA6E;AAC7E,SAAS,MAAM,CAAC,MAAe;IAC7B,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACjD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO;QACT,CAAC;QACD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAC1D,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACb,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/server/webhook.d.ts
CHANGED
|
@@ -20,12 +20,12 @@ export interface WebhookEvent {
|
|
|
20
20
|
type: string;
|
|
21
21
|
created: number;
|
|
22
22
|
/** Who caused it: an API key id (`key_…`), `admin`, or `system`. */
|
|
23
|
-
actor
|
|
23
|
+
actor: string;
|
|
24
24
|
/**
|
|
25
25
|
* The API request that caused it, with the `Idempotency-Key` it sent; `null` when the
|
|
26
26
|
* service's own workers did (a payment credited, a quote expired).
|
|
27
27
|
*/
|
|
28
|
-
request
|
|
28
|
+
request: {
|
|
29
29
|
id: string;
|
|
30
30
|
idempotency_key: string | null;
|
|
31
31
|
} | null;
|
|
@@ -50,9 +50,10 @@ export interface ConstructEventOptions {
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Verifies a delivery and returns its event, as Stripe's `constructEvent` does, failing closed
|
|
53
|
-
* unless a `v1a` signature verifies with one of `publicKeys` (
|
|
54
|
-
*
|
|
55
|
-
* `webhook-id`, and the event is
|
|
53
|
+
* unless a `v1a` signature verifies with one of `publicKeys` (ed25519 keys in Standard Webhooks'
|
|
54
|
+
* `whpk_` form, as `GET /v1/attestation` lists them; pass both while a rotation overlaps), the
|
|
55
|
+
* timestamp is within tolerance, the body's id is the `webhook-id`, and the event is
|
|
56
|
+
* `expectedAccount`'s in `expectedLivemode`.
|
|
56
57
|
*
|
|
57
58
|
* `payload` is the raw request body, before any JSON parsing.
|
|
58
59
|
*/
|