← All Articles
UCP Totals Now Accept Signed Amounts
RC
Ryan C (wry-ry)
UCP contributor focused on schema correctness and checkout flow semantics. Previously contributed to CI pipeline overhauls and documentation improvements.
Why This Matters
UCP's checkout specification has always supported negative amounts — discounts, account credits, and promotional adjustments that reduce the total. The official examples show this clearly. But until now, there was a subtle schema bug: the total field referenced amount.json (unsigned) instead of signed_amount.json.
This mismatch meant that while the spec described negative totals, the schema would reject them. Implementers following the JSON Schema strictly would find their discount scenarios failing validation.
The Problem
When a checkout total goes negative (e.g., a $50 order with a $60 account credit), the total is -$10.00. The old schema couldn't represent this — the amount type only accepted non-negative values.
What Changed Technically
The fix is elegant in its simplicity: a single-line change swapping the schema reference from amount.json to signed_amount.json.
// Before
"total": { "$ref": "amount.json" }
// After
"total": { "$ref": "signed_amount.json" }
Commerce Scenarios Unlocked
This seemingly small change unlocks important commerce patterns that were technically unsupported:
- Account Credits: Customer has store credit exceeding the order value — total goes negative, merchant owes the customer.
- Promotional Overages: Aggressive first-order discounts that exceed item cost, subsidizing customer acquisition.
- Refund Previews: Showing negative totals when previewing refund amounts before confirmation.
- Gift Card Balances: When a gift card value exceeds checkout total, the difference is negative.
Implications for Implementers
If you're implementing a UCP merchant or agent:
- Update your schema: Pull the latest UCP schemas to enable signed total validation.
- Review total handling: Ensure your payment processing can handle negative totals gracefully — these typically indicate credits rather than charges.
- Test edge cases: Validate that your checkout flows handle the zero-crossing correctly (positive → negative → positive).
🔮 What's Next
This PR is currently open and under review. The fix aligns the schema with the specification's documented examples, so approval is expected. Watch for the merge and subsequent spec version bump.
Related work: PR #295 adds attribution extensions to checkout, and PR #296 introduces card network token credentials — both building out UCP's payment infrastructure.