applepayjs

How to fetch user's email address associated with Apple Pay Account from Apple Pay using JavaScript


I wanted to know if Apple has an API which we can use to fetch user's email address associated with apple pay account.

FYI I am using apple pay js (ApplePaySession) for apple pay. Or is there another way to fetch user's email address from Apple pay in JavaScript.

Thank You!


Solution

  • Once the user authorizes the transaction, you will get the shippingContact Object like this:-

    {
    "locality": “India",
    "country": "India",
    "postalCode": "95014-2083",
    "administrativeArea": "CA",
    "emailAddress": “sachin@example.com”,
    "familyName": “Tendulkar",
    "addressLines": [
    "1 Infinite Loop"
    ],
    "givenName": “Sachin",
    "countryCode": "INDIA",
    "phoneNumber": "(408) 555-5555"
    }
    

    from this object you can access the email id.