lamtd / vnpt-epay
Dùng tích hợp cổng thanh toán VNPT EPAY
Requires
- php: ^7.1|^8.0
- ignited/laravel-omnipay: ^3.3
- illuminate/support: ^5.7 || ^6.0 || ^7.0 || ^8.0
- phpviet/laravel-omnipay: ^1.1
Requires (Dev)
- orchestra/testbench: 6.x-dev
This package is auto-updated.
Last update: 2025-03-10 20:03:53 UTC
README
VNPT EPay
Miêu tả
Tạo cổng thanh toán VNPT. Thư viện dùng để bổ sung cổng thanh toán VNPT Epay từ bộ thanh toán Omnipay
Cài đặt
Cài đặt VNPT Epay thông qua Composer:
composer require lamtd/vnpt-epay
Sau khi cài đặt xong bạn cần phải publish config file để thiết lập thông số cho cổng thanh toán bạn cần tích hợp, publish thông qua câu lệnh:
php artisan vendor:publish --provider="PHPViet\Laravel\Omnipay\OmnipayServiceProvider" --tag="config" php artisan vendor:publish --provider="Lamtd\VNPTEpay\VNPTEpayServiceProvider"
Thêm vào cuối file config/laravel-omnipay.php
'VnptEpay' => [ 'driver' => 'VnptEpay', 'options' => [ 'merId' => '', 'EncodeKey' => '', 'VNPTDomain' => 'https://sandbox.megapay.vn:2810', //Domain test 'CANCEL_PASSWORD' => '', 'KEY3DES_ENCRYPT' => '', 'KEY3DES_DECRYPT' => '', ], ],
Sử dụng
Load class:
use Lamtd\VNPTEpay\Facade\Gateway as VNPTEpay;
Gọi ở function:
return VNPTEpay::purchase([ 'amount' => $request -> input('goodsAmount'), 'userFee' => $request -> input('userFee'), 'userId' => $request -> input('userId'), 'callBackUrl' => route('vnpt-epay-success'), 'notiUrl' => '' //khi test local không dùng link ipn được ]) -> send();;
Listen từ vnpt:
$response = VNPTEpay::notification()->send();
Bạn có thể xem demo ở
vendor/lamtd/vnpt-epay/src/laravel/TestVNPTEpaytController.php
Khi chạy thực tế, vì vnpt sử dụng POST JSON nên cần thay đổi listener:
$response = VNPTEpay::notificationJSON()->send();
Demo:
truy cập theo path /vnpt-epay-demo
Dành cho nhà phát triển
Đây là version mình đã test trên phần thanh toán VNPT Epay. Nếu có lỗi hoặc muốn mở rộng chức năng, Hãy tạo các issue
để mình cập nhật cho hoàn chỉnh. Nếu bạn muốn liên hệ trực tiếp hãy gửi mail về lamtd@boonygroup.com . Cảm ơn!