Repository navigation
Conversation
|
Thanks for working on this. Let's put this on-hold until the new UCP version + SDK is launched |
|
Sounds good, and once the new version and SDK are out I will re verify the module against the released text and refresh this PR to match. |
|
The hold condition here has cleared: v2026-08-25 is released and ucp-sdk 0.5.0 is published. Refreshing the module against the released text, and noting the payment constructs moved from shopping to common in ucp#741, so the import this module uses is absent in 0.5.0 while this repo still pins 0.4.4. Will push the refreshed branch shortly. |
80ca776 to
5bf15b1
Compare
|
Status update, since the hold condition here has now cleared. UCP v2026-08-25 released on 2026-08-25, and ucp-sdk v2026-08-25 (0.5.0) followed I have not refreshed the branch yet, because the suite itself still targets the That adoption is tracked separately in #104. Two options from here, whichever you
Happy either way, and happy to leave it on hold if the suite has a different |
damaz91
left a comment
There was a problem hiding this comment.
LGTM — thank you for refreshing this suite for the v2026-08-25 release and covering all seven dev.ucp.common.payment.terms invariants, @vishkaty!
Everything aligns cleanly with docs/specification/payment/extensions/terms.md and source/schemas/common/payment_terms.json:
- PT-001 – PT-003 (
test_selected_term_names_an_offered_term,test_term_ids_unique_within_checkout,test_selected_term_schedules_sum_to_checkout_total):selected_term_idpresence/resolution,terms[].iduniqueness, andschedules[].amountinteger validation and sum to the checkouttotal. - PT-004 & PT-005 (
test_selecting_each_term_recomputes_the_checkout,test_unresolvable_selection_is_not_silently_substituted): Term selection updates (_select_term), in-place schedule rewrite detection (_term_shape), controlPUTverification (_raw_selection_put) before probing an unresolvableselected_term_id, and checking forpayment_term_changedinmessages[]or4xxrejection. - PT-006 & PT-007 (
test_accepted_term_travels_to_the_order,test_due_at_when_present_is_rfc3339): Anchoringselected_idatready_for_complete, verifyingorder.payment.accepted_termID and schedule sum via_fetch_order, and validating RFC 3339date-timeformat and calendar bounds onschedules[].due_at. - The fallback import for
Payment(common.types.payment->shopping.payment) also keeps the test compatible acrossucp-sdkversions.
3a69b13 to
93de62f
Compare
|
Rebased onto main at Run against the sample server booted from samples main Once #121 lands this file moves under |
Seven cases over the payment terms extension, asserted against the raw wire payload: schedule sums, term id uniqueness, selected_term_id resolution, selection handling, and accepted_term on the order. Placed as `common/payments/terms_test.py` and registered as `common.payments.terms_test`, following the layout Universal-Commerce-Protocol#121 landed. Payment terms is a common payment extension, which is why it sits beside the other payment modules rather than under `shopping/`. Universal-Commerce-Protocol#120 made `SUITE_REGISTRY` the only path `--suite=all` runs, so the entry is what makes the module reachable: without it `--suite=all` selects none of these seven. Run against the sample server from samples main: 7 skipped, for the reason the description gives, since nothing in the reference advertises `dev.ucp.common.payment.terms`.
93de62f to
1246fb4
Compare
|
Rebased onto main at The test content is unchanged. The file is now Measured on this head against the sample server from samples main: 7 skipped, for the reason the |
…nformance The spellcheck job flagged three coined words in this module. They are reworded rather than added to .cspell/custom-words.txt, since no other file in the tree uses them. Running the cases for the first time found four defects in them. The reference serves 2026-04-08, where dev.ucp.common.payment.terms is not defined, so all seven skip against it; they were exercised behind an overlay that serves the extension, and each correction below has a server that fails the old code and passes the new one. PT-006 could not reach its assertions. It created the checkout with select_fulfillment=False and then called ensure_fulfillment_ready, and with no fulfillment on the create that helper has no method to update, so it builds one from nothing. The reference rejects that payload for two missing members, id and line_item_ids, of which fulfillment_method.json marks line_item_ids "update": "required" at the served version and id "update": "optional". The case fails on the 422 before asserting anything. The build-from-nothing path is reported upstream in Universal-Commerce-Protocol#102. This case now creates with fulfillment, the path every other completing case in the tree already uses. Against a business that honors the selection on create, as the reference does, readiness then issues no update at all; against one that does not, the helper updates the method the create supplied instead of building one. PT-005 treated a refusal as a silent substitution. A business may decline an unresolvable selected_term_id through the message channel rather than an HTTP 4xx, returning the checkout with a recoverable error for the platform to correct in band. Only an error the probe produced now counts, and only when the selection and the schedules of the term in effect are both unchanged: an incomplete checkout already lists what it still needs as recoverable errors, so counting those would excuse a business that ignored the selection outright, and a refusal that rewrites the term in effect is the case the warning exists to report. PT-004 applied the in-place warning rule to every offered term. terms.md states that unselected terms are indicative and directs a platform not to assume the amounts in terms[] survive selection unchanged, so the module takes the narrower reading: the rule binds only the term already in effect, which is what the case docstring described. The walk now visits that term first, because otherwise the rule is unreachable for a business that lists its default term anywhere but first. _new_terms_checkout skipped when terms[] was present but empty, which no case could then catch. payment_terms.json puts minItems 1 on terms and terms.md requires at least one term where terms is present, so that is asserted. Verified against the flower shop reference with the CI pinned SDK at v2026-04-08-6: --suite=all gives 90 executed, 81 passed, 9 skipped, 0 failures; the pinned pre-commit, ruff, ruff format and cspell are clean. Behind the overlay all seven cases pass, and fourteen servers each breaking one stated obligation redden their own case, including one that silently ignores the selection while carrying an unrelated recoverable error, one that refuses and rewrites the term in effect, and one that lists its default term second.
|
Spellcheck was the red check, and the three flagged words are reworded in Fixing only the spelling felt wrong without saying what running the cases PT-006 could not reach its assertions. It created the checkout with PT-005 treated a refusal as a silent substitution. A business may decline an PT-004 applied the in-place warning rule to every offered term, and failed a _new_terms_checkout skipped when terms[] was present but empty, so a server Verified on the branch as it stands, against the flower shop reference with
|
Adds a conformance module for the payment-terms capability that landed in ucp#602, covering the cross-field invariants the JSON schema cannot express. Offered in the #602 review thread (ucp#692 discussion) once the shape settled.
What it checks (all against the raw wire payload, following the totals_test.py stance):
Conformant variability is accepted, not just the happy path. A business that answers a valid selection by keeping the previous term with a payment_term_changed warning (a selection conflict), changes its default term during fulfillment updates (warned), embeds only an order reference at completion, changes which terms are offered across responses, or rejects an unresolvable selection with a 4xx instead of warning: all pass. Each of these is exercised as its own verification mode.
Gating and current CI behavior. The module gates on
dev.ucp.common.payment.termsin/.well-known/ucp(the discount_test.py pattern) and additionally skips when the driven checkout carries no terms, since offering terms on a given checkout is a business decision. Against the current sample server the module skips cleanly (verified against samples main); the checks activate the day a business or the reference advertises the capability.Verification. Exercised against a minimal golden business implementing the extension: 2 answer postures and 6 additional spec-sanctioned behavior variants all PASS (including an in-place term rewrite that is correctly warned); 11 violation mutants across 14 matrix rows each fail the intended test (wrong schedule sum, duplicate term ids, dangling and missing selected_term_id, ignored selection, silent substitution, missing and mis-summing accepted_term with both full and reference-only order embeds, malformed and naive due_at). Broad violations (a dangling selection, duplicate ids) legitimately fail every test that resolves the selected term; the selection, silence, order, and due_at tests each also have a surgical killer that fails them alone. Ruff lint and format clean per the repo config.
Notes and limits.