-
Notifications
You must be signed in to change notification settings - Fork 316
feat: formalize totals contract #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+238
−37
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5cdfb59
feat: formalize totals contract
igrigorik 6fd2c53
use signed amounts in totals, drop effect field
igrigorik aba5943
enforce sign convention for well-known totals types
igrigorik d2da3cb
Merge branch 'main' into feat/totals-contract
igrigorik f64c7b3
revert total.json rename, preserve $id
igrigorik 9a99204
scope signed amounts to checkout-level totals only
igrigorik 908556d
display_text optional for well-known & required for other
igrigorik 3ef313e
Merge branch 'main' into feat/totals-contract
igrigorik f3a8167
MUST NOT autonomously complete on totals mismatch
igrigorik 33c410a
update discount amounts to negative values in totals
igrigorik 29d949e
relationship between discount extension and totals
igrigorik a3a55f7
Merge branch 'main' into feat/totals-contract
amithanda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "$schema": "https://json-schema.org/draft/2020-12/schema", | ||
| "$id": "https://ucp.dev/schemas/shopping/types/signed_amount.json", | ||
| "title": "Signed Amount", | ||
| "description": "Monetary amount in the currency's minor unit as defined by ISO 4217. Refer to the currency's exponent to determine minor-to-major ratio (e.g., 2 for USD, 0 for JPY, 3 for KWD). May be negative — the sign is intrinsic to the value (e.g., discounts are negative, charges are positive).", | ||
| "type": "integer" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| { | ||
| "$schema": "https://json-schema.org/draft/2020-12/schema", | ||
| "$id": "https://ucp.dev/schemas/shopping/types/totals.json", | ||
| "title": "Totals", | ||
| "description": "Pricing breakdown provided by the business. MUST contain exactly one subtotal and one total entry. Detail types (tax, fee, discount, fulfillment) may appear multiple times for itemization. Platforms MUST render all entries in order using display_text and amount.", | ||
| "type": "array", | ||
| "items": { | ||
| "allOf": [ | ||
| { | ||
| "$ref": "total_line.json" | ||
| }, | ||
| { | ||
| "type": "object", | ||
| "required": [ | ||
| "display_text" | ||
igrigorik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ], | ||
| "properties": { | ||
| "lines": { | ||
igrigorik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "type": "array", | ||
| "items": { | ||
| "type": "object", | ||
| "required": [ | ||
| "display_text", | ||
| "amount" | ||
| ], | ||
| "properties": { | ||
| "display_text": { | ||
| "type": "string", | ||
| "description": "Human-readable label for this sub-line." | ||
| }, | ||
| "amount": { | ||
| "$ref": "signed_amount.json" | ||
| } | ||
| }, | ||
| "description": "Sub-line entry. Additional metadata MAY be included." | ||
| }, | ||
| "description": "Optional itemized breakdown. The parent entry is always rendered; lines are supplementary. Sum of line amounts MUST equal the parent entry amount.", | ||
| "ucp_request": "omit" | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "if": { "properties": { "type": { "enum": ["discount", "items_discount"] } }, "required": ["type"] }, | ||
| "then": { "properties": { "amount": { "exclusiveMaximum": 0 } } } | ||
| }, | ||
| { | ||
| "if": { "properties": { "type": { "enum": ["subtotal", "fulfillment", "tax", "fee"] } }, "required": ["type"] }, | ||
| "then": { "properties": { "amount": { "minimum": 0 } } } | ||
| } | ||
| ] | ||
| }, | ||
| "allOf": [ | ||
| { | ||
| "contains": { "properties": { "type": { "const": "subtotal" } }, "required": ["type"] }, | ||
| "minContains": 1, | ||
| "maxContains": 1 | ||
| }, | ||
| { | ||
| "contains": { "properties": { "type": { "const": "total" } }, "required": ["type"] }, | ||
| "minContains": 1, | ||
| "maxContains": 1 | ||
| } | ||
| ] | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.