Repository navigation
PRE-3761: Stop requiring the phone region to match the address countr… #340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,8 +71,10 @@ public function buildCommonFields( | |
| $common->successUrl = $successUrl; | ||
| $common->cancelUrl = $successUrl . '?' . http_build_query(['status' => 'canceled']); | ||
| if (null !== $order) { | ||
| $common->billing = $this->orderAddressDtoCreator->createBilling($order); | ||
| $common->shipping = $this->orderAddressDtoCreator->createShipping($order); | ||
| // Any valid phone number is sent, even from another country than the address. The | ||
| // creator's strict mode (requireRegionMatch: true) is there for a method that needs it. | ||
| $common->billing = $this->orderAddressDtoCreator->createBilling($order, requireRegionMatch: false); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Info] The ticket's acceptance criterion "Oney: a foreign number is rejected" is still not covered. The description already says so. I confirmed that this builder is only used by
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vu ce matin au daily avec le PM, le critère reste ouvert. Oney n'est pas strict aujourd'hui et on garde cet état |
||
| $common->shipping = $this->orderAddressDtoCreator->createShipping($order, requireRegionMatch: false); | ||
| } | ||
|
|
||
| return $common; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PayPlug\SyliusPayPlugPlugin\Upc; | ||
|
|
||
| /** | ||
| * Lists the regions an address's phone number is read in, in order — shared by | ||
| * OrderAddressDtoCreator (Unified API/Hosted Fields) and the legacy PayPlugPaymentDataCreator. | ||
| */ | ||
| final class PhoneRegionResolver | ||
| { | ||
| /** | ||
| * Overseas territories sharing the French numbering, where shoppers often enter a | ||
| * metropolitan number in national format. | ||
| */ | ||
| private const FRENCH_NUMBERING_TERRITORIES = ['GP', 'MQ', 'RE', 'GF', 'YT', 'PM', 'BL', 'MF', 'NC', 'PF', 'WF']; | ||
|
|
||
| /** | ||
| * Territories sharing the +590 numbering with Guadeloupe: libphonenumber attributes a | ||
| * shared number to the first of these regions it is valid in. | ||
| */ | ||
| private const SHARED_NUMBERING_REGIONS = [ | ||
| 'BL' => ['GP', 'MF'], | ||
| 'MF' => ['GP', 'BL'], | ||
| ]; | ||
|
|
||
| /** | ||
| * @codeCoverageIgnore | ||
| */ | ||
| private function __construct() | ||
| { | ||
| } | ||
|
|
||
| /** | ||
| * @return list<string> the address country first, then the regions sharing its numbering, then | ||
| * FR for an overseas territory sharing the French numbering | ||
| */ | ||
| public static function resolve(string $countryCode): array | ||
| { | ||
| $countryCode = \strtoupper($countryCode); | ||
| if (!\in_array($countryCode, self::FRENCH_NUMBERING_TERRITORIES, true)) { | ||
| return [$countryCode]; | ||
| } | ||
|
|
||
| return [$countryCode, ...(self::SHARED_NUMBERING_REGIONS[$countryCode] ?? []), 'FR']; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Low] The default of
requireRegionMatchis the opposite of what the only caller uses.The only caller in prod (
PaymentCaptureContextBuilder) passesfalse. A future caller that forgets the argument gets strict mode, which drops the phone without any error: exactly the bug this PR fixes.Either option is fine:
truefor backward compatibility, and add a line to the docblock saying that the Hosted Fields capture path usesfalse.Same for
createShipping()at line 61.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, défaut conservé à true (compatibilité), docblock précisant que le chemin Hosted Fields passe false. Pas de suppression du paramètre : le ticket PRE-3761 demande Oney en strict, ce que le paramètre permet.