soheylak / omnipay-saman
1.0.5
2024-04-21 07:24 UTC
Requires
- php: ^7.3
- 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
This package is auto-updated.
Last update: 2025-04-21 10:50:24 UTC
README
composer require soheylak/omnipay-saman
Example
Purchase
The result will be a redirect to the gateway or bank.
$gateway->setTerminalId('xxxxxxxxxxxx'); $gateway->setRedirectUrl('https://www.example.com/return'); $response = $gateway->purchase([ 'Amount' => $amount, 'currency' => $currency, 'ResNum'=>'10', 'CellNumber'=>'9120000000' ])->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)
// Send purchase complete request $response = $gateway->completePurchase([ 'RefNum' => $refNum, 'TerminalNumber' => $terminalNumber, ])->send(); if (!$response->isSuccessful() || $response->isCancelled()) { // Payment failed: display message to customer echo $response->getMessage(); } else { // Payment was successful print_r($response); }
Refund Order
Refund an order by the $refNum:
$response = $gateway->refund([ 'RefNum' => $refNum, 'TerminalNumber' => $terminalNumber, ])->send(); if ($response->isSuccessful()) { // Refund was successful print_r($response); } else { // Refund failed echo $response->getMessage(); }