LogoLogo
Document ValidationsPayment Methods
Latest
Latest
  • D24 APIs
  • Getting Started with D24
  • API Documentation
    • Deposits API
      • Technical and Security Aspects
        • Calculating the Signature
      • Endpoints
        • Deposit Creation Endpoint
          • Notifications
        • PCI Deposit Creation Endpoint
        • Deposit Status Endpoint
        • Payment Methods Endpoint
        • Currency Exchange Endpoint
        • Crypto Exchange Endpoint
        • Country States Codes Endpoint
        • Refund Creation Endpoint
          • Notifications
        • Refund Status Endpoint
      • Payment Methods
        • 🌎America
          • 🇦🇷Argentina
          • 🇧🇴Bolivia
          • 🇧🇷Brazil
          • 🇨🇱Chile
          • 🇨🇦Canada
          • 🇨🇴Colombia
          • 🇪🇨Ecuador
          • 🇬🇹Guatemala
          • 🇲🇽Mexico
          • 🇵🇾Paraguay
          • 🇵🇪Peru
        • 🌍Africa
          • 🇧🇼Botswana
          • 🇨🇲Cameroon
          • 🇨🇬Congo Brazzaville
          • 🇨🇩Congo DRC
          • 🇪🇬Egypt
          • 🇬🇦Gabon
          • 🇬🇭Ghana
          • 🇨🇮Ivory Coast
          • 🇰🇪Kenya
          • 🇳🇬Nigeria
          • 🇲🇼Malawi
          • 🇷🇼Rwanda
          • 🇿🇦South Africa
          • 🇺🇬Uganda
          • 🇿🇲Zambia
          • 🇹🇿Tanzania
        • 🌏Asia
          • 🇧🇩Bangladesh
          • 🇨🇳China
          • 🇭🇰Hong Kong
          • 🇮🇳India
          • 🇮🇩Indonesia
          • 🇯🇵Japan
          • 🇲🇾Malaysia
          • 🇵🇰Pakistan
          • 🇹🇭Thailand
          • 🇹🇷Turkey
          • 🇻🇳Vietnam
      • API Codes
    • Cashouts API
      • Technical and Security Aspects
        • Calculating the Payload-Signature
      • Endpoints
        • Cashout Creation Endpoint
          • Notifications
        • Cashout Status Endpoint
        • Cashout Update Status Endpoint
        • Cashout Cancellation Endpoint
        • Cashout Bank Codes
      • Countries Validations
        • American Countries
          • 🇧🇴Bolivia
          • 🇧🇷Brazil
          • 🇨🇦Canada
          • 🇨🇱Chile
          • 🇨🇴Colombia
          • 🇪🇨Ecuador
          • 🇲🇽Mexico
          • 🇵🇪Peru
          • 🇦🇷Argentina
          • 🇵🇾Paraguay
        • African Countries
          • 🇧🇼Botwsana
          • 🇨🇲Cameroon
          • 🇨🇬Congo Brazzaville
          • 🇨🇩Congo DRC
          • 🇪🇬Egypt
          • 🇬🇦Gabon
          • 🇬🇭Ghana
          • 🇰🇪Kenya
          • 🇲🇼Malawi
          • 🇳🇬Nigeria
          • 🇷🇼Rwanda
          • 🇿🇦SOUTH AFRICA
          • 🇿🇲Zambia
        • Asian Countries
          • 🇧🇩Bangladesh
          • 🇨🇳China
          • 🇮🇳India
          • 🇮🇩Indonesia
          • 🇯🇵Japan
          • 🇲🇾Malaysia
          • 🇹🇭Thailand
          • 🇹🇷Turkey
          • 🇵🇰Pakistan
          • 🇻🇳Vietnam
        • Oceania Countries
          • 🇦🇺Australia
      • API Codes
    • Subscriptions API
      • Technical and Security Aspects
        • Calculating the Signature
      • Subscription Creation Endpoints
        • OneShot Subscription Creation
        • PCI Subscription Creation Endpoint
        • Notifications
      • Subscription Cancellation Endpoint
      • Subscription Status Endpoint
    • Bank Accounts Validation API
      • Technical and Security Aspects
        • Calculating the Signature
      • Endpoints
        • Bank Account Validation Endpoint
        • Pix Key Validation Endpoint
      • API Codes
    • KYC API
      • Technical and Security Aspects
        • Calculating the Signature
      • KYC Endpoint
      • API Codes
    • Reconciliation API
      • Technical and Security Aspects
      • Endpoints
      • API Codes
    • Quickpay
      • Endpoints
        • Deposit creation endpoint
          • Notifications
        • Deposit Status Endpoint
    • Tools for Platforms
      • Technical and Security Aspects
        • Calculating the Signature
      • SubMerchant Creation
        • Notifications
      • SubMerchant Status Endpoint
      • Commission Update Endpoint
  • PLUGINS
    • Shopify
      • Installation
      • Onboarding
      • Customer flow
      • Admin Flow
      • Tutorials
      • FAQ
    • WooCommerce
      • Installation
      • Configuration
  • Deposits Tools
    • Cards SDK
      • With User Interface
        • 🚀Color Customization
      • Without User Interface
    • Java SDK
    • PHP SDK
  • Knowledge Base
    • Countries Specifications
    • Deposits with Cards SDK
      • With User Interface
      • Without User Interface
    • Deposits with 3DS Authentication
    • Deposits with Installments
  • v1 Developers Guide
  • Status Page
