Executable Posted May 20, 2020 Share Posted May 20, 2020 (edited) I've created a new gateway payment. I used the standard callback template. For the moment I get the invoiceId and transactionId. When my callback meets checkCbTransID($transactionId); the page is stopped. I var_dump $transactionId and I got the right id. The weird part is that my invoice is marked as paid. WHMCS : Version: 7.9.0 Here is my code : <?php /** * WHMCS Sample Payment Callback File * * This sample file demonstrates how a payment gateway callback should be * handled within WHMCS. * * It demonstrates verifying that the payment gateway module is active, * validating an Invoice ID, checking for the existence of a Transaction ID, * Logging the Transaction for debugging and Adding Payment to an Invoice. * * For more information, please refer to the online documentation. * * @see https://developers.whmcs.com/payment-gateways/callbacks/ * * @copyright Copyright (c) WHMCS Limited 2017 * @license http://www.whmcs.com/license/ WHMCS Eula */ // Require libraries needed for gateway module functions. require_once __DIR__ . '/../../../init.php'; require_once __DIR__ . '/../../../includes/gatewayfunctions.php'; require_once __DIR__ . '/../../../includes/invoicefunctions.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"); } /** * Validate Callback Invoice ID. * * Checks invoice ID is a valid invoice number. Note it will count an * invoice in any status as valid. * * Performs a die upon encountering an invalid Invoice ID. * * Returns a normalised invoice ID. * * @param int $invoiceId Invoice ID * @param string $gatewayName Gateway Name */ $invoiceId = $_POST['invoiceId']; $invoiceId = checkCbInvoiceID($invoiceId, $gatewayParams['name']); /** * Check Callback Transaction ID. * * Performs a check for any existing transactions with the same given * transaction number. * * Performs a die upon encountering a duplicate. * * @param string $transactionId Unique Transaction ID */ $transactionId = $_POST['transactionId']; checkCbTransID($transactionId); $transactionStatus = true; /** * Log Transaction. * * Add an entry to the Gateway Log for debugging purposes. * * The debug data can be a string or an array. In the case of an * array it will be * * @param string $gatewayName Display label * @param string|array $debugData Data to log * @param string $transactionStatus Status */ logTransaction($gatewayParams['name'], $_POST, $transactionStatus); $success = true; $paymentAmount = $_POST['amount']; if ($success) { /** * Add Invoice Payment. * * Applies a payment transaction entry to the given invoice ID. * * @param int $invoiceId Invoice ID * @param string $transactionId Transaction ID * @param float $paymentAmount Amount paid (defaults to full balance) * @param float $paymentFee Payment fee (optional) * @param string $gatewayModule Gateway module name */ addInvoicePayment( $invoiceId, $transactionId, $paymentAmount, '', $gatewayModuleName ); header("Location: mywebsite.com/invoice.php?id=$invoiceId&statut=success"); }else{ header("Location: mywebsite.com/invoice.php?id=$invoiceId&statut=error"); } Edited May 20, 2020 by Executable 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.