Jump to content
Sign in to follow this  
darrensweb

Stripe Charge Request Incorrect

Recommended Posts

Hi,

I was previously using RoudiApp Stripe plugin and have done for years.

Due to the whole 3d secure and EU payments I decided to switch to the built in Stripe module.

Since doing this alot of my customers when trying to use an existing card are seeing the following error:

No such customer: cus_6wGlZpgCnjkYk2,card_198Q9G4YTT8T6YNYsBuu6vmm

I contacted stripe who are saying the built-in WHMCS plugin is sending the wrong charge request:

They gave me this:

  {
  "error": {
    "code": "resource_missing",
    "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
    "message": "No such customer: cus_6wGlZpgCnjkYk2,card_198Q9G4YTT8T6YNYsBuu6vmm",
    "param": "id",
    "type": "invalid_request_error"
  }
}

Anyone else have this issue? I am using 7.8.1

Share this post


Link to post
Share on other sites

Hi @darrensweb,

The problem here lies with the way the third-party module was storing the data. Unfortunately it was in a format suitable for migration: https://docs.whmcs.com/Stripe#Migrating_from_a_3rd_Party_Stripe_Module

Clients will need to re-enter their card details now you've switched to the official module so data is stored in the expected format.

Share this post


Link to post
Share on other sites

Hi,

 

According to the link you posted if the module is storing data with the cust prefix then it is migratable.

 

I have checked customers who have cards stored and they all have the cust prefix as an example: cus_EmvcvSs4IrJrmC,card_1EJLlh4YTT8T6YNYYjLijBLo

 

So what is it about the above storage that is incorrect?

 

Can it be modified, I have 1000s of customers with cards and could do with a fix.

Share this post


Link to post
Share on other sites

Looking at a transaction that succeeded while I had the new stripe module active I can see the data is stored as follows:

 

{"customer":"cus_Fk4hvEFV4Amdnd","method":"pm_1FEaXw4YTT8T6YNYCLhjq6PH"}

 

The data for my previous plugin was stored like below:

cus_Fk6MxbSUxpORU9,card_1FEcA04YTT8T6YNYwE6IYKDQ

 

Can I alter these manually using some conditional logic and if so what table am I looking for these?

 

I assume if I was to alter the data of the current module for each token like below

["customer";"cus_Fk6MxbSUxpORU9","pm_1FEcA04YTT8T6YNYwE6IYKDQ"]

 

Would that work?

Share this post


Link to post
Share on other sites
16 hours ago, darrensweb said:

Hi,

 

According to the link you posted if the module is storing data with the cust prefix then it is migratable.

 

I have checked customers who have cards stored and they all have the cust prefix as an example: cus_EmvcvSs4IrJrmC,card_1EJLlh4YTT8T6YNYYjLijBLo

 

So what is it about the above storage that is incorrect?

 

Can it be modified, I have 1000s of customers with cards and could do with a fix.

My guess is the storage should ONLY contain "cus_EmvcvSs4IrJrmC". Having the ",card_xxx" breaks it because then it's no longer a valid Stripe customer ID number.

Share this post


Link to post
Share on other sites
4 hours ago, tripsis said:

My guess is the storage should ONLY contain "cus_EmvcvSs4IrJrmC". Having the ",card_xxx" breaks it because then it's no longer a valid Stripe customer ID number.

This is correct. In the link provided by John above, prior to v7.8 only 1 card was supported - therefore the migration is expecting only the "cus_xxx" value to be present. If you are able to edit the `tblclients.gatewayid` to exclude the other unsupported data, cards should be able to charge without issue. Please do note that any already migrated cards would now be invalid and those customers would need to re-enter their cards. 

 

 

Share this post


Link to post
Share on other sites

Hi Guys,

I managed to edit the data and remove the last 30 characters from the "gatewayid"

Worked a charm and all is working fine.

 

Thanks, guys.

Share this post


Link to post
Share on other sites

Hi @darrensweb,

I'm pleased to hear you were able to solve the problem.

For the benefit of others who may find themselves in this same position in future, could you share how you trimmed the last 30 characters from the gatewayid please?

Share this post


Link to post
Share on other sites

Hi,

