silentlun/yii2-alipay

Alipay extension for YII2

Installs: 10

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

1.1 2021-11-04 03:15 UTC

This package is not auto-updated.

Last update: 2025-06-18 11:51:35 UTC


README

Alipay extension for YII2

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist silentlun/yii2-alipay "*"

or add

"silentlun/yii2-alipay": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

Controller

namespace app\controllers;

use yii\web\Controller;
use silentlun\alipay\AliPay;

class SiteController extends Controller
{
    public $alipayConfig = [
        'app_id' => '支付宝应用ID',
        'merchant_private_key' => '支付宝私钥',
        'alipay_public_key' => '支付宝公钥',
    ];
    public function actionPay()
    {
        $order = []; // 订单信息
        $payment = new AliPay($this->alipayConfig);
        $result = $payment->createWebPay($order);
        return $this->renderPartial('alipay', [
            'result' => $result,
        ]);
    }
}