@phala/pay 0.11.0 → 0.11.2
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/README.md +21 -8
- package/THIRD_PARTY_NOTICES +1 -1
- package/dist/icon-svg.d.ts +1 -1
- package/dist/icon-svg.js +5 -5
- package/dist/icon-svg.js.map +1 -1
- package/package.json +1 -1
- package/src/icon-svg.ts +5 -5
package/README.md
CHANGED
|
@@ -186,8 +186,9 @@ import { PaymentElement } from "@phala/pay-react";
|
|
|
186
186
|
- `createQuote(option, { idempotencyKey })` is called once per submit, with the very object of
|
|
187
187
|
`options` the payer chose; a submit while one is pending is ignored. It resolves with
|
|
188
188
|
`{ clientSecret, expectedAddress, apiBase? }`; `apiBase` falls back to the prop. A rejection
|
|
189
|
-
shows "Could not start the payment. Try again." and calls `onError(error)
|
|
190
|
-
|
|
189
|
+
shows "Could not start the payment. Try again." and calls `onError(error)`. To show your own
|
|
190
|
+
reason in that alert instead, pass `errorMessage(cause)`: a non-empty string replaces the text,
|
|
191
|
+
and `null` or `undefined` keeps it. It applies to `createDepositAddress` too.
|
|
191
192
|
- Create the quote with `idempotencyKey` as its `Idempotency-Key`, not an order id of yours: the
|
|
192
193
|
key is a new random UUID for each quote the payer asks for (another option or amount, or a new
|
|
193
194
|
quote after going back from one) and the same only when they retry after `createQuote` failed
|
|
@@ -199,12 +200,24 @@ import { PaymentElement } from "@phala/pay-react";
|
|
|
199
200
|
- After the quote: the checkout, and a way back to the options ("Choose another token or
|
|
200
201
|
network") until a payment is on its way, then "Start over" if it does not complete or "Start a
|
|
201
202
|
new payment" once credited.
|
|
202
|
-
- `createDepositAddress(option)` adds
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
203
|
+
- `createDepositAddress(option)` adds one quiet line at the end of the form, "Paying from an
|
|
204
|
+
exchange? Use a deposit address", for payers sending from an exchange or any wallet: it resolves
|
|
205
|
+
with the deposit address's `address` and `networks` and, to follow its payments, `clientSecret`;
|
|
206
|
+
the element shows `<DepositAddress>` at the chosen option, which states the per-transfer limits.
|
|
207
|
+
- Your own content: `children` go inside the form, under the token and network and above the
|
|
208
|
+
element's button, while the payer chooses. With `hideSubmit`, put your summary and your
|
|
209
|
+
`type="submit"` button there, and the deposit-address line follows your button:
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
<PaymentElement hideSubmit options={options} createQuote={createQuote} createDepositAddress={createDepositAddress}>
|
|
213
|
+
<OrderSummary />
|
|
214
|
+
<Button type="submit">Continue to pay $25.00</Button>
|
|
215
|
+
</PaymentElement>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
A button elsewhere on the page can submit it too: pass `hideSubmit` and an `id`, and give your
|
|
219
|
+
button `type="submit" form={id}` (or call `requestSubmit()` on the form with that id). The
|
|
220
|
+
element is a `<form>`: do not nest it in another one.
|
|
208
221
|
- `value` and `onOptionChange` control the choice (`defaultValue` sets the first one otherwise);
|
|
209
222
|
`onChange({ step, checkout })` reports each step (`options`, `creating`, `checkout`,
|
|
210
223
|
`deposit_address`) and, while paying, each checkout status change; `onSuccess`, `onExpire`,
|
package/THIRD_PARTY_NOTICES
CHANGED
package/dist/icon-svg.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Generated from @web3icons/core@4.0.
|
|
1
|
+
/** Generated from @web3icons/core@4.0.58 by scripts/generate-icons.mjs.
|
|
2
2
|
* SPDX-License-Identifier: MIT; Copyright (c) 2024 0xa3k5.
|
|
3
3
|
* See THIRD_PARTY_NOTICES for the full license. Do not edit.
|
|
4
4
|
*/
|
package/dist/icon-svg.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/** Generated from @web3icons/core@4.0.
|
|
1
|
+
/** Generated from @web3icons/core@4.0.58 by scripts/generate-icons.mjs.
|
|
2
2
|
* SPDX-License-Identifier: MIT; Copyright (c) 2024 0xa3k5.
|
|
3
3
|
* See THIRD_PARTY_NOTICES for the full license. Do not edit.
|
|
4
4
|
*/
|
|
5
5
|
export const ICON_SVG = {
|
|
6
|
-
usdc: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#0B53BF\" d=\"
|
|
7
|
-
usdt: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#009393\" d=\"m12
|
|
8
|
-
pha: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><
|
|
9
|
-
eth: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#8FFCF3\" d=\"M12
|
|
6
|
+
usdc: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#0B53BF\" d=\"M24 0H0v24h24z\"/><path fill=\"#fff\" fill-rule=\"evenodd\" d=\"M12 20c4.435 0 8-3.565 8-8s-3.565-8-8-8-8 3.565-8 8 3.565 8 8 8m2.2-6.735c0-1.165-.7-1.565-2.1-1.73-1-.135-1.2-.4-1.2-.87 0-.465.335-.765 1-.765.6 0 .935.2 1.1.7.035.1.135.165.235.165h.53c.135 0 .235-.1.235-.23v-.036c-.135-.734-.735-1.434-1.5-1.5v-.734c0-.135-.1-.235-.265-.265h-.44c-.135 0-.26.1-.295.265V9c-1 .135-1.665.9-1.665 1.735 0 1.1.665 1.53 2.065 1.7.935.165 1.235.365 1.235.9 0 .53-.47.9-1.1.9-.87 0-1.17-.37-1.27-.87-.03-.13-.13-.2-.23-.2h-.57c-.13 0-.23.1-.23.235v.035c.13.83.665 1.4 1.765 1.565v.74c0 .135.1.224.265.26h.48c.13 0 .22-.09.255-.26V15c1-.165 1.7-.835 1.7-1.735m-5.566 2.49c.483.443 1.05.786 1.666 1.01.1.07.2.2.2.3v.47c0 .064 0 .1-.035.13-.03.134-.165.2-.3.134a6 6 0 0 1 0-11.435c.035-.03.1-.03.135-.03.135.03.2.13.2.265v.465c0 .17-.065.27-.2.335a4.93 4.93 0 0 0-2.965 2.965 4.965 4.965 0 0 0 1.299 5.391M13.535 6.5c.03-.135.165-.2.3-.135a6.05 6.05 0 0 1 3.9 3.935c1 3.165-.735 6.535-3.9 7.535-.035.03-.1.03-.135.03-.135-.03-.2-.13-.2-.265v-.465c0-.17.065-.27.2-.335a4.93 4.93 0 0 0 2.965-2.965 4.967 4.967 0 0 0-2.965-6.4c-.1-.07-.2-.2-.2-.335v-.465c0-.07 0-.1.035-.135\" clip-rule=\"evenodd\"/></svg>",
|
|
7
|
+
usdt: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#009393\" d=\"M24 0H0v24h24z\"/><path fill=\"#fff\" d=\"m12 18.4-8-7.892L7.052 5.6h9.896L20 10.508zm.8-7.2v-.976c1.44.072 2.784.352 3.2.716-.484.424-2.216.732-4 .732s-3.516-.308-4-.732c.412-.364 1.76-.64 3.2-.72v.98zM8 10.936v.588c.412.364 1.756.64 3.2.72V14.4h1.6v-2.16c1.44-.072 2.788-.352 3.2-.716v-1.172c-.412-.364-1.76-.644-3.2-.72V8.8h2.4V7.6H8.8v1.2h2.4v.832c-1.444.076-2.788.356-3.2.72z\"/></svg>",
|
|
8
|
+
pha: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#D1FF52\" d=\"M24 0H0v24h24z\"/><path fill=\"#fff\" fill-rule=\"evenodd\" d=\"M4 4h12.571v3.429H20V12h-3.429V7.429H7.43V12H4zm3.429 11.429h9.142V12H7.43zm0 0V20H4v-4.571z\" clip-rule=\"evenodd\"/></svg>",
|
|
9
|
+
eth: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#000\" d=\"M24 0H0v24h24z\"/><path fill=\"#8FFCF3\" d=\"M12 4v5.912l5 2.236z\"/><path fill=\"#CABCF8\" d=\"m12 4-5 8.148 5-2.236z\"/><path fill=\"#CBA7F5\" d=\"M12 15.98V20l5-6.92z\"/><path fill=\"#74A0F3\" d=\"M12 20v-4.02l-5-2.9z\"/><path fill=\"#CBA7F5\" d=\"m12 15.048 5-2.9-5-2.236z\"/><path fill=\"#74A0F3\" d=\"m7 12.148 5 2.9V9.912z\"/><path fill=\"#202699\" fill-rule=\"evenodd\" d=\"m12 15.048-5-2.9L12 4l5 8.148zm-4.668-3.136 4.588-7.476v5.436zm-.068.204 4.656-2.068v4.768zm4.816-2.068v4.768l4.652-2.7zm0-.176 4.588 2.04-4.588-7.476z\" clip-rule=\"evenodd\"/><path fill=\"#202699\" fill-rule=\"evenodd\" d=\"m12 15.916-5-2.84L12 20l5-6.924zm-4.44-2.34 4.36 2.48v3.56zm4.52 2.48v3.56l4.36-6.04z\" clip-rule=\"evenodd\"/></svg>",
|
|
10
10
|
ethereum: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#8FFCF3\" d=\"M12 3v6.651l5.625 2.516z\"/><path fill=\"#CABCF8\" d=\"m12 3-5.625 9.166L12 9.653z\"/><path fill=\"#CBA7F5\" d=\"M12 16.478V21l5.625-7.784z\"/><path fill=\"#74A0F3\" d=\"M12 21v-4.522l-5.625-3.262z\"/><path fill=\"#CBA7F5\" d=\"m12 15.43 5.625-3.263L12 9.652z\"/><path fill=\"#74A0F3\" d=\"M6.375 12.167 12 15.43V9.652z\"/><path fill=\"#202699\" fill-rule=\"evenodd\" d=\"m12 15.43-5.625-3.263L12 3l5.624 9.166zm-5.252-3.528 5.161-8.41v6.114zm-.077.229 5.238-2.327v5.364zm5.418-2.327v5.364l5.234-3.037zm0-.198 5.161 2.296-5.161-8.41z\" clip-rule=\"evenodd\"/><path fill=\"#202699\" fill-rule=\"evenodd\" d=\"m12 16.406-5.625-3.195L12 21l5.624-7.79zm-4.995-2.633 4.904 2.79v4.005zm5.084 2.79v4.005l4.905-6.795z\" clip-rule=\"evenodd\"/></svg>",
|
|
11
11
|
base: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#00F\" d=\"M3 4.706c0-.585 0-.877.11-1.101.106-.215.28-.39.496-.495C3.83 3 4.122 3 4.706 3h14.588c.585 0 .876 0 1.101.11.215.105.389.28.494.495.111.225.111.517.111 1.101v14.588c0 .585 0 .876-.11 1.101-.106.215-.28.389-.495.494-.225.111-.517.111-1.101.111H4.706c-.585 0-.876 0-1.101-.11a1.08 1.08 0 0 1-.494-.495C3 20.17 3 19.878 3 19.294z\"/></svg>",
|
|
12
12
|
};
|
package/dist/icon-svg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-svg.js","sourceRoot":"","sources":["../src/icon-svg.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAA0E;IAC7F,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"icon-svg.js","sourceRoot":"","sources":["../src/icon-svg.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAA0E;IAC7F,IAAI,EAAE,o0CAAo0C;IAC10C,IAAI,EAAE,iiBAAiiB;IACviB,GAAG,EAAE,uVAAuV;IAC5V,GAAG,EAAE,62BAA62B;IACl3B,QAAQ,EAAE,g4BAAg4B;IAC14B,IAAI,EAAE,yeAAye;CAChf,CAAC"}
|
package/package.json
CHANGED
package/src/icon-svg.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/** Generated from @web3icons/core@4.0.
|
|
1
|
+
/** Generated from @web3icons/core@4.0.58 by scripts/generate-icons.mjs.
|
|
2
2
|
* SPDX-License-Identifier: MIT; Copyright (c) 2024 0xa3k5.
|
|
3
3
|
* See THIRD_PARTY_NOTICES for the full license. Do not edit.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export const ICON_SVG: Record<"usdc" | "usdt" | "pha" | "eth" | "ethereum" | "base", string> = {
|
|
7
|
-
usdc: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#0B53BF\" d=\"
|
|
8
|
-
usdt: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#009393\" d=\"m12
|
|
9
|
-
pha: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><
|
|
10
|
-
eth: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#8FFCF3\" d=\"M12
|
|
7
|
+
usdc: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#0B53BF\" d=\"M24 0H0v24h24z\"/><path fill=\"#fff\" fill-rule=\"evenodd\" d=\"M12 20c4.435 0 8-3.565 8-8s-3.565-8-8-8-8 3.565-8 8 3.565 8 8 8m2.2-6.735c0-1.165-.7-1.565-2.1-1.73-1-.135-1.2-.4-1.2-.87 0-.465.335-.765 1-.765.6 0 .935.2 1.1.7.035.1.135.165.235.165h.53c.135 0 .235-.1.235-.23v-.036c-.135-.734-.735-1.434-1.5-1.5v-.734c0-.135-.1-.235-.265-.265h-.44c-.135 0-.26.1-.295.265V9c-1 .135-1.665.9-1.665 1.735 0 1.1.665 1.53 2.065 1.7.935.165 1.235.365 1.235.9 0 .53-.47.9-1.1.9-.87 0-1.17-.37-1.27-.87-.03-.13-.13-.2-.23-.2h-.57c-.13 0-.23.1-.23.235v.035c.13.83.665 1.4 1.765 1.565v.74c0 .135.1.224.265.26h.48c.13 0 .22-.09.255-.26V15c1-.165 1.7-.835 1.7-1.735m-5.566 2.49c.483.443 1.05.786 1.666 1.01.1.07.2.2.2.3v.47c0 .064 0 .1-.035.13-.03.134-.165.2-.3.134a6 6 0 0 1 0-11.435c.035-.03.1-.03.135-.03.135.03.2.13.2.265v.465c0 .17-.065.27-.2.335a4.93 4.93 0 0 0-2.965 2.965 4.965 4.965 0 0 0 1.299 5.391M13.535 6.5c.03-.135.165-.2.3-.135a6.05 6.05 0 0 1 3.9 3.935c1 3.165-.735 6.535-3.9 7.535-.035.03-.1.03-.135.03-.135-.03-.2-.13-.2-.265v-.465c0-.17.065-.27.2-.335a4.93 4.93 0 0 0 2.965-2.965 4.967 4.967 0 0 0-2.965-6.4c-.1-.07-.2-.2-.2-.335v-.465c0-.07 0-.1.035-.135\" clip-rule=\"evenodd\"/></svg>",
|
|
8
|
+
usdt: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#009393\" d=\"M24 0H0v24h24z\"/><path fill=\"#fff\" d=\"m12 18.4-8-7.892L7.052 5.6h9.896L20 10.508zm.8-7.2v-.976c1.44.072 2.784.352 3.2.716-.484.424-2.216.732-4 .732s-3.516-.308-4-.732c.412-.364 1.76-.64 3.2-.72v.98zM8 10.936v.588c.412.364 1.756.64 3.2.72V14.4h1.6v-2.16c1.44-.072 2.788-.352 3.2-.716v-1.172c-.412-.364-1.76-.644-3.2-.72V8.8h2.4V7.6H8.8v1.2h2.4v.832c-1.444.076-2.788.356-3.2.72z\"/></svg>",
|
|
9
|
+
pha: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#D1FF52\" d=\"M24 0H0v24h24z\"/><path fill=\"#fff\" fill-rule=\"evenodd\" d=\"M4 4h12.571v3.429H20V12h-3.429V7.429H7.43V12H4zm3.429 11.429h9.142V12H7.43zm0 0V20H4v-4.571z\" clip-rule=\"evenodd\"/></svg>",
|
|
10
|
+
eth: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#000\" d=\"M24 0H0v24h24z\"/><path fill=\"#8FFCF3\" d=\"M12 4v5.912l5 2.236z\"/><path fill=\"#CABCF8\" d=\"m12 4-5 8.148 5-2.236z\"/><path fill=\"#CBA7F5\" d=\"M12 15.98V20l5-6.92z\"/><path fill=\"#74A0F3\" d=\"M12 20v-4.02l-5-2.9z\"/><path fill=\"#CBA7F5\" d=\"m12 15.048 5-2.9-5-2.236z\"/><path fill=\"#74A0F3\" d=\"m7 12.148 5 2.9V9.912z\"/><path fill=\"#202699\" fill-rule=\"evenodd\" d=\"m12 15.048-5-2.9L12 4l5 8.148zm-4.668-3.136 4.588-7.476v5.436zm-.068.204 4.656-2.068v4.768zm4.816-2.068v4.768l4.652-2.7zm0-.176 4.588 2.04-4.588-7.476z\" clip-rule=\"evenodd\"/><path fill=\"#202699\" fill-rule=\"evenodd\" d=\"m12 15.916-5-2.84L12 20l5-6.924zm-4.44-2.34 4.36 2.48v3.56zm4.52 2.48v3.56l4.36-6.04z\" clip-rule=\"evenodd\"/></svg>",
|
|
11
11
|
ethereum: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#8FFCF3\" d=\"M12 3v6.651l5.625 2.516z\"/><path fill=\"#CABCF8\" d=\"m12 3-5.625 9.166L12 9.653z\"/><path fill=\"#CBA7F5\" d=\"M12 16.478V21l5.625-7.784z\"/><path fill=\"#74A0F3\" d=\"M12 21v-4.522l-5.625-3.262z\"/><path fill=\"#CBA7F5\" d=\"m12 15.43 5.625-3.263L12 9.652z\"/><path fill=\"#74A0F3\" d=\"M6.375 12.167 12 15.43V9.652z\"/><path fill=\"#202699\" fill-rule=\"evenodd\" d=\"m12 15.43-5.625-3.263L12 3l5.624 9.166zm-5.252-3.528 5.161-8.41v6.114zm-.077.229 5.238-2.327v5.364zm5.418-2.327v5.364l5.234-3.037zm0-.198 5.161 2.296-5.161-8.41z\" clip-rule=\"evenodd\"/><path fill=\"#202699\" fill-rule=\"evenodd\" d=\"m12 16.406-5.625-3.195L12 21l5.624-7.79zm-4.995-2.633 4.904 2.79v4.005zm5.084 2.79v4.005l4.905-6.795z\" clip-rule=\"evenodd\"/></svg>",
|
|
12
12
|
base: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" fill=\"none\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#00F\" d=\"M3 4.706c0-.585 0-.877.11-1.101.106-.215.28-.39.496-.495C3.83 3 4.122 3 4.706 3h14.588c.585 0 .876 0 1.101.11.215.105.389.28.494.495.111.225.111.517.111 1.101v14.588c0 .585 0 .876-.11 1.101-.106.215-.28.389-.495.494-.225.111-.517.111-1.101.111H4.706c-.585 0-.876 0-1.101-.11a1.08 1.08 0 0 1-.494-.495C3 20.17 3 19.878 3 19.294z\"/></svg>",
|
|
13
13
|
};
|