@0to1pay/server-sdk 2.2.0 → 2.3.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.
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # 0to1Pay Server SDK
2
2
 
3
- Node.js 22.20.0 or newer. Install the SDK from npm after publication or use the verified tarball in your merchant backend.
3
+ Node.js 22.20.0 or newer. Install the SDK from npm or use the verified tarball in your merchant backend.
4
4
 
5
5
  ```sh
6
- npm install @0to1pay/server-sdk@2.2.0
6
+ npm install @0to1pay/server-sdk@2.3.1
7
7
  ```
8
8
 
9
9
  ```sh
10
- npm install ./0to1pay-server-sdk-2.2.0.tgz
10
+ npm install ./0to1pay-server-sdk-2.3.1.tgz
11
11
  ```
12
12
 
13
- On a deployment with public signup enabled, sign in to **My workspace** and issue a scoped Sandbox key from **API keys**. On a restricted deployment, get a test project and server key from the platform operator. Set the HTTPS API origin and scoped key in your app's backend environment.
13
+ On a deployment with public signup enabled, open `/merchant` on the Web origin provided by your platform operator. Sign in to **My workspace**, select a project and issue a scoped Sandbox key from **API keys**. On a restricted deployment, get a test project and server key from the platform operator. Set the HTTPS API origin and scoped key in your app's backend environment.
14
14
 
15
15
  ```ts
16
16
  import { ZeroToOnePayClient } from '@0to1pay/server-sdk';
@@ -38,6 +38,12 @@ When Platform enables Base Sepolia, a Sandbox key can discover test USDC at `eip
38
38
 
39
39
  Call `createQuote` with the matching denomination or its registered asset on the selected chain. Then call `createAttempt` with `connection_id` and `quote_id` to read the reserved destination and transfer instructions. Finish checkout with the buyer authorization and signed transaction steps below. Queries also support historical payment and operation records retained by the platform.
40
40
 
41
+ ## Payment receipts
42
+
43
+ The server SDK provides this method in version 2.3.0 and later. The Platform must support `GET /v1/payments/{payment_id}/receipt`. Earlier SDK versions can access that route through authenticated HTTP.
44
+
45
+ Call `getPaymentReceipt(payment_id)` with a server key that has `payments:read`. Display each confirmed amount with its own asset, scale, and network. The receipt reports the funds received at the order’s destinations. Use the payment decision to determine whether to grant the purchased product. An empty available receipt has no confirmed funds. Historical records can return `availability: "unavailable"`.
46
+
41
47
  ## Buyer approval for on-chain checkout
42
48
 
43
49
  The merchant backend authenticates the buyer and checks their access to the quote on every checkout request. Give that checkout a stable, opaque `checkout_session_ref` of 16 to 128 base64url characters. Generate or derive it on the server and keep the raw session cookie or bearer token private. The three calls require a server key with `payments:write`.
@@ -51,7 +57,7 @@ Use the wallet's UTF-8 message signing for the chain. Ethereum and Base use the
51
57
 
52
58
  For test and existing Solana integrations, encode the owner's Ed25519 signature as `0x` followed by 128 hexadecimal characters. The claim helper preserves the case of canonical Base58 Solana transaction signatures that decode to exactly 64 bytes and contain at least one nonzero byte.
53
59
 
54
- The platform compares the finalized transaction's actual token source with the approved wallet and checks the exact token, destination, amount, and timing. An observed transfer without a matching signed claim is held for operator review. In the [0to1Pay Console](https://github.com/0to1pay/console), open the order and select **Review transfer** on the exact confirmed receipt in **Money movements**. A service with `payments:review` can also call `reviewPayment` with `action: 'accept_unattributed_chain_payment'`, that receipt's `movement_id`, the expected payment resource version, and a reason. Set `allow_late_payment: true` only when deliberately approving the specified late transfer. Exchange withdrawals can use this operational review path.
60
+ The platform compares the finalized transaction's actual token source with the approved wallet and checks the exact token, destination, amount, and timing. An observed transfer without a matching signed claim is held for operator review. Sign in with the reviewer role at `/console` on your deployment’s operator Web origin (`CONSOLE_PUBLIC_ORIGIN`). Open the order, find the confirmed receipt in **Money movements**, and select **Review transfer**. A service with `payments:review` can also call `reviewPayment` with `action: 'accept_unattributed_chain_payment'`, that receipt's `movement_id`, the expected payment resource version, and a reason. Set `allow_late_payment: true` only when deliberately approving the specified late transfer. Exchange withdrawals can use this operational review path.
55
61
 
