Repository navigation
PRE-3761: Stop requiring the phone region to match the address countr… - #340
Merged
Merged
Conversation
jhoaraupp
reviewed
Oct 29, 2026
jhoaraupp
left a comment
Contributor
There was a problem hiding this comment.
Review summary: approve once the CHANGELOG is fixed. Nothing here can lose or duplicate money.
Checks run locally (PR head on a scratch worktree, UPC 1.2.2 loaded ahead of a local 1.2.1 vendor):
- PHPUnit: full suite OK, 1071 tests.
OrderAddressDtoCreatorTestandPaymentCaptureContextBuilderTest: 60 tests OK. - The same
tests/PHPUnit/Upcrun against UPC 1.2.1 gives 28 errors and 9 failures, so the^1.2.2bump is required. - ECS: clean on both changed files.
- PHPStan: not conclusive locally (static reflection still reads the 1.2.1 vendor); to confirm on CI.
- Called
splitPhonedirectly on edge cases:0612345678on MQ gives+33612345678, a BL0690…mobile is kept in strict mode thanks to the GP retry,+33…on DE is kept in non-strict mode and dropped in strict mode, and0639…on YT gives+262…. All as expected. - Checked:
PaymentCaptureContextBuilderis only used by the Hosted Fields new-card and saved-card handlers, so the scope described is right and Oney is not affected.
PR title and description (no file to anchor this on):
- The title is cut off: "…to match the address countr…".
- The description has leftover pasted text: "A gen 1 new message (ctrl+End) ↓ territory (
0696…on MQ →+596…)". - Typo carried over from the template: "ffeature".
Not for this PR, but worth knowing: a national-format number is still read in the address country. For example 0612345678 on a DE address becomes +49612345678, a valid German landline. This was already the case before the PR.
Worth keeping: the same region is used for toE164 and isMobile, an unusable number gives [null, null] and never '', the named argument reads clearly at the call site, and the tests cover all 11 territories in both modes.
ilajili
force-pushed
the
feature/PRE-3761_relax-phone-region-match
branch
from
October 29, 2026 14:48
fc22bb2 to
64afcc3
Compare
Require UPC ^1.2.2 and send a valid phone number even when it belongs to another country than the billing or shipping address. A metropolitan French number entered on an overseas address is sent as French, for Hosted Fields and for the other payment methods.
ilajili
force-pushed
the
feature/PRE-3761_relax-phone-region-match
branch
from
October 29, 2026 14:59
64afcc3 to
59fd320
Compare
jhoaraupp
approved these changes
Oct 30, 2026
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.
Description
Phone numbers are no longer dropped from the billing and shipping details sent to PayPlug in two cases:
+33…on a DE address) used to be rejected, becauseOrderAddressDtoCreatorcalled UPC'sPhoneHelperin strict mode.07 81 23 45 67on MQ) used to be read as a local number, judged invalid and sent asnull.Motivation: since UPC 1.2.2 (PRE-3751, payplug/unified-plugin-core#42),
PhoneHelper::toE164()andisMobile()accept an optionalbool $requireRegionMatch = true.OrderAddressDtoCreator::splitPhone()called them with two arguments, so it stayed strict: a number such as+33612345678on a DE address became[null, null]and the payment was created with no phone. This is the same regression PrestaShop hit in5.1.0 (PRE-3704, fixed by PRE-3752 / payplug-prestashop#141). Fixing it here before the next release from
develop.What changes
composer.json/composer.lock:payplug/unified-plugin-core^1.2.1→^1.2.2. The lock diff is the UPC entry and thecontent-hashonly (giggsey/libphonenumber-for-phpstays at 8.13.45).OrderAddressDtoCreator::createBilling()/createShipping(): new optional last parameterbool $requireRegionMatch = true. Constructor and DI are unchanged, and the default keeps the previous strictbehaviour for any other caller.
PaymentCaptureContextBuilder: passesrequireRegionMatch: falsefor billing and shipping.New
Upc\PhoneRegionResolver: the single source of the overseas rule, shared by both paths. For GP, MQ, RE, GF, YT, PM, BL, MF, NC, PF and WF it returns the address region first, then the regions sharing itsnumbering (BL ↔ MF ↔ GP), then
FR; any other country returns only itself. Same rule asgetPhoneNumberRegions()in payplug-prestashop#141. A genuine local number keeps its territory (0696…on MQ →+596…).OrderAddressDtoCreatorretries through that rule in strict and non-strict mode, with the same winning region fortoE164andisMobile. An unusable number gives no phone, never''.Legacy
PayPlugPaymentDataCreator::formatNumber()(libphonenumber) applies the same retry. Signature and return shape are unchanged, and foreign numbers are still accepted as before.CHANGELOG.md: "Requires UPC 1.2.2 or later" under### Changed, and one entry under### Fixed, both in the 2.0.0 sectionWhich code path serves which payment method
OrderAddressDtoCreator(new path): thepayplugmethod with Hosted Fields enabled, new card (CaptureHostedPaymentRequestHandler) and saved card (CaptureAliasPaymentRequestHandler).PayPlugPaymentDataCreator::formatNumber()(legacy path): Oney, Bancontact, Wero, Scalapay, Apple Pay, American Express, andpayplugwithout Hosted Fields.Foreign numbers were already accepted on the legacy path (verified by running
formatNumber()), so only Hosted Fields had that bug. The overseas case affected both paths.Scope, please read
OrderAddressDtoCreatoron Sylius, so that criterion is not covered by this PR.OneyInvalidDataRetrieverandOneyCompleteInfoDTO): they require a valid mobile number but do not check the region, so+33612345678on a DE address passes.A
07 81 23 45 67on MQ is refused by them.formatNumber()is shared, so Oney's payload goes through the new retry. In the checkout-form flow it changes nothing for Oney, because the validators refuse such a number before the payload is built (thevalidators were run; the checkout guard in
PaymentTypeExtensionwas read, not run). A payment that reachescreate()without that form was not traced.PhoneHelper(false), is pending the ticket author. Strict mode exists and is tested through theparameter, ready for that.
Type of Change
BC: none. PHP floor: unchanged (
^8.2). Behaviour: more valid phone numbers are now sent instead of being dropped.Checklist
Code Quality
Testing
sonarcloudCI job (to confirm on theCI)
Security & Ops
Testing notes
Automated (run in Docker, PHP 8.2)
OrderAddressDtoCreatorTest: 49 new cases. They cover the ticket's examples, non-strict, strict through the parameter, strict by default, the11 territories in both modes, a null or lowercase country, and shipping.
PaymentCaptureContextBuilderTest: checks that a foreign number is sent for billing and shipping.FRretry,FRfirst, stricttoE164orisMobile, default flipped tofalse, nostrtoupper) each make at least one test fail.