README.html

OpenAPI PHP Client

Direct Debit are the industry leaders in automated debit order collections in South Africa. We provide debit order systems which assist in the management and automation of your debit order collections. We have created our own payment systems and integrated with popular billing solutions to assist you in invoicing, management of clients and automation of your debit order batches. The API can only be accessed or used if you are an account holder.

  • API version: 1.1.190200

Requirements

  • PHP 5.4.0 +
  • PHP cURL Module

Installation & Usage

Download and extract the files. After completetion include autoload.php:

require_once('/path/to/directdebit-php/autoload.php');

and use the API as needed.

Getting Started

Please follow the installation procedure and see the example.php file below:

<?php
require_once(__DIR__ . '/directdebit-php/autoload.php');

Swagger\Client\Configuration::getDefaultConfiguration()->setUsername('YOUR_INSTALLATION_CODE');
Swagger\Client\Configuration::getDefaultConfiguration()->setPassword('YOUR_API_PASSWORD');
Swagger\Client\Configuration::getDefaultConfiguration()->setHost('https://dos-dr.directdebit.co.za:31143/v1');

$api_instance = new Swagger\Client\Api\EFTBatchesApi();
$api_batches_instance = new Swagger\Client\Api\BatchesApi();

$csv_file_path = 'my-batch.csv';
try {
    $result = $api_instance->eftUploadCsv($csv_file_path);
    echo 'Uploaded Batch ID ', $result['id'], ' with checksum ', $result['checksum'], PHP_EOL;
} catch (Exception $e) {
    echo 'Exception Message: ', $e->getMessage(), PHP_EOL;
    echo 'Exception HTTP Response Body: ', json_encode($e->getResponseHeaders()), PHP_EOL;
    echo 'Exception HTTP Response Code: ', $e->getCode(), PHP_EOL;
    echo 'Exception HTTP Response Body: ', json_encode($e->getResponseBody()), PHP_EOL;
    
    if ($e->getCode() == 400 && $e->getResponseBody()->error == 'checksum') {
        try {
            echo 'Delete duplicate Batch ID', $e->getResponseBody()->id, PHP_EOL;
            $result = $api_batches_instance->deleteBatch($e->getResponseBody()->id);
            if ($result['state'] == 'deleted') {
                $result = $api_instance->eftUploadCsv($csv_file_path);
                echo 'Uploaded Batch ID ', $result['id'], ' with checksum ', $result['checksum'], PHP_EOL;
            }
        } catch (Exception $e) {
            echo 'Exception Message: ', $e->getMessage(), PHP_EOL;
            echo 'Exception HTTP Response Body: ', json_encode($e->getResponseHeaders()), PHP_EOL;
            echo 'Exception HTTP Response Code: ', $e->getCode(), PHP_EOL;
            echo 'Exception HTTP Response Body: ', json_encode($e->getResponseBody()), PHP_EOL;
        }
    } else {
       throw new Exception('No validation for response!', $e->getResponseBody());
    }
}


?>

Documentation for API Endpoints

Class Method HTTP request Description
AVSApi avsGetBatchTransactions GET /batch/avs/{id}/transactions Retrieve a list of transactions and the state of each transaction.
AVSApi avsSubmitBatch POST /batch/avs/{id}/submit Submit a AVS batch to Bankserv.
AVSApi avsUploadCsv POST /batch/avs Upload a AVS CSV batch file containing the transactions to submit to Bankserv.
AVSApi avsUploadJson POST /batch/avs/json Upload AVS JSON transactions to submit to Bankserv.
BatchesApi deleteBatch DELETE /batch/{id} Delete a batch and transactions.
BatchesApi getBatch GET /batch/{id} Retrieve the status of a batch file.
BatchesApi getBatchTransactions GET /batch/{id}/transactions Retrieve a list of transactions and the state of each transaction.
BatchesApi listBatches GET /batch Retrieve a list of uploaded batches.
BatchesApi replaceCsv PUT /batch/{id} Replace an existing batch file.
BatchesApi replaceJson PUT /batch/{id}/json Replace an existing batch with JSON transactions.
BatchesApi submitBatch POST /batch/{id}/submit Submit a batch to Bankserv.
BatchesApi validateBatch POST /batch/{id}/validate Validate a batch file before submitting to Bankserv.
CDVApi account GET /cdv/account Validate a bank account number.
CDVApi branch GET /cdv/branch Validate a branch code.
CDVApi validateCdvBatch POST /cdv/batch Upload a CSV batch file containing transactions to validate before submitting.
EFTBatchesApi eftUploadCsv POST /batch/eft Upload a CSV batch file containing the transactions to submit to Bankserv.
EFTBatchesApi eftUploadJson POST /batch/eft/json Upload JSON transactions to submit to Bankserv.
EFTCreditBatchesApi creditSubmitBatch POST /batch/credit/{id}/submit Submit a EFT Credit batch to Bankserv.
EFTCreditBatchesApi creditUploadCsv POST /batch/credit Upload a CSV batch file containing the credit transactions to submit to Bankserv.
EFTCreditBatchesApi creditUploadJson POST /batch/credit/json Upload JSON transactions to submit to Bankserv.
NAEDOBatchesApi naedoUploadCsv POST /batch/naedo Upload a CSV batch file containing the transactions to submit to Bankserv.
NAEDOBatchesApi naedoUploadJson POST /batch/naedo/json Upload JSON transactions to submit to Bankserv.
ReconApi getRecon GET /recon Retrieve reconciliation of transactions processed.
ReconApi putReinstate PUT /recon/reinstate Reinstate a suspended account.

Documentation For Models

Documentation For Authorization

basic

  • Type: HTTP basic authentication