56
62
  ## Subscription and API request allowance
57
63
 
@@ -491,6 +491,32 @@ paths:
491
491
  $ref: '#/components/responses/RateLimited'
492
492
  '503':
493
493
  $ref: '#/components/responses/Unavailable'
494
+ /payments/{payment_id}/receipt:
495
+ parameters:
496
+ - $ref: '#/components/parameters/payment_id'
497
+ get:
498
+ operationId: getPaymentReceipt
499
+ summary: Read the confirmed funds received for a payment
500
+ tags: [Payments]
501
+ x-required-scope: payments:read
502
+ description: Returns current finalized on-chain funds linked to this payment's bound quote recipients, grouped by exact token and network. Confirmed reversals, refunds, and dispute adjustments are deducted. These are deposits to the order's recipients and do not establish payer identity or eligibility for fulfillment. Historical payments without canonical receipt data are reported as unavailable.
503
+ responses:
504
+ '200':
505
+ description: Successful scoped receipt response.
506
+ content:
507
+ application/json:
508
+ schema:
509
+ $ref: '#/components/schemas/PaymentReceipt'
510
+ '400':
511
+ $ref: '#/components/responses/BadRequest'
512
+ '401':
513
+ $ref: '#/components/responses/Unauthorized'
514
+ '403':
515
+ $ref: '#/components/responses/Forbidden'
516
+ '404':
517
+ $ref: '#/components/responses/NotFound'
518
+ '503':
519
+ $ref: '#/components/responses/Unavailable'
494
520
  /payments/{payment_id}/quotes:
495
521
  parameters:
496
522
  - $ref: '#/components/parameters/payment_id'
@@ -1861,6 +1887,46 @@ components:
1861
1887
  - scale
1862
1888
  additionalProperties: false
1863
1889
  description: The asset registry confirms scale. USDC 10.00 is amount_atomic="10000000", scale=6.
1890
+ PaymentReceipt:
1891
+ type: object
1892
+ required: [payment_id, availability, confirmed_received]
1893
+ additionalProperties: false
1894
+ properties:
1895
+ payment_id: { type: string, format: uuid }
1896
+ availability:
1897
+ type: string
1898
+ enum: [available, unavailable]
1899
+ description: Available allows an empty array when no current finalized deposit remains.
1900
+ confirmed_received:
1901
+ type: array
1902
+ items:
1903
+ $ref: '#/components/schemas/ConfirmedReceiptTotal'
1904
+ ConfirmedReceiptTotal:
1905
+ type: object
1906
+ required: [asset, amount_atomic, scale, symbol, network_id, network_name, last_confirmed_at]
1907
+ additionalProperties: false
1908
+ properties:
1909
+ asset:
1910
+ type: string
1911
+ minLength: 1
1912
+ maxLength: 160
1913
+ amount_atomic:
1914
+ type: string
1915
+ description: Positive sum of finalized deposits, in the asset minor unit.
1916
+ pattern: ^[1-9][0-9]*$
1917
+ scale: { type: integer, minimum: 0, maximum: 36 }
1918
+ symbol:
1919
+ type: [string, 'null']
1920
+ network_id:
1921
+ anyOf:
1922
+ - $ref: '#/components/schemas/ChainNetworkId'
1923
+ - type: 'null'
1924
+ network_name:
1925
+ type: [string, 'null']
1926
+ last_confirmed_at:
1927
+ type: [string, 'null']
1928
+ format: date-time
1929
+ description: Canonical chain timestamp of the latest included deposit.
1864
1930
  NonNegativeMoney:
1865
1931
  type: object
1866
1932
  properties:
@@ -108,6 +108,11 @@ export declare class ZeroToOnePayClient {
108
108
  updated_at: string;
109
109
  resource_version: number;
110
110
  }>;
