Contributing
Issues and pull requests are welcome. The ground rules are what make this package worth using:
- No test hits a real gateway. Every test uses
Http::fake(). - Never trust a callback. Redirects, IPNs and webhooks are claims. A driver confirms the payment with the gateway's own API, checks the amount, and only then changes state.
- Uncertain means pending. A timeout or an ambiguous answer leaves the payment pending;
bdpaygate:syncsettles it later. Only a definite answer from the gateway marks a payment failed. - Run
composer check(Pint, PHPStan, Pest) before opening a PR.
Adding a gateway
- Write
src/Drivers/YourGateway.php: extendAbstractGateway, setpublic const DRIVER, implementcharge()andhandleCallback(). AddSupportsSyncif the gateway has a status API, andSupportsRefunds(with theHandlesRefundstrait) orSupportsPartialRefundsif it has a refund API. - Use the base class:
send()anddecode()for HTTP,createPendingPayment(),findByGatewayReference(),assertAmountMatches(),transition()to change state,stillPending()when the gateway can't confirm,rememberToken()for access tokens. - Send
$payment->gateway_referenceto the gateway as the merchant order id. It is unique per attempt;$payment->referenceis the merchant's own and repeats across retries. - Register it in
BdPayGateManager::DRIVERSand add its block toconfig/bdpaygate.php. - Add
tests/Conformance/YourGatewayScenario.php(seetests/Support/GatewayScenario.php). The shared suite intests/Feature/ConformanceTest.phpthen checks it for forged callbacks, amount mismatches, replayed IPNs, races, timeouts, late successes, sync and refunds. A gateway is supported when it passes. - Add gateway-specific tests in
tests/Feature/YourGatewayTest.phpand a page indocs/gateways/.
src/Drivers/SslCommerzGateway.php with tests/Conformance/SslCommerzScenario.php is the reference.