Add modules/gateways/callback/hutko.php
This commit is contained in:
69
modules/gateways/callback/hutko.php
Normal file
69
modules/gateways/callback/hutko.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
// Require libraries needed for gateway module functions.
|
||||
require_once __DIR__ . '/../../../init.php';
|
||||
require_once __DIR__ . '/../../../includes/gatewayfunctions.php';
|
||||
require_once __DIR__ . '/../../../includes/invoicefunctions.php';
|
||||
require_once __DIR__ . '/../../../modules/gateways/hutko/hutko_helper.php';
|
||||
|
||||
// Detect module name from filename.
|
||||
$gatewayModuleName = basename(__FILE__, '.php');
|
||||
|
||||
// Fetch gateway configuration parameters.
|
||||
$gatewayParams = getGatewayVariables($gatewayModuleName);
|
||||
|
||||
// Die if module is not active.
|
||||
if (!$gatewayParams['type']) {
|
||||
die("Module Not Activated");
|
||||
}
|
||||
|
||||
// signature verified - we can trust this data
|
||||
$calbackContent = Hutko_Helper::getCallbackContent($gatewayParams);
|
||||
$order_id = explode(Hutko_Helper::ORDER_SEPARATOR, $calbackContent["order_id"]);
|
||||
$invoiceId = $order_id[0];
|
||||
$paymentAmount = round($calbackContent["amount"] / 100, 2);
|
||||
$itIsServerCallback = isset($_GET['callbackMode']) && $_GET['callbackMode'] == 'server';
|
||||
|
||||
|
||||
|
||||
|
||||
switch ($calbackContent['order_status']) {
|
||||
case Hutko_Helper::ORDER_APPROVED:
|
||||
$transactionStatus = 'success';
|
||||
break;
|
||||
case Hutko_Helper::ORDER_DECLINED:
|
||||
$transactionStatus = 'failure';
|
||||
break;
|
||||
default:
|
||||
$transactionStatus = 'unhandled hutko order status';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$invoiceId = checkCbInvoiceID($invoiceId, $gatewayParams['name']);
|
||||
|
||||
checkCbTransID($calbackContent["order_id"]);
|
||||
|
||||
logTransaction($gatewayParams['name'], $calbackContent, $transactionStatus);
|
||||
$paymentSuccess = false;
|
||||
|
||||
if ($transactionStatus === 'success' && $itIsServerCallback) {
|
||||
addInvoicePayment(
|
||||
$invoiceId,
|
||||
$calbackContent["order_id"],
|
||||
$paymentAmount,
|
||||
0,
|
||||
$gatewayModuleName
|
||||
);
|
||||
}
|
||||
|
||||
//if no errors and this is server to server callback - return 200 response, no redirect needed
|
||||
if ($itIsServerCallback) {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// redirect user to invoice page
|
||||
callback3DSecureRedirect($invoiceId, $transactionStatus === 'success');
|
||||
Reference in New Issue
Block a user