@0to1pay/server-sdk 2.3.1 → 3.1.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/README.md CHANGED
@@ -3,11 +3,11 @@
3
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.3.1
6
+ npm install @0to1pay/server-sdk@3.1.0
7
7
  ```
8
8
 
9
9
  ```sh
10
- npm install ./0to1pay-server-sdk-2.3.1.tgz
10
+ npm install ./0to1pay-server-sdk-3.1.0.tgz
11
11
  ```
12
12
 
13
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.
@@ -34,15 +34,15 @@ Use `call` for the full merchant API. Use the same idempotency key when retrying
34
34
 
35
35
  Call `listChainAssets` for the assets enabled in the key's environment. The platform can offer a subset of the live combinations. Register a scoped chain connection and its merchant-owned recipient addresses through `createChainConnection` and `registerChainRecipients`. Create a payment using `policy_ref: 'digital_goods_standard_v1'` and a price in `stable:USDC` or `stable:USDT` with scale `6`. Ten USDC uses `{ asset: 'stable:USDC', amount_atomic: '10000000', scale: 6 }`. The atomic amount must be positive and below `2^64`. Every connection in `allowed_connections` must support the selected price denomination.
36
36
 
37
- When Platform enables Base Sepolia, a Sandbox key can discover test USDC at `eip155:84532`. An empty test asset list means the deployment has no test assets configured. Use a registered test connection, recipient, and webhook endpoint from the same project for a Sandbox checkout.
37
+ A Sandbox key can discover the test networks enabled on its Platform deployment. Ethereum Sepolia (`eip155:11155111`) and Base Sepolia (`eip155:84532`) offer test USDC, and TRON Nile (`tron:3448148188`) offers test USDT. An empty test asset list means the deployment has no test assets configured. Use a registered test connection, recipient, and webhook endpoint from the same project for a Sandbox checkout.
38
38
 
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.
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.
40
40
 
41
41
  ## Payment receipts
42
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.
43
+ The Platform must support `GET /v1/payments/{payment_id}/receipt`.
44
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"`.
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. Payments without canonical receipt data can return `availability: "unavailable"`.
46
46
 
47
47
  ## Buyer approval for on-chain checkout
48
48
 
@@ -55,8 +55,6 @@ The merchant backend authenticates the buyer and checks their access to the quot
55
55
 
56
56
  Use the wallet's UTF-8 message signing for the chain. Ethereum and Base use the EVM personal-message signature. TRON uses `signMessageV2`, which returns a `0x`-prefixed signature. EVM and TRON transaction hashes must contain 64 hexadecimal digits. The claim helper accepts `0x` or `0X` and normalizes to lowercase `0x`-prefixed hex. TRON also accepts bare hex.
57
57
 
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.
59
-
60
58
  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.
61
59
 
62
60
  ## Subscription and API request allowance
@@ -65,18 +63,12 @@ To integrate with billing directly, use a dedicated billing key on your server.
65
63
 
66
64
  Use the paid subscription flow to issue a live server key.
67
65
 
68
- 1. Call `listBillingPlans` and `getBillingSubscription` to read plan terms, available USDC networks and current request usage. Live USDC billing can use configured Ethereum or Base connections.
66
+ 1. Call `listBillingPlans` and `getBillingSubscription` to read plan terms, current request usage, and available collection networks. Each collection option identifies its token and network. Ethereum and Base collect USDC, and TRON collects USDT. Test deployments can enable Ethereum Sepolia, Base Sepolia, and TRON Nile.
69
67
  2. Call `createBillingInvoice` with a paid `plan_id`, wallet `payer_address` and an opaque `checkout_session_ref`. Choose an offered `network_id` or omit it for the default configured collector.
70
- 3. Sign the invoice intent, call `authorizeBillingInvoice`, then send the quoted USDC. Sign the transaction claim and call `submitBillingInvoice` with the same checkout session. Each mutation uses its own stable idempotency key.
68
+ 3. Sign the invoice intent, call `authorizeBillingInvoice`, then send the exact token and amount in the quote on its specified network. TRON wallets sign the intent and transaction claim using the TRON V2 message format. Sign the transaction claim and call `submitBillingInvoice` with the same checkout session. Each mutation uses its own stable idempotency key.
71
69
  4. Use `listBillingInvoices` to resume recent invoices and poll `getBillingInvoice` for a single invoice. During `reconciling`, wait for final reconciliation before paying again. An active invoice reflects verified payment and a current prepaid period. An early renewal can be scheduled for the end of the current period.
72
70
  5. Call `issueBillingKey` with `body: {}` and a stable idempotency key. Store the returned token on the server.
73
71
 
74
72
  The allowance counts admitted requests to metered endpoints, including idempotent replays. `API_REQUEST_LIMIT_REACHED` indicates the period's allowance is exhausted. Payment completion and fulfillment operations remain available to keys with the appropriate scopes.
75
73
 
76
- ## Upgrade from 1.x
77
-
78
- - Replace `createConnection`, `validateConnection`, and `rotateConnectionCredentials` with a watch-only `createChainConnection` and registered merchant-controlled recipients.
79
- - Replace `attachExternalAttempt` and `confirmAttempt` with a chain quote and buyer-authorized transaction claim. The `createAttempt` request has `connection_id` and `quote_id`, and returns `201` for the assigned chain attempt.
80
- - Use `getOperation` to inspect operation history. `recoverOperation` and `ingestProviderWebhook` are retired. Merchant fulfillment still uses the signed outbound events handled by `@0to1pay/fulfillment-sdk`.
81
-
82
74
  The SDK is available under the MIT license. See the `LICENSE` file included in the package.
