2017 © Pedro Peláez
 

yii2-extension yii2-gourlio

gourl.io payment extension.

image

mitrm/yii2-gourlio

gourl.io payment extension.

  • Sunday, April 1, 2018
  • by mitrm
  • Repository
  • 1 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 43 % Grown

The README.md

gourl.io

Прием платежей в биткоинах и альткойнах, (*1)

Installation

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

Either run, (*3)

composer require --prefer-dist mitrm/yii2-gourlio "*"

or add, (*4)

"mitrm/yii2-gourlio": "*"

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

Usage

В config/main.php добавить, (*6)

'components' => [
    'gourlio' => [
        'class' => 'mitrm\gourlio\Cryptobox',
        'period' => 'NOEXPIRY',
        'all_key' => [
            'bitcoin' => ['public_key' => '', 'private_key' => ''],
            'speedcoin' => ['public_key' => '', 'private_key' => ''],
            ...
        ]
    ],
]

Формирование данных для оплаты, (*7)

$options = array(
    'order_id' => $order_id,
    'user_id' => Yii::$app->user->id,
    'amount' => $sum,
    'coinName' => 'speedcoin', // bitcoin ...
);
$data_pay = Yii::$app->gourlio->load($options)->getPaymentData();

$data_pay['addr']; // Номер кошелька для перевода средств
$data_pay['amount']; // сумма к оплате

Проверка оплаты, (*8)

$options = array(
    'order_id' => $order_id,
    'user_id' => Yii::$app->user->id,
    'amount' => $sum,
    'coinName' => 'speedcoin', // bitcoin ...
);
if(Yii::$app->gourlio->load($options)->isPaid())  {
    // Оплата пришла
}

Получение оповещений по оплате от gourl.io, (*9)

class PaymentsController extends Controller
{
    public $enableCsrfValidation = false;

    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'result' => [
                'class' => '\mitrm\gourlio\ResultAction',
                'callback' => [$this, 'resultCallbackGourlio'],
            ]
        ];
    }

    /**
     * Обработка оповещения о платеже с gourl.io
     * @param $cryptobox Cryptobox
     * @param $return_data
     * @return string
     */
    public function resultCallbackGourlio($cryptobox, $return_data)
    {
        $model = PaymentRequest::findOne(['id' => $return_data['params']['order'], 'user_id' => $return_data['params']['user']]);
        if (!$model) {
            throw new BadRequestHttpException('Транзакция не найдена');
        }
        $data = [
            'order_id' => $model->id,
            'user_id' => Yii::$app->user->id,
            'amount' => $model->sum,
            'coinName' => $model->currency, // speedcoin, bitcoin, ...
        ];
        $cryptobox->load($data);
        if($cryptobox->isPaid()) {
            $model->sum = $return_data['params']['amount'];
            $model->status_id = PaymentRequest::STATUS_SUCCESS;
            $model->save();
        }
        return $return_data['text_return'];
    }


}

The Versions

01/04 2018

dev-master

9999999-dev https://github.com/mitrm/yii2-gourlio

gourl.io payment extension.

  Sources   Download

AGPL-3.0-or-later

The Requires

 

by Ruslan Miskevich

extension yii2 yii yii 2 bitcoin altcoin gourlio

01/04 2018

1.000

1.000.0.0 https://github.com/mitrm/yii2-gourlio

gourl.io payment extension.

  Sources   Download

AGPL-3.0-or-later

The Requires

 

by Ruslan Miskevich

extension yii2 yii yii 2 bitcoin altcoin gourlio