111
+ getPaymentReceipt(payment_id: string): Promise<{
112
+ payment_id: string;
113
+ availability: "available" | "unavailable";
114
+ confirmed_received: components["schemas"]["ConfirmedReceiptTotal"][];
115
+ }>;
111
116
  createQuote(payment_id: string, body: Schema<'CreateQuote'>, idempotencyKey: string): Promise<{
112
117
  merchant_id: string;
113
118
  project_id: string;
@@ -164,6 +164,9 @@ export class ZeroToOnePayClient {
164
164
  getPayment(payment_id) {
165
165
  return this.call('getPayment', { path: { payment_id } });
166
166
  }
167
+ getPaymentReceipt(payment_id) {
168
+ return this.call('getPaymentReceipt', { path: { payment_id } });
169
+ }
167
170
  createQuote(payment_id, body, idempotencyKey) {
168
171
  return this.call('createQuote', { path: { payment_id }, body, idempotencyKey });
169
172
  }
@@ -272,6 +272,28 @@ export interface paths {
272
272
  patch?: never;
273
273
  trace?: never;
274
274
  };
275
+ "/payments/{payment_id}/receipt": {
276
+ parameters: {
277
+ query?: never;
278
+ header?: never;
279
+ path: {
280
+ payment_id: components["parameters"]["payment_id"];
281
+ };
282
+ cookie?: never;
283
+ };
284
+ /**
285
+ * Read the confirmed funds received for a payment
286
+ * @description Returns current finalized on-chain funds linked to this payment's bound quote recipients, grouped by exact token and network. Confirmed reversals, refunds, and dispute adjustments are deducted. These are deposits to the order's recipients and do not establish payer identity or eligibility for fulfillment. Historical payments without canonical receipt data are reported as unavailable.
287
+ */
288
+ get: operations["getPaymentReceipt"];
289
+ put?: never;
290
+ post?: never;
291
+ delete?: never;
292
+ options?: never;
293
+ head?: never;
294
+ patch?: never;
295
+ trace?: never;
296
+ };
275
297
  "/payments/{payment_id}/quotes": {
276
298
  parameters: {
277
299
  query?: never;
@@ -852,6 +874,30 @@ export interface components {
852
874
  amount_atomic: string;
853
875
  scale: number;
854
876
  };
877
+ PaymentReceipt: {
878
+ /** Format: uuid */
879
+ payment_id: string;
880
+ /**
881
+ * @description Available allows an empty array when no current finalized deposit remains.
882
+ * @enum {string}
883
+ */
884
+ availability: "available" | "unavailable";
885
+ confirmed_received: components["schemas"]["ConfirmedReceiptTotal"][];
886
+ };
887
+ ConfirmedReceiptTotal: {
888
+ asset: string;
889
+ /** @description Positive sum of finalized deposits, in the asset minor unit. */
890
+ amount_atomic: string;
891
+ scale: number;
892
+ symbol: string | null;
893
+ network_id: components["schemas"]["ChainNetworkId"] | null;
894
+ network_name: string | null;
895
+ /**
896
+ * Format: date-time
897
+ * @description Canonical chain timestamp of the latest included deposit.
898
+ */
899
+ last_confirmed_at: string | null;
900
+ };
855
901
  NonNegativeMoney: {
856
902
  asset: string;
857
903
  amount_atomic: string;
@@ -2118,6 +2164,33 @@ export interface operations {
2118
2164
  503: components["responses"]["Unavailable"];
2119
2165
  };
2120
2166
  };
2167
+ getPaymentReceipt: {
2168
+ parameters: {
2169
+ query?: never;
2170
+ header?: never;
2171
+ path: {
2172
+ payment_id: components["parameters"]["payment_id"];
2173
+ };
2174
+ cookie?: never;
2175
+ };
2176
+ requestBody?: never;
2177
+ responses: {
2178
+ /** @description Successful scoped receipt response. */
2179
+ 200: {
2180
+ headers: {
2181
+ [name: string]: unknown;
2182
+ };
2183
+ content: {
2184
+ "application/json": components["schemas"]["PaymentReceipt"];
2185
+ };
2186
+ };
2187
+ 400: components["responses"]["BadRequest"];
2188
+ 401: components["responses"]["Unauthorized"];
2189
+ 403: components["responses"]["Forbidden"];
2190
+ 404: components["responses"]["NotFound"];
2191
+ 503: components["responses"]["Unavailable"];
2192
+ };
2193
+ };
2121
2194
  createQuote: {
2122
2195
  parameters: {
2123
2196
  query?: never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0to1pay/server-sdk",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Server-only 0to1Pay client for direct on-chain stablecoin checkout and fulfillment",