@relai-fi/x402 0.6.9 → 0.6.11-rc.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
@@ -1751,6 +1751,8 @@ import {
1751
1751
  getPayRequest,
1752
1752
  payPayRequest,
1753
1753
  payPayRequestWithCode,
1754
+ payPayRequestWithStoredCode,
1755
+ type PaymentRequestObject,
1754
1756
  } from '@relai-fi/x402';
1755
1757
 
1756
1758
  const config = { facilitatorUrl: 'https://relai.fi/facilitator' };
@@ -1784,6 +1786,16 @@ console.log('Explorer:', result.explorerUrl);
1784
1786
  if (result.changeCode) {
1785
1787
  console.log(`Change $${Number(result.change) / 1e6} USDC → code: ${result.changeCode}`);
1786
1788
  }
1789
+
1790
+ // ── Agent / vault flow: reuse a fetched request object directly ─────────────
1791
+ const fetchedRequest: PaymentRequestObject = await getPayRequest(config, 'MW78SGTW');
1792
+ const storedCodeResult = await payPayRequestWithStoredCode(
1793
+ config,
1794
+ fetchedRequest,
1795
+ 'MYVAULT78',
1796
+ { returnChange: 'code' },
1797
+ );
1798
+ console.log('Stored code payment success:', storedCodeResult.success);
1787
1799
  ```
1788
1800
 
1789
1801
  ### `payPayRequestWithCode` options
@@ -1793,6 +1805,13 @@ if (result.changeCode) {
1793
1805
  | `returnChange` | `'code' \| 'wallet'` | `'code'` | How to return surplus when code value > invoice |
1794
1806
  | `allowOverpayment` | `boolean` | `true` | If `false`, throws when code value ≠ invoice amount |
1795
1807
 
1808
+ `payPayRequestWithStoredCode()` accepts either:
1809
+
1810
+ - a payment request code string, or
1811
+ - a fetched `PaymentRequestObject` from `getPayRequest()`
1812
+
1813
+ Passing the object lets agents skip the extra request lookup when they already have the decoded request in memory. For stored Solana codes, the object must include a valid `code` field because the Solana facilitator endpoint still resolves the merchant request by `requestCode`.
1814
+
1796
1815
  **`returnChange` behaviour:**
1797
1816
 
1798
1817
  | Value | Mechanism | Requires buyer wallet? |