2017 © Pedro Peláez
 

yii2-extension yii2-unitpay-gate

UnitPay billing gate

image

nikitakls/yii2-unitpay-gate

UnitPay billing gate

  • Tuesday, January 23, 2018
  • by nikitakls
  • Repository
  • 1 Watchers
  • 0 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 16 % Grown

The README.md

nikitakls/yii2-unitpay-gate

Unitpay gate for Yii2, (*1)

Installation

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

Either run, (*3)

composer require --prefer-dist nikitakls/yii2-unitpay-gate "*"

or add, (*4)

"nikitakls/yii2-unitpay-gate": "*"

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

Configuration

'components' => [
    'unitpay' => [
        'class' => '\nikitakls\unitpay\Merchant',
        'secretKey' => '',
        'publicKey' => '',
        'orderCurrency' => 'RUB', # 'EUR', 'UAH', 'BYR', 'USD', 'RUB'
        'locale' => 'ru',
    ]
    ...
]

Usage

Once the extension is installed, simply use it in your code by :, (*6)

You can use result action in you controller:, (*7)

class PaymentController extends Controller
{

    public $enableCsrfValidation = false;

    public $unitpay = 'unitpay';


    public function actionInvoice()
    {
        $model = new Invoice();
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            /** @var \nikitakls\unitpay\Merchant $merchant */
            $merchant = Yii::$app->get($this->unitpay);
            return $this->redirect($merchant->payment($model->sum, $model->id, 'Пополнение счета', Yii::$app->user->identity->email, $model->phone));
        } else {
            return $this->render('invoice', [
                'model' => $model,
            ]);
        }
    }

    /**
     * @inheritdoc
     */
    public function actions()
    {

        return [
            'result' => [
                'class' => ResultAction::class,
                'payCallback' => [$this, 'payCallback'],
                'checkCallback' => [$this, 'checkCallback'],
                'failCallback' => [$this, 'failCallback'],
            ],
        ];
    }

    public function payCallback(ResultParam $param)
    {
                $this->loadModel($nInvId)->updateAttributes(['status' => Invoice::STATUS_ACCEPTED]);
                return Yii::$app->get('unitpay')->getSuccessResponse('Pay Success');

    }

    public function checkCallback(ResultParam $param)
    {
                if($this->loadModel($nInvId)){
                    return Yii::$app->get('unitpay')->getSuccessResponse('Check Success. Ready to pay.');
                };
                return Yii::$app->get('unitpay')->getErrorResponse('Message about error');
    }

    public function failCallback(ResultParam $param)
    {
                $this->loadModel($nInvId)->updateAttributes(['status' => Invoice::STATUS_FAIL]);
                Yii::$app->errorHandler->logException($param->getErrorMessage());
                return Yii::$app->get('unitpay')->getSuccessHandlerResponse('Error logged');
    }
}

The Versions

23/01 2018

dev-master

9999999-dev

UnitPay billing gate

  Sources   Download

BSD-3-Clause

The Requires

 

by Nikita Kolesnikov

extension yii2 billing

23/01 2018

v0.0.3

0.0.3.0

UnitPay billing gate

  Sources   Download

BSD-3-Clause

The Requires

 

by Nikita Kolesnikov

extension yii2 billing

22/01 2018

v0.0.2

0.0.2.0

UnitPay billing gate

  Sources   Download

BSD-3-Clause

The Requires

 

by Nikita Kolesnikov

extension yii2 billing

22/01 2018

v0.0.1

0.0.1.0

UnitPay billing gate

  Sources   Download

BSD-3-Clause

The Requires

 

by Nikita Kolesnikov

extension yii2 billing