<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>thread Connect v2 - PHP API Add detailed customer info to transaction in Archived Discussions (Read Only)</title>
    <link>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Connect-v2-PHP-API-Add-detailed-customer-info-to-transaction/m-p/45468#M98156</link>
    <description>&lt;P&gt;I've been trying to make the PHP Transaction API accept customer data, such as name, address, phone, email, etc.&amp;nbsp; For the life of me I can't seem to get any of this information to pass through?&amp;nbsp; I know there's a customer API as well, but I'm just trying to run simple, one time transactions, for exactly one product, so I'd like to handle this in one simple transaction.&amp;nbsp; Is there a way to have the Transaction API accept additional customer information, or do I need to use the Customer API in conjunction?&amp;nbsp; Below is my form and processing script.&amp;nbsp; Any assistance would be greatly appreciated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;?php include ('sq-config.php'); ?&amp;gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta http-equiv="x-ua-compatible" content="ie=edge"&amp;gt;
    &amp;lt;title&amp;gt;Payment Form&amp;lt;/title&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;
    &amp;lt;script type="text/javascript" src="https://js.squareup.com/v2/paymentform"&amp;gt;&amp;lt;/script&amp;gt;
        
    &amp;lt;script&amp;gt;


    var applicationId = '&amp;lt;?php echo $sq_application_id; ?&amp;gt;';
    //var applicationId = 'sandbox-sq0idp-zFBXwgnwha2PNC8iVm6Oig'; // &amp;lt;-- Add your application's ID here

    // You can delete this 'if' statement. It's here to notify you that you need
    // to provide your application ID.
    if (applicationId == '') {
      alert('You need to provide a value for the applicationId variable.');
    }

    // Initializes the payment form. See the documentation for descriptions of
    // each of these parameters.
    var paymentForm = new SqPaymentForm({
      applicationId: applicationId,
      inputClass: 'sq-input',
      inputStyles: [
        {
          fontSize: '15px'
        }
      ],
      cardNumber: {
        elementId: 'sq-card-number',
        placeholder: '•••• •••• •••• ••••'
      },
      cvv: {
        elementId: 'sq-cvv',
        placeholder: 'CVV'
      },
      expirationDate: {
        elementId: 'sq-expiration-date',
        placeholder: 'MM/YY'
      },
      postalCode: {
        elementId: 'sq-postal-code'
      },
      callbacks: {

        // Called when the SqPaymentForm completes a request to generate a card
        // nonce, even if the request failed because of an error.
        cardNonceResponseReceived: function(errors, nonce, cardData) {
          if (errors) {
            console.log("Encountered errors:");

            // This logs all errors encountered during nonce generation to the
            // Javascript console.
            errors.forEach(function(error) {
              console.log('  ' + error.message);
            });

          // No errors occurred. Extract the card nonce.
          } else {

            */
            document.getElementById('card-nonce').value = nonce;
            document.getElementById('nonce-form').submit();

          }
        },

        unsupportedBrowserDetected: function() {
          // Fill in this callback to alert buyers when their browser is not supported.
		  'Your browser is not supported on this payment system.'
        },

        inputEventReceived: function(inputEvent) {
          switch (inputEvent.eventType) {
            case 'focusClassAdded':
              // Handle as desired
              break;
            case 'focusClassRemoved':
              // Handle as desired
              break;
            case 'errorClassAdded':
              // Handle as desired
              break;
            case 'errorClassRemoved':
              // Handle as desired
              break;
            case 'cardBrandChanged':
              // Handle as desired
              break;
            case 'postalCodeChanged':
              // Handle as desired
              break;
          }
        },

        paymentFormLoaded: function() {

          paymentForm.setPostalCode('94901');
        }
      }
    });

    function requestCardNonce(event) {

      event.preventDefault();

      paymentForm.requestCardNonce();
    }
    &amp;lt;/script&amp;gt;

    &amp;lt;!--
      These styles can live in a separate .css file. They're just here to keep this
      example to a single file.
    --&amp;gt;
    &amp;lt;style type="text/css"&amp;gt;
      .sq-input {
        border: 1px solid rgb(223, 223, 223);
        outline-offset: -5px;
        margin-bottom: 5px;
		width:400px;
		display:block;
		margin-bottom:15px;
      }
      .sq-input--focus {
        /* Indicates how form inputs should appear when they have focus */
        outline: 5px auto rgb(59, 153, 252);
      }
      .sq-input--error {
        /* Indicates how form inputs should appear when they contain invalid values */
        outline: 5px auto rgb(255, 97, 97);
      }
	  
	  #wrapper { width:600px; margin:auto; position:relative; top:30px; }
    &amp;lt;/style&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    
    &amp;lt;div id="wrapper"&amp;gt;
    
    &amp;lt;form id="nonce-form" novalidate action="sq-process7.php" method="post"&amp;gt;
    &amp;lt;label&amp;gt;Amount:&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="amt" id="amt" value="100" class="sq-input"&amp;gt; 
   
    &amp;lt;label&amp;gt;First Name&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="given_name" id="given_name" class="sq-input"&amp;gt; 
   
    
    &amp;lt;label&amp;gt;Last Name&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="family_name" id="family_name" class="sq-input"&amp;gt;
    
    &amp;lt;label&amp;gt;Billing Address Line &amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="billing_address" id="billing_address" class="sq-input"&amp;gt;
    
    
    &amp;lt;label&amp;gt;Billing City&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="locality" id="locality" class="sq-input"&amp;gt;
    
    &amp;lt;label&amp;gt;Billing State&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="state" id="state" class="sq-input"&amp;gt;
    
    &amp;lt;label&amp;gt; Billing Email Address&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="email_address" id="email_address" class="sq-input"&amp;gt;
    &amp;lt;label&amp;gt; Billing Phone&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="phone" id="phone" class="sq-input"&amp;gt;
    
        &amp;lt;label&amp;gt;Card Number&amp;lt;/label&amp;gt;
    &amp;lt;div id="sq-card-number"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;label&amp;gt;CVV&amp;lt;/label&amp;gt;
    &amp;lt;div id="sq-cvv"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;label&amp;gt;Expiration Date&amp;lt;/label&amp;gt;
    &amp;lt;div id="sq-expiration-date"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;label&amp;gt;Postal Code&amp;lt;/label&amp;gt;
    &amp;lt;div id="sq-postal-code"&amp;gt;&amp;lt;/div&amp;gt;
   
    &amp;lt;input type="hidden" id="card-nonce" name="nonce"&amp;gt;
  &amp;lt;div class="billing-button-container"&amp;gt;
    &amp;lt;input type="submit" onclick="submitButtonClick(event)" id="card-nonce-submit" class="button mid-blue-button billing-button"&amp;gt;
   &amp;lt;/form&amp;gt;  &amp;lt;/div&amp;gt;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;include ('sq-config.php');
