due/php-ecom-sdk

Due PHP Library

Installs: 27

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 4

Forks: 0

Open Issues: 0

Type:project

v1.0.7 2017-07-24 18:16 UTC

This package is not auto-updated.

Last update: 2024-12-22 03:27:31 UTC


README

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

Run in Postman

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

  1. 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'
  1. 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 -- ');
  1. 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 -- ');

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.