@cosmosapp/pay_sdk 2.2.1 → 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/CHANGELOG.md +17 -0
- package/README.md +61 -3
- package/dist/{chunk-OVFDKC5Z.js → chunk-B3HT6MCO.js} +3 -3
- package/dist/{chunk-OVFDKC5Z.js.map → chunk-B3HT6MCO.js.map} +1 -1
- package/dist/index.cjs +413 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +292 -10
- package/dist/index.d.ts +292 -10
- package/dist/index.js +409 -13
- package/dist/index.js.map +1 -1
- package/dist/{intent-input-GiCgpAWR.d.cts → intent-input-CP5bkBYI.d.cts} +659 -5
- package/dist/{intent-input-GiCgpAWR.d.ts → intent-input-CP5bkBYI.d.ts} +659 -5
- package/dist/web/index.cjs +1 -1
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +2 -2
- package/dist/web/index.d.ts +2 -2
- package/dist/web/index.js +2 -2
- package/llms/04-client.md +5 -3
- package/llms/07-webhooks.md +19 -3
- package/llms/08-products-customers.md +31 -4
- package/llms/09-analytics-health.md +31 -0
- package/llms/13-types-reference.md +26 -3
- package/llms/16-private-payments.md +77 -0
- package/llms/17-usdt0.md +82 -0
- package/llms/README.md +3 -2
- package/llms/llms-full.txt +277 -13
- package/llms/llms.txt +4 -2
- package/package.json +3 -3
package/llms/llms-full.txt
CHANGED
|
@@ -215,8 +215,10 @@ One client exposes every resource through its own manager.
|
|
|
215
215
|
| `client.paymentIntents` | Stellar SEP-7 intents | `createTx` · `createPay` · `fetch` · `list` · `update` · `delete` · `validate` |
|
|
216
216
|
| `client.webhooks` | Endpoints + deliveries + event listener | `create` · `list` · `fetch` · `update` · `delete` · `rotateSecret` · `ping` · `fetchDeliveries` · `redeliver` · `on(...)` · `process` · `createHandler` · `middleware` |
|
|
217
217
|
| `client.products` | Products / prices | `create` · `list` · `fetch` · `update` · `delete` |
|
|
218
|
-
| `client.customers` | Customers | `create` · `list` · `fetch` · `update` · `delete` |
|
|
219
|
-
| `client.
|
|
218
|
+
| `client.customers` | Customers and their wallets | `create` · `list` · `fetch` · `update` · `delete` · `addWallet` · `removeWallet` |
|
|
219
|
+
| `client.privatePayments` | Private payments (amounts hidden on-chain; Stellar Testnet for now) | `create` · `list` · `fetch` · `config` |
|
|
220
|
+
| `client.usdt0` | USDT0 from Stellar to EVM networks (LayerZero, mainnet only) | `routes` · `quote` · `create` · `list` · `fetch` · `submit` |
|
|
221
|
+
| `client.analytics` | Read-only metrics | `summary` · `series` · `balances` · `apiLogs` · `webhookLogs` |
|
|
220
222
|
| `client.health` | Liveness / readiness | `liveness` · `readiness` |
|
|
221
223
|
|
|
222
224
|
## Constructor options
|
|
@@ -251,7 +253,7 @@ client.setGatewayCredentials(secret, consumerUsername); // local-dev direct acce
|
|
|
251
253
|
|
|
252
254
|
## Returned objects are "structures"
|
|
253
255
|
|
|
254
|
-
Manager methods return rich instances (`PaymentIntent`, `WebhookEndpoint`,
|
|
256
|
+
Manager methods return rich instances (`PaymentIntent`, `PrivatePayment`, `Usdt0Transfer`, `WebhookEndpoint`,
|
|
255
257
|
`Product`, `Customer`) that can act on themselves and expose typed accessors —
|
|
256
258
|
e.g. `intent.isPay`, `intent.assetLabel`, `await intent.validate(txHash)`,
|
|
257
259
|
`await endpoint.disable()`. Call `.toJSON()` for the raw payload.
|
|
@@ -579,9 +581,25 @@ interface WebhookEvent {
|
|
|
579
581
|
}
|
|
580
582
|
```
|
|
581
583
|
|
|
582
|
-
Event types
|
|
583
|
-
|
|
584
|
-
`
|
|
584
|
+
Event types (`WebhookEventType`, the same list the API accepts in `eventTypes`):
|
|
585
|
+
|
|
586
|
+
- Payment intents: `PAYMENT_INTENT_CREATED`, `PAYMENT_INTENT_UPDATED`,
|
|
587
|
+
`PAYMENT_INTENT_SUCCEEDED`, `PAYMENT_INTENT_FAILED`, `PAYMENT_INTENT_CANCELLED`,
|
|
588
|
+
`PAYMENT_INTENT_DELETED`.
|
|
589
|
+
- Private payments: `ZK_PAYMENT_SUCCEEDED` (its `data` is a private payment).
|
|
590
|
+
- Same-chain swaps (Stellar, Solana, Monad): `SWAP_CREATED`, `SWAP_SUBMITTED`,
|
|
591
|
+
`SWAP_SUCCEEDED`, `SWAP_FAILED`, `SWAP_EXPIRED`.
|
|
592
|
+
- Cross-chain swaps: `CROSS_CHAIN_SWAP_CREATED`, `CROSS_CHAIN_SWAP_UPDATED`,
|
|
593
|
+
`CROSS_CHAIN_SWAP_SUCCEEDED`, `CROSS_CHAIN_SWAP_REFUNDED`, `CROSS_CHAIN_SWAP_FAILED`,
|
|
594
|
+
`CROSS_CHAIN_SWAP_EXPIRED`.
|
|
595
|
+
- Liquidity: `LIQUIDITY_CREATED`, `LIQUIDITY_SUBMITTED`, `LIQUIDITY_SUCCEEDED`,
|
|
596
|
+
`LIQUIDITY_FAILED`, `LIQUIDITY_EXPIRED`.
|
|
597
|
+
- Fiat ramps: `RECEIVER_UPDATED`, `PAYIN_CREATED`, `PAYIN_UPDATED`, `PAYIN_COMPLETED`,
|
|
598
|
+
`PAYOUT_CREATED`, `PAYOUT_UPDATED`, `PAYOUT_COMPLETED`.
|
|
599
|
+
|
|
600
|
+
A same-chain swap (`SWAP_EXPIRED`) or a liquidity operation (`LIQUIDITY_EXPIRED`) can
|
|
601
|
+
still settle if its transaction lands late: the API then sends `SWAP_SUCCEEDED` or
|
|
602
|
+
`LIQUIDITY_SUCCEEDED`, so treat those two as "not settled yet" rather than final.
|
|
585
603
|
|
|
586
604
|
---
|
|
587
605
|
|
|
@@ -619,7 +637,10 @@ const customer = await client.customers.create({
|
|
|
619
637
|
name: 'Acme Inc.',
|
|
620
638
|
email: 'billing@acme.com', // optional
|
|
621
639
|
alias: 'acme', // optional
|
|
622
|
-
|
|
640
|
+
wallets: [ // optional, up to 20, on Stellar, Solana or Monad
|
|
641
|
+
{ chain: 'stellar', address: 'G...' },
|
|
642
|
+
{ chain: 'solana', address: '7EcD...', label: 'Phantom' },
|
|
643
|
+
],
|
|
623
644
|
reference: 'crm_4821', // optional
|
|
624
645
|
});
|
|
625
646
|
|
|
@@ -634,9 +655,33 @@ for (const c of customers) {
|
|
|
634
655
|
}
|
|
635
656
|
```
|
|
636
657
|
|
|
637
|
-
`Customer` accessors: `id`, `name`, `alias`, `note`, `email`,
|
|
638
|
-
`account
|
|
639
|
-
`payments`, `succeeded`, `total` (null outside
|
|
658
|
+
`Customer` accessors: `id`, `name`, `alias`, `note`, `email`, `wallets`,
|
|
659
|
+
`account` (deprecated: the first wallet's address), `reference`, `createdAt`,
|
|
660
|
+
`updatedAt`, plus list-only stats `payments`, `succeeded`, `total` (null outside
|
|
661
|
+
`list()`).
|
|
662
|
+
|
|
663
|
+
### Customer wallets
|
|
664
|
+
|
|
665
|
+
A customer holds any number of wallets (up to 20) on Stellar, Solana or Monad;
|
|
666
|
+
payment intents paid from any of them count toward the customer. A wallet belongs
|
|
667
|
+
to one customer: one that another of your customers holds answers
|
|
668
|
+
`409 customer_wallet_taken`. `account` on create still works but is deprecated:
|
|
669
|
+
use `wallets`.
|
|
670
|
+
|
|
671
|
+
```ts
|
|
672
|
+
// On the instance: the wallet is added to (or removed from) customer.wallets too.
|
|
673
|
+
const wallet = await customer.addWallet({ chain: 'monad', address: '0x5aAe...', label: 'Treasury' });
|
|
674
|
+
await customer.removeWallet(wallet); // or customer.removeWallet(wallet.id)
|
|
675
|
+
|
|
676
|
+
// On the manager, by id:
|
|
677
|
+
await client.customers.addWallet(customer.id, { chain: 'stellar', address: 'G...' });
|
|
678
|
+
await client.customers.removeWallet(customer.id, 'cw4f0c2a9d...'); // { id, deleted: true }
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
`addWallet` returns the wallet (`{ id, chain, address, label, createdAt }`); a
|
|
682
|
+
wallet the customer already holds answers as it is. Removing one stops its
|
|
683
|
+
payments counting toward the customer; a later settled payment from it adds it as
|
|
684
|
+
a new automatic customer.
|
|
640
685
|
|
|
641
686
|
---
|
|
642
687
|
|
|
@@ -657,6 +702,37 @@ expired, successRate }, volume: [...], webhooks: { endpoints, deliveries, ... }
|
|
|
657
702
|
`balances()` → `{ data: [{ asset, amount, pending, count }], total }`
|
|
658
703
|
where `amount`/`pending` are decimal strings and `count` is the number of payments.
|
|
659
704
|
|
|
705
|
+
### Activity series: `series({ period })`
|
|
706
|
+
|
|
707
|
+
```ts
|
|
708
|
+
const series = await client.analytics.series({ period: 'week' }); // 'day' | 'week' | 'month' | 'year'
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
Payments, swaps, liquidity operations, webhook deliveries and private payments,
|
|
712
|
+
each grouped into UTC buckets of `period` (weeks start on Monday), with the totals
|
|
713
|
+
of the window and of the window of the same length before it, for growth.
|
|
714
|
+
`day` (the default when omitted) is 30 days, `week` 12 weeks, `month` 12 months,
|
|
715
|
+
`year` 5 years. Every `buckets` array is oldest first and pre-seeded, so a quiet
|
|
716
|
+
bucket is a zero.
|
|
717
|
+
|
|
718
|
+
```ts
|
|
719
|
+
// {
|
|
720
|
+
// period,
|
|
721
|
+
// buckets: [{ start, count, succeeded, failed, volume, volumeUsd }], // payment intents
|
|
722
|
+
// totals: { count, succeeded, failed, volume, volumeUsd, unpriced, payers },
|
|
723
|
+
// previous: { count, succeeded, failed, volume, volumeUsd, unpriced },
|
|
724
|
+
// swaps: { buckets, totals: { ..., inProgress, byKind: { dex, chain, crossChain, usdt0 } }, previous },
|
|
725
|
+
// liquidity: { buckets, totals, previous },
|
|
726
|
+
// webhooks: { buckets: [{ start, deliveries, failed }], totals, previous },
|
|
727
|
+
// zkPayments: { buckets, totals: { ..., fees, feesUsd }, previous }, // private payments, in XLM
|
|
728
|
+
// }
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
The `volumeUsd` fields value each asset at NEAR Intents' current reference price:
|
|
732
|
+
an indicative figure at today's price, null when those prices could not be read.
|
|
733
|
+
Private payments run on Stellar Testnet only for now, so a production key counts
|
|
734
|
+
none; their field is named `zkPayments` after the API's `/v1/zk-payments` route.
|
|
735
|
+
|
|
660
736
|
## Health (public probes) — `client.health`
|
|
661
737
|
|
|
662
738
|
```ts
|
|
@@ -857,6 +933,9 @@ WebhookEventType = { PaymentIntentCreated:'PAYMENT_INTENT_CREATED',
|
|
|
857
933
|
PaymentIntentDeleted:'PAYMENT_INTENT_DELETED' }
|
|
858
934
|
WebhookDeliveryStatus = { Pending:'PENDING', Succeeded:'SUCCEEDED', Failed:'FAILED' }
|
|
859
935
|
ProductKind = { Recurring:'recurring', OneTime:'one_time', Link:'link' }
|
|
936
|
+
PrivatePaymentStatus = { Pending:'PENDING', Succeeded:'SUCCEEDED', Expired:'EXPIRED' }
|
|
937
|
+
Usdt0TransferStatus = { Pending:'PENDING', Submitted:'SUBMITTED', Delivered:'DELIVERED',
|
|
938
|
+
Failed:'FAILED', Expired:'EXPIRED' }
|
|
860
939
|
```
|
|
861
940
|
|
|
862
941
|
## Option types (inputs)
|
|
@@ -881,8 +960,23 @@ interface ListWebhookDeliveriesOptions { status?: WebhookDeliveryStatus; take?:
|
|
|
881
960
|
interface CreateProductOptions { name: string; description?: string; amount?: string; assetCode?: string; kind?: ProductKind; active?: boolean; reference?: string; }
|
|
882
961
|
type UpdateProductOptions = Partial<CreateProductOptions>;
|
|
883
962
|
|
|
884
|
-
interface
|
|
885
|
-
|
|
963
|
+
interface AddCustomerWalletOptions { chain: 'stellar' | 'solana' | 'monad'; address: string; label?: string; }
|
|
964
|
+
interface CreateCustomerOptions { name: string; alias?: string; note?: string; email?: string;
|
|
965
|
+
wallets?: AddCustomerWalletOptions[]; account?: string /* deprecated */; reference?: string; }
|
|
966
|
+
type UpdateCustomerOptions = Partial<Omit<CreateCustomerOptions, 'wallets'>>;
|
|
967
|
+
|
|
968
|
+
interface AnalyticsSeriesOptions { period?: 'day' | 'week' | 'month' | 'year'; }
|
|
969
|
+
|
|
970
|
+
interface MerchantFeeOptions { bps?: number; fixed?: string; wallet: string; paidBy?: 'recipient' | 'payer'; }
|
|
971
|
+
interface CreatePrivatePaymentOptions { amount: string; recipient: string; description?: string;
|
|
972
|
+
expiresInMinutes?: number; idempotencyKey?: string; merchantFee?: MerchantFeeOptions; }
|
|
973
|
+
interface ListPrivatePaymentsOptions { status?: PrivatePaymentStatus; take?: number; skip?: number; }
|
|
974
|
+
|
|
975
|
+
interface QuoteUsdt0Options { to: Usdt0Destination; amount: string; source?: string; }
|
|
976
|
+
interface CreateUsdt0TransferOptions { source: string; to: Usdt0Destination; recipient: string; amount: string;
|
|
977
|
+
idempotencyKey?: string; merchantFee?: MerchantFeeOptions; }
|
|
978
|
+
interface ListUsdt0TransfersOptions { status?: Usdt0TransferStatus; take?: number; skip?: number; }
|
|
979
|
+
interface SubmitUsdt0TransferOptions { signedXdr: string; }
|
|
886
980
|
```
|
|
887
981
|
|
|
888
982
|
## Entity payloads (outputs)
|
|
@@ -895,8 +989,13 @@ type UpdateCustomerOptions = Partial<CreateCustomerOptions>;
|
|
|
895
989
|
- `WebhookEvent<T = PaymentIntentData>` — `{ id, type, createdAt, data }`.
|
|
896
990
|
- `ProductData` — `id, name, description, amount, asset, kind, active, reference,
|
|
897
991
|
createdAt, updatedAt`.
|
|
898
|
-
- `CustomerData
|
|
992
|
+
- `CustomerData`: `id, name, alias, note, email, wallets, account, reference,
|
|
899
993
|
createdAt, updatedAt` (+ list-only `payments, succeeded, total`).
|
|
994
|
+
- `CustomerWalletData`: `id, chain, address, label, createdAt`.
|
|
995
|
+
- `AnalyticsSeriesData`: `period, buckets, totals, previous, swaps, liquidity,
|
|
996
|
+
webhooks, zkPayments` (see Analytics & health).
|
|
997
|
+
- `PrivatePaymentData`, `PrivatePaymentsConfigData`: see Private payments.
|
|
998
|
+
- `Usdt0QuoteData`, `Usdt0TransferData`, `Usdt0RoutesData`: see USDT0.
|
|
900
999
|
- `AnalyticsBalancesData` — `{ data: { asset, amount, pending, count }[], total }`.
|
|
901
1000
|
- `ValidationOutcomeData` — `{ valid, status, reason?, paymentIntent? }`.
|
|
902
1001
|
|
|
@@ -1059,3 +1158,168 @@ await x.fetch(); // x.status: AWAITING_DEPOSIT → … → SUCCEED
|
|
|
1059
1158
|
Keep `x.quoteSignature`: it is NEAR Intents' signature over the quote, what
|
|
1060
1159
|
settles a dispute. Webhooks: `SWAP_*` for both same-chain managers,
|
|
1061
1160
|
`CROSS_CHAIN_SWAP_*` here — `client.webhooks.on('crossChainSwapSucceeded', …)`.
|
|
1161
|
+
|
|
1162
|
+
---
|
|
1163
|
+
|
|
1164
|
+
# Private payments
|
|
1165
|
+
|
|
1166
|
+
`client.privatePayments` creates and reads **private payments**: payments whose
|
|
1167
|
+
amount is hidden on-chain. A private payment is priced in XLM and paid with
|
|
1168
|
+
confidential transfers on Cosmos Pay's confidential token (which wraps native XLM).
|
|
1169
|
+
|
|
1170
|
+
- **Network:** they run on **Stellar Testnet only for now**. On mainnet,
|
|
1171
|
+
`config()` answers `enabled: false`, and the series in
|
|
1172
|
+
`client.analytics.series()` counts none for a production key.
|
|
1173
|
+
- **Cost:** a **0.18% commission per payment**, taken from `amount`:
|
|
1174
|
+
`amount` = `netAmount` (what the merchant receives) + `feeAmount` (the
|
|
1175
|
+
commission, rounded up, at least one stroop), paid to Cosmos Pay's fee account.
|
|
1176
|
+
- **Recipient:** the merchant's Stellar account must already hold a confidential
|
|
1177
|
+
account on the token, registered under auditor id 0; otherwise `create` answers
|
|
1178
|
+
`400 recipient_not_registered`.
|
|
1179
|
+
|
|
1180
|
+
The server SDK creates and reads them with your API key. The **payer** completes
|
|
1181
|
+
one in the private checkout, which runs in their browser with no API key and
|
|
1182
|
+
proves the confidential transfers itself (net to the merchant, the commission to
|
|
1183
|
+
the fee account, and a third transfer when there is a merchant fee).
|
|
1184
|
+
|
|
1185
|
+
```ts
|
|
1186
|
+
import { PrivatePaymentStatus } from '@cosmosapp/pay_sdk';
|
|
1187
|
+
|
|
1188
|
+
const payment = await client.privatePayments.create({
|
|
1189
|
+
amount: '25.5', // XLM the payer pays in total (up to 7 decimals)
|
|
1190
|
+
recipient: 'G...', // the merchant, registered on the confidential token
|
|
1191
|
+
description: 'Order #24', // optional, shown by the checkout (not secret, not on-chain)
|
|
1192
|
+
expiresInMinutes: 60, // optional, 1 to 10080 (server default 60)
|
|
1193
|
+
idempotencyKey: 'order-24', // optional, sent as the Idempotency-Key header too
|
|
1194
|
+
// merchantFee: { bps: 150, wallet: 'G...', paidBy: 'recipient' }, // optional, in XLM
|
|
1195
|
+
});
|
|
1196
|
+
|
|
1197
|
+
payment.amount; // '25.5'
|
|
1198
|
+
payment.netAmount; // what the merchant receives
|
|
1199
|
+
payment.feeAmount; // the 0.18% commission
|
|
1200
|
+
payment.expiresAt; // Date: every transfer must close before it
|
|
1201
|
+
|
|
1202
|
+
// ...the payer pays it in the private checkout...
|
|
1203
|
+
await payment.fetch(); // refreshes in place
|
|
1204
|
+
payment.status; // PENDING, then SUCCEEDED (or EXPIRED)
|
|
1205
|
+
payment.isSucceeded; // payer, paymentTxHash, feeTxHash, settledAt are set
|
|
1206
|
+
|
|
1207
|
+
const page = await client.privatePayments.list({
|
|
1208
|
+
status: PrivatePaymentStatus.Succeeded, take: 20, skip: 0,
|
|
1209
|
+
}); // { items: PrivatePayment[], total, take, skip }, newest first
|
|
1210
|
+
|
|
1211
|
+
const one = await client.privatePayments.fetch('cmh4x2k9a0001l70g8v5q3z2w');
|
|
1212
|
+
```
|
|
1213
|
+
|
|
1214
|
+
`status` reads as it is now: a `PENDING` payment past `expiresAt` reads (and
|
|
1215
|
+
filters) as `EXPIRED`, and can still settle with transfers that closed in time.
|
|
1216
|
+
Only payments on the key's network are listed (`dv_` key: testnet, `prod_`: mainnet).
|
|
1217
|
+
|
|
1218
|
+
## The network's setup: `config()`
|
|
1219
|
+
|
|
1220
|
+
```ts
|
|
1221
|
+
const config = await client.privatePayments.config();
|
|
1222
|
+
// {
|
|
1223
|
+
// enabled, network, rpcUrl, networkPassphrase,
|
|
1224
|
+
// token: { contractId, symbol, decimals, underlying, deployedAtLedger } | null,
|
|
1225
|
+
// verifier, auditorRegistry, auditorId, feeBps /* 18 = 0.18% */, feeAccount,
|
|
1226
|
+
// }
|
|
1227
|
+
```
|
|
1228
|
+
|
|
1229
|
+
What a dashboard needs to set a merchant up on the confidential token (register,
|
|
1230
|
+
read the balance, withdraw). Everything in it is public on-chain data or a public
|
|
1231
|
+
URL. When `enabled` is false, every field but `network`, `networkPassphrase`,
|
|
1232
|
+
`auditorId` and `feeBps` is null.
|
|
1233
|
+
|
|
1234
|
+
## `PrivatePayment` accessors
|
|
1235
|
+
|
|
1236
|
+
`id`, `status`, `network`, `tokenContract`, `amount`, `netAmount`, `feeAmount`,
|
|
1237
|
+
`feeBps`, `recipient`, `feeAccount`, `payer`, `paymentTxHash`, `feeTxHash`,
|
|
1238
|
+
`merchantFee`, `merchantFeeTxHash`, `description`, `idempotencyKey`, `expiresAt`,
|
|
1239
|
+
`settledAt`, `createdAt`, `updatedAt`, plus `isPending`, `isSucceeded`,
|
|
1240
|
+
`isExpired`. The API serves them under `/v1/zk-payments`.
|
|
1241
|
+
|
|
1242
|
+
---
|
|
1243
|
+
|
|
1244
|
+
# USDT0 (Stellar to EVM networks)
|
|
1245
|
+
|
|
1246
|
+
`client.usdt0` sends **USDT0**, Tether's omnichain USDT, from Stellar to an EVM
|
|
1247
|
+
network through LayerZero's OFT. Ethereum (`eth`) receives native USDT; every
|
|
1248
|
+
other network receives USDT0. Every route takes an EVM recipient (0x + 40 hex).
|
|
1249
|
+
|
|
1250
|
+
- **Mainnet only.** A `dev` (testnet) key gets `available: false` and no routes
|
|
1251
|
+
from `routes()`, and `400 network_unsupported` from `quote()` and `create()`.
|
|
1252
|
+
- **Fees, in XLM, paid by the holder:** LayerZero's messaging fee (`nativeFee`;
|
|
1253
|
+
the transaction offers `nativeFeeLimit`, 20% more, and the unused part is
|
|
1254
|
+
refunded in the same transaction) and the Stellar network fee (`networkFee`).
|
|
1255
|
+
Any plan commission shows in `feeBps` / `feeAmount` (0 when the deployment has
|
|
1256
|
+
no fee wrapper).
|
|
1257
|
+
- **Dust:** the OFT carries 6 decimals and the asset has 7, so a 7th decimal of
|
|
1258
|
+
`amount` is `dust` that stays in the account.
|
|
1259
|
+
|
|
1260
|
+
Signing works like a swap: the API builds the one Soroban transaction, the
|
|
1261
|
+
account that holds the USDT0 signs it, and `submit` relays the signed XDR. The
|
|
1262
|
+
API never holds a key.
|
|
1263
|
+
|
|
1264
|
+
```ts
|
|
1265
|
+
import { Usdt0TransferStatus } from '@cosmosapp/pay_sdk';
|
|
1266
|
+
|
|
1267
|
+
const { available, routes } = await client.usdt0.routes();
|
|
1268
|
+
// routes: [{ chain: 'eth', name: 'Ethereum', eid: 30101, receives: 'USDT' }, ...]
|
|
1269
|
+
|
|
1270
|
+
const quote = await client.usdt0.quote({ to: 'arb', amount: '12.5' }); // persists nothing
|
|
1271
|
+
// { amountSent, amountReceived, dust, nativeFee, nativeFeeLimit, minAmount, maxAmount, ... }
|
|
1272
|
+
|
|
1273
|
+
const transfer = await client.usdt0.create({
|
|
1274
|
+
source: 'G...', // holds the USDT0, signs, pays the XLM fees
|
|
1275
|
+
to: 'arb', // a route's `chain`
|
|
1276
|
+
recipient: '0x5aAe...', // EVM address credited
|
|
1277
|
+
amount: '12.5',
|
|
1278
|
+
idempotencyKey: 'payout-77', // optional, sent as the Idempotency-Key header too
|
|
1279
|
+
// merchantFee: { bps: 50, wallet: 'G...' }, // optional, in USDT0; needs the fee wrapper
|
|
1280
|
+
});
|
|
1281
|
+
|
|
1282
|
+
// Sign transfer.xdr with the holder's wallet (e.g. Freighter), or open the SEP-7
|
|
1283
|
+
// link transfer.uri. transfer.qr is usually null: a Soroban transaction is too
|
|
1284
|
+
// large for a QR.
|
|
1285
|
+
const outcome = await transfer.submit({ signedXdr });
|
|
1286
|
+
// { submitted, status, txHash, reason, transfer }; the instance is updated in place
|
|
1287
|
+
|
|
1288
|
+
await transfer.fetch(); // the API refreshes it from the ledger and LayerZero Scan
|
|
1289
|
+
transfer.status; // PENDING -> SUBMITTED -> DELIVERED (or FAILED / EXPIRED)
|
|
1290
|
+
transfer.isFinal; // DELIVERED, FAILED or EXPIRED
|
|
1291
|
+
```
|
|
1292
|
+
|
|
1293
|
+
Delivery takes about 27 minutes on every route (LayerZero's verifiers wait for
|
|
1294
|
+
Stellar confirmations). Once `DELIVERED`, `destinationTxHash` is the destination
|
|
1295
|
+
network's transaction; `guid`, `scanStatus` and `scanUrl` follow it on LayerZero
|
|
1296
|
+
Scan.
|
|
1297
|
+
|
|
1298
|
+
A submit the network refuses leaves the transfer `PENDING` (`submitted: false`,
|
|
1299
|
+
`reason`): fix the cause and submit again until `expiresAt`. A transaction that
|
|
1300
|
+
fails on the ledger moves it to `FAILED` (`failureReason`).
|
|
1301
|
+
|
|
1302
|
+
```ts
|
|
1303
|
+
const page = await client.usdt0.list({ status: Usdt0TransferStatus.Delivered, take: 20 });
|
|
1304
|
+
// { items: Usdt0Transfer[], total, take, skip }, newest first, as last refreshed
|
|
1305
|
+
const one = await client.usdt0.fetch('cm2u0t0transfer0000000001'); // refreshes it
|
|
1306
|
+
const raw = await client.usdt0.submit(one.id, { signedXdr }); // manager form
|
|
1307
|
+
```
|
|
1308
|
+
|
|
1309
|
+
## With the shared public key
|
|
1310
|
+
|
|
1311
|
+
A client built with the shared public key (an open-source wallet) gets a
|
|
1312
|
+
`publicToken` from `create`. The `Usdt0Transfer` keeps it and sends it as
|
|
1313
|
+
`X-Record-Token` on its own `fetch()` and `submit()`; with the manager, pass
|
|
1314
|
+
`{ recordToken }` to `fetch(id, { recordToken })` and `submit(id, { signedXdr,
|
|
1315
|
+
recordToken })`. Without it the API answers 404. `list()` is refused to the
|
|
1316
|
+
shared public key. Any other key ignores the token.
|
|
1317
|
+
|
|
1318
|
+
## `Usdt0Transfer` accessors
|
|
1319
|
+
|
|
1320
|
+
`id`, `status`, `network`, `source`, `to`, `eid`, `receives`, `recipient`,
|
|
1321
|
+
`amount`, `amountSent`, `amountReceived`, `dust`, `nativeFee`, `nativeFeeLimit`,
|
|
1322
|
+
`networkFee`, `feeBps`, `feeAmount`, `feeWallet`, `xdr`, `uri`, `qr`, `txHash`,
|
|
1323
|
+
`guid`, `destinationTxHash`, `scanStatus`, `scanUrl`, `failureReason`,
|
|
1324
|
+
`merchantFee`, `idempotencyKey`, `expiresAt`, `submittedAt`, `createdAt`,
|
|
1325
|
+
`updatedAt`, `publicToken`, plus `isPending`, `isDelivered`, `isFinal`.
|
package/llms/llms.txt
CHANGED
|
@@ -25,8 +25,8 @@ The files below are atomic and self-contained — read the ones relevant to the
|
|
|
25
25
|
- [Payment intents](./05-payment-intents.md): createPay/createTx, fetch/list, edit/cancel/delete, validate
|
|
26
26
|
- [Web client](./06-web-client.md): browser wallets, pay() options, custom adapters, DI, direct API
|
|
27
27
|
- [Webhooks](./07-webhooks.md): register endpoints, receive events (http/Express), verify signatures
|
|
28
|
-
- [Products & customers](./08-products-customers.md): catalog CRUD + payment stats
|
|
29
|
-
- [Analytics & health](./09-analytics-health.md): summary, balances, logs, liveness/readiness
|
|
28
|
+
- [Products & customers](./08-products-customers.md): catalog CRUD, customer wallets + payment stats
|
|
29
|
+
- [Analytics & health](./09-analytics-health.md): summary, activity series, balances, logs, liveness/readiness
|
|
30
30
|
- [Assets, wallets & addresses](./10-assets-wallets-addresses.md): typed catalogs + validators
|
|
31
31
|
- [Errors & observability](./11-errors-observability.md): error classes, retries, telemetry events
|
|
32
32
|
- [Configuration](./12-configuration.md): full option reference + self-hosting
|
|
@@ -36,6 +36,8 @@ The files below are atomic and self-contained — read the ones relevant to the
|
|
|
36
36
|
|
|
37
37
|
- [Recipes](./14-recipes.md): checkout, donations, idempotent webhooks, reconciliation, testnet/mainnet
|
|
38
38
|
- [Swaps](./15-swaps.md): same-chain swaps (Stellar DEX, Jupiter on Solana, Kuru Flow on Monad) and cross-chain swaps (NEAR Intents)
|
|
39
|
+
- [Private payments](./16-private-payments.md): payments whose amount is hidden on-chain (Stellar Testnet for now, 0.18% commission)
|
|
40
|
+
- [USDT0](./17-usdt0.md): send USDT0 from Stellar to EVM networks through LayerZero (mainnet only)
|
|
39
41
|
|
|
40
42
|
## Optional
|
|
41
43
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmosapp/pay_sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Official SDK for Cosmos Pay, the stablecoin payments API for Stellar, Solana and Monad: payment intents and checkout, webhooks, swaps (same-chain and cross-chain), fiat ramps, products and customers. Payment links on all three (SEP-7, Solana Pay, EIP-681). Includes a browser client for Stellar wallets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cosmos-pay",
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"dev": "tsup --watch",
|
|
93
93
|
"typecheck": "tsc --noEmit",
|
|
94
94
|
"pretest": "npm run build",
|
|
95
|
-
"test": "node --test test/client.test.mjs test/rest.test.mjs test/payment-intents.test.mjs test/swaps.test.mjs test/webhooks.test.mjs test/structures.test.mjs test/web.test.mjs test/catalogs.test.mjs test/cosmos-wallet.test.mjs test/liquidity.test.mjs test/ramps.test.mjs test/kyc.test.mjs test/aliases-assets.test.mjs test/cross-chain-swaps.test.mjs test/extensions.test.mjs test/openapi.test.mjs",
|
|
96
|
-
"test:watch": "node --test --watch test/client.test.mjs test/rest.test.mjs test/payment-intents.test.mjs test/swaps.test.mjs test/webhooks.test.mjs test/structures.test.mjs test/web.test.mjs test/catalogs.test.mjs test/cosmos-wallet.test.mjs test/liquidity.test.mjs test/ramps.test.mjs test/kyc.test.mjs test/aliases-assets.test.mjs test/cross-chain-swaps.test.mjs test/extensions.test.mjs test/openapi.test.mjs",
|
|
95
|
+
"test": "node --test test/client.test.mjs test/rest.test.mjs test/payment-intents.test.mjs test/swaps.test.mjs test/webhooks.test.mjs test/structures.test.mjs test/web.test.mjs test/catalogs.test.mjs test/cosmos-wallet.test.mjs test/liquidity.test.mjs test/ramps.test.mjs test/kyc.test.mjs test/aliases-assets.test.mjs test/cross-chain-swaps.test.mjs test/extensions.test.mjs test/customers-analytics.test.mjs test/private-payments.test.mjs test/usdt0.test.mjs test/openapi.test.mjs",
|
|
96
|
+
"test:watch": "node --test --watch test/client.test.mjs test/rest.test.mjs test/payment-intents.test.mjs test/swaps.test.mjs test/webhooks.test.mjs test/structures.test.mjs test/web.test.mjs test/catalogs.test.mjs test/cosmos-wallet.test.mjs test/liquidity.test.mjs test/ramps.test.mjs test/kyc.test.mjs test/aliases-assets.test.mjs test/cross-chain-swaps.test.mjs test/extensions.test.mjs test/customers-analytics.test.mjs test/private-payments.test.mjs test/usdt0.test.mjs test/openapi.test.mjs",
|
|
97
97
|
"prepublishOnly": "npm run build",
|
|
98
98
|
"changelog": "npx --yes git-cliff@2 -o CHANGELOG.md",
|
|
99
99
|
"llms": "node scripts/build-llms.mjs",
|