woocommerce / woocommerce-subscriptions-importer-exporter

Import your subscribers to WooCommerce from a CSV. Or export your subscription data from WooCommerce to CSV.
GNU General Public License v3.0
149 stars 57 forks source link

Importing Subscription (Stripe) payment_method_post_meta - _stripe_source id does not import #252

Open cwright2405 opened 2 years ago

cwright2405 commented 2 years ago

Hi ,

When running an import of subscriptions where the payment gateway is stripe the stripe source id does not import. The CSV column format is

payment_method_post_meta _stripe_customer_id:cus_xxx|_stripe_source_id:pm_xxx

Subscription imports successfully but stripe source id remains blank, this means that automatic payment recurrence fails.

adambware commented 2 years ago

I have a similar issue I'm troubleshooting. Importing Stripe payment methods in the same format:

payment_method_post_meta _stripe_customer_id:cus_xxx|_stripe_source_id:pm_xxx

This importer plugin's readme says that only stripe sources beginning with "card_" will be considered valid.

However, the Stripe plugin allows _stripe_source_id in the following formats:

See: validate_subscription_payment_meta() in woocommerce-gateway-stripe/includes/compat/trait-wc-stripe-subscriptions.php

When I import a Stripe payment method source beginning with "pm_", I end up with two wp_postmeta entries on each imported subscription for "_stripe_source_id":

It appears if I run SQL to delete the empty source ID, my payments will process as expected.

I have not found the source of the duplicate postmeta entry..

Maniac199 commented 2 years ago

The duplicate source_id is there no matter what. I was not supplying it and it was still showing up.

kylercarlson commented 2 years ago

Having the same problem today. On initial import, _stripe_source_id displays when looking at the DB, but then gets cleared out and is never visible on the subscription in the backend.

Solved the problem by using WooCommerce Import Export Suite plugin instead. Really frustrating.

kasio99 commented 2 years ago

I'm having the same issue too, no errors thrown though the _stripe_source_id fails to update, very frustrating.

mtg169 commented 1 year ago

For anyone else who runs into this issue where there is a duplicate _stripe_source_id being set with an empty value, the issue is not necessarily with this plugin, but with newer versions of the Stripe plugin and hooks it calls.

I debugged this plugin extensively and the only meta it adds is exactly what's in the spreadsheet.

I decided to then look into the Stripe plugin for anything setting the _stripe_source_id and the issue is caused by backwards compatibility code from when they renamed the meta key from _stripe_card_id to _stripe_source_id. The fix is to modify woocommerce-gateway-stripe/includes/compat/trait-wc-stripe-subscriptions.php and comment out or delete all blocks of code with a comment of For BW compat will remove in future.

This plugin will then work as intended and only add a single meta/key value for the _stripe_source_id.