inverseschool / omnipay-sanaacart
v1.0.0
2025-03-09 12:34 UTC
Requires
- php: ^7.3 || ^8.0
- ext-json: *
- ext-mbstring: *
- omnipay/common: ^3
- php-http/guzzle7-adapter: ^1
- symfony/http-client: ^5
Requires (Dev)
- http-interop/http-factory-guzzle: ^1.2
- omnipay/tests: 4.1.1
- phpstan/phpstan: ^1.8
- squizlabs/php_codesniffer: ^3
README
composer require inverseschool/omnipay-sanaacart
Example
Purchase
The result will be a redirect to the gateway or bank.
$gateway->setAgentKey('xxxxxxxxxxxx'); $response = $gateway->purchase([ 'amount' => $amount, 'orderId' => 'Merchant-Ref-X', 'callbackUrl' => 'https://www.example.com/return', ])->send(); // Process response if ($response->isSuccessful() && $response->isRedirect()) { // store the transaction reference to use in completePurchase() $transactionReference = $response->getTransactionReference(); // Redirect to offsite payment gateway $response->redirect(); } else { // Payment failed: display message to customer echo $response->getMessage(); }
Complete Purchase (Verify)
Verify an order by Transaction Reference
:
// Send purchase complete request $response = $gateway->completePurchase([ 'transactionReference' => $refNum, ])->send(); if (!$response->isSuccessful() || $response->isCancelled()) { // Payment failed: display message to customer echo $response->getMessage(); } else { // Payment was successful print_r($response); }