Code Cookbook

Update Customer Profiles

Update individual customer profiles.

Maintain your customer information by using the UpdateCustomer endpoint to update customer profiles with new contact information.

Before you start

Step 1: Build your UpdateCustomer request

  1. To build your UpdateCustomer request, you will need customer_id for the customer you want to update and provide information for the fields you want to update. In the sample code below, we are updating the email field.
// set the ID of the customer to update.
$customerId = '{REPLACE_ME}';

//Create an UpdateCustomerRequest object
$body = new \SquareConnect\Model\UpdateCustomerRequest();

// Get the customer's new email address.
$body->setEmailAddress($email);

Step 2: Send the request to the UpdateCustomer endpoint

  1. Send your object to the UpdateCustomer endpoint. For now, we'll print the raw result to the screen.
try {
    $result = $customersApi->updateCustomer($customerId, $body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling CustomersApi->updateCustomer: ',
    $e->getMessage(),
    PHP_EOL;
}

If your request is successful, the UpdateCustomer endpoint will return the updated Customer object.

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