Skip to content

feat(core): multi-provider hosted checkout (providerChoices + create-session providerId) - #122

Open
alexasomba wants to merge 3 commits into
emdashCommerce:mainfrom
alexasomba:feat/hosted-multi-provider
Open

alexasomba wants to merge 3 commits into
emdashCommerce:mainfrom
alexasomba:feat/hosted-multi-provider

Conversation

@alexasomba

@alexasomba alexasomba commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What changes

  • HostedCheckoutForm accepts optional providerChoices and shows a selector when more than one provider is supplied. The selector stays available for retry after payment fails or the buyer closes on-page checkout.

  • checkout/create-session uses the selected registered, configured provider and binds it to the checkout draft. An unavailable selection returns a buyer-readable 409. A request without a selection uses the store default.

  • Closes feat(core): multi-provider hosted checkout (providerChoices + create-session providerId) #121.

The provider and checkout reference binding from Checkout and refund safety #115 is already on main. This branch includes the current upstream main.

moset15’s earlier checkout work also touches the hosted form. Each branch merges cleanly with this PR in a local merge check.

Validation

  • Core typecheck and build passed. All 365 Core and 105 Paystack tests passed locally.
  • The route regression covers the default provider, a selected provider, unknown and unconfigured selections, and a webhook from the wrong provider.
  • Verified in Chrome against a local Astro fixture. Digital carts retain the provider-neutral prompt, a 409 or dismissed checkout allows reselection, switching providers opens the selected fixture, and single-provider checkout sends no explicit provider ID.

@alexasomba

alexasomba commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@cavewebs — stacking for #122 review:

This branch currently includes #115; we'll rebase onto main after #115 merges.

#125 (declared webhook body) is independent of the multi-provider hosted checkout work here.

Thanks.

cavewebs added a commit that referenced this pull request Dec 3, 2026
## What and why

Checkout's country field always starts on `US` (`value="US"` in
`HostedCheckoutForm` and in the starter's embedded form), and core has
no setting for where the shop is based. A shopper on a shop outside the
US changes it on every order.

#103 (now carried in #107) works around the same gap in its payout form
by guessing the country from the default currency, and mentions a
shop-country setting as a follow-up. Once both land, that form can start
from this setting.

Part of the roadmap in #108.

## Behaviour

- **Before:** the ship-to country starts on `US`; a digital order's
country starts empty.
- **After, with the setting:** both start on the shop's country.
Customers can still change it.
- **Without the setting nothing changes.**

## Changes

- **New optional setting `storeCountry`** in `settings/schema.ts`:
checked against core's country list (`isValidCountryCode`), trimmed and
upper-cased. A country name or an unknown code is refused; `null` clears
it.
- **Settings → Store → Shop country:** a searchable country picker (the
kit's `Combobox` with `countryOptions()`) above the currency fields. The
card's description now mentions it.
- **`HostedCheckoutForm`:** a new optional `defaultCountry` prop. The
ship-to country starts on it (else `US`), and a digital order's country
is prefilled with it (else empty).
- **Starter:** reads the setting and passes it to the hosted form, and
to the embedded form's shipping and billing country.
- Changeset: minor for core (a new setting and prop), patch for the
starter.

No change to `routes/checkout.ts` or to currencies.

## Tests

`packages/core/test/store-country.test.ts`:

- through the real `admin/settings` route: saves `" ke "` as `KE` and
returns it; can be cleared with `null`; is `null` on a new shop; refuses
`"Kenya"`, `"XX"` and a number with a 400 naming the field;
- source checks on both forms' country inputs and the starter's wiring.

Five of the six fail without the change (the refusal test passes either
way, since an unknown key is refused too). Full suite: core 370 (364
before), paystack 105, lite 144, registry-setup 5, all passing. `tsc
--noEmit` passes for core, `astro check` for the starter, Biome is clean
on the new and changed lines; `bun.lock` is unchanged.

## Review points

- **Why not infer it from the currency?** Several countries share a
currency (USD, EUR), and a shop can sell in a currency that isn't its
own. An explicit setting is cheap and exact.
- **Payout form in #103:** not changed here, to keep this PR off #107's
files. A one-line follow-up after both merge.
- **No formatting churn:** Biome reports some older lines in
`SettingsPage.tsx` on `main`; they're left as they are.

**Next to #122:** both add props near the top of
`HostedCheckoutForm.astro`. If #122 merges first I'll rebase this; the
change itself doesn't overlap.
alexasomba and others added 3 commits December 4, 2026 06:38
…e-session

Adds providerChoices to HostedCheckoutForm and accepts an optional
providerId on checkout/create-session so buyers can pick Paystack vs
Flutterwave without wrapping the route in a host plugin.

Co-authored-by: Cursor <cursoragent@cursor.com>
@alexasomba
alexasomba force-pushed the feat/hosted-multi-provider branch from 0c6089c to 62d952f Compare December 4, 2026 05:39
@alexasomba

Copy link
Copy Markdown
Contributor Author

@cavewebs, I rebased this onto main after #115 merged and kept both the upstream variant-selection test and the provider-selection test. GitHub reports the PR as mergeable, and all 11 checks passed on 62d952f. CI run

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.

feat(core): multi-provider hosted checkout (providerChoices + create-session providerId)

1 participant