I've made it so it programmatically creates a user's mail and shipping address whenever they sign in via an external SSO. e.g. google sso.

The shipping address appears fine in the user's address book which includes the country.

but not in the checkout page, nor in the admin area:

enter image description here

The country comes back as a country code for example: GB or AU but in lower case.

Code for the address creation:

$_customer = array (
            'given_name' => $given_name,
            'family_name' => $family_name,
            'email' => $email,
            'birthdate' => $birthdate,
            'gender' => $gender,
            'street_address' => $decodedAddress->street_address,
            'locality' => $decodedAddress->locality,
            'postal_code' => $decodedAddress->postal_code,
            'country' => $decodedAddress->country,
            'region' => $decodedAddress->region,
            'phone_number' => $phone_number,

        $customer = $this->customerCustomerFactory->create();



        if(empty($decodedAddress->street_address)) {

            $customAddress = $this->addresss->create();



1 Answer 1


Magento doesn't recognize lower case country codes. So the country codes need to be upper-case for Magento to recognize the county code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.