@phala/pay-server 0.13.5 → 0.13.6
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 +23 -0
- package/dist/chains.d.ts +6 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/chains.js +21 -0
- package/dist/chains.js.map +1 -0
- package/dist/generated/openapi.d.ts +65 -0
- package/dist/generated/openapi.d.ts.map +1 -1
- package/dist/helpers.d.ts +2 -0
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +2 -0
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/receipts.d.ts +58 -0
- package/dist/receipts.d.ts.map +1 -0
- package/dist/receipts.js +101 -0
- package/dist/receipts.js.map +1 -0
- package/dist/resources.d.ts +1 -0
- package/dist/resources.d.ts.map +1 -1
- package/dist/resources.js +3 -0
- package/dist/resources.js.map +1 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +23 -0
- package/dist/schemas.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -223,3 +223,26 @@ npm (environment `npm`) with trusted publishing and provenance
|
|
|
223
223
|
[CHANGELOG.md](https://github.com/Phala-Network/phala-pay/blob/main/CHANGELOG.md), under "JS SDK";
|
|
224
224
|
[its releases before v0.5.0](https://github.com/Phala-Network/phala-pay/blob/main/sdk/js/CHANGELOG.md),
|
|
225
225
|
versioned on their own, stay in `sdk/js`.
|
|
226
|
+
|
|
227
|
+
## Requesting a quote check
|
|
228
|
+
|
|
229
|
+
`await pay.quotes.check(quoteId)` requests an immediate read-only discovery pass for an open,
|
|
230
|
+
unexpired quote's issued address. Quiet 202 receipt acknowledges the request only; keep normal
|
|
231
|
+
polling/webhook crediting. Checks permit three/quote/rolling day, 15-second address spacing and
|
|
232
|
+
a separate per-chain daily budget. Concurrent requests coalesce; exhaustion leaves normal scanning
|
|
233
|
+
running.
|
|
234
|
+
|
|
235
|
+
## Receipt helpers
|
|
236
|
+
|
|
237
|
+
`@phala/pay-server/helpers` exports `stripeReceiptInvoice(deposit, { customer, description? })`,
|
|
238
|
+
`stripeReceiptInvoiceItem(deposit, { invoice, customer })`, and
|
|
239
|
+
`stripeReceiptCreditNote(deposit, { invoice, previousRefunded, previousReversed })`.
|
|
240
|
+
They return typed plain Stripe parameters for a credited `Deposit` (`ReceiptDeposit` subset),
|
|
241
|
+
without a Stripe dependency. Invoices include transaction hashes, explorer links and live/test
|
|
242
|
+
metadata; credit notes cover new refund/reversal growth only (`null` for no growth). Amounts
|
|
243
|
+
always use the deposit currency. Use the official `stripe` library from a queue and persist one
|
|
244
|
+
invoice per deposit; see [the receipt flow and examples](../../docs/integration.md#27-receipts).
|
|
245
|
+
|
|
246
|
+
`transactionUrl(chainId, txHash)` and `addressUrl(chainId, address)` are available from both
|
|
247
|
+
`@phala/pay-server` and `/helpers`, with the same explorers as `@phala/pay`; they return
|
|
248
|
+
`undefined` for an unknown chain or malformed hash/address.
|
package/dist/chains.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function networkName(chainId: number): string;
|
|
2
|
+
/** Explorer URL, or undefined for an unknown chain or malformed transaction hash. */
|
|
3
|
+
export declare function transactionUrl(chainId: number, txHash: string): string | undefined;
|
|
4
|
+
/** Explorer URL, or undefined for an unknown chain or malformed address. */
|
|
5
|
+
export declare function addressUrl(chainId: number, address: string): string | undefined;
|
|
6
|
+
//# sourceMappingURL=chains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIlF;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI/E"}
|
package/dist/chains.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { mainnet, sepolia, base, baseSepolia } from "viem/chains";
|
|
2
|
+
// The same viem chains as @phala/pay, checked against the browser registry in tests.
|
|
3
|
+
const chains = [mainnet, sepolia, base, baseSepolia];
|
|
4
|
+
export function networkName(chainId) {
|
|
5
|
+
return chains.find((chain) => chain.id === chainId)?.name ?? `Chain ${chainId}`;
|
|
6
|
+
}
|
|
7
|
+
/** Explorer URL, or undefined for an unknown chain or malformed transaction hash. */
|
|
8
|
+
export function transactionUrl(chainId, txHash) {
|
|
9
|
+
if (txHash.length !== 66 || !/^0x[0-9a-fA-F]{64}$/.test(txHash))
|
|
10
|
+
return undefined;
|
|
11
|
+
const explorer = chains.find((chain) => chain.id === chainId)?.blockExplorers.default.url;
|
|
12
|
+
return explorer === undefined ? undefined : `${explorer}/tx/${txHash}`;
|
|
13
|
+
}
|
|
14
|
+
/** Explorer URL, or undefined for an unknown chain or malformed address. */
|
|
15
|
+
export function addressUrl(chainId, address) {
|
|
16
|
+
if (address.length !== 42 || !/^0x[0-9a-fA-F]{40}$/.test(address))
|
|
17
|
+
return undefined;
|
|
18
|
+
const explorer = chains.find((chain) => chain.id === chainId)?.blockExplorers.default.url;
|
|
19
|
+
return explorer === undefined ? undefined : `${explorer}/address/${address}`;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=chains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CA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6 +531,23 @@ export interface paths {
|
|
|
531
531
|
readonly patch?: never;
|
|
532
532
|
readonly trace?: never;
|
|
533
533
|
};
|
|
534
|
+
readonly "/v1/quotes/{id}/check": {
|
|
535
|
+
readonly parameters: {
|
|
536
|
+
readonly query?: never;
|
|
537
|
+
readonly header?: never;
|
|
538
|
+
readonly path?: never;
|
|
539
|
+
readonly cookie?: never;
|
|
540
|
+
};
|
|
541
|
+
readonly get?: never;
|
|
542
|
+
readonly put?: never;
|
|
543
|
+
/** Request immediate read-only discovery for an open, unexpired quote's issued address. */
|
|
544
|
+
readonly post: operations["check_quote"];
|
|
545
|
+
readonly delete?: never;
|
|
546
|
+
readonly options?: never;
|
|
547
|
+
readonly head?: never;
|
|
548
|
+
readonly patch?: never;
|
|
549
|
+
readonly trace?: never;
|
|
550
|
+
};
|
|
534
551
|
readonly "/v1/quotes/{id}/transactions": {
|
|
535
552
|
readonly parameters: {
|
|
536
553
|
readonly query?: never;
|
|
@@ -3205,6 +3222,24 @@ export interface components {
|
|
|
3205
3222
|
*/
|
|
3206
3223
|
readonly window_start: number;
|
|
3207
3224
|
};
|
|
3225
|
+
/**
|
|
3226
|
+
* @description Quiet receipt of a check request; poll the quote for actual payment status.
|
|
3227
|
+
* @example {
|
|
3228
|
+
* "object": "quote_check",
|
|
3229
|
+
* "status": "received"
|
|
3230
|
+
* }
|
|
3231
|
+
*/
|
|
3232
|
+
readonly QuoteCheck: {
|
|
3233
|
+
/** @description Object discriminator. */
|
|
3234
|
+
readonly object: components["schemas"]["QuoteCheckObject"];
|
|
3235
|
+
/** @description Receipt only; limits and processing outcomes are deliberately not disclosed. */
|
|
3236
|
+
readonly status: components["schemas"]["TransactionSubmissionStatus"];
|
|
3237
|
+
};
|
|
3238
|
+
/**
|
|
3239
|
+
* @description Constant quote-check acknowledgement discriminator.
|
|
3240
|
+
* @enum {string}
|
|
3241
|
+
*/
|
|
3242
|
+
readonly QuoteCheckObject: "quote_check";
|
|
3208
3243
|
/**
|
|
3209
3244
|
* @description A page of quotes, newest first (<https://docs.stripe.com/api/pagination>).
|
|
3210
3245
|
* @example {
|
|
@@ -7516,6 +7551,36 @@ export interface operations {
|
|
|
7516
7551
|
};
|
|
7517
7552
|
};
|
|
7518
7553
|
};
|
|
7554
|
+
readonly check_quote: {
|
|
7555
|
+
readonly parameters: {
|
|
7556
|
+
readonly query?: {
|
|
7557
|
+
/** @description Object's browser client secret; omit with a merchant key */
|
|
7558
|
+
readonly client_secret?: string;
|
|
7559
|
+
};
|
|
7560
|
+
readonly header?: never;
|
|
7561
|
+
readonly path: {
|
|
7562
|
+
/** @description Quote identifier */
|
|
7563
|
+
readonly id: string;
|
|
7564
|
+
};
|
|
7565
|
+
readonly cookie?: never;
|
|
7566
|
+
};
|
|
7567
|
+
readonly requestBody?: never;
|
|
7568
|
+
readonly responses: {
|
|
7569
|
+
/** @description Received, including ignored checks. Poll the quote for payment status. */
|
|
7570
|
+
readonly 202: {
|
|
7571
|
+
headers: {
|
|
7572
|
+
/** @description Tenant data and credentials must never be stored, including errors */
|
|
7573
|
+
readonly "Cache-Control": "no-store";
|
|
7574
|
+
/** @description The request's id, `req_…` (https://docs.stripe.com/api/request_ids) */
|
|
7575
|
+
readonly "Request-Id"?: string;
|
|
7576
|
+
readonly [name: string]: unknown;
|
|
7577
|
+
};
|
|
7578
|
+
content: {
|
|
7579
|
+
readonly "application/json": components["schemas"]["QuoteCheck"];
|
|
7580
|
+
};
|
|
7581
|
+
};
|
|
7582
|
+
};
|
|
7583
|
+
};
|
|
7519
7584
|
readonly submit_quote_transaction: {
|
|
7520
7585
|
readonly parameters: {
|
|
7521
7586
|
readonly query?: {
|