An official Guzzle based wrapper for the Dwolla API.
Official PHP wrapper for Dwolla's v1 API
This repository is for an old version of our API and is no longer actively maintained. Please use our new SDKs.
The PHP JSON and CURL extensions are required for
dwolla-php to operate.
To install without adding to
composer require dwolla/dwolla-php
To add to
composer.json and make this a permanent dependency of your package:
composer require "dwolla/dwolla-php=2.*" composer update && composer install
dwolla-php makes it easy for developers to hit the ground running with our API. Before attempting the following, you should ideally create an application key and secret.
- Set any variables in
Settingsclass. All fields are public.
dwolla-phpwith the class that contains the endpoints you require.
- Use at will!
require '../lib/account.php'; $Account = new Dwolla\Account(); /** * Example 1: Get basic information for * a Dwolla user using their Dwolla ID. */ print_r($Account->basic('812-121-7199'));
accountInst.php for an example of the following.
require '../lib/account.php'; $Account = new Dwolla\Account(); $Account->settings->client_id = "MY KEY"; $Account->settings->client_secret = "MY SECRET"; $Account->settings->sandbox = true; /** * Example 1: Get basic information for * a Dwolla user using their Dwolla ID. */ print_r($Account->basic('812-121-7199'));
require '../lib/account.php'; $Account = new Dwolla\Account(); /** * Example 1: Get full information for * a Dwolla user using their OAuth token via `alternate_token` */ print_r($Account->full('oh-look-another-oauth-token-goes-here'));
It has come to our attention that CURL will reject sending a request (error 60) over HTTPS if a certificate authority bundle is not configured on your system. Due to security reasons (trusted CAs change frequently), we are not bundling a bundle with the library.
You should fetch the CA bundle from a trusted source. We recommend using the one maintained by CURL's authors and available on their page, here.
There are 8 quickstart files which will walk you through working with
dwolla-php's classes/endpoint groupings.
account.php: Retrieve account information, such as balance.
checkouts.php: Offsite-gateway endpoints, server-to-server checkout example.
contacts.php: Retrieve/sort through user contacts.
fundingSources.php: Modify and get information with regards to funding sources.
masspay.php: Create and retrieve jobs/data regarding MassPay jobs.
oauth.php: Examples on retrieving OAuth access/refresh token pairs.
requests.php: Create and retrieve money requests/information regarding money requests.
transactions.php: Send money, get transaction info by ID, etc.
dwolla-php is a conglomerate of multiple classes; each file in the
lib/ directory contains a class which contains all the endpoints for that certain category (similar to Dwolla's developer documentation).
Each endpoint class extends
RestClient located in
basic(): Retrieves basic account information
full(): Retrieve full account information
balance(): Get user balance
nearby(): Get nearby users
getAutoWithdrawal(): Get auto-withdrawal status
toggleAutoWithdrawal(): Toggle auto-withdrawal
disableAutoWithdrawal(): Disable auto-withdrawal
enableAutoWithdrawal(): Enable auto-withdrawal
resetCart(): Clears out item cart.
addToCart(): Adds item to cart.
create(): Creates a checkout session.
get(): Gets status of existing checkout session.
complete(): Completes a checkout session.
verify(): Verifies a checkout session.
get(): Retrieve a user's contacts.
nearby(): Get spots near a location.
info(): Retrieve information regarding a funding source via ID.
get(): List all funding sources.
add(): Add a funding source.
verify(): Verify a funding source.
withdraw(): Withdraw from Dwolla into funding source.
deposit(): Deposit to Dwolla from funding source.
create(): Creates a MassPay job.
getJob(): Gets a MassPay job.
getJobItems(): Gets all items for a specific job.
getItem(): Gets an item from a specific job.
listJobs(): Lists all MassPay jobs.
genAuthUrl(): Generates OAuth permission link URL
get(): Retrieves OAuth + Refresh token pair from Dwolla servers.
refresh(): Retrieves OAuth + Refresh pair with refresh token.
catalog(): Retrieves all endpoints elligible for use with current OAuth token.
create(): Request money from user.
get(): Lists all pending money requests.
info(): Retrieves info for a pending money request.
cancel(): Cancels a money request.
fulfill(): Fulfills a money request.
send(): Sends money
refund(): Refunds money
get(): Lists transactions for user
info(): Get information for transaction by ID.
stats(): Get transaction statistics for current user.
schedule(): Schedule a transaction to occur at a later date.
scheduled(): Get all scheduled transactions.
scheduledById(): Get a scheduled transaction by its ID.
editScheduledById(): Edit scheduled transaction by its ID.
deleteScheduledById(): Delete a scheduled transaction by its ID.
deleteAllScheduled(): Delete all scheduled transactions.
client.php/RestClient() is the base class for all of the aforementioned classes,
_settings.php/Settings() does not inherit from anything and only contains configuration parameters.
dwolla-php uses PHPUnit for unit testing. These tests do not test integration and will occassionally show console API errors due to 'dummy' data being used. Integration testing is planned sometime in the future.
To run the tests, install
composer.json and run:
cd tests ../vendor/bin/phpunit
- Fix disable auto-withdrawal bug
- Add convenience methods to enable and disable autowithdrawal
- Allow GuzzleHttp version ~6.0
- Changed version constraint for GuzzleHttp causing the library to fail due to PSR7 update.
$OAuth->catalog()for the new catalog endpoint, along with unit tests and examples.
- Added the new scheduled transactions endpoints, along with unit tests and examples.
- Added an
$alternate_pinparameter to functions which take PINs.
alternate_tokenparameter to allow functions which use an
oauth_tokento be overriden in cases where the user would have to continuously set/get the variable in the
- Purely cosmetic: revised docstrings to meet PHP standards. Thanks for the tip, @fraserredmond!
- Fixed unescaped variables in error messages (thanks @PrplHaz4)!
- Fix bug in offsite-gateway checkout URL generation.
- Show request made if debug flag is toggled (thanks, @redzarf)!
number_formatbug to allow amounts greater than 999.99.
- Fixed use of
verify()module. Thanks, @tylermenezes!
http://www.dwolla.comto mitigate HTTP 500 on some requests (namely OAuth).
- OAuth->get() bug has been fixed.
- _dwollaparse() now returns error messages from API if any exist.
- Log to file feature added (thank you @redzarf for your pull request).
- Improved error handling,
getBody()called on non-object error has been resolved for failing requests.
- Fix for ISE with OAuth token retrieval.
- Fixed "stuck hostname" bug.
- Fixed improper class resolution (thanks @redzarf!).
- Added PHP magic methods
__set()for compliance with PHP strict (
- All tests are now set to also test against all PHP errors with
Checkouts->Create. It now requires
totalto be included in
- Fix README library installation command. Composer command is
- Changed token retrieval methods to POST to avoid querystring errors with GET and invalid access tokens/code/etc.
- Fixed fundsSource parameter in refund function, thanks @echodreamz.
- Fixed settings class inheritance issue, made unit tests use autoload file.
- Initial release.
1.x written by:
- Michael Schonfeld
- Jeremy Kendall http://about.me/jeremykendall
Copyright (c) 2014 Dwolla Inc, David Stancu
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.