41 lines
1.6 KiB
PHP
41 lines
1.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* PayAnyWay - WHMCS Callback Handler
|
|
*
|
|
* Receives payment status and check notifications from PayAnyWay
|
|
* and automatically marks WHMCS invoices as paid upon successful payments.
|
|
*
|
|
* Notification URL to configure in your app:
|
|
* https://your_whmcs_site/modules/gateways/callback/payanyway.php
|
|
*/
|
|
|
|
require_once __DIR__ . '/../../../init.php';
|
|
require_once __DIR__ . '/../../../includes/gatewayfunctions.php';
|
|
require_once __DIR__ . '/../../../includes/invoicefunctions.php';
|
|
require_once __DIR__ . '/../payanyway.php';
|
|
|
|
$requestData = ($_SERVER['REQUEST_METHOD'] === 'POST') ? $_POST : $_GET;
|
|
|
|
try {
|
|
$gatewayModuleName = 'payanyway';
|
|
$gatewayParams = getGatewayVariables($gatewayModuleName);
|
|
if (!$gatewayParams['type']) {
|
|
payanyway_sendResponse('FAIL', 500); // Module Not Activated
|
|
}
|
|
|
|
$gatewayName = payanyway_getWhmcsVariableOrFail($gatewayParams, 'name');
|
|
$integrityCode = payanyway_getPayAnyWayIntegrityCodeOrFail($gatewayParams);
|
|
|
|
$callbackData = payanyway_getCallbackData($requestData);
|
|
|
|
('CHECK' === $callbackData['MNT_COMMAND'])
|
|
? payanyway_handleCheckCallback($callbackData, $gatewayName, $integrityCode)
|
|
: payanyway_handlePayCallback($callbackData, $gatewayName, $integrityCode, $gatewayModuleName);
|
|
} catch (\PayAnyWayException $e) {
|
|
logTransaction($gatewayModuleName, $requestData, 'Error: ' . $e->getMessage());
|
|
payanyway_sendResponse('FAIL', 500);
|
|
} catch (\Exception $e) {
|
|
logTransaction($gatewayModuleName, $requestData, 'Error: ' . $e->getMessage());
|
|
payanyway_sendResponse('FAIL', 500);
|
|
} |