Configuration options are available for utilizing dwolla.js in both our Sandbox and production environments. Configuration of an environment should take place after you have included the dwolla.js library.
// Sandbox
dwolla.configure("sandbox");
// Production
dwolla.configure("prod");
Param | Type | Value |
---|---|---|
funding-sources-token | string | A funding sources token generated on your server. |
params | object | An object containing params to create a funding source. Contains keys: routingNumber , accountNumber , type , and name . See example below. routingNumber represents a string value nine digit routing number. accountNumber represents a string value account number. type represents a string value of either checking or savings . name represents a string value identifying name of the user's bank. |
callback | function | A callback function that handles the response from Dwolla. |
dwolla.fundingSources.create(
"1zN400zyPUobbdmeNfhTGH2Jh5JkFREJa9YBI8SLXp0ERXNTMT",
{
routingNumber: document.getElementById("routingNumber").value,
accountNumber: document.getElementById("accountNumber").value,
type: document.getElementById("type").value,
name: document.getElementById("name").value,
},
function (err, res) {
console.log(
"Error: " + JSON.stringify(err) + " -- Response: " + JSON.stringify(res)
);
}
);
Assuming dwolla.js
is already included and configured on your page, you will create the function that will call dwolla.fundingSources.create()
. For this example, jQuery is used to call the function that creates a funding source when the user clicks the "Add Bank" button on your page. To test in the sandbox environment, use the dwolla.configure()
helper function and pass in the value of sandbox
.
In our example, dwolla.fundingSources.create()
takes three arguments: a string value of the funding sources token, JavaScript object containing bank account information entered by the user, and a callback function that will handle any error or response.
$("form").on("submit", function () {
dwolla.configure("sandbox");
var token = "Z9BvpNuSrsI7Ke1mcGmTT0EpwW34GSmDaYP09frCpeWdq46JUg";
var bankInfo = {
routingNumber: document.getElementById("routingNumber").value,
accountNumber: document.getElementById("accountNumber").value,
type: document.getElementById("type").value,
name: document.getElementById("name").value,
};
dwolla.fundingSources.create(token, bankInfo, callback);
return false;
});
function callback(err, res) {
var $div = $("<div />");
var logValue = {
error: err,
response: res,
};
$div.text(JSON.stringify(logValue));
console.log(logValue);
$("#logs").append($div);
}
All funds transfers made using the Dwolla Platform are performed by a financial institution partner, and any funds held in a Dwolla Balance are held by a financial institution partner. Learn more about our financial institution partners.