drastik / com.drastikbydesign.stripe

CMS Independent Stripe payment processor for CiviCRM 4.x
Other
35 stars 48 forks source link

invalid_request_error: no such customer #49

Open jmcclelland opened 9 years ago

jmcclelland commented 9 years ago

We were getting this error:

    No such customer: cus_4cZVRZAFBY0NUj; a similar object exists in test mode, but a live mode key was used to make this request.

The people at stripe advised us to delete all customers in test mode via the stripe control panel.

Then we got this error:

    Type: invalid_request_error
    Code:
    Message: No such customer: cus_4cZVRZAFBY0NUj

We resolved the problem by deleting the record with the matching customer number from the civicrm_stripe_customers table.

I think the solution is to add a new column to the civicrm_stripe_customers table that keeps track of whether you are operating in test or live mode to avoid confusing these customer ids.

drastik commented 9 years ago

I thought newer versions of civicrm_stripe did away with this. What version are you using?

jmcclelland commented 9 years ago

Hi. I'm running git commit 883c155eb9d2f552eccc78cd2659db585ac4943b (dated July 1, 2014). I don't see any differences with the current version that seem to suggest this has changed, though.

arborrow commented 9 years ago

Just to note that I ran into what I believe is the same issue. First, here is my environment:

Drupal 7.38, CiviCRM 4.4.18, 4.5-dev (1.9.1), and Stripe 3.1.0

And here is what I was noticing:

From error log:

11-Aug-2015 20:30:28 America/Chicago] Stripe Notice: Undefined property of Stripe_Object instance: customer [12-Aug-2015 03:35:12 America/Chicago] Stripe Notice: Undefined property of Stripe_Transfer instance: customer [12-Aug-2015 10:36:57 America/Chicago] Stripe Notice: Undefined property of Stripe_Customer instance: customer

PHP notices:

Notice: Undefined index: code in CRM_Core_Payment_Stripe->stripeCatchErrors() (line 216 of /home3/ignatia1/public_html/sites/default/files/civicrm/extensions/com.drastikbydesign.stripe/CRM/Core/Payment/Stripe.php).

Notice: Undefined index: code in CRM_Core_Payment_Stripe->stripeCatchErrors() (line 228 of /home3/ignatia1/public_html/sites/default/files/civicrm/extensions/com.drastikbydesign.stripe/CRM/Core/Payment/Stripe.php).

Unknown Error

I did a var_dump and saw that there is no code so that may need to be cleaned up:

Array(3) { ["type"]=> string(21) "invalid_request_error" ["message"]=> string(126) "No such customer: cus_3JP2C3liEa2p9M; a similar object exists in test mode, but a live mode key was used to make this request." ["param"]=> string(2) "id" }

I will try to remove the offending records from the table and see if that helps to resolve things. Peace - Anthony

arborrow commented 9 years ago

p.s. - any chance of taking care of those notices by initializing $err['code']

I have not looked to see what the intended functionality there was but the result is just a vague 'Unknown Error' and being able to see $message would be helpful to have a better idea of what is actually happening. Perhaps something as simple as:

$core_err->push(9000, 0, NULL, 'Unknown Error: '.$message);

arborrow commented 9 years ago

Just another comment that if code is initialized we may want to use isset to determine if there is an error code otherwise set it to 9000. But I think being able to see the message could be helpful.

drastik commented 9 years ago

I think in previous Stripe API versions, that was the index for the error message.

Will have to check for, and flip between code/message since we don't know what API version a user might be at.

mfb commented 6 years ago

I am still getting this error when doing an event registration in test mode, with version 4.7.3 of the extension. Solution was to delete myself from the civicrm_stripe_customers table.

h-c-c commented 6 years ago

Was this on an upgraded instance of the extension? If so, you might want to check that the database upgrades completed successfully.

If it's a fresh install, check that you inputted the test/live keys correctly. The Stripe UI lists the test info at the top of the page and Civi pay processors UI has test info at the bottom. That might explain this behavior if you're having difficulty with a fresh instance. It's a common mistake.

mfb commented 6 years ago

The upgrade happened. My guess is that my customer ID in the civicrm_stripe_customers table was no longer available, either because it was deleted from Stripe, or was created with a different set of Stripe test credentials. Perhaps the extension should catch this case and create a new customer - but admittedly it's more likely to happen to a developer in test mode.. :)