Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tailwind-plus-icpay",
"version": "1.2.39",
"version": "1.2.40",
"private": true,
"packageManager": "pnpm@9.12.3",
"scripts": {
Expand Down
9 changes: 3 additions & 6 deletions src/app/agentic-x402/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,10 @@ const icpayBackend = new Icpay({
})

export async function runJobAndSettle(paymentIntentId: string, usageUsd: number) {
// 1) Convert usageUsd to token smallest unit (you can use ICPay helpers or your own pricing)
const usageAmountAtomic = await computeAtomicAmountFromUsd(usageUsd, /* token info */)

// 2) Commit settlement (must satisfy 0 < settledAmount <= maxAmountRequired)
// 1) Commit settlement (ICPay converts USD to token units and enforces cap)
const result = await icpayBackend.protected.settleX402Upto({
paymentIntentId,
settledAmount: usageAmountAtomic.toString(),
settledAmountUsd: usageUsd,
})

if (!result.ok) {
Expand Down Expand Up @@ -217,7 +214,7 @@ New protected method:
```ts
icpayBackend.protected.settleX402Upto({
paymentIntentId: string;
settledAmount: string | number; // smallest unit, <= maxAmountRequired
settledAmountUsd: string | number; // USD, ICPay converts to token units and enforces <= maxAmountRequired
})
```

Expand Down
Loading