Skip to content

Commit

Permalink
SW-405: fixed handling of missing paypal express address data
Browse files Browse the repository at this point in the history
  • Loading branch information
fatchip-Stefan committed Nov 8, 2022
1 parent da6eda5 commit d903ab5
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions Frontend/MoptPaymentPayone/Components/Classes/PayoneUserHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,29 @@ protected function createForm($type, $data = null, array $options = array())
*/
protected function extractData(array $personalData, $paymentId)
{
// uncomment to simulate missing paypal phone number
// unset($personalData['telephonenumber']);
// uncomment to simulate missing paypal adress data
/*
unset($personalData['street']);
unset($personalData['city']);
unset($personalData['country']);
unset($personalData['countrycode']);
unset($personalData['zip']);
unset($personalData['addressaddition']);
unset($personalData['firstname']);
unset($personalData['lastname']);
unset($personalData['telephonenumber']);
*/
$isPhoneMandatory = Shopware()->Config()->get('requirePhoneField');

// paypal express does not use the billing_ prefix so rename the keys
// also split lastname value into firstname and lastname
if (!isset($personalData['billing_street']) && isset($personalData['street'])) {
$keys = [ 'street', 'city', 'country', 'zip', 'addressaddition', 'lastname', 'telephonenumber'];
// also split lastname (billing firstname and billing lastname) value into firstname and lastname
if (!isset($personalData['billing_street']) && (isset($personalData['street']) || isset($personalData['shipping_street']))) {
$splitName = explode(' ', $personalData['lastname']);
$personalData['lastname'] = $splitName[1];
$personalData['firstname'] = $splitName[0];
$keys = [ 'street', 'city', 'country', 'zip', 'addressaddition', 'firstname', 'lastname', 'telephonenumber'];
foreach ($keys AS $origKey) {
if ($origKey !== 'lastname') {
$personalData['billing_' . $origKey] = (!empty($personalData[$origKey])) ? $personalData[$origKey] : $personalData['shipping_' . $origKey];
} else {
$splitName = explode(' ', $personalData[$origKey]);
$personalData['billing_' . $origKey] = $splitName[1];
$personalData['billing_firstname'] = $splitName[0];
}
$personalData['billing_' . $origKey] = (!empty($personalData[$origKey])) ? $personalData[$origKey] : $personalData['shipping_' . $origKey];
unset($personalData[$origKey]);
}
$personalData['shipping_telephonenumber'] = $personalData['billing_telephonenumber'];
Expand Down

0 comments on commit d903ab5

Please sign in to comment.