1. Go to this page and download the library: Download phpviet/omnipay-vtcpay library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$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
}
$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();
}
$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();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.