Create Customer
1 min
To create a Customer in the Payment Processor, use the action "CreateCustomer" and pass the Customer data in the RequestJSON under "customers."
Note: You can only create one record at a time.
The following is an example of creating a Customer where we are setting every possible field (See Customer for the available fields). The response will return the response from the Payment Processor, which includes the Customer ID (internalId) plus the newly created Salesforce Customer ID (salesforceId).
// Create a Map to store all the data of a Customer
Map<String, Object> customerMap = new Map<String, Object>();
customerMap.put('customerName', 'John Doe');
customerMap.put('email', '[email protected]');
customerMap.put('customerPhone', '616-928-5098');
// Create Stripe Address data
customerMap.put('billingStreetAddress1', '123 Main Street');
customerMap.put('billingStreetAddress2', 'Apt 2');
customerMap.put('billingCity', 'Anytown');
customerMap.put('billingState', 'NY');
customerMap.put('billingCountry', 'US');
customerMap.put('billingPostalCode', '12345');
// Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('customers', new List<Object>{customerMap});
String reqJSON = JSON.serialize(requestJSONMap);
Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version', '1.0');
reqObj.put('action', 'CreateCustomer');
reqObj.put('processorId', 'processorId');
reqObj.put('requestJSON', reqJSON);
// Placing a request to Breadwinner Global API
Map<String, Object> resp = bw_payments.BreadwinnerPaymentsAPI.call(reqObj);
System.debug(resp);