Create customer
Use the createCustomer method to add the details of a customer entity into the 2Checkout system. By default, customer status is Inactive until you assign a specific subscription to the customer. Following that action, customer status reflects the status of the attached subscription(s).
Request parameters
Parameters
Type / Description
sessionID
Required (string)
Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect. The sessionID expires in 10 minutes.
Object
Request sample
<?php
require ('PATH_TO_AUTH');
$newCustomer = new stdClass();
$newCustomer->AvangateCustomerReference = null;
$newCustomer->ExternalCustomerReference = 'ThisIsATestReference123456';
$newCustomer->FirstName = 'NewCustomer';
$newCustomer->LastName = 'NewCustomerLastName';
$newCustomer->Company = null;
$newCustomer->FiscalCode = null;
$newCustomer->Address1 = 'Address';
$newCustomer->Address2 = null;
$newCustomer->City = 'LA';
$newCustomer->Zip = '90210';
$newCustomer->CountryCode = 'us';
$newCustomer->Phone = null;
$newCustomer->Fax = null;
$newCustomer->Email = 'newcustomer@email.com';
$newCustomer->ExistingCards = null;
$newCustomer->Enabled = null;
$newCustomer->Trial = null;
// Add Credit object here
$newCustomer->Credit = new stdClass();
$newCustomer->Credit->Limit = 51.0; // float
$newCustomer->Credit->Remaining = 21.0; // float
$newCustomer->Credit->Currency = 'EUR'; // string
$jsonRpcRequest = array(
'method' => 'createCustomer',
'params' => array($sessionID, $newCustomer),
'id' => $i++,
'jsonrpc' => '2.0'
);
var_dump(callRPC((Object)$jsonRpcRequest, $host, true));Response parameters
Parameters
Type / Description
AvangateCustomerReference
Int
System-generated customer reference.
Last updated
Was this helpful?