@@ -5,7 +5,7 @@ info:
5
5
  version: 1.0.0-design
6
6
  description: 'Seller API for USDC and USDT payments on supported networks and verified order fulfillment.
7
7
  Resource IDs are UUID strings. Merchant API keys are scoped to a merchant, project and environment.
8
- Historical fiat records are available through read endpoints.'
8
+ Payments settle in USDC or USDT on supported networks.'
9
9
  servers:
10
10
  - url: /v1
11
11
  description: Use the origin that serves the OpenAPI document.
@@ -30,8 +30,8 @@ paths:
30
30
  tags: [Billing]
31
31
  x-required-scope: billing:read
32
32
  description: >
33
- Plan prices, included API requests, and configured USDC collection options with available recipients.
34
- Live collection options use Ethereum or Base connections. Paid periods last 30 days.
33
+ Plan prices, included API requests, and available subscription collection options for USDC on Ethereum or Base and USDT on TRON.
34
+ Paid periods last 30 days.
35
35
  responses:
36
36
  '200':
37
37
  description: Successful scoped billing response.
@@ -87,10 +87,10 @@ paths:
87
87
  $ref: '#/components/responses/Unavailable'
88
88
  post:
89
89
  operationId: createBillingInvoice
90
- summary: Create a USDC subscription invoice and payer challenge
90
+ summary: Create a stablecoin subscription invoice and payer challenge
91
91
  tags: [Billing]
92
92
  x-required-scope: billing:write
93
- description: Select an offered USDC network with network_id, or omit it for the configured default. The server snapshots the selected plan terms and network.
93
+ description: Select an offered collection network with network_id, or omit it for the configured default. The selected network determines the six-decimal settlement asset. The invoice records the asset, amount and plan terms.
94
94
  parameters:
95
95
  - $ref: '#/components/parameters/IdempotencyKey'
96
96
  requestBody:
@@ -293,7 +293,7 @@ paths:
293
293
  description: >
294
294
  Live checkout supports Ethereum native USDC and USDT, TRON USDT, and Base native USDC.
295
295
  Only configured networks in the caller's environment are returned.
296
- Base Sepolia's test USDC can appear for Sandbox keys when the deployment enables it.
296
+ Sandbox keys can discover test USDC on Ethereum Sepolia and Base Sepolia and test USDT on TRON Nile when enabled.
297
297
  tags: [Connections]
298
298
  x-required-scope: payments:read
299
299
  responses:
@@ -499,7 +499,7 @@ paths:
499
499
  summary: Read the confirmed funds received for a payment
500
500
  tags: [Payments]
501
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.
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. Payments without canonical receipt data are reported as unavailable.
503
503
  responses:
504
504
  '200':
505
505
  description: Successful scoped receipt response.
@@ -1024,7 +1024,7 @@ paths:
1024
1024
  /connections:
1025
1025
  get:
1026
1026
  operationId: listConnections
1027
- summary: List chain connections and historical connection records
1027
+ summary: List chain connections
1028
1028
  tags:
1029
1029
  - Connections
1030
1030
  x-required-scope: connections:read
@@ -1708,32 +1708,31 @@ components:
1708
1708
  pattern: '^0x[0-9a-fA-F]{64}$'
1709
1709
  ChainSelectorId:
1710
1710
  type: integer
1711
- enum: [1, 999, 8453, 84532, 42161, 31337, 31338, 31339, 31340, 900001, 900002, 728126428, 900003]
1712
- description: EVM or TRON chain ID, or a local or Solana selector. Use network_id for the network reference.
1711
+ enum: [1, 8453, 84532, 11155111, 31337, 31339, 728126428, 3448148188, 900003]
1712
+ description: Supported EVM or TRON chain selector. Use network_id for the network reference.
1713
1713
  ChainNetworkId:
1714
1714
  type: string
1715
- pattern: '^(eip155:[1-9][0-9]*|solana:[1-9A-HJ-NP-Za-km-z]{32}|tron:(728126428|900003|0x2b6653dc))$'
1715
+ pattern: '^(eip155:(1|8453|84532|11155111|31337|31339)|tron:(728126428|3448148188|900003|0x2b6653dc))$'
1716
1716
  description: Decimal TRON identifiers are emitted. The hexadecimal TRON mainnet alias is accepted on connection creation.
1717
1717
  ChainFamily:
1718
1718
  type: string
1719
- enum: [evm, solana, tron]
1719
+ enum: [evm, tron]
1720
1720
  StableDenomination:
1721
1721
  type: string
1722
1722
  enum: ['stable:USDC', 'stable:USDT']
1723
1723
  description: Order denomination, expressed in six decimal places.
1724
1724
  ChainTokenSymbol:
1725
1725
  type: string
1726
- enum: [USDC, USDT, USDT0]
1727
- description: Display ticker. USDT0 is the ASCII display spelling of USD₮0.
1726
+ enum: [USDC, USDT]
1728
1727
  ChainAssetRepresentation:
1729
1728
  type: string
1730
- enum: [native, usdt0, standard_bridge, fixture]
1731
- description: Token deployment type. Historical quotes can include USDT0 or a Standard Bridge token. New live quotes use native tokens.
1729
+ enum: [native, fixture]
1730
+ description: Native tokens are used for live checkout.
1732
1731
  ChainAddress:
1733
1732
  oneOf:
1734
1733
  - $ref: '#/components/schemas/EvmAddress'
1735
1734
  - type: string
