PHP code example of unoapp-dev / laravel-omnipay
1. Go to this page and download the library: Download unoapp-dev/laravel-omnipay library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
unoapp-dev / laravel-omnipay example snippets
'providers' => [
'Ignited\LaravelOmnipay\LaravelOmnipayServiceProvider',
]
'Omnipay' => 'Ignited\LaravelOmnipay\Facades\OmnipayFacade',
$app->register(Ignited\LaravelOmnipay\LumenOmnipayServiceProvider::class);
$app->configure('laravel-omnipay');
...
'gateways' => [
'moneris' => [
'driver' => 'Moneris',
'options' => [
'merchantId' => env('MONERIS_MERCHANT_ID', ''),
'merchantKey' => env('MONERIS_MERCHANT_KEY', ''),
'testMode' => env('MONERIS_TEST_MODE', '')
]
]
]
...
$cardInput = [
'firstName' => 'John',
'lastName' => 'Doe',
'number' => '4242424242424242',
'expiryMonth' => '03',
'expiryYear' => '2025',
'cvv' => '123',
'billingAddress1' => '795 Folsom Ave, Suite 600',
'billingCity' => 'San Francisco',
'billingPostcode' => '94107',
'billingState' => 'California',
'billingCountry' => 'United States',
'billingPhone' => '(555) 539-1037',
'email' => '[email protected] '
];
# 1. Generate payment profile :
$createcardResponse = Omnipay::createCard(['card' => $cardInput])->send();
# 2. Delete payment profile :
$cardParams = [
'cardReference' => $createcardResponse->getCardReference()
];
$deletecardResponse = Omnipay::deleteCard($cardParams)->send();
# 3. Purchase (using payment profile) :
$purchaseParams = [
"amount" => 100,
"order_number" => 11111,
"payment_method" => 'payment_profile',
"cardReference" => $createcardResponse->getCardReference()
];
$purchaseResponse = Omnipay::purchase($purchaseParams)->send();
# 4. Refund :
$refundParams = [
'amount' => 100,
'transactionReference' => $purchaseResponse->getData()
];
$refundResponse = Omnipay::refund($refundParams)->send();
Omnipay::setGateway('moneris');
$gateway = Omnipay::getGateway('moneris');
php artisan vendor:publish --provider="Ignited\LaravelOmnipay\LaravelOmnipayServiceProvider" --tag=config