Templates
Template Setup Guides

Dwolla Plugin

Link to plugin page: https://zeroqode.com/plugin/dwolla-achbank-payments-plugin-1568285782768x592616517541273900

Introduction

Enable ACH/Bank payments and transfers in your application with the Dwolla API.

Prerequisites

You must have an account with Dwolla to interact with the API. Create you development account at: https://accounts-sandbox.dwolla.com/sign-up

Make sure you have a Plaid account https://dashboard.plaid.com/signup and turned on Dwolla integration in your Plaid account here: https://dashboard.plaid.com/account/integrations

Dwolla Account Setup

To use this plugin you need to create a Dwolla account. You can create a Dwolla sandbox account at: https://accounts-sandbox.dwolla.com/sign-up. For a production account visit https://www.dwolla.com/get-started/ or contact sales at https://www.dwolla.com/contact/

After signing up, navigate to the applications tab at https://dashboard-sandbox.dwolla.com/applications-legacy and create an app.

After creating the app copy the necessary credentials below and paste them in the Dwolla Plugin Settings in Bubble

The Environment field should be set to sandbox when using Dwolla Sandbox API keys and changed to production when you go to production.

Creating Customers

Dwolla has multiple customer types with various limitations as can be seen here: https://developers.dwolla.com/resources/account-types.html. This plugin currently supports creating two customer types which are Personal Verified Customer and Unverified customer . You can choose which one to create for your app user based on your needs.

When you create a customer, a customer resource link is returned. You should save this link to your user as it would be need later on. The customer link is something like: https://api-sandbox.dwolla.com/customers/9da3aa7c-2524-430b-a751-6dc722735fce

Creating Funding Sources

When you create a customer in Dwolla, the customer needs to have a funding source in order for you to send money to or receive money from the customer. There are two types of Dwolla funding sources which are balance and bank. Read more here: https://docs.dwolla.com/#funding-sources. In this documentation we would only be handling bank funding sources.

To simplify the process of adding a bank funding source, this plugin is designed to work with the Plaid plugin by Copilot. You would use Plaid to collect the user's account details and then continue the process with Dwolla.

Also, you would likely want to charge your users variable amounts in the future, to do this, you need to create a funding source with an on-demand transfer authorization. Read more here: https://docs.dwolla.com/#create-an-on-demand-transfer-authorization

We will now go through the steps of creating a funding source for a customer with an on-demand transfer authorization.

In your application where you want a user to add their bank account you need to get an on-demand transfer authorization after they click a similar button to the one below:

Your workflow should be like below:

  • Create on-demand transfer authorization

  • Set the body text returned by the first action on the Authorization Popup

  • Set the actual authorization link returned by the first action on the Authorization Popup

  • Display the authorization popup with the body text being shown and a confirmation button like below

When the Agree & Continue button is clicked your workflow should then:

  • Trigger Get account with Plaid

  • Take the authorization link from the Popup and set it on another group (preferably the group that contains the bank account management elements)

You need to install the Plaid plugin and set it up properly to use this Dwolla plugin. Follow the instructions here: https://bubble.io/plugin/plaid-1520814291764x674322781867343900

After you have installed and setup plaid, make sure you have turned on Dwolla integration in your Plaid account here: https://dashboard.plaid.com/account/integrations

Now back to the funding source creation, after the user has selected their bank account with Plaid, your Plaid token has been created workflow would look like below:

  • Show a loading animation because the process can take a few seconds

  • Get a Plaid access token

  • Get bank account detail with the access token (This is optional but advised to get proper name of the bank account to save in your database)

  • Get a Dwolla Processor token

  • Use the Dwolla Processor token to create a dwolla funding source with authorization. (The authorization is the one saved before from the authorization popup)

  • Next you can now create a bank account object with all the information from Plaid and most importantly the funding source link from Dwolla

  • Once the account object is create you should add it to the user.

Charging Customers

Now that you have created a funding source with an on-demand authorization, you will now be able to charge users varying amounts of money in the future. To do so, you need to use the "Receive money from Customer" plugin action.

Make sure you setup the plugin action correctly.

  • The Source Funding Source is the customer bank account which you want to debit. The value used here should be a funding source link as gotten from the topic above.

  • The destination Funding Source is your Dwolla master account balance. The value used here should be a funding source ID gotten from your dashboard page at: https://dashboard-sandbox.dwolla.com/account/funding-sources

The receive money action will return a Dwolla Transfer resource link. You should extract the ID from this link and store it in a transaction object for future reference and webhook confirmations. To extract the ID from the URL, truncate from end to last 36 digits as done below

​Sending Funds to Customers

This is similar to above but you would simple use the "Send money to customer" action and also the source and destination would be flipped as seen below

Webhooks

To receive webhooks in Dwolla, you need to subscribe to them with the plugin action "Create webhook subscription".

Ideally you are going to create 2 subscriptions. The first one is to initialize the API endpoint to fetch the request data.

On a test page in your app simple add a workflow to create a webhook subscription. The URL to be subscribed should be that of the API endpoint wherein you wish to receive these webhooks.

The API workflow endpoint URL should be copied from the detecting request data mode of the API endpoint like below

After you have subscribed to the URL gotten above, trigger a webhook event by create an unverified customer so that your endpoint can detect the request data and then you can save it.

Once this is done, create another subscription for this URL but without the /initialize portion.

If you want, you can delete the first initialize webhook subscription using the delete webhook subscription plugin action.

Handling Webhook events

The most common use of webhooks is to confirm success or failure of transfers to or from users. In your API endpoint which receives all Dwolla webhook events, you can trigger other API workflows depending on the kind of webhook event received.

As seen in the image above, a workflow called monthly_payment_successful is triggered when a search for monthly payment which has the ID fetched from the transfer resource URL and when the webhook event has a topic of transfer_completed. It then terminates the workflow based on the same condition. If this condition is not met, it moves on to the next one workflow action whose condition is met.

Demo to preview the settings