omnipay/securepay
Omnipay SecurePay is a driver for the Omnipay PHP payment library that adds support for the SecurePay (Australia) gateway, letting you process purchases, refunds, and payment queries through a consistent, framework-agnostic API.
composer require omnipay/securepay; it pulls in omnipay/common. There is no Laravel auto-discovery and no service provider — you wire it up yourself.vendor/omnipay/securepay/src/. The gateway classes (SecurePayGateway, SecurePayDirectPostGateway) and their Message/*Request::getData() methods are the authoritative docs for which parameters are actually sent. getDefaultParameters() tells you what must be configured.config/services.php, resolve env vars there (never in application code), then build the gateway once and inject/bind it.// config/services.php
'securepay' => [
'merchant_id' => env('SECUREPAY_MERCHANT_ID'),
'transaction_password' => env('SECUREPAY_TRANSACTION_PASSWORD'),
'test_mode' => env('SECUREPAY_TEST_MODE', true),
],
$gateway = Omnipay::create('SecurePay');
$gateway->setMerchantId(config('services.securepay.merchant_id'));
$gateway->setTransactionPassword(config('services.securepay.transaction_password'));
$gateway->setTestMode(config('services.securepay.test_mode'));
$gateway->purchase([...])->send(), branch on isSuccessful() / isRedirect() / failure, and persist $response->getTransactionReference() — you will need it for refunds.App\Payments\SecurePayGateway) bound in a provider. Avoid sprinkling Omnipay::create() across controllers; it re-reads config and makes testing harder.amount as a string ("10.00"), currency 'AUD', a stable transactionId (your order number), and a card array built from validated input (number, expiry month/year, CVV, first/last name, billing fields the driver expects).$response = $gateway->purchase([
'amount' => number_format($order->total, 2, '.', ''),
'currency' => 'AUD',
'transactionId' => $order->number,
'card' => $validatedCard,
])->send();
if ($response->isSuccessful()) {
$order->update([
'status' => 'paid',
'gateway_txn_reference' => $response->getTransactionReference(),
'gateway_code' => $response->getCode(),
'gateway_message' => $response->getMessage(),
]);
}
$gateway->refund(['amount' => ..., 'transactionId' => $order->gateway_txn_reference]). Store both identifiers.SecurePayDirectPostGateway, pass returnUrl/cancelUrl, call $response->redirect(), and add a callback controller that calls $gateway->completePurchase($request->all())->send(). Exclude that route from CSRF.transactionId from the order and check your local ledger before sending, so retries/refreshes cannot double-charge.composer require resolves against your PHP and omnipay/common versions; PHP 8 support often needs a constraint bump or a fork. Trial it on a branch before adopting.setTestMode(true) with live credentials produces authentication failures, not a helpful "test mode" error.isSuccessful() reflects approval, but declines can still return HTTP 200 with an error code. Always store getCode() and getMessage() alongside the reference.send() can throw on connection/timeout. Wrap it, set an HTTP client timeout (SecurePay's XML endpoint can be slow), and only retry if you have idempotency in place.VerifyCsrfToken::$except; Laravel 11 validateCsrfTokens(except: [...])).getData() methods are where you confirm exactly what's on the wire.env() call inside your payment service returns null once php artisan config:cache runs.How can I help you explore Laravel packages today?