chumakovanton / yii2-tinkoff-pay
oplata.tinkoff.ru 商户 API 扩展
v0.0.7-alpha
2019-06-28 07:52 UTC
Requires
- php: ^7.1.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- roave/security-advisories: dev-master
- yiisoft/yii2: ~2.0.14
This package is auto-updated.
Last update: 2024-09-28 09:11:21 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();