arm092 / omnipay-ameriabank
AmeriaBank gateway for Omnipay payment processing library
Requires
- php: ^7.4|8.*
- ext-json: *
- omnipay/common: ^3
Requires (Dev)
- omnipay/tests: ^v4.0.0
This package is auto-updated.
Last update: 2024-11-20 22:22:04 UTC
README
AmeriaBank driver for the Omnipay Laravel payment processing library
Omnipay is a framework-agnostic, multi-gateway payment processing library for PHP 5.5+. This package implements Arca support for Omnipay.
Installation
Omnipay is installed via Composer. To install, simply add it
to your composer.json
file:
{ "require": { "arm092/omnipay-ameriabank": "^1" } }
And run composer to update your dependencies:
composer update
Or you can simply run
composer require arm092/omnipay-ameriabank
Basic Usage
- Use Omnipay gateway class:
use Omnipay\Omnipay;
- Initialize Ameria gateway:
$gateway = Omnipay::create('Ameria'); $gateway->setClientId(env('AMERIA_CLIENT_ID')); // Merchant ID - Provided by bank $gateway->setUsername(env('AMERIA_USERNAME')); // Username - Provided by bank $gateway->setPassword(env('AMERIA_PASSWORD')); // Password - Provided by bank $purchase = $gateway->purchase(); // Creating purchase request $purchase->setReturnUrl(env('AMERIA_RETURN_URL')); // Return url, that should be point to your arca webhook route $purchase->setAmount(10); // Amount to charge - should be decimal - use only 10 AMD if you are in test mode $purchase->setTransactionId(XXXX); // Transaction ID from your system $purchase->setTestMode(true); // For enabling test mode $purchase->setOpaque(json_encode(['email' => 'user@example.com'])); // Is not mandatory field and used as additional information during information exchange
- Call send, check if request is successful and redirect to AmeriaBank's hosted page
$purchaseResponse = $purchase->send(); if ($purchaseResponse->isSuccessfull()) { $purchaseResponse->setLanguage(\App::getLocale()); // Interface language ('am', 'ru', 'en') $purchaseResponse->setTestMode(true); // For enabling test mode $purchaseResponse->redirect(); }
- Create a webhook controller to handle the back URL request at your
AMERIA_RETURN_URL
and catch the webhook as follows
$gateway = Omnipay::create('Ameria'); $gateway->setClientId(env('AMERIA_CLIENT_ID')); $gateway->setUsername(env('AMERIA_USERNAME')); $gateway->setPassword(env('AMERIA_PASSWORD')); $purchaseCompleteRequest = $gateway->completePurchase(); $purchaseCompleteRequest->setTransactionId(request()->get('paymentID')); $purchaseCompleteResponse = $purchaseCompleteRequest->send(); // Do the rest with $purchase and response with 'OK' if ($purchaseCompleteResponse->isSuccessful()) { // Your logic } return new Response('OK');
For general usage instructions, please see the main Omnipay repository.
Support
If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag so it can be easily found.
If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a mailing list which you can subscribe to.
If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.