frankirox/yii2-2checkout

Yii2 extension for 2checkout library forked from joni-jones/yii2-2checkout

Installs: 210

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Type:yii2-extension

dev-master 2015-01-02 03:55 UTC

This package is not auto-updated.

Last update: 2024-04-13 14:34:30 UTC


README

Extension provides access for 2Checkout library methods from Yii2 framework.

How to install?

Get it via composer by adding the package to your composer.json:

{
  "require": {
    "joni-jones/yii2-2checkout": "*"
  }
}

or run

php composer.phar require --prefer-dist joni-jones/yii2-2checkout "*"

Usage

Once the extension is installed, simply modify your application configuration as follows:

return [
    'components' => [
        'twocheckout' => [
            'class' => 'yii\twocheckout\Twocheckout',
            'privateKey' => '',
            'sellerId' => '',
            'secretWord' => '', //by default is 'tango'
            'username' => '', //required to Admin API call
            'password' => '', //required to Admin API call
            'sandbox' => true, //by default false,
        ]
    ],
    // ...
];

The Charge class usage example (equal to Twocheckout_Charge::form()):

$product['currency_code'] = 'USD';
$product['mode'] = '2CO';
$product['li_0_price'] = '0.01';
$product['merchant_order_id'] = '1122312';
$product['li_0_name'] = 'Credit';
$product['li_0_quantity'] = '1';
$product['li_0_type'] = 'product';
$product['li_0_tangible'] = 'N';
$product['li_0_product_id'] = '43242342';
$product['sid'] = Yii::$app->twocheckout->sellerId;
$product['demo'] = Yii::$app->twocheckout->demo;
$product['key'] = md5($product['merchant_order_id'].$product['li_0_product_id']);
Yii::$app->twocheckout->charge->form($product);

Full documentation you can find on 2Checkout site.