developer:soap-1.2:methods:addcustomer

Soap API v1.2

addCustomer

This method adds a customer to your stored customer database so that their information can be recalled at a later date.

Description

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.

See also runCustomerTransaction, enableCustomer, disableCustomer, deleteCustomer, searchCustomerID, getCustomer, searchCustomers, getCustomerHistory, addCustomerPaymentMethod, deleteCustomerPaymentMethod, updateCustomer, quickUpdateCustomer

Syntax

integer addCustomer ( ueSecurityToken Token, CustomerObject CustomerData )

Arguments

Type Name Description
ueSecurityToken Token Merchant security token: used to identify merchant and validate transaction.
CustomerObject CustomerData Includes customer information such as customer number, merchant assigned customer ID, billing address, receipt settings, recurring billing settings, and other pertinent information.

Return Value

integer Returns result of add customer request.

Examples

PHP

For directions on how to set up the WSDL link, create “$token” and “$client”, go to PHP Soap How-to.

<?php 
 
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@usaepay.com',
		'Phone'=>'333-333-3333',
		'Fax'=>'333-333-3334'),
	'PaymentMethods' => array(
		array(
			'CreditCardData' => array(
					'CardNumber'=>'4444555566667779',
					'CardExpiration'=>'0213',
					'CardType'=>'', 'CardCode'=>'','AvsStreet'=>'',
					'AvsZip'=>'', 'CardPresent'=>'','MagStripe'=>'',
					'TermType'=>'','MagSupport'=>'','XID'=>'', 'CAVV'=>'',
					'ECI'=>'','InternalCardAuth'=>'', 'Pares'=>''
				), 
				"Expires"=>"2010-4-1",
				"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(); 
} 
 
?> 

Java

This example uses the USAePay Java library. For directions on how to install the library and create the token/client objects, go to either the Java JAX-RPC Howto or the Java JAX-WS Howto.

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());
}

.NET VB

Dim customer As usaepay.CustomerObject = New usaepay.CustomerObject
        Dim address As usaepay.Address = New usaepay.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 usaepay.PaymentMethod
        payMethod(0) = New usaepay.PaymentMethod
        payMethod(0).CreditCardData = New usaepay.CreditCardData
        payMethod(0).CreditCardData.CardExpiration = "1212"
        payMethod(0).CreditCardData.CardNumber = "4444555566667779"
        payMethod(0).CreditCardData.AvsStreet = "123 Main st."
        payMethod(0).CreditCardData.AvsZip = "90046"
        payMethod(0).MethodName = "My Visa"
 
        customer.PaymentMethods = payMethod
        Dim response As String
 
        response = client.addCustomer(token, customer)
        MsgBox(String.Concat(response))

.NET C#

usaepay.CustomerObject customer = new usaepay.CustomerObject();
            usaepay.Address address = new usaepay.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";
 
            usaepay.PaymentMethod[] payMethod = new usaepay.PaymentMethod[1];
            payMethod[0] = new usaepay.PaymentMethod();
            payMethod[0].CreditCardData = new usaepay.CreditCardData();
            payMethod[0].CreditCardData.CardExpiration = "1212";
            payMethod[0].CreditCardData.CardNumber = "4444555566667779";
            payMethod[0].CreditCardData.AvsStreet = "123 Main St.";
            payMethod[0].CreditCardData.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

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns1="urn:usaepay" 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">10.10.16.218</ClientIP>
<PinHash xsi:type="ns1:ueHash">
<HashValue xsi:type="xsd:string">8c642cf3751532c07f5c875ba9c0886f69edf2ad</HashValue>
<Seed xsi:type="xsd:string">12634965322079128547</Seed>
<Type xsi:type="xsd:string">sha1</Type>
</PinHash>
<SourceKey xsi:type="xsd:string">YOUR SOURCE KEY HERE</SourceKey>
</Token>
<CustomerData xsi:type="ns1:CustomerObject">
<Amount xsi:type="xsd:double">44.93</Amount>
<BillingAddress xsi:type="ns1:Address">
<City xsi:type="xsd:string">Los Angeles</City>
<Company xsi:type="xsd:string">Acme Corp</Company>
<Country xsi:type="xsd:string">US</Country>
<Email xsi:type="xsd:string">charlie@usaepay.com</Email>
<Fax xsi:type="xsd:string">333-333-3334</Fax>
<FirstName xsi:type="xsd:string">John</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">C651383706</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">1848604853</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">246701483</OrderID>
<PaymentMethods SOAP-ENC:arrayType="ns1:PaymentMethod[1]" xsi:type="ns1:PaymentMethodArray">
<item xsi:type="ns1:PaymentMethod">
<CreditCardData xsi:type="ns1:CreditCardData">
<AvsStreet xsi:type="xsd:string"></AvsStreet>
<AvsZip xsi:type="xsd:string"></AvsZip>
<CardCode xsi:type="xsd:string"></CardCode>
<CardExpiration xsi:type="xsd:string">0213</CardExpiration>
<CardNumber xsi:type="xsd:string">4444555566667779</CardNumber>
<CardPresent xsi:type="xsd:boolean">false</CardPresent>
<CardType xsi:type="xsd:string"></CardType>
<CAVV xsi:type="xsd:string"></CAVV>
<ECI xsi:type="xsd:integer">0</ECI>
<InternalCardAuth xsi:type="xsd:boolean">false</InternalCardAuth>
<MagStripe xsi:type="xsd:string"></MagStripe>
<MagSupport xsi:type="xsd:string"></MagSupport>
<Pares xsi:type="xsd:string"></Pares>
<TermType xsi:type="xsd:string"></TermType>
<XID xsi:type="xsd:string"></XID>
</CreditCardData>
<Expires xsi:type="xsd:string">2010-4-1</Expires>
<MethodName xsi:type="xsd:string">My Visa</MethodName>
<SecondarySort xsi:type="xsd:integer">1</SecondarySort>
</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">Recurring</Source>
<Tax xsi:type="xsd:double">0</Tax>
<User xsi:type="xsd:string"></User>
</CustomerData>
</ns1:addCustomer>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
developer/soap-1.2/methods/addcustomer.txt · Last modified: 2010/10/20 11:37 by irina

Page Tools