azzepis Posted July 7, 2021 Share Posted July 7, 2021 (edited) Hi. I'm using custom payment gateway module based on WHMCS github example which is using card tokens for automated payments. (WHMCS 8.1.3-release.1) User can add credit card to WHMCS using https://whmcs/index.php/account/paymentmethods , and WHMCS saves card token for feature payments. If there is unpaid invoice and client wants to pay it using my custom payment method and saved card - he is clicking on "Pay button" on the invoice page, after that this page https://whmcs/index.php/invoice/11888222217/pay is displayed (screenshot) After that he clicks on "Submit Payment" - page is reloading and he is getting error message with text from $_LANG['creditcarddeclined'] (second screenshot) But: Gateway returns 'success' in logs Transaction succefuly added to invoice Invoice marked as paid My capture function is returnig next: <?php $result = [ // 'success' if successful, otherwise 'declined', 'error' for failure 'status' => 'success', // The unique transaction id for the payment 'transid' => $response['transaction_id'], // Optional fee amount for the transaction 'fee' => $response['fee'], // Return only if the token has updated or changed 'gatewayid' => $response['token'], // Data to be recorded in the gateway log - can be a string or array 'rawdata' => $response, ]; return $result; $response - it's an Array with populated data from gateway response Can you please help me find out why error message is displayed if returned array contains 'status' => 'success' ? Thank you Edited July 7, 2021 by azzepis added WHMCS version 0 Quote Link to comment Share on other sites More sharing options...
azzepis Posted July 19, 2021 Author Share Posted July 19, 2021 Maybe some one has unencrypted WHMCS module that works correct? So I will compare it with my code and will try to find own errors... 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted July 19, 2021 Share Posted July 19, 2021 The above return is correct for capture, however, capture is, AFAIK, only done during crons or the admin manually hitting capture in the admin invoice page. On the client invoice page, that uses an input function -- remoteinput and returns to there or a callback file. What happens when you try to capture via the admin? The sample modules at https://github.com/whmcs/ may help a bit but some items are missing there. I am sure there is a open source gateway laying around some where. 0 Quote Link to comment Share on other sites More sharing options...
azzepis Posted July 20, 2021 Author Share Posted July 20, 2021 Thank you very much for your answer. I did some additional logging - and I see that capture function is called during process I described before. Callback is not called, the same as remoteinput function. If I'm trying to pay as admin using 'pay with credit card" button on invoice page like https://whmcs/admin/invoices.php?action=edit&id=45684841405 I see a capture error: But transaction added successfully, invoice marked as PAID successfully, money gone from my card successfully 🙂 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted July 20, 2021 Share Posted July 20, 2021 Are you doing a logTransaction just before you return and if so is that showing up? It seems like it is doing its job but then another return is happening or not returning anything. Sorta hard to know without seeing the complete code. Past that, I would say you're hitting a WHMCS bug but uh I would imagine there would be lots more posts about this if that was the case. 0 Quote Link to comment Share on other sites More sharing options...
azzepis Posted July 21, 2021 Author Share Posted July 21, 2021 Thanks again! Yes, I do logging almost after every operation in my log and to Transaction log too. I see this in transaction log: Invoice ID => 11405 User ID => 12 Amount => 1.00 success => 1 transaction_id => 11405/162000086345/12 fee => 0 token => xxxexxxx-xxxx-xxxx-xxxx-xxxxxxxxxx and this: Invoice ID => 11405 User ID => 12 Amount => 1.00 merchantAccount => mymerchant authTicket => orderReference => 11405/562000086345/12 merchantSignature => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx amount => 1 currency => UAH authCode => 12323423242 email => my@email.me phone => 956783311 createdDate => 1626770968 processingDate => 1626770971 cardPan => 33****3333 cardType => Visa issuerBankCountry => Ukraine issuerBankName => COMMERCIAL BANK recToken => xxxexxxx-xxxx-xxxx-xxxx-xxxxxxxxxx transactionStatus => Approved reason => Ok reasonCode => 1100 fee => 0 paymentSystem => card merchantTransactionType => SALE d3AcsUrl => d3Md => d3Pareq => returnUrl => Also attached gateway code (some data and was deleted, but all logic saved) new 2 (2).txt 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted July 21, 2021 Share Posted July 21, 2021 Couple items in the _capture function wanted to note: Line 157 - $postfields but that does not exist but rather $postFields does -- note the "f" and "F" -- PHP is CaSe sensitive. Line 221 - $gatewayModuleName doesn't exist 242 - add a logging entry with $response print_r'd . 257 - add a logging entry indicating it declined and print_r $response . I am sort of thinking line 221 is the issue where addinvoicepayment is expecting a gateway name and isn't getting one but doesn't error until after it has done all the invoice payment steps and $invoice_res does not equal success and thus you get the declined error. That is why I suggest to add a logging entry after that and before returns. 0 Quote Link to comment Share on other sites More sharing options...
azzepis Posted July 22, 2021 Author Share Posted July 22, 2021 12 hours ago, steven99 said: Couple items in the _capture function wanted to note: Line 157 - $postfields but that does not exist but rather $postFields does -- note the "f" and "F" -- PHP is CaSe sensitive. Line 221 - $gatewayModuleName doesn't exist 242 - add a logging entry with $response print_r'd . 257 - add a logging entry indicating it declined and print_r $response . I am sort of thinking line 221 is the issue where addinvoicepayment is expecting a gateway name and isn't getting one but doesn't error until after it has done all the invoice payment steps and $invoice_res does not equal success and thus you get the declined error. That is why I suggest to add a logging entry after that and before returns. Hello. I'm using $postfields with lowercase letters, it was mistype in txt file thank you, gatewayModuleName changed to $gatewayParams['name'] thank you, added I will test now and let you know 0 Quote Link to comment Share on other sites More sharing options...
azzepis Posted July 22, 2021 Author Share Posted July 22, 2021 1. gatewayModuleName changed to $params['paymentmethod'] , and I see 'Sample Remote Input Gateway Module' in gatewaylog in gateway column and this is a name of my gateway. Anyway error still occurs. 2. $response from row 242: Invoice ID => 22425 User ID => 12 Amount => 3.02 success => 1 transaction_id => 22425/1626945023/12 fee => 0 token => xxxxxxxxxxx-xxxx-xxx-xxx-xxxxxxxxxxx 3. Declined print_r is not printed to log , because it's not declined, I think 🙂 Also I added $invoice_res value to log after addInvoicePayment function and got: Invoice ID => 22425 User ID => 12 Amount => 3.02 $invoice_res => 1 0 Quote Link to comment Share on other sites More sharing options...
secretreal Posted August 3, 2023 Share Posted August 3, 2023 Hi, Did you solve this? I got same error too.. But in several months ago was working perfectly :S 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.