1736
- pattern: '^[1-9A-HJ-NP-Za-km-z]{32,44}$'
1735
+ pattern: '^T[1-9A-HJ-NP-Za-km-z]{33}$'
1737
1736
  ChainQuoteTerms:
1738
1737
  type: object
1739
1738
  additionalProperties: false
@@ -1753,12 +1752,10 @@ components:
1753
1752
  $ref: '#/components/schemas/ChainAssetRepresentation'
1754
1753
  token_address:
1755
1754
  $ref: '#/components/schemas/ChainAddress'
1756
- recipient_owner:
1757
- $ref: '#/components/schemas/ChainAddress'
1758
1755
  start_block:
1759
1756
  type: string
1760
1757
  pattern: '^[1-9][0-9]{0,18}$'
1761
- description: First block or slot eligible for observation.
1758
+ description: First block eligible for observation.
1762
1759
  anchor_hash:
1763
1760
  $ref: '#/components/schemas/EvmHash'
1764
1761
  starts_at_epoch:
@@ -1827,7 +1824,7 @@ components:
1827
1824
  properties:
1828
1825
  denomination:
1829
1826
  $ref: '#/components/schemas/StableDenomination'
1830
- description: Determines the denomination for recipient registration. Omission selects USDC on EVM and Solana or USDT on TRON. EVM recipients are shared before a quote is assigned.
1827
+ description: Determines the denomination for recipient registration. Omission selects USDC on EVM or USDT on TRON. EVM recipients are shared before a quote is assigned.
1831
1828
  recipients:
1832
1829
  type: array
1833
1830
  minItems: 1
@@ -1839,12 +1836,12 @@ components:
1839
1836
  properties:
1840
1837
  address:
1841
1838
  $ref: '#/components/schemas/ChainAddress'
1842
- description: Seller wallet address. On Solana the service derives the associated token account for the selected mint.
1839
+ description: Seller wallet address.
1843
1840
  signature:
1844
1841
  type: string
1845
1842
  writeOnly: true
1846
- pattern: '^0x[0-9a-fA-F]{128}([0-9a-fA-F]{2})?$'
1847
- description: Scoped EIP-191 proof on EVM, TIP-191 personal proof on TRON, or Ed25519 proof on Solana, encoded as hex.
1843
+ pattern: '^0x[0-9a-fA-F]{130}$'
1844
+ description: Scoped EIP-191 proof on EVM or TIP-191 personal proof on TRON, encoded as hex.
1848
1845
  ChainRecipients:
1849
1846
  type: object
1850
1847
  additionalProperties: false
@@ -1859,10 +1856,9 @@ components:
1859
1856
  $ref: '#/components/schemas/ChainNetworkId'
1860
1857
  denomination:
1861
1858
  $ref: '#/components/schemas/StableDenomination'
1862
- description: Solana denomination for these mint-specific addresses.
1863
1859
  addresses:
1864
1860
  type: array
1865
- description: Address pool entries. On Solana these are associated token accounts for the selected mint.
1861
+ description: Registered wallet addresses.
1866
1862
  items:
1867
1863
  $ref: '#/components/schemas/ChainAddress'
1868
1864
  Money:
@@ -1870,7 +1866,7 @@ components:
1870
1866
  properties:
1871
1867
  asset:
1872
1868
  type: string
1873
- description: A stablecoin denomination or exact registered chain asset. Historical responses may contain fiat prices.
1869
+ description: A stablecoin denomination or exact registered chain asset.
1874
1870
  minLength: 1
1875
1871
  maxLength: 160
1876
1872
  amount_atomic:
@@ -2420,10 +2416,6 @@ components:
2420
2416
  type:
2421
2417
  type: string
2422
2418
  enum:
2423
- - checkout_session
2424
- - payment_intent
2425
- - paypal_order
2426
- - paypal_capture
2427
2419
  - chain_transaction
2428
2420
  id:
2429
2421
  type: string
@@ -2468,8 +2460,6 @@ components:
2468
2460
  $ref: '#/components/schemas/ChainTokenSymbol'
2469
2461
  representation:
2470
2462
  $ref: '#/components/schemas/ChainAssetRepresentation'
2471
- recipient_owner:
2472
- $ref: '#/components/schemas/ChainAddress'
2473
2463
  starts_at_epoch:
2474
2464
  type: integer
2475
2465
  minimum: 1
@@ -2630,7 +2620,7 @@ components:
2630
2620
  - resource_version
2631
2621
  additionalProperties: false
2632
2622
  description: A transfer instruction identifies the registered asset and assigned recipient for an unfinished quote.
2633
- The Worker verifies funds from finalized chain evidence. Historical fiat attempts return no action.
2623
+ The Worker verifies funds from finalized chain evidence. The transfer instruction is available while the quote can accept payment.
2634
2624
  allOf:
2635
2625
  - if:
2636
2626
  properties:
@@ -2743,7 +2733,7 @@ components:
2743
2733
  type: object
2744
2734
  properties:
2745
2735
  asset:
2746
- const: stable:USDC
2736
+ $ref: '#/components/schemas/StableDenomination'
2747
2737
  amount_atomic:
2748
2738
  type: string
2749
2739
  pattern: '^(0|[1-9][0-9]{0,19})$'
@@ -2760,6 +2750,12 @@ components:
2760
2750
  $ref: '#/components/schemas/Environment'
2761
2751
  price:
2762
2752
  $ref: '#/components/schemas/BillingPrice'
