sillsoft/yii2-liqpay
Composer 安装命令:
composer require sillsoft/yii2-liqpay
包简介
https://www.liqpay.ua/ checkout
关键字:
README 文档
README
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist sillsoft/yii2-liqpay "*"
or add
"sillsoft/yii2-liqpay": "*"
to the require section of your composer.json file.
Usage
config.php:
'modules' => [ 'liqpay' => [ 'class' => 'sillsoft\liqpay\Module', 'publicKey' => '', 'privateKey' => '', ], ]
Controller
$order_id = 1; $repository = Yii::$container->get(LiqPayPaymentRepository::class); $orderModel = $repository->createOrUpdate($order_id); $liqpay = Yii::$container->get(Liqpay::class); return $liqpay->renderPaymentForm([ 'amount' => 10, 'currency' => 'UAH', 'description' => Yii::t('frontend', 'Оплата за товари'), 'order_id' => $order_id, 'language' => Yii::$app->language, 'result_url' => Yii::$app->urlManager->createAbsoluteUrl(['/checkout/thanks']), 'server_url' => Yii::$app->urlManager->createAbsoluteUrl(['/liq-pay/server']), ]);
Callback
public function actionServer(): Response { $request = Yii::$app->getRequest(); if ($request->getIsPost()) { $data = $request->post('data'); $orderId = ArrayHelper::getValue($data, 'order_id', false); $data = json_decode(base64_decode($data), true); $repository = Yii::$container->get(LiqPayPaymentRepository::class); $orderModel = $repository->findOneByOrderId($orderId); if (!$orderModel) throw new ErrorException("Payment By Order Id $orderId not found"); $repository = Yii::$container->get(LiqPayPaymentRepository::class); $repository->createOrUpdate($orderId, $data); return $this->asJson([ 'success' => true ]); } throw new BadRequestHttpException(); }
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-03