Node
Use Dwolla’s SDK for Node to build applications that interact with the Dwolla API to perform account-to-account payment functions.
Node
dwolla-v2
is available on NPM with source code available on our GitHub page.
Getting Started
Installation
To begin using this SDK, you will first need to download and install it on your machine. We use npm to distribute this package.
Initialization
Before any API requests can be made, you must first determine which environment you will be using, as well as fetch the application key and secret. To fetch your application key and secret, please visit one of the following links:
- Production: https://dashboard.dwolla.com/applications
- Sandbox: https://dashboard-sandbox.dwolla.com/applications
Finally, you can create an instance of Client
with key
and secret
replaced with the application key and secret that you fetched from one of the aforementioned links, respectively.
Making Requests
Once you’ve created a Client
, currently, you can make low-level HTTP requests. High-level abstraction is planned for this SDK; however, at the time of writing, it has not yet been fully implemented.
Low-Level Requests
To make low-level HTTP requests, you can use the get()
, post()
, and delete()
methods. These methods will return a Promise
containing the response object.
The following snippet defines Dwolla’s response object, both with a successful and errored response. Although the snippet uses try
/catch
, you can also use .then()
/.catch()
if you prefer.
An errored response is returned when Dwolla’s servers respond with a status code that is greater than or equal to 400, whereas a successful response is when Dwolla’s servers respond with a 200-level status code.
GET
POST
DELETE
Setting Headers
When a request is sent to Dwolla, a few headers are automatically sent (e.g., Accept
, Content-Type
, User-Agent
); however, if you would like to send additional headers, such as Idempotency-Key
, this can be done by passing in a third (3rd) argument for POST
requests.
To learn more about how to make your requests idempotent, check out our developer documentation on this topic!
Community
- If you have any feedback, please reach out to us on our forums or by creating a GitHub issue.
- If you would like to contribute to this library, bug reports and pull requests are always appreciated!
Docker
If you prefer to use Docker to run dwolla-v2-node locally, a Dockerfile is included at the root directory. Follow these instructions from Docker’s website to create a Docker image from the Dockerfile, and run it.