require 'vendor/autoload.php';

$nonce = $_POST['nonce'];

$amt = (is_numeric($_POST['amt']) ? (int)$_POST['amt'] : 0);
$given_name = $_POST['given_name'];
$family_name = $_POST['family_name'];
$billing_address1 = $_POST['billing_address1'];
$billing_address2 = $_POST['billing_address2'];
$locality = $_POST['locality'];
$administrative_district_level_1 = $_POST['state'];
$postal_code = $_POST['sq-postal-code'];
$email_address = $_POST['email_address'];

$full_name = $given_name . " " . $family_name;

$access_token = $sq_access_token;

# Helps ensure this code has been reached via form submission
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
  error_log("Received a non-POST request");
  echo "Request not allowed";
  http_response_code(405);
  return;
}
# Fail if the card form didn't send a value for `nonce` to the server

///// Customer //////////

$customer_info = array(
        'given_name' =&amp;gt; $given_name,
        'family_name' =&amp;gt; $family_name,
        'email_address' =&amp;gt; $email_address,
		'phone_number' =&amp;gt; $phone_number
    );
	
$customer_body = (object)$customer_info;

$api_instance = new SquareConnect\Api\CustomersApi();
$customer_body = new \SquareConnect\Model\CreateCustomerRequest(); // \SquareConnect\Model\CreateCustomerRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

try {
    $result = $api_instance-&amp;gt;createCustomer($customer_info);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling CustomersApi-&amp;gt;createCustomer: ', $e-&amp;gt;getMessage(), PHP_EOL;
}

