PHP code example of bookin / yii2-wallet-one

1. Go to this page and download the library: Download bookin/yii2-wallet-one library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bookin / yii2-wallet-one example snippets


'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'],
    ]
]

$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();

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
    ]
]);

$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';