LaravelPackages.net
Acme Inc.
Toggle sidebar
nhanchaukp/alepay

Tích hợp thanh toán Alepay cho Laravel

1.270
0
1.0.3
About nhanchaukp/alepay

nhanchaukp/alepay is a Laravel package for tích hợp thanh toán alepay cho laravel. It currently has 0 GitHub stars and 1.270 downloads on Packagist (latest version 1.0.3). Install it with composer require nhanchaukp/alepay. Discover more Laravel packages by nhanchaukp or browse all Laravel packages to compare alternatives.

Last updated

Tích hợp thanh toán Alepay cho Laravel

Hướng dẫn cài đặt

Cài đặt package

composer require nhanchaukp/alepay

Publish file cấu hình tài khoản

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

Thay đổi các giá trị liên quan đến tài khoản kết nối với Alepay ở file: config/alepay

Hiển thị trang demo

Thêm vào routes web.php

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

Alepay::routes();

Truy cập demo tại domain.com/demo-alepay.

Các phương thức

Tạo yêu cầu và lấy link thanh toán

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' => '[email protected]',
    'buyerPhone' => '0929389359',
    'buyerAddress' => 'Vung liem',
    'buyerCity' => 'Vinh Long',
    'buyerCountry' => 'Viet Nam',

];

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

Lấy thông tin giao dịch

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

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

Xác thực dữ liệu webhook

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

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