Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cc5bd3c

Browse files
Updated doc
1 parent cd5c98d commit cc5bd3c

File tree

1 file changed

+71
-2
lines changed

1 file changed

+71
-2
lines changed

‎README.md

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<a href="https://momo.vn" target="_blank">
2+
<a href="https://vtcpay.vn" target="_blank">
33
<img src="https://raw.githubusercontent.com/phpviet/omnipay-vtcpay/master/resources/logo.png" height="100px">
44
</a>
55
<h1 align="center">Omnipay: VTCPay</h1>
@@ -35,8 +35,77 @@ composer require phpviet/omnipay-vtcpay
3535

3636
hoặc nếu bạn muốn sử dụng không dựa trên framework thì tiếp tục xem tiếp.
3737

38-
### Khởi tạo yêu cầu thanh toán
38+
### Khởi tạo gateway:
3939

40+
```php
41+
use Omnipay\Omnipay;
42+
43+
$gateway = Omnipay::create('VTCPay');
44+
$gateway->setWebsiteId('Do VTCPay cấp');
45+
$gateway->setSecurityCode('Do VTCPay cấp');
46+
```
47+
48+
Gateway khởi tạo ở trên dùng để tạo các yêu cầu xử lý đến VTCPay hoặc dùng để nhận yêu cầu do VTCPay gửi đến.
49+
50+
### Tạo yêu cầu thanh toán:
51+
52+
```php
53+
$response = $gateway->purchase([
54+
'receiver_account' => '0963465816',
55+
'reference_number' => microtime(false),
56+
'amount' => 50000,
57+
'url_return' => 'https://phpviet.org'
58+
])->send();
59+
60+
if ($response->isRedirect()) {
61+
$redirectUrl = $response->getRedirectUrl();
62+
63+
// TODO: chuyển khách sang trang VTCPay để thanh toán
64+
}
65+
```
66+
67+
Kham khảo thêm các tham trị khi tạo yêu cầu và VTCPay trả về tại [đây](https://vtcpay.vn/tai-lieu-tich-hop-website).
68+
69+
### Kiểm tra thông tin `url_return` khi khách được VTCPay redirect về:
70+
71+
```php
72+
$response = $gateway->completePurchase()->send();
73+
74+
if ($response->isSuccessful()) {
75+
// TODO: xử lý kết quả và hiển thị.
76+
print $response->amount;
77+
print $response->reference_number;
78+
79+
var_dump($response->getData()); // toàn bộ data do VTCPay gửi sang.
80+
81+
} else {
82+
83+
print $response->getMessage();
84+
}
85+
```
86+
87+
Kham khảo thêm các tham trị khi VTCPay trả về tại [đây](https://vtcpay.vn/tai-lieu-tich-hop-website).
88+
89+
90+
### Kiểm tra thông tin `IPN` do VTCPay gửi sang:
91+
92+
```php
93+
$response = $gateway->notification()->send();
94+
95+
if ($response->isSuccessful()) {
96+
// TODO: xử lý kết quả.
97+
print $response->amount;
98+
print $response->reference_number;
99+
100+
var_dump($response->getData()); // toàn bộ data do VTCPay gửi sang.
101+
102+
} else {
103+
104+
print $response->getMessage();
105+
}
106+
```
107+
108+
Kham khảo thêm các tham trị khi VTCPay gửi sang tại [đây](https://vtcpay.vn/tai-lieu-tich-hop-website).
40109

41110
## Dành cho nhà phát triển
42111

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /