Jump to content

Executable

Senior Member
  • Content Count

    20
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Executable

  • Rank
    Junior Member
  1. Cheers, I'm using WHMCS 7.5.2. It works very well and no issue when suddenly I click on the overview to view per month or year. The graph is loading forever. I'm using the default template, blend. The response of https://domain/?rp=/admin/widget/refresh&widget=Overview&viewperiod=month is giving me my homepage page. Thanks for any help
  2. Yep, I'm sending the right information because I'm able to retreive the response from the callback file. I'm using mercanet as third party (https://documentation.mercanet.bnpparibas.net/index.php/Connecteur_POST)
  3. I tried as you said but my callback page isn't called, so my invoice isn't marked as paid
  4. How the third party will know where to redirect ? So it should be something like : https://mydomain/viewinvoice.php?id=$invoiceId";
  5. I created a minimalist gateway module : <?php if (!defined("WHMCS")) { die("This file cannot be accessed directly"); } function gatewaymodule_MetaData() { return array( 'DisplayName' => 'Sample Payment Gateway Module', 'APIVersion' => '1.1', // Use API Version 1.1 'DisableLocalCreditCardInput' => true, 'TokenisedStorage' => false, ); } function gatewaymodule_config() { return array( // the friendly display name for a payment gateway should be // defined here for backwards compatibility 'FriendlyName' => array( 'Type' => 'System', 'Value' => 'Sample Third Party Payment Gateway Module', ), // a text field type allows for single line text input 'accountID' => array( 'FriendlyName' => 'Account ID', 'Type' => 'text', 'Size' => '25', 'Default' => '', 'Description' => 'Enter your account ID here', ), // a password field type allows for masked text input 'secretKey' => array( 'FriendlyName' => 'Secret Key', 'Type' => 'password', 'Size' => '25', 'Default' => '', 'Description' => 'Enter secret key here', ), // the yesno field type displays a single checkbox option 'testMode' => array( 'FriendlyName' => 'Test Mode', 'Type' => 'yesno', 'Description' => 'Tick to enable test mode', ), // the dropdown field type renders a select menu of options 'dropdownField' => array( 'FriendlyName' => 'Dropdown Field', 'Type' => 'dropdown', 'Options' => array( 'option1' => 'Display Value 1', 'option2' => 'Second Option', 'option3' => 'Another Option', ), 'Description' => 'Choose one', ), // the radio field type displays a series of radio button options 'radioField' => array( 'FriendlyName' => 'Radio Field', 'Type' => 'radio', 'Options' => 'First Option,Second Option,Third Option', 'Description' => 'Choose your option!', ), // the textarea field type allows for multi-line text input 'textareaField' => array( 'FriendlyName' => 'Textarea Field', 'Type' => 'textarea', 'Rows' => '3', 'Cols' => '60', 'Description' => 'Freeform multi-line text input field', ), ); } function gatewaymodule_link($params) { // Invoice Parameters $invoiceId = $params['invoiceid']; $amount = $params['amount']; $currencyCode = $params['currency']; $transaction = "TEST" . rand(100000,999999); $ReturnUrl = "https://mydomain/modules/gateways/callback/gatewaymodule.php"; $secretKey = "SECRET"; $hash=hash('sha256', $invoiceId.$amount.$currencyCode.$transaction.$normalReturnUrl.$secretKey); $htmlOutput = " <form method='post' action='https://payment-gateway.com/'> <input type='hidden' name='amount' value='$amount'> <input type='hidden' name='ReturnUrl' value='$ReturnUrl'> <input type='hidden' name='transaction' value='$transaction'> <input type='hidden' name='invoiceid' value='$invoiceId'> <input type='hidden' name='currency' value='$currencyCode'> <input type='hidden' name='hash' value='$seal'> <input type='submit' value='Pay'><br> </form> "; return $htmlOutput; } function gatewaymodule_refund($params) { // Gateway Configuration Parameters $accountId = $params['accountID']; $secretKey = $params['secretKey']; $testMode = $params['testMode']; $dropdownField = $params['dropdownField']; $radioField = $params['radioField']; $textareaField = $params['textareaField']; // Transaction Parameters $transactionIdToRefund = $params['transid']; $refundAmount = $params['amount']; $currencyCode = $params['currency']; // Client Parameters $firstname = $params['clientdetails']['firstname']; $lastname = $params['clientdetails']['lastname']; $email = $params['clientdetails']['email']; $address1 = $params['clientdetails']['address1']; $address2 = $params['clientdetails']['address2']; $city = $params['clientdetails']['city']; $state = $params['clientdetails']['state']; $postcode = $params['clientdetails']['postcode']; $country = $params['clientdetails']['country']; $phone = $params['clientdetails']['phonenumber']; // System Parameters $companyName = $params['companyname']; $systemUrl = $params['systemurl']; $langPayNow = $params['langpaynow']; $moduleDisplayName = $params['name']; $moduleName = $params['paymentmethod']; $whmcsVersion = $params['whmcsVersion']; // perform API call to initiate refund and interpret result return array( // 'success' if successful, otherwise 'declined', 'error' for failure 'status' => 'success', // Data to be recorded in the gateway log - can be a string or array 'rawdata' => $responseData, // Unique Transaction ID for the refund transaction 'transid' => $refundTransactionId, // Optional fee amount for the fee value refunded 'fees' => $feeAmount, ); } function gatewaymodule_cancelSubscription($params) { // Gateway Configuration Parameters $accountId = $params['accountID']; $secretKey = $params['secretKey']; $testMode = $params['testMode']; $dropdownField = $params['dropdownField']; $radioField = $params['radioField']; $textareaField = $params['textareaField']; // Subscription Parameters $subscriptionIdToCancel = $params['subscriptionID']; // System Parameters $companyName = $params['companyname']; $systemUrl = $params['systemurl']; $langPayNow = $params['langpaynow']; $moduleDisplayName = $params['name']; $moduleName = $params['paymentmethod']; $whmcsVersion = $params['whmcsVersion']; // perform API call to cancel subscription and interpret result return array( // 'success' if successful, any other value for failure 'status' => 'success', // Data to be recorded in the gateway log - can be a string or array 'rawdata' => $responseData, ); } and the callback : <?php require_once __DIR__ . '/../../../init.php'; require_once __DIR__ . '/../../../includes/gatewayfunctions.php'; require_once __DIR__ . '/../../../includes/invoicefunctions.php'; $gatewayModuleName = basename(__FILE__, '.php'); $gatewayParams = getGatewayVariables($gatewayModuleName); if (!$gatewayParams['type']) { die("Module Not Activated"); } $secretKey = 'SECRET'; $invoiceId = $_POST["invoiceid"]; $transactionId = $_POST["transaction"]; $paymentAmount = $_POST["amount"]; $hash = $_POST["hash"]; $invoiceId = checkCbInvoiceID($invoiceId, $gatewayParams['name']); checkCbTransID($transactionId); logTransaction($gatewayParams['name'], $_POST, "TEST"); if ($success) { addInvoicePayment( $invoiceId, $transactionId, $paymentAmount, 0, $gatewayModuleName ); } When I try a payment and get redirected to callback/gatewaymodule.php logTransaction($gatewayParams['name'], $_POST, "TEST"); is triggered twice. How can I avoid that ?
  6. 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"); }
  7. Hello, I added a custom gateway using Mastercard payment and everytime I'm making a payment i have a double transaction every time. I don't know how to debug it and how to fix it. I commented out the following function in the callback: //checkCbTransID($transactionId); WHMCS : 7.9.0 I'm using mercanet as Gateway (https://documentation.mercanet.bnpparibas.net/index.php?title=Connecteur_POST)
  8. I'm trying to login into my admin area using my correct credentials. then I click on login button, I'm redirected into this page : Oops! Something went wrong and we couldn't process your request. Please go back to the previous page and try again. If the problem persists, please contact us. « Back to Homepage Here is what I got from my webserver log : 2019/09/23 15:34:40 [error] 29188#0: *13488328 FastCGI sent in stderr: "PHP message: [WHMCS Application] ERROR: WHMCS\Exception: Could not determine admin user id in /var/www/html/xxx.com/vendor/whmcs/whmcs-foundation/lib/Installer/Composer/ComposerJson.php:0 Stack trace: #0 /var/www/html/xxx.com/vendor/whmcs/whmcs-foundation/lib/Admin/Controller/HomepageController.php(0): WHMCS\Admin->hasPermission('Update WHMCS') #1 [internal function]: WHMCS\Admin\Controller\HomepageController->index(Object(WHMCS\Http\Message\ServerRequest)) #2 /var/www/html/xxx.com/vendor/middlewares/utils/src/CallableHandler.php(26): call_user_func_array(Array, Array) #3 /var/www/html/xxx.com/vendor/middlewares/fast-route/src/FastRoute.php(96): Middlewares\Utils\CallableHandler::execute(Array, Array) #4 /var/www/html/xxx.com/resources/views/admin/assent/shared/data-eula.php(0): Middlewares\FastRoute->process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate)) #5 /var/www/html/xxx.com/resources/views/admin/assent/shared/data-eula.php(0): WHMCS\Route\" while reading response header from upstream, client: 192.0.0.192, server: xxx.com, request: "GET /admin/index.php?rp=/admin/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.xxx.com" I'm using nginx as webserver
  9. Well I tried on my mobile phone and also tried on desktop browser (using the responsive in the console) and still the same issue. The part I don't really understand, is that if I try to login using an admin account to login into the clientarea it's working, I can connect throught mobile interface. Hard to tell what's happening. To be sure I used the correct credentials I saved them into the browser when I logged in the first time. So I'm sure it's not a typo error
  10. Hello, I'm trying to connect with my mobile device with the correct credentials and I get When I try with the same credentials on desktop I'm able to login to my account. I'm using version 7.7.1 of WHMCS. My website is under SSL. PHP : PHP7.1.29
  11. On every page of my website I have this following error in my console. I don't what is the root of the problem
  12. Thanks for the answer, I managed to use it. I would like to know what does the line $ca->initPage(); And my final page looks like : use WHMCS\ClientArea; use WHMCS\Database\Capsule; require 'init.php'; $ca = new ClientArea(); //$ca->initPage(); // What does this line do ? if(isset($_POST['email']) and isset($_POST['password']) and $ca->isLoggedIn()){ $conn = new mysqli("HOST", "USER", "PASSWORD", "DATABASE"); if($stmt = $conn->prepare("SELECT `id` FROM `tblclients` WHERE `email` = ? AND `password` = ?")) { $stmt->bind_param("ss", $_POST['email'], $_POST['password']); $stmt->execute(); $result = $stmt->get_result(); while($row = $result->fetch_assoc()) { $id_user = $row['id']; } $stmt->close(); } $conn->close(); }else{ header("Location: ../../../index.php"); } if(isset($id_user) and !empty($id_user) and isset($_POST['service_id']) and $ca->isLoggedIn()){ //Logged in }else{ //Not logged }
  13. Thank you for the answer. I found a workaround with the following code : if(isset($_POST['email']) and isset($_POST['password'])){ $conn = new mysqli("HOST", "USER", "PASS", "DATABASE"); if($stmt = $conn->prepare("SELECT `id` FROM `tblclients` WHERE `email` = ? AND `password` = ?")) { $stmt->bind_param("ss", $_POST['email'], $_POST['password']); $stmt->execute(); $result = $stmt->get_result(); while($row = $result->fetch_assoc()) { $id_user = $row['id']; } $stmt->close(); } $conn->close(); } if(isset($id_user) and !empty($id_user)){ //LOGGED IN }else{ //WRONG CREDENTIALS }
  14. I would to know if it's possible to check user session into a custom page with php ? The custom page is situated on the same server and is in the whmcs folder. I need it to secure the page. Thank you for any reply
  15. I enable the error as you said, but I don't know where to watch for debugging
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated