This method adds a customer to your stored customer database so that their information can be recalled at a later date.
The customer will be assigned a unique customer number by the gateway (CustNum), which you can then use to establish recurring billing cycles, recall customer data, and manually charge the customer for later products or services without needing to reenter their information.
integer addCustomer ( ueSecurityToken Token, CustomerObject CustomerData )
Type |
Name |
Description |
Token |
Merchant security token: used to identify merchant and validate transaction. |
|
CustomerData |
Includes customer information such as customer number, merchant assigned customer ID, billing address, receipt settings, recurring billing settings, and other pertinent information. |
integer |
Returns result of add customer request. |
try {
$CustomerData=array(
'BillingAddress'=>array(
'FirstName'=>'John',
'LastName'=>'Doe',
'Company'=>'Acme Corp',
'Street'=>'1234 main st',
'Street2'=>'Suite #123',
'City'=>'Los Angeles',
'State'=>'CA',
'Zip'=>'12345',
'Country'=>'US',
'Email'=>'charlie@eBizCharge.com',
'Phone'=>'333-333-3333',
'Fax'=>'333-333-3334'),
'PaymentMethods' => array(
'CardNumber'=>'4444555566667779',
'CardExpiration'=>'0213',
'CardType'=>'', 'CardCode'=>'','AvsStreet'=>'',
'AvsZip'=>'',
"MethodName"=>"My Visa",
"SecondarySort"=>1)
),
'CustomData'=>base64_encode(serialize(array("mydata"=>"We could put anything in here!"))),
'CustomFields'=>array(
array('Field'=>'Foo', 'Value'=>'Testing'),
array('Field'=>'Bar', 'Value'=>'Tested')
),
'CustomerID'=>123123 + rand(),
'Description'=>'Weekly Bill',
'Enabled'=>false,
'Amount'=>'44.93',
'Tax'=>'0',
'Next'=>'2012-01-21',
'Notes'=>'Testing the soap addCustomer Function',
'NumLeft'=>'50',
'OrderID'=>rand(),
'ReceiptNote'=>'addCustomer test Created Charge',
'Schedule'=>'weekly',
'SendReceipt'=>true,
'Source'=>'Recurring',
'User'=>'',
'CustNum'=>'C'.rand()
);
$Result=$client->addCustomer($token,$CustomerData);
}
catch(SoapFault $e) {
echo "SoapFault: " .$e->getMessage(); print_r($e);
echo "\n\nRequest: " . $tran->__getLastRequest();
echo "\n\nResponse: " . $tran->__getLastResponse();
}
?>
try {
CustomerObject customer = new CustomerObject();
// Setup address information
Address address = new Address();
address.setFirstName("John");
address.setLastName("Doe");
address.setCompany("Acme INC");
address.setStreet("343 Main Street");
address.setStreet2("Suite 222");
address.setCity("Somewhere");
address.setState("CA");
address.setZip("91920");
address.setCountry("US");
address.setEmail("joe@example.com");
address.setFax("595-343-4454");
address.setPhone("333-444-5555");
customer.setBillingAddress(address);
// Set recurring billing options
customer.setEnabled(true);
customer.setAmount(5.00);
customer.setTax(0.50);
customer.setNext("2009-09-01");
customer.setNumLeft(new BigInteger("-1"));
customer.setSchedule("Monthly");
customer.setOrderID("100090");
customer.setDescription("Monthly Member Fee");
// setup Payment Methods
PaymentMethodArray paymethods = new PaymentMethodArray();
PaymentMethod paymethod = new PaymentMethod();
paymethod.setExpires("2012-09-01");
CreditCardData ccdata = new CreditCardData();
ccdata.setCardNumber("4444555566667779");
ccdata.setCardExpiration("0912");
ccdata.setAvsStreet("343 Main");
ccdata.setAvsZip("90990");
paymethod.setCreditCardData(ccdata);
paymethod.setMethodName("My Visa");
paymethods.add(paymethod);
customer.setPaymentMethods(paymethods);
// Setup custom fields
FieldValueArray customfields = new FieldValueArray();
customfields.add(new FieldValue("Dorky","Testing"));
customfields.add(new FieldValue("Donkey","Tested"));
customfields.add(new FieldValue("Wonky","Tested"));
customer.setCustomFields(customfields);
// Create request object
AddCustomerRequest request = new AddCustomerRequest();
request.setToken(token);
request.setCustomerData(customer);
// Create response object
AddCustomerResponse response;
// Add Customer
response = client.addCustomer(request);
System.out.println("Added customer " + response.getAddCustomerReturn() );
} catch (Exception e) {
System.out.println("Soap Exception: " + e.getMessage());
}
Dim customer As eBizCharge.CustomerObject = New eBizCharge.CustomerObject
Dim address As eBizCharge.Address = New eBizCharge.Address
address.FirstName = "John"
address.LastName = "Doe"
address.Company = "Acme"
address.Street = "123 main st."
address.City = "Hollywood"
address.State = "ca"
address.Zip = "91607"
address.Country = "USA"
customer.BillingAddress = address
customer.Enabled = True
customer.Amount = 5.0
customer.Next = "2010-08-15"
customer.Schedule = "monthly"
Dim payMethod(0) As eBizCharge.PaymentMethod
payMethod(0) = New eBizCharge.PaymentMethod
payMethod(0).CardExpiration = "1212"
payMethod(0).CardNumber = "4444555566667779"
payMethod(0).AvsStreet = "123 Main st."
payMethod(0).AvsZip = "90046"
payMethod(0).MethodName = "My Visa"
customer.PaymentMethods = payMethod
Dim response As String
response = client.addCustomer(token, customer)
MsgBox(String.Concat(response))
eBizCharge.CustomerObject customer = new eBizCharge.CustomerObject();
eBizCharge.Address address = new eBizCharge.Address();
address.FirstName = "John";
address.LastName = "Doe";
address.Company = "Acme";
address.Street = "123 main st.";
address.City = "Hollywood";
address.State = "ca";
address.Zip = "91607";
address.Country = "USA";
customer.BillingAddress = address;
customer.Enabled = true;
customer.Amount = 5.00;
customer.Next = "2010-08-15";
customer.Schedule = "monthly";
eBizCharge.PaymentMethod[] payMethod = new eBizCharge.PaymentMethod[1];
payMethod[0] = new eBizCharge.PaymentMethod();
payMethod[0].CardExpiration = "1212";
payMethod[0].CardNumber = "4444555566667779";
payMethod[0].AvsStreet = "123 Main st.";
payMethod[0].AvsZip = "90046";
payMethod[0].MethodName = "My Visa";
customer.PaymentMethods = payMethod;
string response;
try
{
response = client.addCustomer(token, customer);
MessageBox.Show(string.Concat(response));
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:eBizCharge" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:addCustomer>
<Token xsi:type="ns1:ueSecurityToken">
<ClientIP xsi:type="xsd:string">192.168.0.1</ClientIP>
<PinHash xsi:type="ns1:ueHash">
<HashValue xsi:type="xsd:string">11ac55b0a0b59f8f028dbf85bc32266fa973dd0e</HashValue>
<Seed xsi:type="xsd:string">12678150211876663375</Seed>
<Type xsi:type="xsd:string">sha1</Type>
</PinHash>
<SourceKey xsi:type="xsd:string">HB4P7C4K2w2ZCQQQXRqrxDj6agrS2NIT</SourceKey>
</Token>
<CustomerData xsi:type="ns1:CustomerObject">
<Amount xsi:type="xsd:double">59.99</Amount>
<BillingAddress xsi:type="ns1:Address">
<City xsi:type="xsd:string">Los Angeles</City>
<Company xsi:type="xsd:string">Vlads Corp</Company>
<Country xsi:type="xsd:string">US</Country>
<Email xsi:type="xsd:string">charlie@eBizCharge.com</Email>
<Fax xsi:type="xsd:string">333-333-3334</Fax>
<FirstName xsi:type="xsd:string">Vlad</FirstName>
<LastName xsi:type="xsd:string">Doe</LastName>
<Phone xsi:type="xsd:string">333-333-3333</Phone>
<State xsi:type="xsd:string">CA</State>
<Street xsi:type="xsd:string">1234 main st</Street>
<Street2 xsi:type="xsd:string">Suite #123</Street2>
<Zip xsi:type="xsd:string">12345</Zip>
</BillingAddress>
<CustNum xsi:type="xsd:string">C1957486753</CustNum>
<CustomData xsi:type="xsd:string">YToxOntzOjY6Im15ZGF0YSI7czozMDoiV2UgY291bGQgcHV0IGFueXRoaW5nIGluIGhlcmUhIjt9</CustomData>
<CustomFields SOAP-ENC:arrayType="ns1:FieldValue[2]" xsi:type="ns1:FieldValueArray">
<item xsi:type="ns1:FieldValue">
<Field xsi:type="xsd:string">Foo</Field>
<Value xsi:type="xsd:string">Testing</Value>
</item>
<item xsi:type="ns1:FieldValue">
<Field xsi:type="xsd:string">Bar</Field>
<Value xsi:type="xsd:string">Tested</Value>
</item>
</CustomFields>
<CustomerID xsi:type="xsd:string">730163741</CustomerID>
<Description xsi:type="xsd:string">Weekly Bill</Description>
<Enabled xsi:type="xsd:boolean">false</Enabled>
<Next xsi:type="xsd:string">2012-01-21</Next>
<Notes xsi:type="xsd:string">Testing the soap addCustomer Function</Notes>
<NumLeft xsi:type="xsd:integer">50</NumLeft>
<OrderID xsi:type="xsd:string">1621046782</OrderID>
<PaymentMethods SOAP-ENC:arrayType="ns1:PaymentMethod[1]" xsi:type="ns1:PaymentMethodArray">
<item xsi:type="ns1:PaymentMethod">
<MethodName xsi:type="xsd:string">My Visa</MethodName>
<SecondarySort xsi:type="xsd:integer">1</SecondarySort>
<CardExpiration xsi:type="xsd:string">0213</CardExpiration>
<CardNumber xsi:type="xsd:string">4444555566667779</CardNumber>
</item>
</PaymentMethods>
<ReceiptNote xsi:type="xsd:string">addCustomer test Created Charge</ReceiptNote>
<Schedule xsi:type="xsd:string">weekly</Schedule>
<SendReceipt xsi:type="xsd:boolean">true</SendReceipt>
<Source xsi:type="xsd:string">BlahBlah</Source>
<Tax xsi:type="xsd:double">4.93</Tax>
<User xsi:type="xsd:string">TestUser</User>
<URL xsi:type="xsd:string">http://www.acme.com</URL>
</CustomerData>
</ns1:addCustomer>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>