Implementing Verify with Express Checkout

Edited

Overview

This document provides a comprehensive guide on integrating the Verify API with popular express checkout providers such as PayPal, Apple Pay, Google Pay and Klarna. By verifying the addresses stored by customers in their chosen payment methods, businesses can enhance the accuracy of shipping details and improve overall transaction efficiency.

Verify Address Parameters

To verify an address with the Verify API, you’ll need to include the key address fields in your request. At a minimum, this requires at least one address line and the country code. Other fields such as city, region, and postcode can also be provided to improve accuracy:

  • Address line(s) (one required)

  • City (optional)

  • Region (optional)

  • Postcode (optional)

  • Country code (required)

How you gather this information will depend on the express checkout provider you are integrating with. Your implementation will need to handle the different ways each provider supplies address details and pass them into the Verify API request.

Getting Address Parameters

To assist you with integrating the Verify API, we have included detailed examples for retrieving address information from popular payment platforms using JavaScript.

PayPal

When the user has authorized the transaction with PayPal, the provider will make the full address available to you through an address object. This will contain the address details as follows:

{
  "address_line_1": "8 Silver Birches",
  "address_line_2": "Millfarm",
  "admin_area_2": "Dunboyne",
  "admin_area_1": "CO MEATH",
  "country_code": "IE",
  "postal_code": "A86 VC04"
}

To verify this address, capture the following fields from the address object:

var aaAddress = response.purchase_units[0].shipping.address;
var aaAddressLines = [aaAddress.organization_name,aaAddress.street_address, aaAddress.street_address2];
var aaCity = aaAddress.admin_area_2;
var aaRegion = aaAddress.admin_area_1;
var aaPostcode = shipping_address.postal_code;
var aaCountry = aaAddress.country_code;

Apple Pay

When the user has authorized the transaction with Apple Pay, the provider will make the full address available to you through a shippingContact object. This will contain the address details as follows:

{
  "locality": "Cupertino",
  "country": "United States",
  "postalCode": "95014-2083",
  "administrativeArea": "CA",
  "emailAddress": "ravipatel@example.com",
  "familyName": "Patel",
  "addressLines": [
  "1 Infinite Loop"
  ],
  "givenName": "Ravi",
  "countryCode": "US",
  "phoneNumber": "(408) 555-5555"
}

To verify this address, capture the following fields from the shippingContact object:

var aaAddressLines = shippingContact.addressLines;
var aaCity = shippingContact.locality;
var aaRegion = shippingContact.administrativeArea;
var aaPostcode = shippingContact.postalCode;
var aaCountry = shippingContact.countryCode;

Google Pay

When the user has authorized the transaction with Google Pay, the provider will make the full address available to you through an address object. This will contain the address details as follows:

{
  "name": "John Doe",
  "address1": "c/o Google LLC",
  "address2": "1600 Amphitheatre Pkwy",
  "address3": "Building 40",
  "locality": "Mountain View",
  "administrativeArea": "CA",
  "countryCode": "US",
  "postalCode": "94043",
  "sortingCode": ""
}

To verify this address, capture the following fields from the address object:

var aaAddressLines = [address.address1, address.address2, address.address3];
var aaCity = address.locality;
var aaRegion = address.administrativeArea;
var aaPostcode = address.postalCode;
var aaCountry = address.countryCode;

Klarna

When the user has authorized the transaction with Klarna, the provider will make the full address available to you through a shipping_address object. This will contain the address details as follows:

{
  "attention": "Attn",
  "city": "New York",
  "country": "US",
  "email": "test.sam@test.com",
  "family_name": "Andersson",
  "given_name": "Adam",
  "organization_name": "string",
  "phone": "+13106683312",
  "postal_code": "10024-3941",
  "region": "US-NY",
  "street_address": "509 Amsterdam Ave",
  "street_address2": "Floor 22 / Flat 2",
  "title": "Mr."
}

To verify this address, capture the following fields from the shipping_address object:

var aaAddressLines = [shipping_address.organization_name,shipping_address.street_address, shipping_address.street_address2];
var aaCity = shipping_address.city;
var aaRegion = shipping_address.region;
var aaPostcode = shipping_address.postal_code;
var aaCountry = address.countryCode;

Sending Address to Verify API

After you have successfully gathered all the required address information from the provider, submit the data to the Verify API:

var verifyRequest = 'https://api.autoaddress.com/3.0/verify?city='+aaCity+'&region='+aaRegion+'&postcode='+aaPostcode+'&country='+aaCountry+'&token=YOUR_TOKEN'

aaAddressLines.forEach(line => {
     if (line !== ''){
       addressLine = '&addressLine='+line;
       verifyRequest = verifyRequest.concat(addressLine);
     }
});

For full details on calling the Verify API and processing its response, see our Verify Address documentation.