TWO-24751/feat: Payment terms chip selector and offset pricing fee#323
Open
dgjlindsay wants to merge 3 commits into
Open
TWO-24751/feat: Payment terms chip selector and offset pricing fee#323dgjlindsay wants to merge 3 commits into
dgjlindsay wants to merge 3 commits into
Conversation
Buyer-selectable invoice terms at checkout (chip per term, Magento parity) plus optional pass-through of the service fee as a buyer-facing line, computed by POST /v1/pricing/order/fee - the plugin does no fee arithmetic, it posts the offset settings as a buyer_fee_share block and charges exactly the backend's answer (simple / partial / incremental reference-terms variants). Architecture per TWO-24751's checkout-type separation requirement: all business logic (term resolution, selection validation, fee quoting, cart fee, payload terms) lives in WC_Twoinc_Payment_Terms; twoinc.js renders chips from the wc-ajax endpoints and posts selections back, so the Gutenberg port (TWO-24767) only needs a new presentation layer. Term availability resolves brand config (available_terms, new key: 14/30/60/90 for Two) intersected with the merchant's admin subset, behind a single seam method - the planned backend term-availability surface replaces only that method (see the TWO-24751 design-constraint comment; no scattered term-grid reads). The fee enters the cart as a native WC fee (taxed by the store's tax handling, keeping net + tax = gross internally consistent - same posture as Magento's store-configured surcharge tax rate) and flows into the order payload through the existing fee line-item path. The selected term + offered set ride the create-order payload as terms/available_terms. Failed fee quotes are fail-soft: chips render without labels, checkout never blocks. Single-term sets render one non-interactive chip. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
🖌 Pre-commit success 🏆DetailsExit code: 0 Author ✍️@dgjlindsay |
Replace all references to a specific partner brand name with generic "brand overlay" terminology in comments across the plugin.
WC_Twoinc_Payment_Terms::fetch_term_fee calls $gateway->make_request() from outside the gateway class; with the method private that path fatals the moment a fee quote runs against the real gateway (the unit-test stub masked it by declaring its own public override). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Buyer-selectable invoice terms at checkout (chip selector, Magento parity) + optional offset pricing: the merchant's service fee passed to the buyer as a separate line, in three variants (simple 100%, partial percentage, incremental vs a reference term).
Design
POST /v1/pricing/order/feeas abuyer_fee_shareblock; the backend's answer is charged verbatim (mirrors Magento's SurchargeCalculator pattern).WC_Twoinc_Payment_Termsclass owns term resolution, selection validation, fee quoting, the cart fee, and payload terms.twoinc.jsrenders chips from two wc-ajax endpoints (two_term_fees,two_select_term).get_available_terms()= brandavailable_terms(new key, 14/30/60/90 for Two) ∩ merchant admin subset. The planned backend term-availability surface replaces only this method — see the design-constraint comment on TWO-24751. Deliberate divergence from the ticket text: the admin day list is constrained to the brand set rather than free-form, so the future backend swap can't widen what a brand allows.updated_checkout.terms/available_terms; selection also posts with the checkout form (hidden field) so order-pay-page flows work sessionless.Tests
6 new unit specs (PHP 8.2 via
make test-unit, all green): brand∩admin resolution, default fallback, the three buyer_fee_share shapes + malformed-percentage fallback, payload terms presence/absence, invalid-POST fallback.🤖 Generated with Claude Code