Examples

Remove the postal code requirement from the Square payment form

Remove payment form postal code requirement for merchants outside of regions where a postal code is required.

For merchants based outside those locations, the postal code requirement can be removed.

Before you start

  • You have integrated the payment form into your web application.
  • Your web application can get the location country of the merchant who is using the application.
    • If you look up the merchant's location by using the Locations API, You will need an access token. If you are using OAuth, you will need the MERCHANT_PROFILE_READ permission.

Step 1: Get the location country of the merchant

  1. Call the Location API's ListLocations endpoint to get a collection of the merchant's locations.
GET /v2/locations
  1. Parse the response to find the correct location whose status is ACTIVE and capabities include CREDIT_CARD_PROCESSING.
{
"locations": [
    {
        "id": "18YC4JDH91E1H",
        "name": "your location name",
        "address": {
            "address_line_1": "123 Main St",
            "locality": "San Francisco",
            "administrative_district_level_1": "CA",
            "postal_code": "94114",
            "country": "US"
        },
        "capabilities": [
            "CREDIT_CARD_PROCESSING"
        ],
        "status": "ACTIVE",
        "country": "US",
        "phone_number": "+1 650-354-7217",
        "business_name": "Pumbaa's business name"
    }
    ]
}
3. Find the **location.country** code of the location in the list of `"US", "CA", "GB"`. 4. If the location's **country** code is in the list in the previous step, you cannot remove the postal code requirement. Otherwise, continue to the next step.

Step 2: Remove the postal code requirement

  1. Update your SqPaymentForm initializing logic to set postalCode to false.
// Create and initialize a payment form object
var paymentForm = new SqPaymentForm({

...

  postalCode: false,

  // SqPaymentForm callback functions
  callbacks: {
      ...
  }
});
Next
API Development 101 >

Contact Developer Support, join our Slack channel, or ask for help on Stack Overflow