Skip to content

TWO-24814/TWO-24952: source payment terms + surcharge cap (+ default term) from the merchant API#236

Open
dgjlindsay wants to merge 1 commit into
stagingfrom
doug/TWO-24814-api-source-terms-surcharge
Open

TWO-24814/TWO-24952: source payment terms + surcharge cap (+ default term) from the merchant API#236
dgjlindsay wants to merge 1 commit into
stagingfrom
doug/TWO-24814-api-source-terms-surcharge

Conversation

@dgjlindsay

Copy link
Copy Markdown
Contributor

What

The offerable payment terms, the buyer-surcharge cap and the merchant's default term are per-merchant commercial values — they vary between merchants of the same brand — so GET /v1/merchant is their authoritative source, not brand.xml. This mirrors the minimum-order-value pattern already in the plugin.

End state

  • Service/Merchant/RecordProvider — one verify_api_key → GET /v1/merchant fetch, cached + memoised per API key. Single source of the merchant record for every consumer.
  • Service/Merchant/SettingsProvidergetAvailableTerms (available_terms), getSurchargeLimit (surcharge_limit), getDefaultTerm (due_in_days).
  • MinimumOrderProvider now consumes RecordProvider (parsing only); its fetch/cache protocol moved into the shared provider — no behaviour change.
  • Admin payment-terms + surcharge-grid blocks and the AvailablePaymentTerms source model read the offerable terms and the surcharge cap from the merchant API. The admin still narrows the buyer-facing term set.
  • getDefaultPaymentTerm prefers the merchant's due_in_days when it is an offered term, else the existing admin/lowest-available fallback (ABN-439 behaviour preserved). SettingsProvider is injected into ConfigRepository via a \Proxy to break the construction cycle.
  • Removes the now-unused getAvailablePaymentTerms / getSurchargeFixedMax from BrandRegistryInterface and its implementors, the Descriptor fields/getters, the Loader parse, and <available_payment_terms> from the vanilla brand.xml. brand.xsd keeps the elements optional for the transition.

Scope / companion

Vanilla-engine half. A companion overlay PR removes the now-inert <available_payment_terms> + <surcharge_fixed_max> from the ABN brand.xml (they go dormant the moment this merges). Targets staging.

Fresh-install note

When the API key is unset/invalid the offerable-terms set resolves empty (the admin can't offer terms until the key validates) — accepted, since a valid key always returns a non-empty set.

Tests

218 unit tests green (new RecordProviderTest + SettingsProviderTest; MinimumOrderProviderTest slimmed to parsing; Repository tests cover the API-preferred default term). phpstan + setup:di:compile run in CI.


PR description authored by Claude (Doug's session).

…erchant API

TWO-24814 / TWO-24952 / TWO-24859

The offerable payment terms, the buyer-surcharge cap and the merchant's
default term are per-merchant commercial values — they vary between
merchants of the same brand — so GET /v1/merchant is their authoritative
source, not brand.xml. Mirrors the minimum-order-value pattern already
in place.

- Add Service/Merchant/RecordProvider: one verify_api_key -> GET
  /v1/merchant fetch, cached + memoised per API key. Single source of the
  merchant record for every consumer.
- Add Service/Merchant/SettingsProvider: getAvailableTerms (available_terms),
  getSurchargeLimit (surcharge_limit), getDefaultTerm (due_in_days).
- MinimumOrderProvider now consumes RecordProvider (parsing only); the
  fetch/cache protocol moved into the shared provider.
- Admin payment-terms + surcharge-grid blocks and the AvailablePaymentTerms
  source model read the offerable terms and surcharge cap from the merchant
  API; the admin still narrows the buyer-facing term set.
- getDefaultPaymentTerm prefers the merchant's due_in_days when it is an
  offered term, else the existing admin/lowest fallback. SettingsProvider is
  injected into ConfigRepository via a \Proxy to break the construction cycle.
- Remove the now-unused getAvailablePaymentTerms / getSurchargeFixedMax from
  BrandRegistryInterface and its implementors, the Descriptor fields/getters,
  the Loader parse, and <available_payment_terms> from the vanilla brand.xml.
  brand.xsd keeps the elements optional for the transition.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant