chumakovanton/yii2-tinkoff-pay

oplata.tinkoff.ru 商户 API 扩展

安装: 592

依赖项: 0

建议者: 0

安全: 0

星标: 4

关注者: 3

分支: 9

开放问题: 3

类型:yii2-extension

v0.0.7-alpha 2019-06-28 07:52 UTC

README

oplata.tinkoff.ru 商户 API 扩展

安装

安装此扩展的首选方式是通过 composer.

运行

php composer.phar require --prefer-dist chumakovanton/yii2-tinkoff-pay "*"

或添加

"chumakovanton/yii2-tinkoff-pay": "*"

到您的 composer.json 文件的 require 部分中。

使用

配置应用程序

'components' => [
    //  ...
    'tinkoffPay' => [
            'class' => \chumakovanton\tinkoffPay\TinkoffPay::className(),
            'terminalKey' => 'terminalKey',
            'secretKey' => 'secretKey',
            'apiUrl' => 'https://securepay.tinkoff.ru/v2'
        ],
]

一旦安装了扩展,只需在您的代码中简单使用它即可

/** @var \chumakovanton\tinkoffPay\TinkoffPay $paymentService */
$paymentService = Yii::$app->tinkoffPay;

$paymentRequest = $paymentService->initPay('order1', 1000);

$paymentRequest->addData('user_id', 123);

try {
    $response = $paymentRequest->send();
} catch (\chumakovanton\tinkoffPay\exceptions\HttpException $exception) {
    throw new \yii\web\HttpException($exception->statusCode, $exception->getMessage());
}

$paymentUrl = $response->getPaymentUrl();