Powered by GitBook
On this page
  • Introduction
  • Installation
  • Requirements
  • Install
  • Usage
  • Deposit Credentials
  • Classes
  • Create Deposit
  • Deposit Status
  • Payment Methods
  • Exchange Rates
  • Create Refund
  • Refund Status

Was this helpful?

  1. Deposits Tools

PHP SDK

Learn how to use our SDK in PHP to facilitate even further the integration with our Deposits APIs

PreviousJava SDKNextCountries Specifications

Last updated 4 years ago

Was this helpful?

Introduction

The Deposits PHP SDK (Software Development Kit) is a software package you can download and add to your existing code facilitating the integration by having pre-defined classes and functions you can call to integrate the .

Review and download the source code from GitHub by clicking on the button below

Installation

Requirements

  • PHP 5.6 or later

Install

Via Composer

Install PHP SDK via Composer
composer require directa24/cashin-php-sdk

Usage

Begin by initializing your credentials

Deposit Credentials

$x_login = "fUEhPEKrUt";
$api_key = "lTMZgRTakW";
$secret_key = "wSHTfsMMdNskTppilncuZPEklgLmdUAOg";

$directa24 = Directa24::getInstance($x_login, $api_key, $secret_key);

Make sure you have whitelisted your servers IPs on our Merchant Panel by going to Settings -> API Access.

As soon as you are ready with the integration and you have the production credentials, replace the credentials with the production ones and set the ProductionMode to True to use the production endpoints.

Set Production Mode to True
Directa24::setProductionMode(true);

Classes

Create Deposit

Hosted Checkout Experience

$create_deposit_request = new CreateDepositRequest();
$create_deposit_request->invoice_id = Helpers::generateRandomString(8);
$create_deposit_request->amount = 100;
$create_deposit_request->country = "BR";
$create_deposit_request->currency = "BRL";
$create_deposit_request->language = "en";

try {
    $response = $directa24->createDeposit($create_deposit_request);

    if ($response->checkout_type === 'HOSTED') {
        $redirect_url = $response->redirect_url;
        $response->deposit_id;
        $response->user_id;
        $response->merchant_invoice_id;
        header('Location: '. $redirect_url);
    }
    echo json_encode($response);
} catch (Directa24Exception $ex){
    echo $ex;
}

ONE SHOT Experience

$address = new Address();
$address->street = "Rua Dr. Franco Ribeiro, 52";
$address->city = "Rio Branco";
$address->state = "AC";
$address->zip_code = "11600-234";


$payer = new  Payer();
$payer->id = "4-9934519";
$payer->address = $address;
$payer->document = "72697858059";
$payer->document_type = "CPF";
$payer->email = "[email protected]";
$payer->first_name = "Ricardo";
$payer->last_name = "Carlos";
$payer->phone = "+598 99730878";


$bank_account = new BankAccount();
$bank_account->bank_code = "01";
$bank_account->account_number = "3242342";
$bank_account->account_type = "SAVING";
$bank_account->beneficiary = "Ricardo Carlos";
$bank_account->branch = "12";


$create_deposit_request = new CreateDepositRequest();
$create_deposit_request->invoice_id = Helpers::generateRandomString(8);
$create_deposit_request->amount = 100;
$create_deposit_request->country = "BR";
$create_deposit_request->currency = "BRL";
$create_deposit_request->language = "en";
$create_deposit_request->payer = $payer;
$create_deposit_request->payment_method = "BB";
$create_deposit_request->bank_account = $bank_account;
$create_deposit_request->early_release = false;
$create_deposit_request->fee_on_payer = false;
$create_deposit_request->surcharge_on_payer = false;
$create_deposit_request->bonus_amount = 0.1;
$create_deposit_request->bonus_relative = false;
$create_deposit_request->strikethrough_price = 0.1;
$create_deposit_request->description = "Test";
$create_deposit_request->client_ip = "186.51.171.84";
$create_deposit_request->device_id = "00000000-00000000-01234567-89ABCDEF";
$create_deposit_request->back_url = "https://yoursite.com/deposit/108/cancel";
$create_deposit_request->success_url = "https://yoursite.com/deposit/108/confirm";
$create_deposit_request->error_url = "https://yoursite.com/deposit/108/error";
$create_deposit_request->notification_url = "https://yoursite.com/ipn";
$create_deposit_request->test = true;
$create_deposit_request->mobile = false;

