PHP code example of tecsin / yii2-voguepay

1. Go to this page and download the library: Download tecsin/yii2-voguepay 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/ */

    

tecsin / yii2-voguepay example snippets


'components' => [
    //...
    'modules' => [
        //...
        'pay2' => [
            'class' => 'tecsin\pay2\Module',
            'userModelClass' => 'app\models\User',
            'controllerMap' => [
                'manage' => [
                    'class' => 'yii2mod\comments\controllers\ManageController',
                    'layout' => '@app/modules/admin/views/layouts/main',
                    'accessControlConfig' => [
                        'class' => 'yii\filters\AccessControl',
                        'rules' => [
                            [
                                'allow' => true,
                                'roles' => ['admin', 'manager'],
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
],


namespace app\controllers;

class SiteController extends \yii\web\Controller
{
    //...
    public function actions()
    {
        return [
            //...
            'voguepay-notification' => [
                'class' => 'tecsin\pay2\actions\Pay2NotificationAction', // see this class if you will change anything for better explanations
                'modelClass' => 'tecsin\pay2\models\NotificationExample'//this is the default model to run for every notification 
                'method' => 'voguepay'//the method to be called in modelClass, and must have a parameter which should be an array of transaction from voguepay
            ],
            'set-data' => [
                'class' => 'tecsin\pay2\actions\InitSaleAction', //redirects user to voguepay payment page after saving the pay now form data to db
                //this is mandatory if you use the PayButton widget
            ],
        ];
    }
}

    <?= tecsin\pay2\widgets\PayButton::widget() 

    $MsModel = new \tecsin\pay2\models\VoguepayMs(['aaaMerchantId' => '11111', 'mmmMemo' => 'one sparklyn yellow wedding dress', 'tttTotalCost' => '200310', 'rrrMerchantRef' => time().mt_rand(0,999999999)]);
    if($MsModel->validate()){
       return $MsModel->setRequest()->sendRequest()->sendResponse();
    } 

    $MsModel = new \tecsin\pay2\models\VoguepayMs(['aaaMerchantId' => '11111', 'mmmMemo' => 'one sparklyn yellow wedding dress', 'tttTotalCost' => '200310', 'rrrMerchantRef' => time().mt_rand(0,999999999), 'showPayButton' => true]);
    if($MsModel->validate()){
        $response =  $MsModel->setRequest()->sendRequest()->sendResponse();
        return $response;//response is json {status: "success|error", success|error : { message: "https://www.voguepay.com/payment-url|errorMesssge"}}
    } 

php yii migrate --migrationPath="@vendor/tecsin/yii2-voguepay/migrations"