@ic-pay/icpay-sdk 1.4.93 → 1.4.99

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,6 +1,6 @@
1
1
  # ICPay SDK
2
2
 
3
- Official SDK for integrating Internet Computer payments with ICPay.
3
+ Official SDK for integrating **ICPay** — multi-chain crypto payments on **EVM (e.g. Base)**, **Solana**, and **Internet Computer**. Use one API for payment intents, USD or token amounts, wallet connection, balances, and advanced flows (X402, ATXP) across all supported chains.
4
4
 
5
5
  ## Installation
6
6
 
@@ -26,14 +26,15 @@ import Icpay from '@ic-pay/icpay-sdk';
26
26
 
27
27
  const sdk = new Icpay({
28
28
  publishableKey: process.env.NEXT_PUBLIC_ICPAY_PK!,
29
- // Optional for EVM flows in browser:
29
+ // Optional: pass wallet providers for browser flows
30
30
  evmProvider: (globalThis as any)?.ethereum,
31
+ solanaProvider: (globalThis as any)?.solana,
31
32
  debug: false,
32
33
  });
33
34
 
34
- // Create a USD payment (amount in USD, token resolved by shortcode)
35
+ // Create a USD payment (amount in USD; token/chain by shortcode, e.g. base_usdc, sol_usdc, ic_icp)
35
36
  const tx = await sdk.createPaymentUsd({
36
- tokenShortcode: 'icp',
37
+ tokenShortcode: 'base_usdc',
37
38
  usdAmount: 5,
38
39
  metadata: { orderId: 'ORDER-123' },
39
40
  });
