Sign up for a free account at https://app.due.com/register
Working PHP Example: https://static.due.com/code-examples/due-ecom-php-test.zip
Request Access: https://due.com/blog/request-access-use-due-payment-gateway-woocommerce/
API Docs: https://api-docs.due.com
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');
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');
- The default environment is production, but you can set it to stage for testing
\Due\Due::setEnvName('stage'); //set to 'stage' or 'prod'
\Due\Due::setRailType('us'); //set to 'us' or 'us_int'
- Set your API Key and App Id
//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 -- ');
- 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(' -- SET API KEY HERE -- ');
//Platform Id given after approval
\Due\Due::setPlatformId(' -- SET PLATFORM ID HERE -- ');
$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;
$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;
If you would like to contribute, please contact us at support@due.com.