try {
    $response = $directa24->createDeposit($create_deposit_request);
    
    if ($response->checkout_type === 'ONE_SHOT') {
        $payment_info = $response->payment_info;

        if ($payment_info->type === 'CREDIT_CARD') {
            header('Location: ' . $response->redirect_url);
        }

        // Referenced transfer
        if ($payment_info->type === 'BANK_TRANSFER') {
            header('Location: ' . $response->redirect_url);
        }

        // Bank deposit
        if ($payment_info->type === 'BANK_DEPOSIT') {
            echo '<pre>';
            print_r($payment_info->metadata);
            echo '</pre>';
        }

        // Several types of payment methods: Boleto, Picpay, Oxxo
        if ($payment_info->type === 'VOUCHER') {
            $metadata = $payment_info->metada;
            if (isset($metadata->qr_code)) {
                echo '<img src="' . $metadata->qr_code . '"/>';
            } else if (isset($metadata->digital_line) || isset($metadata->barcode)) {
                echo '<pre>';
                print_r($metadata);
                echo '</pre>';
            }
        }
    }

} catch (\Directa24Exception $ex) {
    echo $ex;
}

The amount and the country are the only mandatory fields for a successful request. The rest of the fields needs to be sent depending on the flow you have chosen as those will be collected by us if not sent.

Deposit Status

$depositId = 300533668;
$directa24->depositStatus($depositId);

Make sure you are adding the deposit_id received on your notification_url in the field depositId.

Payment Methods

 $data = $this->directa24->paymentMethods('BR');
 foreach ($data as $paymentMethodResponse) {
   $paymentMethodResponse->country;
 }

Exchange Rates

$amount_in_dollars = 100;
$country = 'BR';
$data = $this->directa24->currencyExchange($country, $amount_in_dollars);

Create Refund

In order to create a refund, you need to send the deposit_id, merchant_invoice_id, and the bank_account object (only for non-cc payments, otherwise, it is optional).

$bank_account = new BankAccount();
$bank_account->bank_code = "01";
$bank_account->account_number = "3242342";
$bank_account->account_type = "SAVING";
$bank_account->beneficiary = "Ricardo Carlos";
$bank_account->branch = "12";


$create_refund_request = new CreateRefundRequest();
$create_refund_request->deposit_id = 300533180;
$create_refund_request->invoice_id = 'MP_b451645f30b8415ba833d37f3fa21209';
$create_refund_request->amount = 1;
$create_refund_request->bank_account = $bank_account;
$create_refund_request->comments = 'test';
$create_refund_request->notification_url = "https://yoursite.com/deposit/108/confirm";


$directa24 = Directa24::getInstance("fUEhPEKrUt", "lTMZgRTakW", "wSHTfsMMdNskTppilncuZPEklgLmdUAOg");

try {
    $refund_id = $directa24->refund($create_refund_request);
    echo $refund_id;
} catch (\Directa24Exception $ex) {
    echo $ex;
}

Refund Status

$refundId = 168250;
$directa24->refundStatus($refundId);

for more information about the API Keys.

Once the credentials and the IPs have been properly set-up, you are ready to start using the classes the SDK provides. Each Class can be used to execute the functionalities of its respective

Make sure you take a look at the to review how the integration of each of them works, the validations and the responses formats.

Check the respective to see the format of the responses, fields requirements and validations.

Every time you need to create a deposit, you will need to invoke the CreateDepositRequest Class with all the objects containing the information required to be sent. The amount of information required depends on the flow you have chosen, either the or the

As soon as the deposit is created and you have received the notification in your notification_url, you will want to retrieve the of the deposit.

Click here to see the

For the best user experience, we recommend integrating our to automatically retrieve the of payment methods name, logos, types and more that your account has available.

In order to do that, invoke the PaymentMethodRequest Class containing the of the country you need the payment methods from in the field PaymentMethodRequest.country

If you need to know the Exchange Rate of a given currency, you can do so by invoking ExchangeRateRequest with the of the origin and the amount you want to convert to USD.

Deposit Endpoint.
Deposit Endpoints here
Endpoint Page
Payment Methods Endpoint
list
Deposits Endpoints
deposits status flow.
Click here
Hosted Checkout Experience
ONE SHOT Experience.
Country's ISO code
Country's ISO code
status
Open in GitHub