-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Sellix/New-Code-11
Initial Version - 1.1
- Loading branch information
Showing
9 changed files
with
539 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* WHMCS Sellix Pay Payment Gateway Module Return Page | ||
* | ||
* @copyright Copyright (c) WHMCS Limited 2023 | ||
* @license http://www.whmcs.com/license/ WHMCS Eula | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../../init.php'; | ||
require_once __DIR__ . '/../../../../includes/gatewayfunctions.php'; | ||
require_once __DIR__ . '/../../../../includes/invoicefunctions.php'; | ||
require_once __DIR__ . '/../../../../modules/gateways/sellixpay.php'; | ||
|
||
$gatewayModuleName = 'sellixpay'; | ||
|
||
$gatewayParams = getGatewayVariables($gatewayModuleName); | ||
|
||
if (!$gatewayParams['type']) { | ||
die("Module Not Activated"); | ||
} | ||
|
||
try { | ||
if (isset($_REQUEST["invoiceid"]) && !empty($_REQUEST["invoiceid"])) { | ||
$invoiceid = $_REQUEST["invoiceid"]; | ||
$invoiceid = trim($invoiceid); | ||
$invoiceid = (int)$invoiceid; | ||
$systemUrl = $gatewayParams['systemurl']; | ||
$redirectUrl = $systemUrl.'/viewinvoice.php?id='.$invoiceid; | ||
sellixRedirect($redirectUrl); | ||
} else { | ||
throw new \Exception('Empty response received from gateway.'); | ||
} | ||
} catch (\Exception $e) { | ||
$error_message = $e->getMessage(); | ||
sellixLog($gatewayParams['name'], $error_message, 'Return from gateway'); | ||
$htmlOutput = '<h6 style="color:red">An error occurred while returning from payment gateway: '.$error_message.'</h6>'; | ||
echo $htmlOutput; | ||
exit; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
/** | ||
* WHMCS Sellix Pay Payment Gateway Module Webhook Page | ||
* | ||
* @copyright Copyright (c) WHMCS Limited 2023 | ||
* @license http://www.whmcs.com/license/ WHMCS Eula | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../../init.php'; | ||
require_once __DIR__ . '/../../../../includes/gatewayfunctions.php'; | ||
require_once __DIR__ . '/../../../../includes/invoicefunctions.php'; | ||
require_once __DIR__ . '/../../../../modules/gateways/sellixpay.php'; | ||
|
||
$jsonData = file_get_contents('php://input'); | ||
$data = json_decode($jsonData, true); | ||
|
||
$gatewayModuleName = 'sellixpay'; | ||
$gatewayParams = getGatewayVariables($gatewayModuleName); | ||
|
||
try { | ||
|
||
sellixLog($gatewayParams['name'], $data, 'Webhook received data'); | ||
|
||
if ((null === $data['data']) || (null === $data['data']['uniqid']) || empty($data['data']['uniqid'])) { | ||
$message = 'Sellixpay: suspected fraud. Code-001'; | ||
throw new \Exception($message); | ||
} | ||
|
||
$sellix_order = sellixValidSellixOrder($gatewayParams, $data['data']['uniqid']); | ||
|
||
if (isset($_REQUEST["invoiceid"]) && !empty($_REQUEST["invoiceid"])) { | ||
$invoiceid = $_REQUEST["invoiceid"]; | ||
$invoiceid = trim($invoiceid); | ||
$invoiceid = (int)$invoiceid; | ||
|
||
$transactionId = $sellix_order['uniqid']; | ||
$paymentAmount = $sellix_order['total']; | ||
$message1 = 'Invoice #' . $invoiceid; | ||
$message2 = ' (' . $sellix_order['uniqid'] . '). Status: ' . $sellix_order['status']; | ||
|
||
updateSellixpayOrder($invoiceid, 'status', $sellix_order['status']); | ||
updateSellixpayOrder($invoiceid, 'transaction_id', $transactionId); | ||
updateSellixpayOrder($invoiceid, 'response', json_encode($sellix_order)); | ||
|
||
sellixLog($gatewayParams['name'], $message1.$message2, 'Webhook Concern Invoice'); | ||
|
||
$invoiceId = checkCbInvoiceID($invoiceid, $gatewayParams['name']); | ||
checkCbTransID($transactionId); | ||
|
||
if ($sellix_order['status'] == 'PROCESSING') { | ||
addInvoicePayment($invoiceid,$transactionId,$paymentAmount,0,$gatewayModuleName); | ||
} elseif ($sellix_order['status'] == 'COMPLETED') { | ||
addInvoicePayment($invoiceid,$transactionId,$paymentAmount,0,$gatewayModuleName); | ||
} elseif ($sellix_order['status'] == 'WAITING_FOR_CONFIRMATIONS') { | ||
|
||
} elseif ($sellix_order['status'] == 'PARTIAL') { | ||
|
||
} elseif ($sellix_order['status'] == 'PENDING') { | ||
|
||
} | ||
} else { | ||
throw new \Exception('Empty response received from gateway.'); | ||
} | ||
} catch (\Exception $e) { | ||
$error_message = $e->getMessage(); | ||
$message = 'Payment error. '.$error_message; | ||
sellixLog($gatewayParams['name'], $message, 'Webhook from Gateway Catch'); | ||
echo $message; | ||
exit; | ||
|
||
} | ||
echo 'Web hook finished'; | ||
exit; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.