The official PHP SDK for the Dwolla API. Supports server-side PHP calls to Dwolla’s endpoints with typed models, simple client helpers, and OAuth token handling to manage customers, funding sources, transfers, webhooks, and more.
Important
Beta Release – This SDK is currently in beta. We have run smoke coverage (SDK build/clients) and a sandbox getting-started flow (root, list customers, create unverified customer, add funding source). Broader operation coverage and retry wiring are still in progress. Breaking changes may occur as we continue hardening and expanding tests; use with caution in production. We welcome beta users to integrate, report issues, and help us catch edge cases.
Dwolla API: Dwolla API Documentation
The SDK relies on Composer to manage its dependencies.
To install the SDK and add it as a dependency to an existing composer.json file:
composer require "dwolla/dwolla-php"declare(strict_types=1);
require 'vendor/autoload.php';
use Dwolla;
use Dwolla\Models\Operations;
$sdk = Dwolla\Dwolla::builder()->build();
$request = new Operations\CreateApplicationAccessTokenRequest(
grantType: Operations\GrantType::ClientCredentials,
);
$requestSecurity = new Operations\CreateApplicationAccessTokenSecurity(
basicAuth: '<YOUR_API_KEY_HERE>',
);
$response = $sdk->tokens->create(
request: $request,
security: $requestSecurity
);
if ($response->object !== null) {
// handle response
}This SDK supports the following security scheme globally:
| Name | Type | Scheme |
|---|---|---|
clientIDclientSecrettokenURL |
oauth2 | OAuth2 Client Credentials Flow |
You can set the security parameters through the setSecurity function on the SDKBuilder when initializing the SDK. For example:
declare(strict_types=1);
require 'vendor/autoload.php';
use Dwolla;
use Dwolla\Models\Components;
$sdk = Dwolla\Dwolla::builder()
->setSecurity(
new Components\Security(
clientID: '<YOUR_CLIENT_ID_HERE>',
clientSecret: '<YOUR_CLIENT_SECRET_HERE>',
)
)
->build();
$response = $sdk->root->get(
);
if ($response->root !== null) {
// handle response
}Some operations in this SDK require the security scheme to be specified at the request level. For example:
declare(strict_types=1);
require 'vendor/autoload.php';
use Dwolla;
use Dwolla\Models\Operations;
$sdk = Dwolla\Dwolla::builder()->build();
$request = new Operations\CreateApplicationAccessTokenRequest(
grantType: Operations\GrantType::ClientCredentials,
);
$requestSecurity = new Operations\CreateApplicationAccessTokenSecurity(
basicAuth: '<YOUR_API_KEY_HERE>',
);
$response = $sdk->tokens->create(
request: $request,
security: $requestSecurity
);
if ($response->object !== null) {
// handle response
}Available methods
- get - Retrieve account details
- list - List account mass payments
- list - List and search account transfers
- create - Create a client token
- list - List and search customers
- create - Create a customer
- get - Retrieve a customer
- update - Update a customer
- listAvailableConnections - List available exchange connections
- create - Create customer exchange session
- initiate - Initiate a KBA session
- list - List mass payments for customer
- list - List and search transfers for a customer
- get - Retrieve a document
- get - Retrieve exchange resource
- createReAuth - Create re-authentication exchange session
- get - Retrieve exchange session
- get - Retrieve a funding source
- updateOrRemove - Update or remove a funding source
- getVanRouting - Retrieve VAN account and routing numbers
- get - Retrieve funding source balance
- get - Retrieve micro-deposits details
- initiate - Initiate micro-deposits
- verify - Verify micro-deposits
- create - Create an on-demand transfer authorization
- getQuestions - Retrieve KBA Questions
- verify - Verify KBA Questions
- list - List label ledger entries
- create - Create a label ledger entry
- get - Retrieve a label ledger entry
- get - root
- simulate - Simulate bank transfer processing (Sandbox only)
- create - Create an application access token
- get - Retrieve a transfer failure reason
- list - List fees for a transfer
- list - List retries for a webhook
- list - List webhook subscriptions
- create - Create a webhook subscription
- get - Retrieve a webhook subscription
- update - Update a webhook subscription
- delete - Delete a webhook subscription
- list - List webhooks for a webhook subscription
Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an exception.
By default an API error will raise a Errors\APIException exception, which has the following properties:
| Property | Type | Description |
|---|---|---|
$message |
string | The error message |
$statusCode |
int | The HTTP status code |
$rawResponse |
?\Psr\Http\Message\ResponseInterface | The raw HTTP response |
$body |
string | The response content |
When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the create method throws the following exceptions:
| Error Type | Status Code | Content Type |
|---|---|---|
| Errors\UnauthorizedException | 401 | application/json |
| Errors\APIException | 4XX, 5XX | */* |
declare(strict_types=1);
require 'vendor/autoload.php';
use Dwolla;
use Dwolla\Models\Errors;
use Dwolla\Models\Operations;
$sdk = Dwolla\Dwolla::builder()->build();
try {
$request = new Operations\CreateApplicationAccessTokenRequest(
grantType: Operations\GrantType::ClientCredentials,
);
$requestSecurity = new Operations\CreateApplicationAccessTokenSecurity(
basicAuth: '<YOUR_API_KEY_HERE>',
);
$response = $sdk->tokens->create(
request: $request,
security: $requestSecurity
);
if ($response->object !== null) {
// handle response
}
} catch (Errors\UnauthorizedExceptionThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\APIException $e) {
// handle default exception
throw $e;
}You can override the default server globally using the setServer(string $serverName) builder method when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
| Name | Server | Description |
|---|---|---|
prod |
https://api.dwolla.com |
Production server |
sandbox |
https://api-sandbox.dwolla.com |
Sandbox server |
declare(strict_types=1);
require 'vendor/autoload.php';
use Dwolla;
use Dwolla\Models\Operations;
$sdk = Dwolla\Dwolla::builder()
->setServer('prod')
->build();
$request = new Operations\CreateApplicationAccessTokenRequest(
grantType: Operations\GrantType::ClientCredentials,
);
$requestSecurity = new Operations\CreateApplicationAccessTokenSecurity(
basicAuth: '<YOUR_API_KEY_HERE>',
);
$response = $sdk->tokens->create(
request: $request,
security: $requestSecurity
);
if ($response->object !== null) {
// handle response
}The default server can also be overridden globally using the setServerUrl(string $serverUrl) builder method when initializing the SDK client instance. For example:
declare(strict_types=1);
require 'vendor/autoload.php';
use Dwolla;
use Dwolla\Models\Operations;
$sdk = Dwolla\Dwolla::builder()
->setServerURL('https://api.dwolla.com')
->build();
$request = new Operations\CreateApplicationAccessTokenRequest(
grantType: Operations\GrantType::ClientCredentials,
);
$requestSecurity = new Operations\CreateApplicationAccessTokenSecurity(
basicAuth: '<YOUR_API_KEY_HERE>',
);
$response = $sdk->tokens->create(
request: $request,
security: $requestSecurity
);
if ($response->object !== null) {
// handle response
}This SDK is currently in beta; expect potential breaking changes while we stabilize. We follow Semantic Versioning for published versions, but until GA we recommend pinning to an exact version and validating in your environment.
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.