///////////

if (is_null($nonce)) {
  echo "Invalid card data";
  http_response_code(422);
  return;
}
\SquareConnect\Configuration::getDefaultConfiguration()-&amp;gt;setAccessToken($access_token);

$customer_body = (object)$customer_info;

$api_instance = new SquareConnect\Api\CustomersApi();
$customer_body = new \SquareConnect\Model\CreateCustomerRequest(); // \SquareConnect\Model\CreateCustomerRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

try {
    $result = $api_instance-&amp;gt;createCustomer($customer_info);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling CustomersApi-&amp;gt;createCustomer: ', $e-&amp;gt;getMessage(), PHP_EOL;
}

///////////


$locations_api = new \SquareConnect\Api\LocationsApi();
try {
  $locations = $locations_api-&amp;gt;listLocations();
  #We look for a location that can process payments
  $location = current(array_filter($locations-&amp;gt;getLocations(), function($location) {
    return !empty($location-&amp;gt;getCapabilities()) &amp;amp;&amp;amp;
      in_array('CREDIT_CARD_PROCESSING', $location-&amp;gt;getCapabilities());
  }));
} catch (\SquareConnect\ApiException $e) {
  echo "Caught exception!&amp;lt;br/&amp;gt;";
  print_r("&amp;lt;strong&amp;gt;Response body:&amp;lt;/strong&amp;gt;&amp;lt;br/&amp;gt;");
  echo "&amp;lt;pre&amp;gt;"; var_dump($e-&amp;gt;getResponseBody()); echo "&amp;lt;/pre&amp;gt;";
  echo "&amp;lt;br/&amp;gt;&amp;lt;strong&amp;gt;Response headers:&amp;lt;/strong&amp;gt;&amp;lt;br/&amp;gt;";
  echo "&amp;lt;pre&amp;gt;"; var_dump($e-&amp;gt;getResponseHeaders()); echo "&amp;lt;/pre&amp;gt;";
  exit(1);
}