@@ -41,28 +42,34 @@ const tx = await sdk.createPaymentUsd({
41
42
  console.log('Payment status:', tx.status);
42
43
  ```
43
44
 
45
+ ## Supported chains
46
+
47
+ - **EVM** — Base (and other EVM chains): native and ERC‑20; automatic chain switching/addition hints.
48
+ - **Solana** — SOL and SPL tokens; Phantom, Backpack, and other Solana wallets.
49
+ - **Internet Computer** — ICP and ICRC tokens; Plug, Internet Identity, NFID, etc.
50
+
51
+ Use `tokenShortcode` (e.g. `base_usdc`, `sol_usdc`, `ic_icp`) or `ledgerCanisterId` to target a specific chain/token. Full list: `getVerifiedLedgers()` or [docs.icpay.org](https://docs.icpay.org).
52
+
44
53
  ## Features
45
54
 
46
- - Public/secret key support (browser and Node.js)
47
- - Create payment intents in USD or token amounts
48
- - Multi-chain payment processing:
49
- - EVM (native and ERC‑20), with automatic chain switching/addition hints
50
- - Internet Computer
51
- - Wallet helpers: show connection modal, connect to providers, get providers, account address
52
- - Balances and prices: external wallet balances, single-ledger balance, verified ledgers, all ledgers with prices
53
- - Chain/ledger metadata: chains, ledger info (decimals, prices, logos)
54
- - Evented API: start/success/error + transaction lifecycle events
55
- - Advanced flows:
56
- - X402: HTTP 402 workflow with verify, settle + fallbacks
57
- - ATXP: quote/pay/execute
55
+ - **Keys** — Publishable key (browser-safe) and secret key (server-only) support.
56
+ - **Payments** — Create payment intents in USD or token amounts; relay to your EVM/IC/Solana addresses.
57
+ - **Multi-chain** Single SDK for EVM (Base, etc.), Solana, and Internet Computer.
58
+ - **Wallet helpers** Show connection modal, connect by provider, get providers, account address; WalletConnect QR and deep links.
59
+ - **Balances & prices** — External wallet balances, single-ledger balance, verified ledgers, all ledgers with prices.
60
+ - **Chain/ledger metadata** `getChains()`, ledger info (decimals, prices, logos), token/chain filtering.
61
+ - **Events** Lifecycle events: start/success/error and transaction events (e.g. `icpay-sdk-transaction-completed`).
62
+ - **Advanced flows** **X402**: HTTP 402 sign-and-settle for IC, EVM, and Solana; **ATXP**: quote/pay/execute.
63
+ - **Onramp** Optional fiat-to-crypto via Transak (configurable per account).
58
64
 
59
65
  ## Documentation
60
66
 
61
- For full usage guides, configuration, API reference, and examples, see: https://docs.icpay.org
67
+ Full usage, configuration, API reference, and examples: **[https://docs.icpay.org](https://docs.icpay.org)**
68
+ Sandbox (testnets): **[betterstripe.com](https://betterstripe.com)** — Base Sepolia, Solana Devnet, and other test networks.
62
69
 
63
70
  ## AI agents
64
71
 
65
- Using Cursor, Claude Code, Antigravity, Windsurf, Continue, GitHub Copilot, Kiro, or Trae while working with ICPay? Add the **ICPay skill** so the agent follows SDK, widget, payment links, and integration conventions.
72
+ Using Cursor, Claude Code, Antigravity, Windsurf, Continue, GitHub Copilot, Kiro, or Trae with ICPay? Add the **ICPay skill** so the agent follows SDK, widget, payment links, and integration conventions.
66
73
 
67
74
  ### If the SDK is already in node_modules
68
75
 
@@ -78,7 +85,6 @@ Use the same pattern for other IDEs (`.claude/skills/`, `.agent/skills/`, etc.).
78
85
 
79
86
  Run the **copy** commands below from the **icpay-sdk repo root** (after `git clone https://github.com/icpay/icpay-sdk && cd icpay-sdk`). If you can use symlinks, prefer symlinking so the skill stays updated on `git pull`; see "Where Cursor looks for skills" below.
80
87
 
81
-
82
88
  | IDE / Agent | Where the skill goes | Copy command |
83
89
  |-------------|----------------------|--------------|
84
90
  | **Cursor** (project) | `.cursor/skills/icpay/` | `mkdir -p .cursor/skills && cp -r skills/icpay .cursor/skills/` |
@@ -98,4 +104,4 @@ Cursor, Claude Code, and Antigravity use the full skill folder; the others use `
98
104
  ## TypeScript
99
105
 
100
106
  - Fully typed with bundled `.d.ts`
101
- - Named exports include `IcpayError`, `IcpayWallet`, events and types
107
+ - Named exports include `IcpayError`, `IcpayWallet`, events, and types
package/dist/http.d.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  export type RequestHeaders = Record<string, string>;
2
- export declare class HttpClient {
2
+ /** Public API contract for the HTTP client (get, post, patch). */
3
+ export interface IHttpClient {
4
+ get<T = any>(path: string, headers?: RequestHeaders): Promise<T>;
5
+ post<T = any>(path: string, body?: any, headers?: RequestHeaders): Promise<T>;
6
+ patch<T = any>(path: string, body?: any, headers?: RequestHeaders): Promise<T>;
7
+ setHeader(name: string, value: string | undefined): void;
8
+ }
9
+ export declare class HttpClient implements IHttpClient {
3
10
  private baseURL;
4
11
  private defaultHeaders;
5
12
  constructor(options: {
@@ -9,6 +16,7 @@ export declare class HttpClient {
9
16
  setHeader(name: string, value: string | undefined): void;
10
17
  get<T = any>(path: string, headers?: RequestHeaders): Promise<T>;
11
18
  post<T = any>(path: string, body?: any, headers?: RequestHeaders): Promise<T>;
19
+ patch<T = any>(path: string, body?: any, headers?: RequestHeaders): Promise<T>;
12
20
  private resolve;
13
21
  private handleResponse;
14
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEpD,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAAiB;gBAE3B,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,cAAc,CAAA;KAAE;IAKlE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS;IAQ3C,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAShE,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAUnF,OAAO,CAAC,OAAO;YAKD,cAAc;CAY7B"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEpD,kEAAkE;AAClE,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACjE,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC9E,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC/E,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CAC1D;AAED,qBAAa,UAAW,YAAW,WAAW;IAC5C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAAiB;gBAE3B,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,cAAc,CAAA;KAAE;IAKlE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS;IAQ3C,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAShE,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAU7E,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAUpF,OAAO,CAAC,OAAO;YAKD,cAAc;CAY7B"}
package/dist/http.js CHANGED
@@ -31,6 +31,15 @@ class HttpClient {
31
31
  });
32
32
  return this.handleResponse(res);
33
33
  }
34
+ async patch(path, body, headers) {
35
+ const url = this.resolve(path);
36
+ const res = await fetch(url, {
37
+ method: 'PATCH',
38
+ headers: { ...this.defaultHeaders, ...(headers || {}) },
39
+ body: body === undefined ? undefined : JSON.stringify(body),
40
+ });
41
+ return this.handleResponse(res);
42
+ }
34
43
  resolve(path) {
35
44
  if (/^https?:\/\//i.test(path))
36
45
  return path;
package/dist/http.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;IAIrB,YAAY,OAAsD;QAChE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,cAAc,GAAG,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC;IAC3F,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,KAAyB;QAC/C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACpC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAU,IAAY,EAAE,OAAwB;QACvD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAC3B,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE;SACzC,CAAC,CAAC;QAClB,OAAO,IAAI,CAAC,cAAc,CAAI,GAAG,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,IAAI,CAAU,IAAY,EAAE,IAAU,EAAE,OAAwB;QACpE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,GAA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GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QACpF,MAAM,IAAI,GAAG,MAAM,IAAI,IAAI,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAO,CAAC,CAAC,CAAE,IAAqB,CAAC;QAC/E,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,GAAG,GAAQ,IAAI,KAAK,CAAC,QAAQ,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;YACpE,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;YACxB,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;YAChB,MAAM,GAAG,CAAC;QACZ,CAAC;QACD,OAAO,IAAS,CAAC;IACnB,CAAC;CACF;AA/DD,gCA+DC"}
package/dist/index.d.ts CHANGED
@@ -25,6 +25,8 @@ export declare class Icpay {
25
25
  canisterTxId?: number;
26
26
  transactionId?: string;
27
27
  orderId?: string;
28
+ /** When paying with an existing intent on a payment link page, pass link context so the intent is linked. */
29
+ icpayPaymentLink?: Record<string, unknown>;
28
30
  }): Promise<{
29
31
  paymentId: string | null;
30
32
  paymentIntentId: string | null;
@@ -172,6 +174,11 @@ export declare class Icpay {
172
174
  */
173
175
  getLedgerBalance(ledgerCanisterId: string): Promise<bigint>;
174
176
  private createPackedMemo;
177
+ /**
178
+ * Resolve payment intent from config or request: use full intent if provided, else fetch by id via API.
179
+ * Returns null when no pre-provided intent (caller should create via POST).
180
+ */
181
+ private getOrResolvePaymentIntent;
175
182
  /**
176
183
  * Create a payment to a specific canister/ledger (public method)
177
184
  * This is now a real transaction
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,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E,GAAG;QAAE,IAAI,EAAE,MAAM,IAAI,CAAA;KAAE;IAgC3H,6DAA6D;YAC/C,0BAA0B;YAmD1B,mBAAmB;IAmE/B;;KAEC;IACG,uBAAuB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IA0CrD;;OAEG;IACH,OAAO,CAAC,aAAa;CAUtB;AAGD,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,cAAc,UAAU,CAAC;AAGzB,eAAe,KAAK,CAAC"}
package/dist/index.js CHANGED
@@ -319,12 +319,15 @@ class Icpay {
319
319
  async notifyPayment(params) {
320
320
  this.emitMethodStart('notifyPayment', { paymentIntentId: params.paymentIntentId });
321
321
  try {
322
- const resp = await this.publicApiClient.post('/sdk/public/payments/notify', {
322
+ const body = {
323
323
  paymentIntentId: params.paymentIntentId,
324
324
  canisterTxId: params.canisterTxId,
325
325
  transactionId: params.transactionId,
326
326
  orderId: params.orderId,
327
- });
327
+ };
328
+ if (params.icpayPaymentLink && typeof params.icpayPaymentLink === 'object')
329
+ body.icpayPaymentLink = params.icpayPaymentLink;
330
+ const resp = await this.publicApiClient.post('/sdk/public/payments/notify', body);
328
331
  this.emitMethodSuccess('notifyPayment', { status: resp?.status, paymentIntentId: resp?.paymentIntentId });
329
332
  return resp;
330
333
  }
@@ -765,6 +768,7 @@ class Icpay {
765
768
  paymentIntentId: paymentIntentId,
766
769
  maxAttempts: 120,
767
770
  delayMs: 1000,
771
+ icpayPaymentLink: request?.metadata?.icpayPaymentLink,
768
772
  });
769
773
  // Derive status from API response
770
774
  let statusString = 'pending';
@@ -1099,7 +1103,7 @@ class Icpay {
1099
1103
  return out;
1100
1104
  }
1101
1105
  try {
1102
- await this.performNotifyPaymentIntent({ paymentIntentId: params.paymentIntentId, transactionId: signature, maxAttempts: 1 });
1106
+ await this.performNotifyPaymentIntent({ paymentIntentId: params.paymentIntentId, transactionId: signature, maxAttempts: 1, icpayPaymentLink: params.metadata?.icpayPaymentLink });
1103
1107
  }
1104
1108
  catch { }
1105
1109
  const finalQuick = await this.awaitIntentTerminal({
@@ -1289,7 +1293,7 @@ class Icpay {
1289
1293
  catch { }
1290
1294
  // Inform API immediately with tx hash so it can start indexing
1291
1295
  try {
1292
- await this.performNotifyPaymentIntent({ paymentIntentId: params.paymentIntentId, transactionId: txHash, maxAttempts: 1 });
1296
+ await this.performNotifyPaymentIntent({ paymentIntentId: params.paymentIntentId, transactionId: txHash, maxAttempts: 1, icpayPaymentLink: params.metadata?.icpayPaymentLink });
1293
1297
  }
1294
1298
  catch { }
1295
1299
  const finalResponse = await this.awaitIntentTerminal({
@@ -1425,6 +1429,40 @@ class Icpay {
1425
1429
  }
1426
1430
  return new Uint8Array(out);
1427
1431
  }
1432
+ /**
1433
+ * Resolve payment intent from config or request: use full intent if provided, else fetch by id via API.
1434
+ * Returns null when no pre-provided intent (caller should create via POST).
1435
+ */
1436
+ async getOrResolvePaymentIntent(request) {
1437
+ const isFullIntent = (o) => o && typeof o === 'object' && o.id && typeof (o.amount === 'string' ? o.amount : String(o.amount ?? '')) === 'string' &&
1438
+ (o.chainType != null || o.chainId != null || (o.ledgerCanisterId != null && o.ledgerCanisterId !== ''));
1439
+ const fromRequest = request?.paymentIntent;
1440
+ const fromConfig = this.config?.paymentIntent;
1441
+ if (fromRequest && isFullIntent(fromRequest)) {
1442
+ (0, utils_1.debugLog)(this.config.debug || false, 'using payment intent from request');
1443
+ return { paymentIntent: fromRequest, onramp: null };
1444
+ }
1445
+ if (fromConfig && isFullIntent(fromConfig)) {
1446
+ (0, utils_1.debugLog)(this.config.debug || false, 'using payment intent from config');
1447
+ return { paymentIntent: fromConfig, onramp: null };
1448
+ }
1449
+ const intentId = (fromRequest && typeof fromRequest.id === 'string' && fromRequest.id) ||
1450
+ (fromConfig && typeof fromConfig.id === 'string' && fromConfig.id) ||
1451
+ (typeof this.config?.paymentIntentId === 'string' && this.config.paymentIntentId) || null;
1452
+ if (intentId && this.publicApiClient) {
1453
+ try {
1454
+ (0, utils_1.debugLog)(this.config.debug || false, 'fetching payment intent by id', { intentId });
1455
+ const resp = await this.publicApiClient.get(`/sdk/public/payments/intents/${encodeURIComponent(intentId)}`);
1456
+ if (resp?.paymentIntent) {
1457
+ return { paymentIntent: resp.paymentIntent, onramp: resp.onramp ?? null };
1458
+ }
1459
+ }
1460
+ catch (e) {
1461
+ (0, utils_1.debugLog)(this.config.debug || false, 'fetch payment intent failed', e);
1462
+ }
1463
+ }
1464
+ return null;
1465
+ }
1428
1466
  /**
1429
1467
  * Create a payment to a specific canister/ledger (public method)
1430
1468
  * This is now a real transaction
@@ -1437,17 +1475,18 @@ class Icpay {
1437
1475
  let ledgerCanisterId = request.ledgerCanisterId;
1438
1476
  const tokenShortcode = request?.tokenShortcode;
1439
1477
  const isOnrampFlow = (request?.onrampPayment === true) || (this?.config?.onrampPayment === true);
1440
- if (!ledgerCanisterId && !tokenShortcode && !request.symbol && !isOnrampFlow) {
1478
+ const hasPaymentIntent = request?.paymentIntent != null || this.config?.paymentIntent != null || (typeof this.config?.paymentIntentId === 'string' && this.config.paymentIntentId);
1479
+ if (!ledgerCanisterId && !tokenShortcode && !request.symbol && !isOnrampFlow && !hasPaymentIntent) {
1441
1480
  const err = new errors_1.IcpayError({
1442
1481
  code: errors_1.ICPAY_ERROR_CODES.INVALID_CONFIG,
1443
- message: 'Provide either tokenShortcode or ledgerCanisterId (symbol is deprecated).',
1482
+ message: 'Provide either tokenShortcode or ledgerCanisterId (symbol is deprecated), or pass paymentIntent.',
1444
1483
  details: { request }
1445
1484
  });
1446
1485
  this.emitMethodError('createPayment', err);
1447
1486
  throw err;
1448
1487
  }
1449
1488
  let memo = undefined;
1450
- // 1) Create payment intent via API (backend will finalize amount/price)
1489
+ // 1) Resolve or create payment intent: use pre-provided (config/request) or fetch by id, else create via API
1451
1490
  let paymentIntentId = null;
1452
1491
  let paymentIntentCode = null;
1453
1492
  let intentChainType;
@@ -1455,114 +1494,162 @@ class Icpay {
1455
1494
  let accountCanisterId;
1456
1495
  let resolvedAmountStr = typeof request.amount === 'string' ? request.amount : (request.amount != null ? String(request.amount) : undefined);
1457
1496
  let intentResp;
1497
+ let expectedSenderPrincipal;
1458
1498
  try {
1459
- (0, utils_1.debugLog)(this.config.debug || false, 'creating payment intent');
1460
- // Resolve expected sender principal:
1461
- // Start with any value explicitly provided on the request or via connectedWallet.
1462
- let expectedSenderPrincipal = request.expectedSenderPrincipal ||
1463
- this.connectedWallet?.owner ||
1464
- this.connectedWallet?.principal?.toString();
1465
- // If none yet and a Solana provider is present (e.g., Phantom), prefer its publicKey (base58).
1466
- try {
1467
- const solProv = this.config?.solanaProvider || globalThis?.solana;
1468
- const solPk = solProv?.publicKey ? String(solProv.publicKey) : undefined;
1469
- if (!expectedSenderPrincipal && solPk) {
1470
- expectedSenderPrincipal = String(solPk);
1471
- }
1472
- }
1473
- catch { }
1474
- // Only if still missing, fall back to EVM accounts.
1475
- if (!expectedSenderPrincipal) {
1476
- const evm = this.config?.evmProvider || globalThis?.ethereum;
1477
- if (evm?.request) {
1478
- try {
1479
- const accounts = await evm.request({ method: 'eth_accounts' });
1480
- if (Array.isArray(accounts) && accounts[0]) {
1481
- const lowerAccounts = accounts.map((a) => String(a).toLowerCase());
1482
- const providedRaw = request?.expectedSenderPrincipal;
1483
- if (providedRaw) {
1484
- const provided = String(providedRaw).toLowerCase();
1485
- expectedSenderPrincipal = lowerAccounts.includes(provided) ? accounts[lowerAccounts.indexOf(provided)] : accounts[0];
1499
+ const meta = request?.metadata || {};
1500
+ const isAtxp = Boolean(meta?.icpay_atxp_request) && typeof (meta?.atxp_request_id) === 'string';
1501
+ const onramp = (request.onrampPayment === true || this.config.onrampPayment === true) && this.config.onrampDisabled !== true ? true : false;
1502
+ // If we have a pre-provided intent or an id to fetch, resolve first (skip create for non-ATXP/non-onramp create flows)
1503
+ if (!isAtxp && !onramp) {
1504
+ const resolved = await this.getOrResolvePaymentIntent(request);
1505
+ if (resolved) {
1506
+ let pi = resolved.paymentIntent;
1507
+ const intentHasToken = (pi?.ledgerId != null) || (pi?.ledgerCanisterId && String(pi.ledgerCanisterId).trim() !== '');
1508
+ if (!intentHasToken) {
1509
+ const tokenToSet = request?.tokenShortcode;
1510
+ if (tokenToSet && typeof tokenToSet === 'string' && this.publicApiClient) {
1511
+ try {
1512
+ await this.publicApiClient.patch(`/sdk/public/payments/intents/${encodeURIComponent(pi.id)}/set-token`, { tokenShortcode: tokenToSet.trim() });
1513
+ const refetched = await this.publicApiClient.get(`/sdk/public/payments/intents/${encodeURIComponent(pi.id)}`);
1514
+ if (refetched?.paymentIntent)
1515
+ pi = refetched.paymentIntent;
1486
1516
  }
1487
- else {
1488
- expectedSenderPrincipal = accounts[0];
1517
+ catch (e) {
1518
+ (0, utils_1.debugLog)(this.config.debug || false, 'set-token failed', e);
1519
+ throw new errors_1.IcpayError({
1520
+ code: errors_1.ICPAY_ERROR_CODES.API_ERROR,
1521
+ message: 'Payment intent requires a token to be selected. Setting token failed.',
1522
+ details: e,
1523
+ retryable: true,
1524
+ userAction: 'Ensure tokenShortcode is valid and try again',
1525
+ });
1489
1526
  }
1490
1527
  }
1528
+ else {
1529
+ throw new errors_1.IcpayError({
1530
+ code: errors_1.ICPAY_ERROR_CODES.INVALID_CONFIG,
1531
+ message: 'Payment intent requires a token to be selected before payment. Provide tokenShortcode in the request.',
1532
+ details: { paymentIntentId: pi?.id },
1533
+ retryable: false,
1534
+ userAction: 'Select a token (e.g. pass tokenShortcode) and try again',
1535
+ });
1536
+ }
1491
1537
  }
1492
- catch { }
1538
+ intentResp = { paymentIntent: pi, onramp: resolved.onramp };
1539
+ expectedSenderPrincipal = request.expectedSenderPrincipal ||
1540
+ this.connectedWallet?.owner || this.connectedWallet?.principal?.toString();
1493
1541
  }
1494
1542
  }
1495
- if (!expectedSenderPrincipal && !((request?.onrampPayment === true) || (this?.config?.onrampPayment === true))) {
1496
- throw new errors_1.IcpayError({
1497
- code: errors_1.ICPAY_ERROR_CODES.WALLET_NOT_CONNECTED,
1498
- message: 'Wallet must be connected to create payment intent',
1499
- details: { connectedWallet: this.connectedWallet },
1500
- retryable: false,
1501
- userAction: 'Connect your wallet first'
1502
- });
1503
- }
1504
- const onramp = (request.onrampPayment === true || this.config.onrampPayment === true) && this.config.onrampDisabled !== true ? true : false;
1505
- const meta = request?.metadata || {};
1506
- const isAtxp = Boolean(meta?.icpay_atxp_request) && typeof (meta?.atxp_request_id) === 'string';
1507
- // Resolve recipientAddress only for non-onramp flows
1508
- const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
1509
- const reqAny = request;
1510
- const addrObj = (reqAny?.recipientAddresses) || {};
1511
- const candidateEvm = addrObj.evm ? addrObj.evm : undefined;
1512
- const candidateIC = addrObj.ic ? addrObj.ic : undefined;
1513
- const candidateSol = addrObj.sol ? addrObj.sol : undefined;
1514
- let recipientAddress = undefined;
1515
- if (!onramp) {
1516
- // Choose a default to persist on the intent; EVM will override to ZERO if non-hex when building tx
1517
- recipientAddress = (reqAny?.recipientAddress) || candidateEvm || candidateIC || candidateSol || ZERO_ADDRESS;
1518
- (0, utils_1.debugLog)(this.config.debug || false, 'recipientAddress resolved for intent', { recipientAddress });
1519
- }
1520
- if (isAtxp) {
1521
- // Route ATXP intents to the ATXP endpoint so they link to the request
1522
- const atxpRequestId = String(meta.atxp_request_id);
1523
- const endpoint = `/sdk/public/atxp/requests/${encodeURIComponent(atxpRequestId)}/payment-intents`;
1524
- intentResp = await this.publicApiClient.post(endpoint, {
1525
- tokenShortcode: tokenShortcode || undefined,
1526
- description: request.description,
1527
- recipientAddress,
1528
- recipientAddresses: request?.recipientAddresses || undefined,
1529
- externalCostAmount: request?.externalCostAmount ?? request?.metadata?.externalCostAmount ?? undefined,
1530
- fiat_currency: request?.fiat_currency,
1531
- });
1532
- }
1533
- else {
1534
- if (onramp) {
1535
- // Route onramp flows to the dedicated onramp endpoint without requiring token/ledger
1536
- intentResp = await this.publicApiClient.post('/sdk/public/onramp/intents', {
1537
- usdAmount: request.amountUsd,
1538
- description: request.description,
1539
- metadata: normalizeSdkMetadata(request.metadata || {}),
1540
- widgetParams: request.widgetParams || undefined,
1541
- recipientAddresses: request?.recipientAddresses || undefined,
1542
- fiat_currency: request?.fiat_currency,
1543
+ if (!intentResp) {
1544
+ (0, utils_1.debugLog)(this.config.debug || false, 'creating payment intent via API');
1545
+ // Resolve expected sender principal:
1546
+ // Start with any value explicitly provided on the request or via connectedWallet.
1547
+ expectedSenderPrincipal =
1548
+ request.expectedSenderPrincipal ||
1549
+ this.connectedWallet?.owner ||
1550
+ this.connectedWallet?.principal?.toString();
1551
+ // If none yet and a Solana provider is present (e.g., Phantom), prefer its publicKey (base58).
1552
+ try {
1553
+ const solProv = this.config?.solanaProvider || globalThis?.solana;
1554
+ const solPk = solProv?.publicKey ? String(solProv.publicKey) : undefined;
1555
+ if (!expectedSenderPrincipal && solPk) {
1556
+ expectedSenderPrincipal = String(solPk);
1557
+ }
1558
+ }
1559
+ catch { }
1560
+ // Only if still missing, fall back to EVM accounts.
1561
+ if (!expectedSenderPrincipal) {
1562
+ const evm = this.config?.evmProvider || globalThis?.ethereum;
1563
+ if (evm?.request) {
1564
+ try {
1565
+ const accounts = await evm.request({ method: 'eth_accounts' });
1566
+ if (Array.isArray(accounts) && accounts[0]) {
1567
+ const lowerAccounts = accounts.map((a) => String(a).toLowerCase());
1568
+ const providedRaw = request?.expectedSenderPrincipal;
1569
+ if (providedRaw) {
1570
+ const provided = String(providedRaw).toLowerCase();
1571
+ expectedSenderPrincipal = lowerAccounts.includes(provided) ? accounts[lowerAccounts.indexOf(provided)] : accounts[0];
1572
+ }
1573
+ else {
1574
+ expectedSenderPrincipal = accounts[0];
1575
+ }
1576
+ }
1577
+ }
1578
+ catch { }
1579
+ }
1580
+ }
1581
+ if (!expectedSenderPrincipal && !((request?.onrampPayment === true) || (this?.config?.onrampPayment === true))) {
1582
+ throw new errors_1.IcpayError({
1583
+ code: errors_1.ICPAY_ERROR_CODES.WALLET_NOT_CONNECTED,
1584
+ message: 'Wallet must be connected to create payment intent',
1585
+ details: { connectedWallet: this.connectedWallet },
1586
+ retryable: false,
1587
+ userAction: 'Connect your wallet first'
1543
1588
  });
1544
1589
  }
1545
- else {
1546
- intentResp = await this.publicApiClient.post('/sdk/public/payments/intents', {
1547
- amount: (typeof request.amount === 'string' ? request.amount : (request.amount != null ? String(request.amount) : undefined)),
1548
- // Prefer tokenShortcode if provided
1590
+ const onramp = (request.onrampPayment === true || this.config.onrampPayment === true) && this.config.onrampDisabled !== true ? true : false;
1591
+ const meta = request?.metadata || {};
1592
+ const isAtxp = Boolean(meta?.icpay_atxp_request) && typeof (meta?.atxp_request_id) === 'string';
1593
+ // Resolve recipientAddress only for non-onramp flows
1594
+ const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
1595
+ const reqAny = request;
1596
+ const addrObj = (reqAny?.recipientAddresses) || {};
1597
+ const candidateEvm = addrObj.evm ? addrObj.evm : undefined;
1598
+ const candidateIC = addrObj.ic ? addrObj.ic : undefined;
1599
+ const candidateSol = addrObj.sol ? addrObj.sol : undefined;
1600
+ let recipientAddress = undefined;
1601
+ if (!onramp) {
1602
+ // Choose a default to persist on the intent; EVM will override to ZERO if non-hex when building tx
1603
+ recipientAddress = (reqAny?.recipientAddress) || candidateEvm || candidateIC || candidateSol || ZERO_ADDRESS;
1604
+ (0, utils_1.debugLog)(this.config.debug || false, 'recipientAddress resolved for intent', { recipientAddress });
1605
+ }
1606
+ if (isAtxp) {
1607
+ // Route ATXP intents to the ATXP endpoint so they link to the request
1608
+ const atxpRequestId = String(meta.atxp_request_id);
1609
+ const endpoint = `/sdk/public/atxp/requests/${encodeURIComponent(atxpRequestId)}/payment-intents`;
1610
+ intentResp = await this.publicApiClient.post(endpoint, {
1549
1611
  tokenShortcode: tokenShortcode || undefined,
1550
- // Legacy fields for backwards compatibility
1551
- symbol: tokenShortcode ? undefined : request.symbol,
1552
- ledgerCanisterId: tokenShortcode ? undefined : ledgerCanisterId,
1553
1612
  description: request.description,
1554
- expectedSenderPrincipal,
1555
- metadata: normalizeSdkMetadata(request.metadata || {}),
1556
- amountUsd: request.amountUsd,
1557
- // With tokenShortcode, backend derives chain. Keep legacy chainId for old flows.
1558
- chainId: tokenShortcode ? undefined : request.chainId,
1559
- widgetParams: request.widgetParams || undefined,
1560
1613
  recipientAddress,
1561
1614
  recipientAddresses: request?.recipientAddresses || undefined,
1562
1615
  externalCostAmount: request?.externalCostAmount ?? request?.metadata?.externalCostAmount ?? undefined,
1563
1616
  fiat_currency: request?.fiat_currency,
1564
1617
  });
1565
1618
  }
1619
+ else {
1620
+ if (onramp) {
1621
+ // Route onramp flows to the dedicated onramp endpoint without requiring token/ledger
1622
+ intentResp = await this.publicApiClient.post('/sdk/public/onramp/intents', {
1623
+ usdAmount: request.amountUsd,
1624
+ description: request.description,
1625
+ metadata: normalizeSdkMetadata(request.metadata || {}),
1626
+ widgetParams: request.widgetParams || undefined,
1627
+ recipientAddresses: request?.recipientAddresses || undefined,
1628
+ fiat_currency: request?.fiat_currency,
1629
+ });
1630
+ }
1631
+ else {
1632
+ intentResp = await this.publicApiClient.post('/sdk/public/payments/intents', {
1633
+ amount: (typeof request.amount === 'string' ? request.amount : (request.amount != null ? String(request.amount) : undefined)),
1634
+ // Prefer tokenShortcode if provided
1635
+ tokenShortcode: tokenShortcode || undefined,
1636
+ // Legacy fields for backwards compatibility
1637
+ symbol: tokenShortcode ? undefined : request.symbol,
1638
+ ledgerCanisterId: tokenShortcode ? undefined : ledgerCanisterId,
1639
+ description: request.description,
1640
+ expectedSenderPrincipal,
1641
+ metadata: normalizeSdkMetadata(request.metadata || {}),
1642
+ amountUsd: request.amountUsd,
1643
+ // With tokenShortcode, backend derives chain. Keep legacy chainId for old flows.
1644
+ chainId: tokenShortcode ? undefined : request.chainId,
1645
+ widgetParams: request.widgetParams || undefined,
1646
+ recipientAddress,
1647
+ recipientAddresses: request?.recipientAddresses || undefined,
1648
+ externalCostAmount: request?.externalCostAmount ?? request?.metadata?.externalCostAmount ?? undefined,
1649
+ fiat_currency: request?.fiat_currency,
1650
+ });
1651
+ }
1652
+ }
1566
1653
  }
1567
1654
  paymentIntentId = intentResp?.paymentIntent?.id || null;
1568
1655
  paymentIntentCode = intentResp?.paymentIntent?.intentCode ?? null;
@@ -2251,6 +2338,12 @@ class Icpay {
2251
2338
  // We forward both amountUsd and amount (if provided), and do not resolve canister here.
2252
2339
  const ledgerCanisterId = request.ledgerCanisterId || '';
2253
2340
  const tokenShortcode = request?.tokenShortcode;
2341
+ // Resolve existing payment intent id so API reuses it instead of creating a second intent (e.g. pay link page)
2342
+ const existingIntentId = (typeof request?.paymentIntentId === 'string' && request.paymentIntentId) ||
2343
+ (typeof request?.paymentIntent?.id === 'string' && request.paymentIntent.id) ||
2344
+ (typeof this.config?.paymentIntentId === 'string' && this.config.paymentIntentId) ||
2345
+ (typeof this.config?.paymentIntent?.id === 'string' && this.config.paymentIntent.id) ||
2346
+ null;
2254
2347
  // Hit X402 endpoint
2255
2348
  const body = {
2256
2349
  amount: request.amount,
@@ -2266,6 +2359,9 @@ class Icpay {
2266
2359
  recipientAddress: request?.recipientAddress || '0x0000000000000000000000000000000000000000',
2267
2360
  fiat_currency: request?.fiat_currency ?? request?.fiatCurrency ?? this.config?.fiat_currency,
2268
2361
  };
2362
+ if (existingIntentId) {
2363
+ body.paymentIntentId = existingIntentId;
2364
+ }
2269
2365
  if (body.fiat_currency === undefined || body.fiat_currency === '') {
2270
2366
  delete body.fiat_currency;
2271
2367
  }
@@ -2589,7 +2685,7 @@ class Icpay {
2589
2685
  catch { }
2590
2686
  if (sig) {
2591
2687
  try {
2592
- await this.performNotifyPaymentIntent({ paymentIntentId, transactionId: sig, maxAttempts: 1 });
2688
+ await this.performNotifyPaymentIntent({ paymentIntentId, transactionId: sig, maxAttempts: 1, icpayPaymentLink: request.metadata?.icpayPaymentLink });
2593
2689
  }
2594
2690
  catch { }
2595
2691
  }
@@ -3857,6 +3953,8 @@ class Icpay {
3857
3953
  body.externalCostAmount = params.externalCostAmount;
3858
3954
  if (typeof params.recipientPrincipal === 'string')
3859
3955
  body.recipientPrincipal = params.recipientPrincipal;
3956
+ if (params.icpayPaymentLink && typeof params.icpayPaymentLink === 'object')
3957
+ body.icpayPaymentLink = params.icpayPaymentLink;
3860
3958
  const resp = await notifyClient.post(notifyPath, body);
3861
3959
  // If this is the last attempt, return whatever we got
3862
3960
  if (attempt === maxAttempts) {
@@ -3908,6 +4006,7 @@ class Icpay {
3908
4006
  accountCanisterId: params.accountCanisterId,
3909
4007
  externalCostAmount: params.externalCostAmount,
3910
4008
  recipientPrincipal: params.recipientPrincipal,
4009
+ icpayPaymentLink: params.metadata?.icpayPaymentLink,
3911
4010
  });
3912
4011
  const status = resp?.paymentIntent?.status || resp?.payment?.status || resp?.status || '';
3913
4012
  const norm = typeof status === 'string' ? status.toLowerCase() : '';