2017 © Pedro Peláez
 

yii2-extension yii2-wallet-one

Component for WalletOne service

image

bookin/yii2-wallet-one

Component for WalletOne service

  • Monday, August 15, 2016
  • by bookin
  • Repository
  • 2 Watchers
  • 6 Stars
  • 178 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 2 Versions
  • 6 % Grown

The README.md

Yii2 component for WalletOne

Total Downloads Latest Unstable Version License, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

To install, either run, (*3)

$ php composer.phar require bookin/yii2-wallet-one "@dev"

or add, (*4)

"bookin/yii2-wallet-one": "@dev"

to the require section of your composer.json file., (*5)

Usage

Configure component:

'walletone'=>[
    'class'=>'bookin\walletone\WalletOne',
    'secretKey'=>'....',
    'signatureMethod'=>'sha1',
    'buttonLabel'=>'....',
    'walletOptions'=>[
        'WMI_MERCHANT_ID'=>'...',
        'WMI_CURRENCY_ID'=>'...',
        'WMI_SUCCESS_URL'=>['site/payment-success'],
        'WMI_FAIL_URL'=>['site/payment-fail'],
    ]
]

secretKey - it your secret key, you can find it on setting integration page your account, (*6)

walletOptions - it parameters for generating a payment form, you can set permanent data, (*7)

signatureMethod - EDS creation method, this parameter must be the same as your selected method on the setting integration page your account (default - sha1), (*8)

buttonLabel - label for WalletOneButton, (*9)

If you don't use encryption method, you need set signatureMethod and secretKey to NULL, (*10)

Example show form

You can get fields (add some options), and create form:, (*11)

$action = Yii::$app->walletone->apiUrl;
$formData = Yii::$app->walletone->getFields([
    'WMI_PAYMENT_AMOUNT'=>'1.00',
    'WMI_CURRENCY_ID'=>WalletOne::CurrencyID('UAH'),
    'WMI_DESCRIPTION'=>'Top up the account - '.Yii::$app->user->identity->username,
    'WMI_PAYMENT_NO'=>Yii::$app->user->id
]);
echo Html::beginForm($action);
foreach($formData as $key => $value){
    echo Html::hiddenInput($key, $value);
}
echo Html::submitButton('Pay', ['class'=>'btn btn-info']);
echo Html::endForm();

Or use simple form (button), (*12)

echo WalletOneButton::widget([
    'walletOptions'=>[
        'WMI_PAYMENT_AMOUNT'=>'1.00',
        'WMI_CURRENCY_ID'=>WalletOne::CurrencyID('UAH'),
        'WMI_DESCRIPTION'=>'Top up the account - '.Yii::$app->user->identity->username,
        'WMI_PAYMENT_NO'=>Yii::$app->user->id
    ]
]);

Example success action

$post = Yii::$app->request->post();

/** @var WalletOne $walletone */
$walletone = Yii::$app->walletone;

try{
    if($walletone->checkPayment($post)){
        //... save info about payment
    }
}catch (ErrorException $c){
    return 'WMI_RESULT=RETRY&WMI_DESCRIPTION='.$c->getMessage();
}
return 'WMI_RESULT=OK';

Problems

If you enabled enableCsrfValidation for your application you should disable it manually (Yii::app()->request->enableCsrfValidation = false;) before initializing form to have the correct token., (*13)

The Versions

15/08 2016

dev-master

9999999-dev

Component for WalletOne service

  Sources   Download

BSD-3-Clause

The Requires

 

15/08 2016

1.0.0

1.0.0.0

Component for WalletOne service

  Sources   Download

BSD-3-Clause

The Requires