Download the PHP package tamfuldev/payment-gateway without Composer
On this page you can find all versions of the php package tamfuldev/payment-gateway. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tamfuldev/payment-gateway
More information about tamfuldev/payment-gateway
Files in tamfuldev/payment-gateway
Package payment-gateway
Short Description A unified abstraction for integrating multiple domestic and international payment gateways in Laravel (VNPay, MoMo, Stripe, PayPal, ...).
License Apache-2.0
Homepage https://github.com/tamfuldev/payment-gateway
Informations about the package payment-gateway
Payment Gateway
A unified abstraction for integrating multiple domestic and international payment gateways in Laravel through a single, consistent API:
Instead of learning each provider's signing scheme, endpoints and payload formats, you code against one contract. Adding a new provider means writing one driver — the calling code never changes.
Features
- One API for every gateway —
charge, webhook verification, and normalized events. - Security-first — constant-time signature verification (
hash_equals), no floats for money, secrets read only from config, thin webhook controller that never trusts client input blindly. - Correct money handling — integer minor units via a
Moneyvalue object, with proper zero-decimal support (VND, JPY) vs. 2-decimal currencies (USD, EUR). - Framework-friendly — auto-discovered service provider, publishable config, a
Paymentfacade, and an auto-registered webhook route. - Built to extend — SOLID design (Manager/Factory + Strategy + DTOs), interface segregation so a gateway only implements the capabilities it actually supports.
Requirements
- PHP
^8.2 - Laravel
^11.0 || ^12.0
Installation
Publish the config file:
Then set your credentials in .env (see .env.example):
Usage
1. Create a payment
ChargeResponse also carries status, method (redirect / QR / card / wallet), an optional
qrContent, and a gatewayReference.
Money: always build amounts with
Money::ofMajor()(accepts a string/int, never a float) orMoney::ofMinor(). The library manages each currency's decimal places for you.
2. Handle webhooks / IPN
The package auto-registers a route: POST /payment/webhook/{gateway}. It verifies the signature,
normalizes the payload, and dispatches an event. You listen for the event to record the order:
Available events:
| Event | When |
|---|---|
PaymentCompleted |
A verified webhook reports a successful payment |
PaymentFailed |
A verified webhook reports a failed/declined payment |
An invalid signature returns 400 and dispatches nothing.
3. Change the webhook prefix or middleware
Supported gateways
| Group | Gateway | Status |
|---|---|---|
| Vietnam | VNPay | ✅ charge + webhook verification (reference driver) |
| Vietnam | MoMo, ZaloPay, OnePay, PayOS, VietQR | 🔜 planned |
| International | Stripe, PayPal, Paddle, 2Checkout | 🔜 planned |
| Wallet / Crypto | Binance Pay, Coinbase Commerce | 🔜 planned |
The VNPay reference driver focuses on getting charge + webhook verification right (the security-critical core). Refund/query are follow-up work (they require extra fields such as
transactionDate/transactionType).
Adding a new gateway
- Create
src/Gateways/<Name>/<Name>Gateway.phpextendingAbstractGatewayand implementingPaymentGateway(plus capability interfaces likeSupportsRefundonly if the gateway supports them). - Register a
create<Name>Driver()method inPaymentManager. - Add a config block under
config/payment.php(read secrets fromenv()only there). - Verify webhooks with a constant-time comparison (
hash_equals). - Write tests first (signing + charge + webhook), mocking HTTP.
See CLAUDE.md for the full architecture and security checklist.
Architecture
Development
This repo ships a Docker toolchain, so you don't need PHP/Composer installed locally.
If you do have PHP/Composer locally, the equivalent composer scripts work too
(composer install, composer ci, ...).
Security
If you discover a security issue, please email the maintainer rather than opening a public issue. Key guarantees the library enforces: constant-time signature checks, integer-only money, and secrets sourced exclusively from configuration.
License
Apache-2.0 — see LICENSE.
All versions of payment-gateway with dependencies
illuminate/support Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0
illuminate/contracts Version ^11.0|^12.0