Jump to content

payment successfull but error displayed (credit card token)


azzepis

Recommended Posts

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)

Screenshot_122.jpg.41d1a48401c8f2155a10d98ef28baf6f.jpg

After that he clicks on "Submit Payment" - page is reloading and he is getting error message with text from $_LANG['creditcarddeclined']  (second screenshot)

Screenshot_123.jpg.7eca4bfa410207c3b40688e8db9cad87.jpg

But:

  1. Gateway returns 'success' in logs
  2. Transaction succefuly added to invoice
  3. 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 by azzepis
added WHMCS version
Link to comment
Share on other sites

  • 2 weeks later...

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. 

Link to comment
Share on other sites

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:

Screenshot_1.jpg.e0fa3998dd0b9b75b0e10e6bc1ca092e.jpg

 

But transaction added successfully, invoice marked as PAID successfully, money gone from my card successfully 🙂

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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