Skip to content

Dwolla/dwolla-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dwolla-php

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.

Summary

Dwolla API: Dwolla API Documentation

Table of Contents

SDK 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"

SDK Example Usage

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
}

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
clientID
clientSecret
tokenURL
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
}

Per-Operation Security Schemes

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 Resources and Operations

Available methods
  • get - Retrieve account details
  • list - List exchanges for an account
  • create - Create an exchange for an account
  • create - Create a funding source for an account
  • list - List funding sources for an account
  • list - List account mass payments
  • list - List and search account transfers
  • get - Retrieve beneficial owner
  • update - Update beneficial owner
  • delete - Remove beneficial owner
  • list - List documents for beneficial owner
  • create - Create a document for beneficial owner
  • list - List business classifications
  • get - Retrieve a business classification
  • create - Create a client token
  • list - List customer beneficial owners
  • create - Create customer beneficial owner
  • get - Retrieve beneficial ownership status
  • certify - Certify beneficial ownership
  • list - List documents for customer
  • create - Create a document for customer
  • list - List exchanges for a customer
  • create - Create an exchange for a customer
  • create - Create customer exchange session
  • list - List customer funding sources
  • create - Create customer funding source
  • list - List labels for a customer
  • create - Create a label for a customer
  • list - List mass payments for customer
  • list - List and search transfers for a customer
  • get - Retrieve a document
  • list - List events
  • get - Retrieve event
  • list - List exchange partners
  • get - Retrieve exchange partner
  • get - Retrieve exchange resource
  • get - Retrieve exchange session
  • 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
  • get - Retrieve a label
  • remove - Remove a label
  • list - List label ledger entries
  • create - Create a label ledger entry
  • get - Retrieve a label ledger entry
  • create - Create a label reallocation
  • get - Retrieve a label reallocation
  • create - Initiate a mass payment
  • get - Retrieve a mass payment
  • update - Update a mass payment
  • list - List items for a mass payment
  • get - Retrieve mass payment item
  • simulate - Simulate bank transfer processing (Sandbox only)
  • create - Create an application access token
  • create - Initiate a transfer
  • get - Retrieve a transfer
  • cancel - Cancel a transfer
  • get - Retrieve a transfer failure reason
  • list - List fees for a transfer
  • get - Retrieve a webhook
  • retry - Retry a webhook
  • 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

Error Handling

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 */*

Example

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;
}

Server Selection

Select Server by Name

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

Example

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
}

Override Server URL Per-Client

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
}

Maturity

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.

Contributions

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.

About

PHP SDK for Dwolla API

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages