craftcms / commerce-stripe

Stripe payment gateway for Craft Commerce
https://plugins.craftcms.com/commerce-stripe
MIT License
31 stars 48 forks source link

Live environment fails when test customer is used #311

Open ryssbowh opened 2 months ago

ryssbowh commented 2 months ago

Description

We have a website just gone live (migrated from Craft 3) where payments are failing for admin users. Those users have been making payments on the dev version of the website and in Stripe they are linked to a test environment. Stripe complains :

Could not fetch Stripe customer: No such customer: 'cus_Ge1tS7lpPzAWCK'; a similar object exists in test mode, but a live mode key was used to make this request

The only thing I can do is deleting the record in the stripe_customers table and it fixes the issue.

Shouldn't stripe customers be environment aware ? or should we have a way to delete those references in Craft itself ?

Thank you

Steps to reproduce

  1. Make a payment on a dev site in a Stripe test environment
  2. Make a payment on the live version of the dev site in a Stripe production environment

Additional info

linear[bot] commented 2 months ago

PT-2147 Live environment fails when test customer is used

ryssbowh commented 1 month ago

This is also an issue when trying to save payment methods using craft\commerce\controllers\PaymentSourcesController::actionAdd

sm9 commented 2 weeks ago

Hi, we have also just run into this issue. We're using Craft 4.10.2, Commerce 4.6.4, Stripe for Craft Commerce 4.1.5, and PHP 8.1.29.

User accounts that have placed orders on the staging site and Stripe test mode previously are showing the error that @ryssbowh has reported above on the live site in Stripe live mode.

Is carrying out the suggested fix above safe, and also what @lukeholder recommends doing as a workaround for now? Or is a proper fix imminent?

The only thing I can do is deleting the record in the stripe_customers table and it fixes the issue.

Thanks,

Stephen