@bitpal/checkout 0.6.0 → 0.7.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 +17 -5
- package/dist/index.cjs +5 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,10 +63,16 @@ shows the per-order deposit address + QR, and confirms the payment on-chain.
|
|
|
63
63
|
```ts
|
|
64
64
|
const { data: session } = await bitpal.checkout.createSession({
|
|
65
65
|
line_items: [
|
|
66
|
-
{ name: 'Pro Plan', amount: '29', currency: 'USDC' }, //
|
|
66
|
+
{ name: 'Pro Plan', amount: '29', currency: 'USDC' }, // `currency` = price denomination (USD via USDC)
|
|
67
|
+
],
|
|
68
|
+
// Payment options the buyer may choose — (chain, token) pairs. Mix tokens freely.
|
|
69
|
+
// `chain` accepts a short-name ('base' | 'arbitrum' | 'bnb' | 'tron' | 'solana') or a CAIP-2 id;
|
|
70
|
+
// it resolves to the right testnet/mainnet chain for your mode (test vs live key) automatically.
|
|
71
|
+
allowed_assets: [
|
|
72
|
+
{ chain: 'base', token: 'USDC' },
|
|
73
|
+
{ chain: 'tron', token: 'USDT' },
|
|
74
|
+
{ chain: 'solana', token: 'USDC' },
|
|
67
75
|
],
|
|
68
|
-
pay_chain: 'eip155:84532', // Base Sepolia (test mode). Live mode: 'eip155:8453' (Base mainnet).
|
|
69
|
-
// Or use allowed_pay_chains for a buyer-picked chain.
|
|
70
76
|
expires_in_seconds: 1800,
|
|
71
77
|
success_url: 'https://yourstore.com/thanks',
|
|
72
78
|
});
|
|
@@ -75,7 +81,13 @@ const { data: session } = await bitpal.checkout.createSession({
|
|
|
75
81
|
redirect(session.checkout_url!);
|
|
76
82
|
```
|
|
77
83
|
|
|
78
|
-
|
|
84
|
+
**Setting the payment options** (precedence, highest first):
|
|
85
|
+
|
|
86
|
+
- **`allowed_assets`** — `(chain, token)` cells. The standard, most explicit way; the buyer picks any listed pair (lets you mix tokens, e.g. USDC on Base + USDT on Tron).
|
|
87
|
+
- `allowed_pay_chains: string[]` — shorthand for "the line-item `currency` across these chains" (one token, many chains).
|
|
88
|
+
- `pay_chain: string` — a single fixed chain, no buyer choice.
|
|
89
|
+
|
|
90
|
+
`pay_chain` and `allowed_pay_chains` are mutually exclusive; `allowed_assets` takes precedence over both. Omit all three and it defaults to **one chain × the line-item currency**. `currency` on the line item is always the **price denomination** (what the amount is quoted in) — independent of which token the buyer pays with.
|
|
79
91
|
|
|
80
92
|
### Self-hosted flow: issue a deposit address yourself
|
|
81
93
|
|
|
@@ -89,7 +101,7 @@ const { data } = await bitpal.checkout.issueDepositAddress(session.id, {
|
|
|
89
101
|
session_token: session.session_token!, // from createSession
|
|
90
102
|
refundAddress: '0xBuyerWallet...', // VM-matched (EVM 0x… / Tron T… / Solana base58); committed, immutable after issuance
|
|
91
103
|
chain: 'eip155:84532', // match the session's chain (test: Base Sepolia / live: eip155:8453).
|
|
92
|
-
// only needed for multi-option (allowed_pay_chains) sessions
|
|
104
|
+
// only needed for multi-option (allowed_assets / allowed_pay_chains) sessions
|
|
93
105
|
token: 'USDC',
|
|
94
106
|
});
|
|
95
107
|
|
package/dist/index.cjs
CHANGED
|
@@ -214,7 +214,11 @@ var BitPalCheckoutClient = class {
|
|
|
214
214
|
if (params.pay_chain && params.allowed_pay_chains && params.allowed_pay_chains.length > 0) {
|
|
215
215
|
throw new Error("[BitPal] pay_chain and allowed_pay_chains are mutually exclusive \u2014 use only one.");
|
|
216
216
|
}
|
|
217
|
-
const body = {
|
|
217
|
+
const body = {
|
|
218
|
+
...params,
|
|
219
|
+
line_items: params.line_items.map(validateLineItem),
|
|
220
|
+
...params.allowed_assets ? { allowed_assets: params.allowed_assets.map((a) => ({ caip2: a.chain, token: a.token })) } : {}
|
|
221
|
+
};
|
|
218
222
|
const res = await this.request(
|
|
219
223
|
"POST",
|
|
220
224
|
"/v1/checkout/sessions",
|
package/dist/index.d.cts
CHANGED
|
@@ -67,6 +67,17 @@ interface CreateSessionParams {
|
|
|
67
67
|
* 예: ['eip155:84532', 'eip155:11155420', 'eip155:80002', 'eip155:421614']
|
|
68
68
|
*/
|
|
69
69
|
allowed_pay_chains?: string[];
|
|
70
|
+
/**
|
|
71
|
+
* chain×token cell 허용 목록(**결제 수단** 표준 입력) — buyer 가 (체인, 토큰) 조합을 고른다.
|
|
72
|
+
* allowed_pay_chains(×단일 currency shorthand)보다 우선. 서로 다른 토큰을 섞을 때 사용.
|
|
73
|
+
* `chain` 은 short-name('base','tron','solana') 또는 CAIP-2 둘 다 허용(서버가 mode-relative 로 정규화).
|
|
74
|
+
* paymentLinks.allowed_assets 와 동일 형태(SDK 일관).
|
|
75
|
+
* 예: [{ chain: 'base', token: 'USDC' }, { chain: 'tron', token: 'USDT' }]
|
|
76
|
+
*/
|
|
77
|
+
allowed_assets?: Array<{
|
|
78
|
+
chain: string;
|
|
79
|
+
token: string;
|
|
80
|
+
}>;
|
|
70
81
|
/** 결제 자산 (예: USDC) */
|
|
71
82
|
pay_asset?: string;
|
|
72
83
|
/** 허용 오차 (%, 기본값: 2.00) */
|
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,17 @@ interface CreateSessionParams {
|
|
|
67
67
|
* 예: ['eip155:84532', 'eip155:11155420', 'eip155:80002', 'eip155:421614']
|
|
68
68
|
*/
|
|
69
69
|
allowed_pay_chains?: string[];
|
|
70
|
+
/**
|
|
71
|
+
* chain×token cell 허용 목록(**결제 수단** 표준 입력) — buyer 가 (체인, 토큰) 조합을 고른다.
|
|
72
|
+
* allowed_pay_chains(×단일 currency shorthand)보다 우선. 서로 다른 토큰을 섞을 때 사용.
|
|
73
|
+
* `chain` 은 short-name('base','tron','solana') 또는 CAIP-2 둘 다 허용(서버가 mode-relative 로 정규화).
|
|
74
|
+
* paymentLinks.allowed_assets 와 동일 형태(SDK 일관).
|
|
75
|
+
* 예: [{ chain: 'base', token: 'USDC' }, { chain: 'tron', token: 'USDT' }]
|
|
76
|
+
*/
|
|
77
|
+
allowed_assets?: Array<{
|
|
78
|
+
chain: string;
|
|
79
|
+
token: string;
|
|
80
|
+
}>;
|
|
70
81
|
/** 결제 자산 (예: USDC) */
|
|
71
82
|
pay_asset?: string;
|
|
72
83
|
/** 허용 오차 (%, 기본값: 2.00) */
|
package/dist/index.js
CHANGED
|
@@ -165,7 +165,11 @@ var BitPalCheckoutClient = class {
|
|
|
165
165
|
if (params.pay_chain && params.allowed_pay_chains && params.allowed_pay_chains.length > 0) {
|
|
166
166
|
throw new Error("[BitPal] pay_chain and allowed_pay_chains are mutually exclusive \u2014 use only one.");
|
|
167
167
|
}
|
|
168
|
-
const body = {
|
|
168
|
+
const body = {
|
|
169
|
+
...params,
|
|
170
|
+
line_items: params.line_items.map(validateLineItem),
|
|
171
|
+
...params.allowed_assets ? { allowed_assets: params.allowed_assets.map((a) => ({ caip2: a.chain, token: a.token })) } : {}
|
|
172
|
+
};
|
|
169
173
|
const res = await this.request(
|
|
170
174
|
"POST",
|
|
171
175
|
"/v1/checkout/sessions",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitpal/checkout",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "BitPal Checkout SDK — non-custodial crypto checkout: create sessions, issue per-order deposit addresses, poll status, verify signed webhooks.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|