2753
+ description: The plan's reference price in USDC.
2754
+ prices:
2755
+ type: array
2756
+ description: Fixed nominal prices in each supported subscription asset. Availability depends on collection_options.
2757
+ items:
2758
+ $ref: '#/components/schemas/BillingPrice'
2763
2759
  request_limit:
2764
2760
  type: integer
2765
2761
  minimum: 1
@@ -2767,7 +2763,7 @@ components:
2767
2763
  type: [integer, 'null']
2768
2764
  enum: [30, null]
2769
2765
  description: The free test plan uses UTC calendar months.
2770
- required: [plan_id, environment, price, request_limit, period_days]
2766
+ required: [plan_id, environment, price, prices, request_limit, period_days]
2771
2767
  additionalProperties: false
2772
2768
  BillingPlans:
2773
2769
  type: object
@@ -2778,7 +2774,7 @@ components:
2778
2774
  $ref: '#/components/schemas/BillingPlan'
2779
2775
  collection_options:
2780
2776
  type: array
2781
- description: Currently offered USDC networks. Existing servers may omit this field.
2777
+ description: Currently offered collection networks and settlement assets with available recipients.
2782
2778
  items:
2783
2779
  $ref: '#/components/schemas/BillingCollectionOption'
2784
2780
  required: [plans]
@@ -2791,11 +2787,14 @@ components:
2791
2787
  network_name:
2792
2788
  type: string
2793
2789
  family:
2794
- type: string
2795
- enum: [evm, solana]
2790
+ $ref: '#/components/schemas/ChainFamily'
2791
+ asset:
2792
+ $ref: '#/components/schemas/StableDenomination'
2793
+ scale:
2794
+ const: 6
2796
2795
  is_default:
2797
2796
  type: boolean
2798
- required: [network_id, network_name, family, is_default]
2797
+ required: [network_id, network_name, family, asset, scale, is_default]
2799
2798
  additionalProperties: false
2800
2799
  BillingSubscription:
2801
2800
  type: object
@@ -2834,7 +2833,7 @@ components:
2834
2833
  $ref: '#/components/schemas/ChainCheckoutSessionRef'
2835
2834
  network_id:
2836
2835
  $ref: '#/components/schemas/ChainNetworkId'
2837
- description: USDC collection network offered in BillingPlans. The deployment's default connection is used when omitted.
2836
+ description: Collection network offered in BillingPlans. Ethereum and Base settle in USDC, TRON settles in USDT. The default connection is used when omitted.
2838
2837
  required: [plan_id, payer_address, checkout_session_ref]
2839
2838
  additionalProperties: false
2840
2839
  BillingInvoice:
@@ -2851,6 +2850,8 @@ components:
2851
2850
  type: string
2852
2851
  enum: [pending, reconciling, active, scheduled, expired, revoked]
2853
2852
  description: Reconciling means a wallet-authorized invoice still awaits final reconciliation after transaction submission or quote expiry. Resume that invoice and wait before paying another one.
2853
+ price:
2854
+ $ref: '#/components/schemas/BillingPrice'
2854
2855
  quote:
2855
2856
  $ref: '#/components/schemas/Quote'
2856
2857
  intent:
@@ -2861,7 +2862,7 @@ components:
2861
2862
  period_end:
2862
2863
  type: [string, 'null']
2863
2864
  format: date-time
2864
- required: [invoice_id, plan_id, environment, status, quote, intent, period_start, period_end]
2865
+ required: [invoice_id, plan_id, environment, status, price, quote, intent, period_start, period_end]
2865
2866
  additionalProperties: false
2866
2867
  BillingInvoiceList:
2867
2868
  type: object
@@ -2905,12 +2906,12 @@ components:
2905
2906
  description: Stable opaque reference assigned by the merchant server to the authenticated buyer checkout.
2906
2907
  ChainIntentSignature:
2907
2908
  type: string
2908
- pattern: '^0x(?:[0-9A-Fa-f]{128}|[0-9A-Fa-f]{130})$'
2909
- description: Use a 0x-prefixed wallet signature. Encode raw Solana Ed25519 signature bytes as hex.
2909
+ pattern: '^0x[0-9A-Fa-f]{130}$'
2910
+ description: A 0x-prefixed 65-byte wallet signature.
2910
2911
  ChainIntentTransactionId:
2911
2912
  type: string
2912
- pattern: '^(0x[0-9A-Fa-f]{64}|[0-9A-Fa-f]{64}|[1-9A-HJ-NP-Za-km-z]{64,88})$'
2913
- description: EVM and TRON IDs are canonicalized to lowercase 0x-prefixed hex. TRON accepts bare hex. Solana signatures remain case-sensitive base58.
2913
+ pattern: '^(0x)?[0-9A-Fa-f]{64}$'
2914
+ description: EVM and TRON IDs are canonicalized to lowercase 0x-prefixed hex. TRON accepts bare hex.
2914
2915
  CreateChainIntent:
2915
2916
  type: object
2916
2917
  properties:
@@ -3144,10 +3145,7 @@ components:
3144
3145
  provider:
3145
3146
  type: string
3146
3147
  enum:
3147
- - stripe
3148
- - paypal
3149
3148
  - evm
3150
- - solana
3151
3149
  - tron
3152
3150
  chain_id:
3153
3151
  $ref: '#/components/schemas/ChainSelectorId'
@@ -3186,9 +3184,6 @@ components:
3186
3184
  format: uri
3187
3185
  minItems: 0
3188
3186
  maxItems: 1000
3189
- webhook_url:
3190
- description: Retained for historical reads.
3191
- type: 'null'
3192
3187
  validated_at:
3193
3188
  anyOf:
