This guide’s payment flow is based on the Commerce Payments Protocol.
Demo
Check and Capture
ReadpaymentState(paymentInfoHash) before capture. The amount must be nonzero, no greater than capturableAmount, and submitted strictly before authorizationExpiry.
The operator supplies an absolute feeAmount in raw token units. The protocol validates it against the per-capture minFeeBps and maxFeeBps stored in PaymentInfo.
TypeScript
capturableAmount and increases refundableAmount by the same gross amount. The receiver gets the gross amount minus fees.
Verify
PaymentCaptured(paymentInfoHash, amount, feeAmount, feeReceiver) and the expected receiver transfers before marking the fulfillment increment settled.Capture a Partial Amount
Pass a smalleramount to the same capture call for every increment. The sum of successful captures cannot exceed PaymentAuthorized.amount, and each capture independently validates its fee bounds. The remaining reservation is tracked onchain without a custom checkout contract.
For a 100 USDC authorization, a 64 USDC capture leaves 36 USDC capturable and makes 64 USDC refundable. You can capture another increment or void the remainder.
After every capture, reconcile
PaymentCaptured.amount with the new capturableAmount and refundableAmount before another worker advances the order.Capture Deadline
See Also
Void an Authorization
Return the unneeded remainder to the payer.
Refund a Payment
Return previously captured value to the payer.