protected function Checkout::populateProfile in Commerce PayPal 8
Populate the given profile with the given PayPal address.
Parameters
\Drupal\profile\Entity\ProfileInterface $profile: The profile to populate.
array $address: The PayPal address.
1 call to Checkout::populateProfile()
- Checkout::updateProfile in src/
Plugin/ Commerce/ PaymentGateway/ Checkout.php - Updates the profile of the given type using the response returned by PayPal.
File
- src/
Plugin/ Commerce/ PaymentGateway/ Checkout.php, line 861
Class
- Checkout
- Provides the PayPal Checkout payment gateway.
Namespace
Drupal\commerce_paypal\Plugin\Commerce\PaymentGatewayCode
protected function populateProfile(ProfileInterface $profile, array $address) {
// Map PayPal address keys to keys expected by AddressItem.
$mapping = [
'address_line_1' => 'address_line1',
'address_line_2' => 'address_line2',
'admin_area_1' => 'administrative_area',
'admin_area_2' => 'locality',
'postal_code' => 'postal_code',
'country_code' => 'country_code',
];
foreach ($address as $key => $value) {
if (!isset($mapping[$key])) {
continue;
}
// PayPal address fields have a higher maximum length than ours.
$value = $key == 'country_code' ? $value : mb_substr($value, 0, 255);
$profile->address->{$mapping[$key]} = $value;
}
}