2017 © Pedro Peláez
 

yii2-extension yii2-robokassa

Robokassa payment extension.

image

sadykh/yii2-robokassa

Robokassa payment extension.

  • Tuesday, February 21, 2017
  • by Sadykh
  • Repository
  • 1 Watchers
  • 0 Stars
  • 39 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 25 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

yii2-robokassa

Install via Composer

composer require sadykh/yii2-robokassa

Configuration

'components' => [
    'robokassa' => [
        'class' => '\sadykh\robokassa',
        'baseUrl' => 'https://auth.robokassa.ru/Merchant/Index.aspx',
        'sMerchantLogin' => '',
        'sMerchantPass1' => '',
        'sMerchantPass2' => '',
        'isTest' => !YII_ENV_PROD,
    ]
    ...
]

Example

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

    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'result' => [
                'class' => '\robokassa\ResultAction',
                'callback' => [$this, 'resultCallback'],
            ],
            'success' => [
                'class' => '\robokassa\SuccessAction',
                'callback' => [$this, 'successCallback'],
            ],
            'fail' => [
                'class' => '\robokassa\FailAction',
                'callback' => [$this, 'failCallback'],
            ],
        ];
    }

    /**
     * Callback.
     * @param \sadykh\robokassa\Merchant $merchant merchant.
     * @param integer $nInvId invoice ID.
     * @param float $nOutSum sum.
     * @param array $shp user attributes.
     */
    public function successCallback($merchant, $nInvId, $nOutSum, $shp)
    {
        $this->loadModel($nInvId)->updateAttributes(['status' => Invoice::STATUS_ACCEPTED]);
        return $this->goBack();
    }
    public function resultCallback($merchant, $nInvId, $nOutSum, $shp)
    {
        $this->loadModel($nInvId)->updateAttributes(['status' => Invoice::STATUS_SUCCESS]);
        return 'OK' . $nInvId;
    }
    public function failCallback($merchant, $nInvId, $nOutSum, $shp)
    {
        $model = $this->loadModel($nInvId);
        if ($model->status == Invoice::STATUS_PENDING) {
            $model->updateAttributes(['status' => Invoice::STATUS_FAIL]);
            return 'Ok';
        } else {
            return 'Status has not changed';
        }
    }

    /**
     * @param integer $id
     * @return Invoice
     * @throws \yii\web\BadRequestHttpException
     */
    protected function loadModel($id) {
        $model = Invoice::find($id);
        if ($model === null) {
            throw new BadRequestHttpException;
        }
        return $model;
    }
}

The Versions

21/02 2017

dev-master

9999999-dev

Robokassa payment extension.

  Sources   Download

BSD-3-Clause

The Requires

 

by Sergey Gonimar
by Sadykh Sadykhov

yii2 robokassa

21/02 2017

1.1.3

1.1.3.0

Robokassa payment extension.

  Sources   Download

BSD-3-Clause

The Requires

 

by Sergey Gonimar
by Sadykh Sadykhov

yii2 robokassa

21/02 2017

1.1.2

1.1.2.0

Robokassa payment extension.

  Sources   Download

BSD-3-Clause

The Requires

 

by Sergey Gonimar
by Sadykh Sadykhov

yii2 robokassa

01/02 2016

1.1.1

1.1.1.0

Robokassa payment extension.

  Sources   Download

BSD-3-Clause

The Requires

 

by Sergey Gonimar

yii2 robokassa

01/07 2015

1.1

1.1.0.0

Robokassa payment extension.

  Sources   Download

BSD-3-Clause

The Requires

 

by Sergey Gonimar

yii2 robokassa

17/06 2015

1.0.1

1.0.1.0

Robokassa payment extension.

  Sources   Download

BSD-3-Clause

The Requires

 

by Sergey Gonimar

yii2 robokassa

05/04 2014

1.0.0

1.0.0.0

Robokassa payment extension.

  Sources   Download

BSD-3-Clause

The Requires

 

by Sergey Gonimar

yii2 robokassa