Due E-Commerce PHP SDK
Sign up for a free account at https://app.due.com/register
Request Access: https://due.com/blog/request-access-use-due-payment-gateway-woocommerce/
API Docs: https://api-docs.due.com
Composer
You can install the bindings via Composer. Run the following command:
composer require due/php-ecom-sdk
To use the bindings, use Composer's autoload:
require_once('vendor/autoload.php');
Manual Installation
If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php
file.
require_once('/path/to/php-ecom-sdk/init.php');
Getting Started
- The default environment is production, but you can set it to stage for testing
\Due\Due::setEnvName('stage'); //set to 'stage' or 'prod'
- Set your API Key and App Id
//API Key from your Due Account
\Due\Due::setApiKey('1cdb92X9e9613a5r3a64c2X49ec17f7x1b8ac40adcqc0s23bb7f8bxc7q1y');
//App Id given after approval
\Due\Due::setAppId('test_30b4d69aQ1fb4Q8dkwn3');
- Platforms will set their Platform Id instead of an App Id. Please contact support@due.com for more info on Platform Payments.
//Platform user's Due API Key
\Due\Due::setApiKey('1cdb92X9e9613a5r3a64c2X49ec17f7x1b8ac40adcqc0s23bb7f8bxc7q1y');
//Platform Id given after approval
\Due\Due::setPlatformId('18Q3Xa21e42xp');
Create A Customer
$customer = \Due\Customers::create(array(
'email' => 'customer@email.com',
'phone' => '2226061234',
'full_name' => 'Alex Brown',
'card_id' => '2726251911',
'card_hash' => 'CC_f4nu9f2nfue9432fnu4e932fbu432gfb4u923fnjdwbu29'
));
$customer_id = $customer->id;
Charge A Customer
$transaction = \Due\Customers::charge(array(
'amount' => 15,
'currency' => 'USD',
'customer_id' => $customer_id
));
$transaction_id = $transaction->id;
Get Transaction
$transaction = \Due\Transactions::get(array(
'id' => $transaction_id
));
Get Transaction List
$transactions_list = \Due\Transactions::all(array(
'page' => 1
));
foreach ($transactions_list->transactions as $transaction) {
$transaction_id = $transaction->id;
}
Charge A Card
$transaction = \Due\Charge::card(array(
'amount' => 15,
'currency' => 'USD',
'card_id' => '1238203690',
'card_hash' => 'CC_XMzfDhNahJsfPAGPzVpX'
));
$transaction_id = $transaction->id;
Get A Customer
$customer = \Due\Customers::get(array(
'id' => $customer_id
));
$customer_id = $customer->id;
Get Customer List
$customer_list = \Due\Customers::all(array(
'page' => 1
));
foreach ($customer_list->customers as $customer) {
$customer_id = $customer->id;
}
Update Customer
$customer->card_id = '132311820';
$customer->card_hash = 'CC_VXV81vIv7rx0VRXbLlxq';
$updated_customer = \Due\Customers::update($customer);
$customer_id = $customer->id;
Contribution Requests
If you would like to contribute, please contact us at support@due.com.