1. Go to this page and download the library: Download apility/nets-easy-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/ */
apility / nets-easy-omnipay example snippets
use Omnipay\Common\GatewayFactory;
use Apility\Omnipay\NetsEasy\Gateway as NetsEasyGateway;
$factory = new GatewayFactory();
$gateway = $factory->create(NetsEasyGateway::class);
$gateway->setMerchantNumber(/* ... */);
$gateway->setSecretKey(/* ... */);
$gateway->setCheckoutKey(/* ... */);
// Some API keys contains the "test-" prefix. If this is present, we automatically enable test mode.
// However, if your API key does not contain this prefix, you can manually toggle test mode using this method:
$gateway->setTestMode(true);
$transaction = $gateway->fetchTransaction(['paymentId' => $_GET['paymentid']])->send();
if (!$transaction->isSuccessful()) {
die('Failed to fetch transaction: ' . $transaction->getMessage());
}
if ($transaction->getChargedAmount()) {
header('Location: /receipt.php?paymentid=' . $transaction->getPaymentId());
return;
}
if ($transaction->getCancelledAmount() > 0) {
die('Payment was cancelled: ' . $transaction->getPaymentId());
return;
}
if ($transaction->getRefundedAmount() > 0) {
die('Payment refunded: ' . $transaction->getPaymentId());
}
if ($transaction->getUnscheduledSubscriptionId()) {
header('Location: /unscheduledSubscriptionCallback.php?paymentid=' . $transaction->getPaymentId());
return;
}
header('Location: /capture.php?paymentid=' . $transaction->getPaymentId());