$api = new \SquareConnect\Api\TransactionsApi();
$idempotencyKey = uniqid();
$api-&amp;gt;charge($location_id, array(
  'idempotency_key' =&amp;gt; $idempotencyKey,
  'amount_money' =&amp;gt; array(
    'amount' =&amp;gt; $amt, 'currency' =&amp;gt; 'USD'
  ),
  'card_nonce' =&amp;gt; $nonce,
  'note' =&amp;gt; $full_name,
  'buyer_email_address' =&amp;gt; $email_address,
  
  'shipping_address' =&amp;gt; array(
    'address_line_1' =&amp;gt; $billing_address1,
    'locality' =&amp;gt; $locality,
    'administrative_district_level_1' =&amp;gt; $administrative_district_level_1,
    'postal_code' =&amp;gt; $postal_code,
    'country' =&amp;gt; 'US'
  ),
  
  'billing_address' =&amp;gt; array(
    'address_line_1' =&amp;gt; $billing_address1,
    'address_line_2' =&amp;gt; $billing_address2,
    'administrative_district_level_1' =&amp;gt; $administrative_district_level_1,
    'locality' =&amp;gt; $locality,
    'postal_code' =&amp;gt; $postal_code,
    'country' =&amp;gt; 'US'
  ),
  
  'reference_id' =&amp;gt; 'optional reference #112358',
  'note' =&amp;gt; 'optional note',
  'given_name' =&amp;gt; $given_name,
        'family_name' =&amp;gt; $family_name,
        'email_address' =&amp;gt; $email_address,
		'phone_number' =&amp;gt; $phone_number
));&lt;/PRE&gt;</description>
    <pubDate>Wed, 09 Aug 2017 02:04:02 GMT</pubDate>
    <dc:creator>bomweb</dc:creator>
    <dc:date>2017-08-09T02:04:02Z</dc:date>
    <item>
      <title>Connect v2 - PHP API Add detailed customer info to transaction</title>
      <link>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Connect-v2-PHP-API-Add-detailed-customer-info-to-transaction/m-p/45468#M98156</link>
      <description>&lt;P&gt;I've been trying to make the PHP Transaction API accept customer data, such as name, address, phone, email, etc.&amp;nbsp; For the life of me I can't seem to get any of this information to pass through?&amp;nbsp; I know there's a customer API as well, but I'm just trying to run simple, one time transactions, for exactly one product, so I'd like to handle this in one simple transaction.&amp;nbsp; Is there a way to have the Transaction API accept additional customer information, or do I need to use the Customer API in conjunction?&amp;nbsp; Below is my form and processing script.&amp;nbsp; Any assistance would be greatly appreciated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;?php include ('sq-config.php'); ?&amp;gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta http-equiv="x-ua-compatible" content="ie=edge"&amp;gt;
    &amp;lt;title&amp;gt;Payment Form&amp;lt;/title&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;
    &amp;lt;script type="text/javascript" src="https://js.squareup.com/v2/paymentform"&amp;gt;&amp;lt;/script&amp;gt;
        
    &amp;lt;script&amp;gt;


    var applicationId = '&amp;lt;?php echo $sq_application_id; ?&amp;gt;';
    //var applicationId = 'sandbox-sq0idp-zFBXwgnwha2PNC8iVm6Oig'; // &amp;lt;-- Add your application's ID here

    // You can delete this 'if' statement. It's here to notify you that you need
    // to provide your application ID.
    if (applicationId == '') {
      alert('You need to provide a value for the applicationId variable.');
    }

    // Initializes the payment form. See the documentation for descriptions of
    // each of these parameters.
    var paymentForm = new SqPaymentForm({
      applicationId: applicationId,
      inputClass: 'sq-input',
      inputStyles: [
        {
          fontSize: '15px'
        }
      ],
      cardNumber: {
        elementId: 'sq-card-number',
        placeholder: '•••• •••• •••• ••••'
      },
      cvv: {
        elementId: 'sq-cvv',
        placeholder: 'CVV'
      },
      expirationDate: {
        elementId: 'sq-expiration-date',
        placeholder: 'MM/YY'
      },
      postalCode: {
        elementId: 'sq-postal-code'
      },
      callbacks: {

        // Called when the SqPaymentForm completes a request to generate a card
        // nonce, even if the request failed because of an error.
        cardNonceResponseReceived: function(errors, nonce, cardData) {
          if (errors) {
            console.log("Encountered errors:");

            // This logs all errors encountered during nonce generation to the
            // Javascript console.
            errors.forEach(function(error) {
              console.log('  ' + error.message);
            });

          // No errors occurred. Extract the card nonce.
          } else {

            */
            document.getElementById('card-nonce').value = nonce;
            document.getElementById('nonce-form').submit();

          }
        },

        unsupportedBrowserDetected: function() {
          // Fill in this callback to alert buyers when their browser is not supported.
		  'Your browser is not supported on this payment system.'
        },

        inputEventReceived: function(inputEvent) {
          switch (inputEvent.eventType) {
            case 'focusClassAdded':
              // Handle as desired
              break;
            case 'focusClassRemoved':
              // Handle as desired
              break;
            case 'errorClassAdded':
              // Handle as desired
              break;
            case 'errorClassRemoved':
              // Handle as desired
              break;
            case 'cardBrandChanged':
              // Handle as desired
              break;
            case 'postalCodeChanged':
              // Handle as desired
              break;
          }
        },

        paymentFormLoaded: function() {

          paymentForm.setPostalCode('94901');
        }
      }
    });

    function requestCardNonce(event) {

      event.preventDefault();

      paymentForm.requestCardNonce();
    }
    &amp;lt;/script&amp;gt;

    &amp;lt;!--
      These styles can live in a separate .css file. They're just here to keep this
      example to a single file.
    --&amp;gt;
    &amp;lt;style type="text/css"&amp;gt;
      .sq-input {
        border: 1px solid rgb(223, 223, 223);
        outline-offset: -5px;
        margin-bottom: 5px;
		width:400px;
		display:block;
		margin-bottom:15px;
      }
      .sq-input--focus {
        /* Indicates how form inputs should appear when they have focus */
        outline: 5px auto rgb(59, 153, 252);
      }
      .sq-input--error {
        /* Indicates how form inputs should appear when they contain invalid values */
        outline: 5px auto rgb(255, 97, 97);
      }
	  
	  #wrapper { width:600px; margin:auto; position:relative; top:30px; }
    &amp;lt;/style&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    
    &amp;lt;div id="wrapper"&amp;gt;
    
    &amp;lt;form id="nonce-form" novalidate action="sq-process7.php" method="post"&amp;gt;
    &amp;lt;label&amp;gt;Amount:&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="amt" id="amt" value="100" class="sq-input"&amp;gt; 
   
    &amp;lt;label&amp;gt;First Name&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="given_name" id="given_name" class="sq-input"&amp;gt; 
   
    
    &amp;lt;label&amp;gt;Last Name&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="family_name" id="family_name" class="sq-input"&amp;gt;
    
    &amp;lt;label&amp;gt;Billing Address Line &amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="billing_address" id="billing_address" class="sq-input"&amp;gt;
    
    
    &amp;lt;label&amp;gt;Billing City&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="locality" id="locality" class="sq-input"&amp;gt;
    
    &amp;lt;label&amp;gt;Billing State&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="state" id="state" class="sq-input"&amp;gt;
    
    &amp;lt;label&amp;gt; Billing Email Address&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="email_address" id="email_address" class="sq-input"&amp;gt;
    &amp;lt;label&amp;gt; Billing Phone&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="phone" id="phone" class="sq-input"&amp;gt;
    
        &amp;lt;label&amp;gt;Card Number&amp;lt;/label&amp;gt;
    &amp;lt;div id="sq-card-number"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;label&amp;gt;CVV&amp;lt;/label&amp;gt;
    &amp;lt;div id="sq-cvv"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;label&amp;gt;Expiration Date&amp;lt;/label&amp;gt;
    &amp;lt;div id="sq-expiration-date"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;label&amp;gt;Postal Code&amp;lt;/label&amp;gt;
    &amp;lt;div id="sq-postal-code"&amp;gt;&amp;lt;/div&amp;gt;
   
    &amp;lt;input type="hidden" id="card-nonce" name="nonce"&amp;gt;
  &amp;lt;div class="billing-button-container"&amp;gt;
    &amp;lt;input type="submit" onclick="submitButtonClick(event)" id="card-nonce-submit" class="button mid-blue-button billing-button"&amp;gt;
   &amp;lt;/form&amp;gt;  &amp;lt;/div&amp;gt;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;include ('sq-config.php');
