PHP code example of due / php-ecom-sdk

1. Go to this page and download the library: Download due/php-ecom-sdk 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/ */

    

due / php-ecom-sdk example snippets






\Due\Due::setEnvName('stage'); //set to 'stage' or 'prod'
\Due\Due::setRailType('us'); //set to 'us' or 'us_int'

//API Key from your Due Account
\Due\Due::setApiKey(' -- SET API KEY HERE -- ');
//App Id given after approval
\Due\Due::setAppId(' -- SET APP ID HERE -- ');

//Platform user's Due API Key
\Due\Due::setApiKey(' -- SET API KEY HERE -- ');
//Platform Id given after approval
\Due\Due::setPlatformId(' -- SET PLATFORM ID HERE -- ');

$customer = \Due\Customers::create(array(
    'email' => '[email protected]',
    'phone' => '2226061234',
    'full_name' => 'Alex Brown',
    'card_id' => '2726251911',
    'card_hash' => 'CC_f4nu9f2nfue9432fnu4e932fbu432gfb4u923fnjdwbu29'
));

$customer_id = $customer->id;

$transaction = \Due\Customers::charge(array(
    'amount' => 15,
    'currency' => 'USD',
    'customer_id' => $customer_id
));

$transaction_id = $transaction->id;

$transaction = \Due\Transactions::get(array(
    'id' => $transaction_id
));

$transactions_list = \Due\Transactions::all(array(
    'page' => 1
));

foreach ($transactions_list->transactions as $transaction) {
    $transaction_id = $transaction->id;
}

$transaction = \Due\Charge::card(array(
    'amount' => 15,
    'currency' => 'USD',
    'card_id' => '1238203690',
    'card_hash' => 'CC_XMzfDhNahJsfPAGPzVpX'
));

$transaction_id = $transaction->id;

$customer = \Due\Customers::get(array(
    'id' => $customer_id
));

$customer_id = $customer->id;

$customer_list = \Due\Customers::all(array(
    'page' => 1
));

foreach ($customer_list->customers as $customer) {
    $customer_id = $customer->id;
}

$customer->card_id = '132311820';
$customer->card_hash = 'CC_VXV81vIv7rx0VRXbLlxq';
$updated_customer = \Due\Customers::update($customer);

$customer_id = $customer->id;
bash
composer