1. Go to this page and download the library: Download swiftmade/omnipay-everypay 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/ */
swiftmade / omnipay-everypay example snippets
$gateway = Omnipay::create('EveryPay')->initialize([
'username' => '', // EveryPay api username
'secret' => '', // EveryPay api secret
'accountName' => '', // merchant account ID
'testMode' => true, // set to false for production!
'locale' => 'en', // et=Estonian, see integration guide for more options.
]);
$purchase = $gateway
->purchase([
'amount' => $amount,
'paymentType' => PaymentType::ONE_OFF,
])
->setTransactionId($orderId) // unique order id for this purchase
->setReturnUrl($customerUrl) // the url to redirect if the payment fails or gets cancelled
->setClientIp($_SERVER['REMOTE_ADDR']) // optional, helps fraud detection
->setEmail(''); // optional, helps fraud detection
// Use this, if you want to make the payment using a previously stored card token
// Only applicable for MIT and CIT payment types.
$purchase->setCardReference($token);
// Uncomment if you want to store the card as a token after the payment
// (Only supported with One-off payment type)
$purchase->setSaveCard(true);
$response = $purchase->send();
// IMPORTANT: Store this payment data somewhere so that we can validate / process it later
$payment = $response->getData();
return $response->redirect(); // this will return a self-submitting html form to EveryPay Gateway API
$purchase = $gateway
->purchase([
'amount' => $amount,
'paymentType' => PaymentType::CIT,
])
->setTransactionId($orderId) // unique order id for this purchase
->setCardReference('previously stored card token')
->setReturnUrl($customerUrl)
->setClientIp($_SERVER['REMOTE_ADDR']) // optional, helps fraud detection
->setEmail(''); // optional, helps fraud detection
$response = $purchase->send();
// Store the payment response data if you wish.
$payment = $response->getData();
if ($response->isSuccessful()) {
// Payment done!
} else if($response->isRedirect()) {
// 3DS Confirmation needed!
// Redirect the user to 3DS Page.
return $response->redirect();
} else {
// Something went wrong!
// Check $response->getMessage();
}
// Here, pass the payment array that we previously stored when creating the payment
$response = $gateway->completePurchase()
// These values are passed back to you by EveryPay
->setTransactionId($_GET['order_reference'])
->setTransactionReference($_GET['payment_reference'])
->send();
if (!$response->isSuccessful()) {
// Payment failed!
// Check $response->getMessage() for more details.
}
// Payment succeeded!
// Here's your payment reference number: $response->getTransactionReference()
if ($card = $response->getCardToken()) {
// You also got back a card token
// Store this somewhere safe for future use!
}
// Here, pass the payment array that we previously stored when creating the payment
$gateway->authorize([
'amount' => $amount,
'paymentType' => PaymentType::CIT,
])
->setCardReference('previously stored card token')
// Set all the other parameters. See previous examples ...
->send();
// Redirect the user to 3DS confirmation as necessary.
// When EveryPay redirects the user back, do this...
// This won't capture the payment yet, but makes sure the authorization is successful.
$authorizeResponse = $gateway->completeAuthorize()
->setTransactionId($_GET['order_reference'])
->setTransactionReference($_GET['payment_reference'])
->send();
// Hold on to this.. You'll use this reference to capture the payment.
$paymentReference = $authorizeResponse->getTransactionReference();
// When you're ready to capture, call:
$response = $gateway->capture([
'amount' => $amount, // You can capture partially, or the whole amount.
'transactionReference' => $paymentReference,
])->send();
if ($response->isSuccessful()) {
// Payment captured!
} else {
// Something went wrong!
// Check $response->getMessage();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.