require 'vendor/autoload.php';

$nonce = $_POST['nonce'];

$amt = (is_numeric($_POST['amt']) ? (int)$_POST['amt'] : 0);
$given_name = $_POST['given_name'];
$family_name = $_POST['family_name'];
$billing_address1 = $_POST['billing_address1'];
$billing_address2 = $_POST['billing_address2'];
$locality = $_POST['locality'];
$administrative_district_level_1 = $_POST['state'];
$postal_code = $_POST['sq-postal-code'];
$email_address = $_POST['email_address'];

$full_name = $given_name . " " . $family_name;

$access_token = $sq_access_token;

# Helps ensure this code has been reached via form submission
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
  error_log("Received a non-POST request");
  echo "Request not allowed";
  http_response_code(405);
  return;
}
# Fail if the card form didn't send a value for `nonce` to the server

///// Customer //////////

$customer_info = array(
        'given_name' =&amp;gt; $given_name,
        'family_name' =&amp;gt; $family_name,
        'email_address' =&amp;gt; $email_address,
		'phone_number' =&amp;gt; $phone_number
    );
	
$customer_body = (object)$customer_info;

$api_instance = new SquareConnect\Api\CustomersApi();
$customer_body = new \SquareConnect\Model\CreateCustomerRequest(); // \SquareConnect\Model\CreateCustomerRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

try {
    $result = $api_instance-&amp;gt;createCustomer($customer_info);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling CustomersApi-&amp;gt;createCustomer: ', $e-&amp;gt;getMessage(), PHP_EOL;
}

///////////

if (is_null($nonce)) {
  echo "Invalid card data";
  http_response_code(422);
  return;
}
\SquareConnect\Configuration::getDefaultConfiguration()-&amp;gt;setAccessToken($access_token);

$customer_body = (object)$customer_info;

