Skip to main content
dwolla-php is available on Packagist with source code available on our GitHub page.
Beta Release – This SDK is currently in beta. All API operations are fully supported, and we’re gathering feedback from early adopters before making this generally available. Breaking changes may occur as we continue refining the SDK. Please use caution when integrating into production environments. We welcome beta users to integrate, report issues, and help us identify any edge cases.

Getting Started

Installation

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"

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: Finally, you can create an instance of Dwolla with your application credentials:
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',
            clientSecret: 'YOUR_CLIENT_SECRET',
        )
    )
    ->build();

Making Requests

Once you’ve created a Dwolla client, you can make requests using the SDK methods.

High-Level SDK Methods

The PHP SDK provides strongly-typed methods for all Dwolla API operations:
// Get root API information
$response = $sdk->root->get();

// List customers
$response = $sdk->customers->list();

// Get customer details
$response = $sdk->customers->get(id: 'customer-id-here');

Authentication

The SDK supports multiple authentication schemes:
use Dwolla;
use Dwolla\Models\Components;

$sdk = Dwolla\Dwolla::builder()
    ->setSecurity(
        new Components\Security(
            clientID: 'YOUR_CLIENT_ID',
            clientSecret: 'YOUR_CLIENT_SECRET',
        )
    )
    ->build();

Application Access Token Creation

When creating application access tokens, you’ll need to provide Basic Authentication at the request level:
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_BASIC_AUTH',
);

$response = $sdk->tokens->create(
    request: $request,
    security: $requestSecurity
);

if ($response->object !== null) {
    // handle response
}

Working with Transfers

// Initiate a transfer
$response = $sdk->transfers->create(/* transfer parameters */);

// Get transfer details
$response = $sdk->transfers->get(id: 'transfer-id-here');

// Cancel a transfer (if eligible)
$response = $sdk->transfers->cancel(id: 'transfer-id-here');

Working with Funding Sources

// List customer funding sources
$response = $sdk->customers->fundingSources->list(id: 'customer-id-here');

// Create a funding source
$customerUrl = "https://api-sandbox.dwolla.com/customers/customer-id-here";
$response = $sdk->customers->fundingSources->create(
    id: 'customer-id-here',
    requestBody: [
        "routingNumber" => "222222226",
        "accountNumber" => "123456789",
        "bankAccountType" => "checking",
        "name" => "My Checking Account"
    ]
);

// Get funding source balance
$response = $sdk->fundingSources->balance->get(id: 'funding-source-id-here');

Error Handling

The SDK provides comprehensive error handling with typed exception classes:
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_BASIC_AUTH',
    );

    $response = $sdk->tokens->create(
        request: $request,
        security: $requestSecurity
    );

    if ($response->object !== null) {
        // handle response
    }
} catch (Errors\UnauthorizedExceptionThrowable $e) {
    // handle unauthorized error
    throw $e;
} catch (Errors\APIException $e) {
    // handle default exception
    throw $e;
}
By default, an API error will raise an Errors\APIException exception, which has the following properties:
PropertyTypeDescription
$messagestringThe error message
$statusCodeintThe HTTP status code
$rawResponse?\Psr\Http\Message\ResponseInterfaceThe raw HTTP response
$bodystringThe response content

Server Selection

You can specify which Dwolla environment to use:
use Dwolla;

// Use sandbox environment
$sdk = Dwolla\Dwolla::builder()
    ->setServer('sandbox')
    ->build();

// Use production environment
$sdk = Dwolla\Dwolla::builder()
    ->setServer('prod')
    ->build();

// Use custom server URL
$sdk = Dwolla\Dwolla::builder()
    ->setServerURL('https://api-sandbox.dwolla.com')
    ->build();
NameServerDescription
prodhttps://api.dwolla.comProduction server
sandboxhttps://api-sandbox.dwolla.comSandbox server

Available Resources and Operations

The SDK provides access to the following resources:
  • Root - API entry point
  • Tokens - Application access token management
  • Accounts - Account details, funding sources, transfers, mass payments, and exchanges
  • Customers - Customer management, beneficial owners, documents, funding sources, transfers, labels, KBA, and exchanges
  • Beneficial Owners - Beneficial owner management and documents
  • Business Classifications - Business classification lookup
  • Documents - Document retrieval
  • Events - Event listing and retrieval
  • Exchange Partners - Exchange partner management
  • Exchanges - Exchange resource management and sessions
  • Exchange Sessions - Exchange session management
  • Funding Sources - Funding source management, balances, micro-deposits, and VAN routing
  • KBA - Knowledge-based authentication
  • Labels - Label management, ledger entries, and reallocations
  • Mass Payments - Mass payment initiation and management
  • Transfers - Transfer initiation, retrieval, cancellation, and fee management
  • Webhooks - Webhook retrieval and retry management
  • Webhook Subscriptions - Webhook subscription management
  • Sandbox Simulations - Bank transfer processing simulation (Sandbox only)
For detailed information on each resource and its operations, see the SDK documentation on GitHub.

Community

  • If you have any feedback, please reach out to us on our forums or by creating a GitHub issue.
  • 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.