nhanchaukp/alepay

Alepay支付集成到Laravel

安装: 961

依赖: 0

建议者: 0

安全: 0

星星: 0

关注者: 1

分支: 0

开放问题: 0

语言:Blade

1.0.3 2023-05-21 06:06 UTC

This package is not auto-updated.

Last update: 2024-09-23 11:05:32 UTC


README

安装指南

安装包

composer require nhanchaukp/alepay

发布账户配置文件

php artisan vendor:publish --tag=alepay-config

在文件 config/alepay 中更改与Alepay连接的账户相关值

显示演示页面

添加到web.php路由

use Nhanchaukp\Alepay\Facades\Alepay;
...

Alepay::routes();

domain.com/demo-alepay 访问演示。

方法

创建请求并获取支付链接

use Nhanchaukp\Alepay\Facades\Alepay;
...

$orderInfo = [
    'amount' => 100000,
    'orderCode' => 'FCODE123',
    'currency' => 'VND',
    'orderDescription' => 'Test thanh toán Alepay',
    'totalItem' => 1,
    'checkoutType' => 3,
    'allowDomestic' => true,

    'buyerName' => 'Nhan Chau KP',
    'buyerEmail' => 'demoalepay@gmail.com',
    'buyerPhone' => '0929389359',
    'buyerAddress' => 'Vung liem',
    'buyerCity' => 'Vinh Long',
    'buyerCountry' => 'Viet Nam',

];

$result = Alepay::requestPayment($orderInfo);

获取交易信息

use Nhanchaukp\Alepay\Facades\Alepay;
...

public function alepayResult(Request $request)
{
    if ($request->errorCode == '000') {
        // success
        $info = Alepay::getTransactionInfo($request->transactionCode);
        dd($info);
    } else {
        // error
    }
}

验证webhook数据

use Nhanchaukp\Alepay\Facades\Alepay;
...

public function webhook(Request $request)
{
    return response()->json([
        'raw' => $request->all(),
        'verify' => Alepay::verifyTransaction($request->all())
    ]);
}