$api_instance = new SquareConnect\Api\CustomersApi();
$customer_body = new \SquareConnect\Model\CreateCustomerRequest(); // \SquareConnect\Model\CreateCustomerRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

try {
    $result = $api_instance-&amp;gt;createCustomer($customer_info);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling CustomersApi-&amp;gt;createCustomer: ', $e-&amp;gt;getMessage(), PHP_EOL;
}

///////////


$locations_api = new \SquareConnect\Api\LocationsApi();
try {
  $locations = $locations_api-&amp;gt;listLocations();
  #We look for a location that can process payments
  $location = current(array_filter($locations-&amp;gt;getLocations(), function($location) {
    return !empty($location-&amp;gt;getCapabilities()) &amp;amp;&amp;amp;
      in_array('CREDIT_CARD_PROCESSING', $location-&amp;gt;getCapabilities());
  }));
} catch (\SquareConnect\ApiException $e) {
  echo "Caught exception!&amp;lt;br/&amp;gt;";
  print_r("&amp;lt;strong&amp;gt;Response body:&amp;lt;/strong&amp;gt;&amp;lt;br/&amp;gt;");
  echo "&amp;lt;pre&amp;gt;"; var_dump($e-&amp;gt;getResponseBody()); echo "&amp;lt;/pre&amp;gt;";
  echo "&amp;lt;br/&amp;gt;&amp;lt;strong&amp;gt;Response headers:&amp;lt;/strong&amp;gt;&amp;lt;br/&amp;gt;";
  echo "&amp;lt;pre&amp;gt;"; var_dump($e-&amp;gt;getResponseHeaders()); echo "&amp;lt;/pre&amp;gt;";
  exit(1);
}

$api = new \SquareConnect\Api\TransactionsApi();
$idempotencyKey = uniqid();
$api-&amp;gt;charge($location_id, array(
  'idempotency_key' =&amp;gt; $idempotencyKey,
  'amount_money' =&amp;gt; array(
    'amount' =&amp;gt; $amt, 'currency' =&amp;gt; 'USD'
  ),
  'card_nonce' =&amp;gt; $nonce,
  'note' =&amp;gt; $full_name,
  'buyer_email_address' =&amp;gt; $email_address,
  
  'shipping_address' =&amp;gt; array(
    'address_line_1' =&amp;gt; $billing_address1,
    'locality' =&amp;gt; $locality,
    'administrative_district_level_1' =&amp;gt; $administrative_district_level_1,
    'postal_code' =&amp;gt; $postal_code,
    'country' =&amp;gt; 'US'
  ),
  
  'billing_address' =&amp;gt; array(
    'address_line_1' =&amp;gt; $billing_address1,
    'address_line_2' =&amp;gt; $billing_address2,
    'administrative_district_level_1' =&amp;gt; $administrative_district_level_1,
    'locality' =&amp;gt; $locality,
    'postal_code' =&amp;gt; $postal_code,
    'country' =&amp;gt; 'US'
  ),
  
  'reference_id' =&amp;gt; 'optional reference #112358',
  'note' =&amp;gt; 'optional note',
  'given_name' =&amp;gt; $given_name,
        'family_name' =&amp;gt; $family_name,
        'email_address' =&amp;gt; $email_address,
		'phone_number' =&amp;gt; $phone_number
));&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Aug 2017 02:04:02 GMT</pubDate>
      <guid>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Connect-v2-PHP-API-Add-detailed-customer-info-to-transaction/m-p/45468#M98156</guid>
      <dc:creator>bomweb</dc:creator>
      <dc:date>2017-08-09T02:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: Connect v2 - PHP API Add detailed customer info to transaction</title>
      <link>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Connect-v2-PHP-API-Add-detailed-customer-info-to-transaction/m-p/45579#M98157</link>
      <description>&lt;P&gt;Never mind, I've decided to go in a different route and not use the API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 01:00:22 GMT</pubDate>
      <guid>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Connect-v2-PHP-API-Add-detailed-customer-info-to-transaction/m-p/45579#M98157</guid>
      <dc:creator>bomweb</dc:creator>
      <dc:date>2017-08-10T01:00:22Z</dc:date>
    </item>
  </channel>
</rss>

