PHP code example of dwolla / dwollaswagger

1. Go to this page and download the library: Download dwolla/dwollaswagger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dwolla / dwollaswagger example snippets




DwollaSwagger\Configuration::$username = "API_KEY";
DwollaSwagger\Configuration::$password = "API_SECRET";

# For Sandbox
$apiClient = new DwollaSwagger\ApiClient("https://api-sandbox.dwolla.com");

# For Production
$apiClient = new DwollaSwagger\ApiClient("https://api.dwolla.com");

$tokensApi = new DwollaSwagger\TokensApi($apiClient);
$appToken = $tokensApi->token();

$customersApi = new DwollaSwagger\CustomersApi($apiClient);

$customer = $customersApi->create([
  "firstName" => "Jane",
  "lastName" => "Merchant",
  "email" => "[email protected]",
  "type" => "receive-only",
  "businessName" => "Jane Corp llc",
  "ipAddress" => "99.99.99.99"
], [
  "Idempotency-Key" => "51a62-3403-11e6-ac61-9e71128cae77"
]);
$customer; # => "https://api-sandbox.dwolla.com/customers/fc451a7a-ae30-4404-aB95-e3553fcd733f"

# Retrieve an Account by ID
$accountsApi = new DwollaSwagger\AccountsApi($apiClient);
$account = $accountsApi->id("8a2cdc8d-629d-4a24-98ac-40b735229fe2");

# Retrieve a Customer by ID
$customerUrl = 'https://api-sandbox.dwolla.com/customers/07d59716-ef22-4fe6-98e8-f3190233dfb8';
$customersApi = new DwollaSwagger\CustomersApi($apiClient);
$customer = $customersApi->getCustomer($customerUrl);

# Create a customer funding source
$customerUrl = "https://api-sandbox.dwolla.com/customers/AB443D36-3757-44C1-A1B4-29727FB3111C";
$fsApi = new DwollaSwagger\FundingsourcesApi($apiClient);

$fundingSource = $fsApi->createCustomerFundingSource([
  "routingNumber" => "222222226",
  "accountNumber" => "123456789",
  "bankAccountType" => "checking",
  "name" => "Jane Doe’s Checking"
], $customerUrl);
$fundingSource; # => "https://api-sandbox.dwolla.com/funding-sources/375c6781-2a17-476c-84f7-db7d2f6ffb31"

try{
    $new_customer = $customersApi->create([
        //request_body
    ]);
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getResponseBody(), "\n";
}