For those that used RoudiApp Stripe gateway before upgrading to WHMCS v7.8's Stripe gateway:

0/ If you are not fluent with PHP and MySQL, do not attempt this yourself. Seek help from a professional. Make a database backup before attempting anything. I cannot be held responsible if theses scripts misbehave on your WHMCS installation.

1/ Best way forward: BEFORE upgrading to WHMCS 7.8, convert your gatewayid token to a format that the WHMCS 7.8 upgrade script understand:

Tested OK on MySQL 5.7.

update tblclients set gatewayid=SUBSTRING_INDEX(SUBSTRING_INDEX(gatewayid,',',1),',',-1);

and that's it. You don't need to execute Step 2.

2/ Salvaging your Stripe customer token if you upgraded already to WHMCS 7.8 without converting your gatewayid first:

Tested OK on PHP 5.6, MySQL 5.7.

<?php
require 'configuration.php';//WHMCS configuration file
mysql_connect($db_host, $db_username, $db_password);
mysql_select_db($db_name);
$query = "select userid,payment_id from tblpaymethods";
$pay_result = mysql_query($query);
while ($row = mysql_fetch_array($pay_result, MYSQL_ASSOC)) {
  $clientid = $row['userid'];
  $payid = $row['payment_id'];
  $hash = md5($cc_encryption_hash.$clientid);
  $query = "SET block_encryption_mode = 'aes-256-cbc';";
  $result = mysql_query($query);
  $query = "SELECT AES_DECRYPT(UNHEX(card_data),'{$hash}',unhex('00000000000000000000000000000000')) AS card_data FROM tblcreditcards WHERE id='{$payid}'";
  $result = mysql_query($query);
  $row = mysql_fetch_array($result, MYSQL_ASSOC);
  $card_data = json_decode($row['card_data'], true);
  echo "UserID: " . $clientid. " Data: ". var_export($card_data, true) . PHP_EOL;
  if ($card_data && array_key_exists('remoteToken', $card_data)) {
    if (strpos($card_data['remoteToken'], ',card')) {
      list($token_customer,$token_card) = explode(',', $card_data['remoteToken']);
      echo "UserID: " . $clientid . " Token Customer: " . $token_customer . PHP_EOL;
      $new_card_data = json_encode(array("remoteToken" => $token_customer));
      $query = "update tblcreditcards set card_data=hex(aes_encrypt('{$new_card_data}', '{$hash}', unhex('00000000000000000000000000000000'))) where id='{$payid}';";
      $result = mysql_query($query);
    }
  }
}
?>

 

Share this post


Link to post
Share on other sites

Any idea how to do this with MariaDB 10.3? 

So far problem encountered is 

SET block_encryption_mode = 'aes-256-cbc

doesn't exist and

AES_DECRYPT

can't take three parameters.

Share this post


Link to post
Share on other sites

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.

Sign in to follow this  

  • Similar Content

    • By cameronelsea
      I can get to my admin area fine, however, whenever I click the settings button to try and edit my general settings and what not, it redirects me to my home page.
    • By Mechanic
      HI,
      In WHMCS 7.8.3 + 2Checkout payment gateway, the discount is being applied twice when a client tries to create a recurring subscription.
      This does not happen when they try to make a one off payment.
      This can be reproduced by creating a similar invoice under any other client account.
       
    • By Luthersites
      When I try to do the update I get the following error:
      Unable to complete incremental updates: Unable to import the 7.8.0 Alpha1 database file. Unable to import /home/lutherh/public_html/resources/sql/upgrade780alpha1.sql: SQLSTATE[42000]: Syntax error or access violation: 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
      I can't find anything on your site that talks about this error, and I find it odd that the database has incorrectly set column types.  Please advise as to what I need to do.
    • By zarvis
      Hi,
       
      From today morning the Invoices are not being updated, and the API callback is getting failed for the Coingate and perfect money modules.
      Anyone else facing similar issue?
       
      Regards
      Chandrakant
    • By loopmail
      Looking around and some clients have enabled 2fa for the primary user, but there seem to be no details for it on the contacts page. is this not a feature on offer to contacts or a way for administrators to see the status/clear the status for contacts?

       
  • 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