承接 sillsoft/yii2-liqpay 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sillsoft/yii2-liqpay

Composer 安装命令:

composer require sillsoft/yii2-liqpay

包简介

https://www.liqpay.ua/ checkout

README 文档

README

https://www.liqpay.ua/

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-03