Appearance
739 — Upgrade stripe-php 9.9 → ^22.1 and pin the Stripe API version explicitly
Objective
stripe/stripe-php is locked at v9.9.0 (2022), which sends no Stripe-Version header, so every shop silently runs on its own Stripe account's default API version. Move to ^22.1 — the first line whose CI tests PHP 8.5 (epic #971) — and set one explicit API version at every SDK entry point, fixing the two places the newer API breaks or exposes (payment_method_types, no_payment_required). Live Stripe test-account checks happen later, when a client provides test keys.
Acceptance criteria
Copied verbatim from issue #739 — first the body's criteria, then the "Amended at triage" changes (owner decisions, 2026-11-10), which supersede the body where they conflict.
Body criteria (verbatim)
- Prerequisite, and it gates every criterion below: the Stripe account's current default API version has been read from the Stripe Dashboard (Workbench, API versions) and recorded in a comment on this issue. It cannot be derived from the repository, and it determines whether the pin step is a no-op or a migration.
composer.jsondeclares"stripe/stripe-php": "^21.0", andcomposer show stripe/stripe-phpreports an installed21.xversion.composer why-not stripe/stripe-php 21.3.1returns no blocking line attributable to our own constraint.- All four SDK entry points pass an explicit API version equal to the value recorded above:
src/Stripe/Checkout/StripeCheckout.php:147and:285via theStripeClientconfig keystripe_version, andsrc/Domains/Checkout/Payment/Adapters/StripeAdapter.php:31plussrc/Rest/Checkout/Controllers/Checkout.php:1489viaStripe::setApiVersion(). Verify by grepping forstripe_versionandsetApiVersionand confirming four hits, none of them a hardcodeddahliavalue at this stage. vendor/bin/phpunitis green on all four suites (Unit, Integration, Database, Legacy), compared against the same run ondevelopbefore the bump. Regenerateautoload_classmap.phpand deletecache/container.phpfirst, or phantom failures will be misread as real.composer check-containerexits 0 — a green Unit suite is not proof the DI container compiles.vendor/bin/phpcsshows no new sniff or message on each changed file versusgit show develop:<file>for that same file. The baseline is not green, so only a delta counts.- Unit coverage exists for at least one SDK-touching path. There is none today: every
stripehit undertests/is currently a bare string or a comment. - On a test Stripe account, each of these completes end to end and reaches a PAID order: a normal card checkout through the legacy storefront; a REST-placed order via
POST /rest/checkout/place-orderwith paywaystripe; and one run each withENABLE_PRODUCT_PRICES_APIon and off, andENABLE_CUSTOMERS_APIon and off (the fourSTRIPEkeys atecommercen/eshop/libraries/AdvPaymentsRegistry.php:644-654). - A changelog fragment is added, and an entry appended to
rest_api_versions.phpif any REST-observable behaviour changes. If nothing observable changes, the PR says so explicitly instead.
Amended at triage (verbatim)
Acceptance criteria — changes from the owner decisions above (all other criteria in the body stand)
- The "prerequisite" criterion (read the account default from the Dashboard) is dropped: the version is fixed by decision 2.
composer.jsondeclares"stripe/stripe-php": "^22.1";composer show stripe/stripe-phpreports22.x;composer why-not stripe/stripe-php 22.1.0returns no blocking line from our own constraint. The lock diff moves onlystripe/stripe-php(and the content hash).- All four entry points (lines above) pass an explicit API version equal to
\Stripe\Util\ApiVersion::CURRENTof the installed SDK —stripe_versionin theStripeClientconfig,Stripe::setApiVersion()next tosetApiKey(). No registry key or admin field is added. StripeAdapterno longer sendspayment_method_types; the Session it creates is still card-capable under endive (replacement chosen at delivery:allowed_payment_method_typesor the account's dynamic payment methods), proven by a unit test on the request params.no_payment_requiredis handled in both places (legacy switch atAdv_checkout.php:3359and RESTCheckout.php:2090): an order whose Stripe session reportsstatus = completeandpayment_status = no_payment_requiredis treated as paid; unit coverage for both.- The end-to-end test-account checkout criterion is moved out of the merge gate (decision 4); unit tests with a mocked Stripe HTTP layer cover each SDK-touching path changed here.
- Changelog fragment with a Check for overrides / composer note for the 35 forks that pin
^9.5, and an entry inrest_api_versions.phponly if a REST response changes (otherwise the PR says so).
Decisions
- Target version —
"stripe/stripe-php": "^22.1"(v22.1.0). Why: owner decision; first line CI-tested on PHP 8.5, needs PHP >= 7.4 (we support 8.1 and 8.5). Rejected:^21.3(CI only to 8.4; the endive break would come later anyway). - One API version, from one place — a small new class
Advisable\Stripe\StripeApiVersion(src/Stripe/StripeApiVersion.php) withcurrent(): stringreturning\Stripe\Util\ApiVersion::CURRENTof the installed SDK (2026-10-28.endivefor v22.1.0). All four entry points use it:StripeCheckout.php:147and:285switchnew StripeClient(<key>)tonew StripeClient(['api_key' => <key>, 'stripe_version' => StripeApiVersion::current()]);StripeAdapter.php:32andCheckout.php:2087add\Stripe\Stripe::setApiVersion(StripeApiVersion::current())next tosetApiKey(). Why: owner decision (fixed version, no registry override) plus one place to change when the SDK moves. Rejected: a per-installationSTRIPE.API_VERSIONregistry key (owner declined; would also need an ElxisSettings.phpport); hard-coding the date string at four sites (drifts from the SDK). - Fail loudly on an old SDK (owner decision, 2026-11-10, after the independent PR review) —
StripeApiVersion::current()first callsassertSupported(\Stripe\Stripe::VERSION)and throws aRuntimeException("stripe/stripe-php 22.1.0 or later is required ...") when the installed SDK is older thanMINIMUM_SDK_VERSION(22.1.0). Why: stripe-php 9.9.0 also hasApiVersion::CURRENT(2022-08-01),setEnableTelemetry()and thestripe_versionoption, so a fork that merges this code but keeps^9.5would otherwise run silently on API2022-08-01, whereallowed_payment_method_typesdoes not exist (the global no-hidden-fallbacks rule). Rejected: relying on the changelog note alone (11 forks conflict on thatcomposer.jsonline). The test fake also sets a stale global API version so the static-path pin tests can fail; theStripeClientpin cannot be told apart by a behavioural test while the SDK's own default equalscurrent(), and stays as the explicit pin. payment_method_types→allowed_payment_method_types—StripeAdapter.php:35replaces'payment_method_types' => ['card']with'allowed_payment_method_types' => ['card'](after the developer confirms that parameter exists forCheckout\Session::createin v22.1.0 / API2026-10-28.endive; if it does not, STOP and report). Why: endive removedpayment_method_types; this keeps today's card-only behaviour. Rejected: dropping the parameter and relying on the account's dynamic payment methods (would change which methods customers see, per account, untested).no_payment_required= paid — a Stripe session withstatus = completeandpayment_status = no_payment_requiredis treated exactly likepaid: the legacy switch inecommercen/checkout/controllers/Adv_checkout.php(~3359) gets that case on thepaidarm, andCheckout::verifyStripePayment()(src/Rest/Checkout/Controllers/Checkout.php:2090) accepts both. Why: owner decision; a 100%-discount order otherwise falls through with no outcome. Rejected: a separate issue.- Implementer —
domain-developerfor the whole change. Why: almost all of it is insrc/(Stripe wrapper, Domains adapter, REST controller); the legacy part is one switch case inAdv_checkout.php, too small for a second agent. Rejected: splitting legacy/modern across two developers. - Lock change kept minimal —
composer require stripe/stripe-php:^22.1 --no-update(or edit the line), thencomposer update stripe/stripe-php(no-W). Thecomposer.lockdiff may move onlystripe/stripe-phpand the content hash. Why: reviewable dependency PR. Rejected: a full update. - Tests — unit tests with the SDK's injectable HTTP client (a fake
\Stripe\HttpClient\ClientInterfaceviaApiRequestor::setHttpClient, or theStripeClienthttp_clientoption — whichever v22.1.0 supports) for each changed path: theStripe-Versionheader equalsStripeApiVersion::current()at all four entry points;StripeAdaptersendsallowed_payment_method_typesand notpayment_method_types;verifyStripePayment()true forpaidandno_payment_required, false otherwise; the legacyno_payment_requiredarm. Tests restore any global SDK state they set (Stripe::$apiKey,$apiVersion, the HTTP client). - SDK side effects to check, not assume — the issue body names two v20+/v21 behaviours: telemetry, and
trigger_error(E_USER_WARNING)on a Stripe notice header (v22.0.0 addsSTRIPE_SUPPRESS_NOTICES). The developer reads the v22.1.0 source and reports what each does; if the SDK writes any file outside the app (e.g. under$HOME/%APPDATA%), disable that at the same four sites. Notice warnings stay on (they reach the existing error logging). Why: the body's description dates from v21 and is unverified. - REST changelog — the docs agent adds a
rest_api_versions.phpentry only if a REST response or contract changes (acceptingno_payment_requiredin verification changes an outcome for such orders, so it decides and says so). Why: repo convention.
Contracts
- New
Advisable\Stripe\StripeApiVersion::current(): string— the one source of the pinned Stripe API version. Checkout::verifyStripePayment()(REST) — now also returns true forpayment_status = no_payment_required(withstatus = complete).- Every Stripe API request from our code carries
Stripe-Version: <StripeApiVersion::current()>(today: none). - No existing public/protected method signature changes; no registry key, config key or DB change. Amended 2026-11-10 (owner, after review): two additive test seams are accepted —
Adv_checkout::stripeResponseSuccess()widened fromprivatetoprotected(its siblingstripeResponseFail()already is) and a newprotected Checkout::stripeSecretKey()in the REST controller; no fork declares either name (all fork checkouts checked), and the changelog fragment carries the Check for overrides note.
Out of scope
- Running the Database test suite locally for this change — waived by the owner (2026-11-10): the change touches no database code; the fast suite (all suites except the
databasegroup) gave identical failing names before and after, and the Bitbucket pipeline runs the fast suite on PHP 8.1 and 8.5, with the full suite nightly ondevelop. - The live end-to-end checkouts on a Stripe test account — later, when a client provides test keys (owner decision 4).
- A Stripe webhook handler — #723 (it must match this pin when it lands).
application/libraries/merchant/Merchant_stripe.php(raw cURL, loaded by nothing).- A per-installation API-version setting (owner declined).
- Porting the 35 forks' own
composer.jsonpins — they get the changelog note.
Open questions carried
- None blocking. The two SDK side effects (telemetry, notice warnings) are verified by the developer, with the rule above.