Perl Dwolla: Create a Customer

Back to Index

Shows how to create a new Customer. To create Unverified Customers, you need to provide only the customer’s full name and email address, as well as a business name if applicable. A successful request is indicated by a response status code of 201 with an empty response body.

Documentation: https://docsv2.dwolla.com/#create-a-customer

CURL Command

curl -X POST https://api-sandbox.dwolla.com/customers \
-H "Content-Type: application/vnd.dwolla.v1.hal+json" \
-H "Accept: application/vnd.dwolla.v1.hal+json" \
-H "Authorization: Bearer DWOLLA_ACCESS_TOKEN" \
-d '{
  "firstName": "Joe",
  "lastName": "Merchant",
  "email": "jmerchant@nomail.net",
  "ipAddress": "99.99.99.99",
  "businessName": "Merchant Joe, Inc."
}'

Perl Example

use chilkat();

$rest = chilkat::CkRest->new();

#  URL: https://api-sandbox.dwolla.com/customers
$bTls = 1;
$port = 443;
$bAutoReconnect = 1;
$success = $rest->Connect("api-sandbox.dwolla.com",$port,$bTls,$bAutoReconnect);
if ($success != 1) {
    print "ConnectFailReason: " . $rest->get_ConnectFailReason() . "\r\n";
    print $rest->lastErrorText() . "\r\n";
    exit;
}

$json = chilkat::CkJsonObject->new();
$json->UpdateString("firstName","Joe");
$json->UpdateString("lastName","Merchant");
$json->UpdateString("email",'jmerchant@nomail.net');
$json->UpdateString("ipAddress","99.99.99.99");
$json->UpdateString("businessName","Merchant Joe, Inc.");

$rest->AddHeader("Content-Type","application/vnd.dwolla.v1.hal+json");
$rest->AddHeader("Authorization","Bearer DWOLLA_ACCESS_TOKEN");
$rest->AddHeader("Accept","application/vnd.dwolla.v1.hal+json");

$sbRequestBody = chilkat::CkStringBuilder->new();
$json->EmitSb($sbRequestBody);
$sbResponseBody = chilkat::CkStringBuilder->new();
$success = $rest->FullRequestSb("POST","/customers",$sbRequestBody,$sbResponseBody);
if ($success != 1) {
    print $rest->lastErrorText() . "\r\n";
    exit;
}