awesomemotive / easy-digital-downloads

Sell digital downloads through WordPress
https://easydigitaldownloads.com
GNU General Public License v2.0
862 stars 475 forks source link

Stripe recurring profile doesn't migrate when moving customer #9647

Open brianleejackson opened 1 year ago

brianleejackson commented 1 year ago

Bug Report

Expected behavior

There are many times when an account will have a typo on it; the person no longer exists, someone has changed in the company, etc. This means I have to create a new customer/user ID and move everything over to it. The problem is, the recurring profile for Stripe doesn't seem to automatically get moved over.

If I have created a new customer along with a new user ID, I would assume changing the customer on a purchase record would also move the recurring profile along with it.

Actual behavior

Typically the Stripe record shows on the following URL under "Recurring Profiles."

/wp-admin/edit.php?post_type=download&page=edd-customers&view=overview&id=XXXXX#edd_general_subscriptions

However, when creating a new customer/user ID and then updating the customer attached to it, the Stripe recurring profile is no longer there. It's still attached to the old user ID.

Steps to reproduce the behavior

1) Create a customer and user ID with a Stripe purchase/subscription. 2) Create a second customer and user ID with nothing. 3) Move the purchase to the second customer. Typically this is done in the dropdown on the individual order page where it says "assign to existing customer." 4) Check the URL as mentioned above of the second customer. It won't have the Stripe recurring profile attached to it. It's still attached to the first customer/user ID.

Typically a way to fix this manually is to search for the recurring profile ID in wp_usermeta using %LIKE% since it will be inside a serialized array, then you have to update the user id to the new one.

Information (if a specific version is affected):

PHP Version: 8.1

EDD Version (or branch):

WordPress Version: 6.2.1

Any other relevant information:

Perhaps there is a better way to move everything from a customer/user ID to a new account, and I'm missing something. But the above seems like a bug.

Happy to provide any additional information if needed.

Thanks

cklosowski commented 1 year ago

Hey @brianleejackson Thanks for the detailed issue.

While on the surface your assessment is accurate, there are some considerations that need to be taken when moving payments around. While the concept you are detailng here is not ideal, it is 'intentional' that we don't link a new customer in EDD to the old Stripe customer Profile ID.

There are a number of cases where this is not the desired outcome and in some cases is actually not possible, depending on circumstances and the state of the customer's purchase history.

We are looking into some other Stripe Customer Record related changes in the future to better facilitate multi-currency support and other aspects of Stripe's Customer records, and we'll keep this situation in mind when we're looking at this.

brianleejackson commented 1 year ago

Thanks for the detailed response @cklosowski. That makes sense, and definitely would like to see improvements going forward with how this might be handled. Part of me was wondering if I was missing something, so glad to confirm that part at least.