Perl Dwolla: Create Funding Source for an Account

Back to Index

Shows how to add a bank account to a Dwolla account. The bank account will have a status of unverified upon creation. Before a Dwolla account is eligible to transfer money from their bank or credit union account they need to verify ownership of the account via micro-deposit verification. Success is indicated by a 201 response status code with an empty response body.

Documentation: https://docsv2.dwolla.com/#create-a-funding-source-for-an-account

CURL Command

curl -X POST https://api-sandbox.dwolla.com/funding-sources \
-H "Content-Type: application/vnd.dwolla.v1.hal+json" \
-H "Accept: application/vnd.dwolla.v1.hal+json" \
-H "Authorization: Bearer DWOLLA_ACCESS_TOKEN" \
-d '{
    "routingNumber": "222222226",
    "accountNumber": "123456789",
    "bankAccountType": "checking",
    "name": "My Bank"
}'

Perl Example

use chilkat();

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

#  URL: https://api-sandbox.dwolla.com/funding-sources
$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("routingNumber","222222226");
$json->UpdateString("accountNumber","123456789");
$json->UpdateString("bankAccountType","checking");
$json->UpdateString("name","My Bank");

$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","/funding-sources",$sbRequestBody,$sbResponseBody);
if ($success != 1) {
    print $rest->lastErrorText() . "\r\n";
    exit;
}