3194
3189
  - type: string
@@ -3218,13 +3213,12 @@ components:
3218
3213
  - status
3219
3214
  - capabilities
3220
3215
  - return_origins
3221
- - webhook_url
3222
3216
  - validated_at
3223
3217
  - created_at
3224
3218
  - updated_at
3225
3219
  - resource_version
3226
3220
  additionalProperties: false
3227
- description: Ready chain connections can be used for new payments. Historical connection records remain available for reads.
3221
+ description: Ready chain connections can be used for new payments.
3228
3222
  allOf:
3229
3223
  - if:
3230
3224
  properties:
@@ -198,6 +198,5 @@ export declare class ZeroToOnePayClient {
198
198
  })>;
199
199
  }
200
200
  export { recipientProofMessage, type RecipientProof } from './recipient-proof.js';
201
- export { solanaRecipientProofMessage } from './solana-recipient-proof.js';
202
201
  export { tronRecipientProofMessage } from './tron-recipient-proof.js';
203
202
  export { ZeroToOnePayClient as PaymentToFulfillmentClient, ZeroToOnePayContractError as PaymentToFulfillmentContractError, ZeroToOnePayError as PaymentToFulfillmentError, type ZeroToOnePayClientOptions as PaymentToFulfillmentClientOptions, };
@@ -14,29 +14,13 @@ for (const [path, item] of Object.entries(spec.paths)) {
14
14
  const keyPattern = /^[A-Za-z0-9._:-]{16,128}$/;
15
15
  const hexTransactionId = /^0x[0-9a-f]{64}$/i;
16
16
  const tronTransactionId = /^(?:0x)?[0-9a-f]{64}$/i;
17
- const solanaTransactionId = /^[1-9A-HJ-NP-Za-km-z]{64,88}$/;
18
- const base58Alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
19
- function isSolanaTransactionId(value) {
20
- if (!solanaTransactionId.test(value))
21
- return false;
22
- const leadingZeroBytes = value.search(/[^1]/);
23
- if (leadingZeroBytes < 0 || leadingZeroBytes >= 64)
24
- return false;
25
- let decoded = 0n;
26
- for (const digit of value.slice(leadingZeroBytes)) {
27
- decoded = decoded * 58n + BigInt(base58Alphabet.indexOf(digit));
28
- }
29
- const limit = 1n << BigInt((64 - leadingZeroBytes) * 8);
30
- return decoded >= (limit >> 8n) && decoded < limit;
31
- }
32
17
  /** Return the exact UTF-8 message the approved payer signs after broadcasting. */
33
18
  export function chainIntentClaimMessage(intent, transactionId) {
34
- const valid = intent.family === 'solana' ? isSolanaTransactionId(transactionId) :
35
- { evm: hexTransactionId, tron: tronTransactionId }[intent.family]?.test(transactionId);
36
- if (!valid)
19
+ const pattern = intent.family === 'evm' ? hexTransactionId
20
+ : intent.family === 'tron' ? tronTransactionId : undefined;
21
+ if (!pattern?.test(transactionId))
37
22
  throw new Error('Invalid chain transaction ID');
38
- const canonical = intent.family === 'solana' ? transactionId :
39
- '0x' + transactionId.replace(/^0x/i, '').toLowerCase();
23
+ const canonical = '0x' + transactionId.replace(/^0x/i, '').toLowerCase();
40
24
  return intent.signing_message + '\nTransaction: ' + canonical;
41
25
  }
42
26
  export class ZeroToOnePayError extends Error {
@@ -190,7 +174,6 @@ export class ZeroToOnePayClient {
190
174
  }
191
175
  }
192
176
  export { recipientProofMessage } from './recipient-proof.js';
193
- export { solanaRecipientProofMessage } from './solana-recipient-proof.js';
194
177
  export { tronRecipientProofMessage } from './tron-recipient-proof.js';
195
178
  // Keep the SDK exports used by existing merchant integrations.
196
179
  export { ZeroToOnePayClient as PaymentToFulfillmentClient, ZeroToOnePayContractError as PaymentToFulfillmentContractError, ZeroToOnePayError as PaymentToFulfillmentError, };
@@ -12,7 +12,7 @@ export interface paths {
12
12
  };
13
13
  /**
14
14
  * List request plans and subscription prices
15
- * @description Plan prices, included API requests, and configured USDC collection options with available recipients. Live collection options use Ethereum or Base connections. Paid periods last 30 days.
15
+ * @description Plan prices, included API requests, and available subscription collection options for USDC on Ethereum or Base and USDT on TRON. Paid periods last 30 days.
16
16
  */
17
17
  get: operations["listBillingPlans"];
18
18
  put?: never;
@@ -57,8 +57,8 @@ export interface paths {
57
57
  get: operations["listBillingInvoices"];
58
58
  put?: never;
59
59
  /**
60
- * Create a USDC subscription invoice and payer challenge
61
- * @description Select an offered USDC network with network_id, or omit it for the configured default. The server snapshots the selected plan terms and network.
60
+ * Create a stablecoin subscription invoice and payer challenge
61
+ * @description Select an offered collection network with network_id, or omit it for the configured default. The selected network determines the six-decimal settlement asset. The invoice records the asset, amount and plan terms.
62
62
  */
63
63
  post: operations["createBillingInvoice"];
64
64
  delete?: never;
@@ -182,7 +182,7 @@ export interface paths {
182
182
  };
183
183
  /**
184
184
  * List supported USDC and USDT deployments on configured networks
185
- * @description Live checkout supports Ethereum native USDC and USDT, TRON USDT, and Base native USDC. Only configured networks in the caller's environment are returned. Base Sepolia's test USDC can appear for Sandbox keys when the deployment enables it.
185
+ * @description Live checkout supports Ethereum native USDC and USDT, TRON USDT, and Base native USDC. Only configured networks in the caller's environment are returned. Sandbox keys can discover test USDC on Ethereum Sepolia and Base Sepolia and test USDT on TRON Nile when enabled.
186
186
  */
187
187
  get: operations["listChainAssets"];
188
188
  put?: never;
@@ -283,7 +283,7 @@ export interface paths {
283
283
  };
284
284
  /**
285
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.
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. Payments without canonical receipt data are reported as unavailable.
287
287
  */
288
288
  get: operations["getPaymentReceipt"];
289
289
  put?: never;
@@ -537,7 +537,7 @@ export interface paths {
537
537
  path?: never;
538
538
  cookie?: never;
539
539
  };
540
- /** List chain connections and historical connection records */
540
+ /** List chain connections */
541
541
  get: operations["listConnections"];
542
542
  put?: never;
543
543
  post?: never;
@@ -784,29 +784,26 @@ export interface components {
784
784
  EvmAddress: string;
785
785
  EvmHash: string;
786
786
  /**
787
- * @description EVM or TRON chain ID, or a local or Solana selector. Use network_id for the network reference.
787
+ * @description Supported EVM or TRON chain selector. Use network_id for the network reference.
788
788
  * @enum {integer}
789
789
  */
790
- ChainSelectorId: 1 | 999 | 8453 | 84532 | 42161 | 31337 | 31338 | 31339 | 31340 | 900001 | 900002 | 728126428 | 900003;
790
+ ChainSelectorId: 1 | 8453 | 84532 | 11155111 | 31337 | 31339 | 728126428 | 3448148188 | 900003;
791
791
  /** @description Decimal TRON identifiers are emitted. The hexadecimal TRON mainnet alias is accepted on connection creation. */
792
792
  ChainNetworkId: string;
793
793
  /** @enum {string} */
794
- ChainFamily: "evm" | "solana" | "tron";
794
+ ChainFamily: "evm" | "tron";
795
795
  /**
796
796
  * @description Order denomination, expressed in six decimal places.
797
797
  * @enum {string}
798
798
  */
799
799
  StableDenomination: "stable:USDC" | "stable:USDT";
800
+ /** @enum {string} */
801
+ ChainTokenSymbol: "USDC" | "USDT";
800
802
  /**
801
- * @description Display ticker. USDT0 is the ASCII display spelling of USD₮0.
802
- * @enum {string}
803
- */
804
- ChainTokenSymbol: "USDC" | "USDT" | "USDT0";
805
- /**
806
- * @description Token deployment type. Historical quotes can include USDT0 or a Standard Bridge token. New live quotes use native tokens.
803
+ * @description Native tokens are used for live checkout.
807
804
  * @enum {string}
808
805
  */
809
- ChainAssetRepresentation: "native" | "usdt0" | "standard_bridge" | "fixture";
806
+ ChainAssetRepresentation: "native" | "fixture";
810
807
  ChainAddress: components["schemas"]["EvmAddress"] | string;
811
808
  ChainQuoteTerms: {
812
809
  chain_id: components["schemas"]["ChainSelectorId"];
@@ -816,8 +813,7 @@ export interface components {
816
813
  symbol?: components["schemas"]["ChainTokenSymbol"];
817
814
  representation?: components["schemas"]["ChainAssetRepresentation"];
818
815
  token_address: components["schemas"]["ChainAddress"];
819
- recipient_owner?: components["schemas"]["ChainAddress"];
820
- /** @description First block or slot eligible for observation. */
816
+ /** @description First block eligible for observation. */
821
817
  start_block: string;
822
818
  anchor_hash: components["schemas"]["EvmHash"];
823
819
  /** @description Earliest eligible transfer time, as a UTC Unix timestamp in seconds. */
@@ -847,12 +843,12 @@ export interface components {
847
843
  network_id?: components["schemas"]["ChainNetworkId"];
848
844
  } & (unknown | unknown);
849
845
  RegisterChainRecipients: {
850
- /** @description Determines the denomination for recipient registration. Omission selects USDC on EVM and Solana or USDT on TRON. EVM recipients are shared before a quote is assigned. */
846
+ /** @description Determines the denomination for recipient registration. Omission selects USDC on EVM or USDT on TRON. EVM recipients are shared before a quote is assigned. */
851
847
  denomination?: components["schemas"]["StableDenomination"];
852
848
  recipients: {
853
- /** @description Seller wallet address. On Solana the service derives the associated token account for the selected mint. */
849
+ /** @description Seller wallet address. */
854
850
  address: components["schemas"]["ChainAddress"];
855
- /** @description Scoped EIP-191 proof on EVM, TIP-191 personal proof on TRON, or Ed25519 proof on Solana, encoded as hex. */
851
+ /** @description Scoped EIP-191 proof on EVM or TIP-191 personal proof on TRON, encoded as hex. */
856
852
  signature: string;
857
853
  }[];
858
854
  };
@@ -861,14 +857,13 @@ export interface components {
861
857
  connection_id: string;
862
858
  chain_id: components["schemas"]["ChainSelectorId"];
863
859
  network_id?: components["schemas"]["ChainNetworkId"];
864
- /** @description Solana denomination for these mint-specific addresses. */
865
860
  denomination?: components["schemas"]["StableDenomination"];
866
- /** @description Address pool entries. On Solana these are associated token accounts for the selected mint. */
861
+ /** @description Registered wallet addresses. */
867
862
  addresses: components["schemas"]["ChainAddress"][];
868
863
  };
869
864
  /** @description The asset registry confirms scale. USDC 10.00 is amount_atomic="10000000", scale=6. */
870
865
  Money: {
871
- /** @description A stablecoin denomination or exact registered chain asset. Historical responses may contain fiat prices. */
866
+ /** @description A stablecoin denomination or exact registered chain asset. */
872
867
  asset: string;
873
868
  /** @description Positive integer in the asset minor unit; never a float. */
874
869
  amount_atomic: string;
@@ -1061,7 +1056,7 @@ export interface components {
1061
1056
  };
1062
1057
  ExternalResource: {
1063
1058
  /** @enum {string} */
1064
- type: "checkout_session" | "payment_intent" | "paypal_order" | "paypal_capture" | "chain_transaction";
1059
+ type: "chain_transaction";
1065
1060
  id: string;
1066
1061
  };
1067
1062
  CreateAttempt: {
@@ -1086,7 +1081,6 @@ export interface components {
1086
1081
  denomination?: components["schemas"]["StableDenomination"];
1087
1082
  symbol?: components["schemas"]["ChainTokenSymbol"];
1088
1083
  representation?: components["schemas"]["ChainAssetRepresentation"];
1089
- recipient_owner?: components["schemas"]["ChainAddress"];
1090
1084
  /** @description Earliest eligible transfer time, as a UTC Unix timestamp in seconds. */
1091
1085
  starts_at_epoch: number;
1092
1086
  /** Format: date-time */
@@ -1113,7 +1107,7 @@ export interface components {
1113
1107
  registered_at: string;
1114
1108
  verified_at: string | null;
1115
1109
  };
1116
- /** @description A transfer instruction identifies the registered asset and assigned recipient for an unfinished quote. The Worker verifies funds from finalized chain evidence. Historical fiat attempts return no action. */
1110
+ /** @description A transfer instruction identifies the registered asset and assigned recipient for an unfinished quote. The Worker verifies funds from finalized chain evidence. The transfer instruction is available while the quote can accept payment. */
1117
1111
  Attempt: {
1118
1112
  /** Format: uuid */
1119
1113
  merchant_id: string;
@@ -1175,8 +1169,7 @@ export interface components {
1175
1169
  /** @enum {string} */
1176
1170
  PaidBillingPlanId: "starter" | "growth" | "scale";
1177
1171
  BillingPrice: {
1178
- /** @constant */
1179
- asset: "stable:USDC";
1172
+ asset: components["schemas"]["StableDenomination"];
1180
1173
  amount_atomic: string;
1181
1174
  /** @constant */
1182
1175
  scale: 6;
@@ -1184,7 +1177,10 @@ export interface components {
1184
1177
  BillingPlan: {
1185
1178
  plan_id: components["schemas"]["BillingPlanId"];
1186
1179
  environment: components["schemas"]["Environment"];
1180
+ /** @description The plan's reference price in USDC. */
1187
1181
  price: components["schemas"]["BillingPrice"];
1182
+ /** @description Fixed nominal prices in each supported subscription asset. Availability depends on collection_options. */
1183
+ prices: components["schemas"]["BillingPrice"][];
1188
1184
  request_limit: number;
1189
1185
  /**
1190
1186
  * @description The free test plan uses UTC calendar months.
@@ -1194,14 +1190,16 @@ export interface components {
1194
1190
  };
1195
1191
  BillingPlans: {
1196
1192
  plans: components["schemas"]["BillingPlan"][];
1197
- /** @description Currently offered USDC networks. Existing servers may omit this field. */
1193
+ /** @description Currently offered collection networks and settlement assets with available recipients. */
1198
1194
  collection_options?: components["schemas"]["BillingCollectionOption"][];
1199
1195
  };
1200
1196
  BillingCollectionOption: {
1201
1197
  network_id: components["schemas"]["ChainNetworkId"];
1202
1198
  network_name: string;
1203
- /** @enum {string} */
1204
- family: "evm" | "solana";
1199
+ family: components["schemas"]["ChainFamily"];
1200
+ asset: components["schemas"]["StableDenomination"];
1201
+ /** @constant */
1202
+ scale: 6;
1205
1203
  is_default: boolean;
1206
1204
  };
1207
1205
  BillingSubscription: {
@@ -1220,7 +1218,7 @@ export interface components {
1220
1218
  plan_id: components["schemas"]["PaidBillingPlanId"];
1221
1219
  payer_address: components["schemas"]["ChainAddress"];
1222
1220
  checkout_session_ref: components["schemas"]["ChainCheckoutSessionRef"];
1223
- /** @description USDC collection network offered in BillingPlans. The deployment's default connection is used when omitted. */
1221
+ /** @description Collection network offered in BillingPlans. Ethereum and Base settle in USDC, TRON settles in USDT. The default connection is used when omitted. */
1224
1222
  network_id?: components["schemas"]["ChainNetworkId"];
1225
1223
  };
1226
1224
  BillingInvoice: {
@@ -1233,6 +1231,7 @@ export interface components {
1233
1231
  * @enum {string}
1234
1232
  */
1235
1233
  status: "pending" | "reconciling" | "active" | "scheduled" | "expired" | "revoked";
1234
+ price: components["schemas"]["BillingPrice"];
1236
1235
  quote: components["schemas"]["Quote"];
1237
1236
  intent: components["schemas"]["ChainIntent"];
1238
1237
  /** Format: date-time */
@@ -1257,9 +1256,9 @@ export interface components {
1257
1256
  };
1258
1257
  /** @description Stable opaque reference assigned by the merchant server to the authenticated buyer checkout. */
1259
1258
  ChainCheckoutSessionRef: string;
1260
- /** @description Use a 0x-prefixed wallet signature. Encode raw Solana Ed25519 signature bytes as hex. */
1259
+ /** @description A 0x-prefixed 65-byte wallet signature. */
1261
1260
  ChainIntentSignature: string;
1262
- /** @description EVM and TRON IDs are canonicalized to lowercase 0x-prefixed hex. TRON accepts bare hex. Solana signatures remain case-sensitive base58. */
1261
+ /** @description EVM and TRON IDs are canonicalized to lowercase 0x-prefixed hex. TRON accepts bare hex. */
1263
1262
  ChainIntentTransactionId: string;
1264
1263
  CreateChainIntent: {
1265
1264
  checkout_session_ref: components["schemas"]["ChainCheckoutSessionRef"];
@@ -1343,7 +1342,7 @@ export interface components {
1343
1342
  enforce_expiry: boolean;
1344
1343
  binding_methods: string[];
1345
1344
  };
1346
- /** @description Ready chain connections can be used for new payments. Historical connection records remain available for reads. */
1345
+ /** @description Ready chain connections can be used for new payments. */
1347
1346
  Connection: {
1348
1347
  /** Format: uuid */
1349
1348
  merchant_id: string;
@@ -1353,7 +1352,7 @@ export interface components {
1353
1352
  /** Format: uuid */
1354
1353
  connection_id: string;
1355
1354
  /** @enum {string} */
1356
- provider: "stripe" | "paypal" | "evm" | "solana" | "tron";
1355
+ provider: "evm" | "tron";
1357
1356
  chain_id?: components["schemas"]["ChainSelectorId"];
1358
1357
  network_id?: components["schemas"]["ChainNetworkId"];
1359
1358
  network_name?: string;
@@ -1367,8 +1366,6 @@ export interface components {
1367
1366
  status: "unvalidated" | "ready" | "disabled" | "error";
1368
1367
  capabilities: components["schemas"]["Capabilities"];
1369
1368
  return_origins: string[];
1370
- /** @description Retained for historical reads. */
1371
- webhook_url: null;
1372
1369
  validated_at: string | null;
1373
1370
  /** Format: date-time */
1374
1371
  created_at: string;
@@ -4,7 +4,7 @@ const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
4
4
  export function tronRecipientProofMessage(input) {
5
5
  const origin = new URL(input.origin);
6
6
  const validChain = input.environment === 'live' ? input.chain_id === 728126428 :
7
- input.environment === 'test' && input.chain_id === 900003;
7
+ input.environment === 'test' && (input.chain_id === 900003 || input.chain_id === 3448148188);
8
8
  if (!validChain || !['https:', 'http:'].includes(origin.protocol) || origin.origin !== input.origin ||
9
9
  ![input.merchant_id, input.project_id, input.connection_id].every(value => uuid.test(value)) || !address.test(input.address)) {
10
10
  throw new Error('INVALID_TRON_RECIPIENT_PROOF_SCOPE');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0to1pay/server-sdk",
3
- "version": "2.3.1",
3
+ "version": "3.1.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Server-only 0to1Pay client for direct on-chain stablecoin checkout and fulfillment",
@@ -1,3 +0,0 @@
1
- import type { RecipientProof } from './recipient-proof.js';
2
- /** Return the exact UTF-8 message a recipient's Solana wallet signs via signMessage. */
3
- export declare function solanaRecipientProofMessage(input: RecipientProof, denomination?: 'stable:USDC' | 'stable:USDT'): string;
@@ -1,28 +0,0 @@
1
- const publicKey = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
2
- const identifier = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
3
- /** Return the exact UTF-8 message a recipient's Solana wallet signs via signMessage. */
4
- export function solanaRecipientProofMessage(input, denomination = 'stable:USDC') {
5
- const origin = new URL(input.origin);
6
- const network = input.chain_id === 900001 ? 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp'
7
- : input.chain_id === 900002 ? 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1' : undefined;
8
- if (!network || !['https:', 'http:'].includes(origin.protocol) || origin.origin !== input.origin ||
9
- ![input.merchant_id, input.project_id, input.connection_id].every(value => identifier.test(value)) ||
10
- !['test', 'live'].includes(input.environment) || !publicKey.test(input.address) ||
11
- input.address === '11111111111111111111111111111111') {
12
- throw new Error('INVALID_SOLANA_RECIPIENT_PROOF_SCOPE');
13
- }
14
- if (denomination !== 'stable:USDC' && denomination !== 'stable:USDT')
15
- throw new Error('INVALID_SOLANA_RECIPIENT_PROOF_ASSET');
16
- return [
17
- denomination === 'stable:USDC' ? 'StablePay Solana recipient registration v1' : 'StablePay Solana recipient registration v2',
18
- `I authorize the use of my native ${denomination.slice('stable:'.length)} associated token account for one order on this StablePay connection.`,
19
- '',
20
- 'Origin: ' + origin.origin,
21
- 'Merchant: ' + input.merchant_id.toLowerCase(),
22
- 'Project: ' + input.project_id.toLowerCase(),
23
- 'Environment: ' + input.environment,
24
- 'Connection: ' + input.connection_id.toLowerCase(),
25
- 'Network: ' + network,
26
- 'Wallet: ' + input.address,
27
- ].join('\n');
28
- }