phpviet/omnipay-vtcpay

支持集成VTCPay支付网关的库。

1.0.1 2019-07-05 10:33 UTC

This package is auto-updated.

Last update: 2024-09-06 02:56:14 UTC


README

Omnipay: VTCPay


Latest version Build status Quantity score StyleCI Total download License

信息

这是一个支持集成VTCPay支付网关的库,基于Omnipay League平台开发。

要了解Omnipay网关的概念和使用方法,请访问此处查看。

安装

通过Composer安装Omnipay VTCPay。

composer require phpviet/omnipay-vtcpay

使用方法

支持集成到当前流行的各种框架中

如果您希望不依赖框架使用,请继续查看。

初始化网关

use Omnipay\Omnipay;

$gateway = Omnipay::create('VTCPay');
$gateway->initialize([
    'website_id' => 'Do VTCPay cấp',
    'security_code' => 'Do VTCPay cấp',
]);

上述网关初始化用于向VTCPay发送处理请求,或用于接收VTCPay发送的请求。

创建支付请求

$response = $gateway->purchase([
    'receiver_account' => '0963465816',
    'reference_number' => microtime(false),
    'amount' => 50000,
    'url_return' => 'https://phpviet.org'
])->send();

if ($response->isRedirect()) {
    $redirectUrl = $response->getRedirectUrl();
    
    // TODO: chuyển khách sang trang VTCPay để thanh toán
}

有关创建请求和VTCPay返回的详细参数,请参考此处

检查客户被VTCPay重定向回时的url_return信息

$response = $gateway->completePurchase()->send();

if ($response->isSuccessful()) {
    // TODO: xử lý kết quả và hiển thị.
    print $response->amount;
    print $response->reference_number;
    
    var_dump($response->getData()); // toàn bộ data do VTCPay gửi sang.
    
} else {

    print $response->getMessage();
}

有关VTCPay返回的详细参数,请参考此处

检查VTCPay发送的IPN信息

$response = $gateway->notification()->send();

if ($response->isSuccessful()) {
    // TODO: xử lý kết quả.
    print $response->amount;
    print $response->reference_number;
    
    var_dump($response->getData()); // toàn bộ data do VTCPay gửi sang.
    
} else {

    print $response->getMessage();
}

有关VTCPay发送的详细参数,请参考此处

开发者指南

如果您觉得我们的库有不足或错误,并且希望共同开发,我们非常欢迎!请创建issue来为下一个版本提供想法,或者创建PR来补充不足或错误。对于与安全相关的错误,请通过vuongxuongminh@gmail.com发送邮件,而不是创建issue。谢谢!