woocommerce-subscriptions-importer-exporter icon indicating copy to clipboard operation
woocommerce-subscriptions-importer-exporter copied to clipboard

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

Open cwright2405 opened this issue 3 years ago • 5 comments

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.

cwright2405 avatar Feb 23 '22 09:02 cwright2405

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:

  • card_
  • src_
  • pm_

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":

  • The first "_stripe_source_id" meta_value is empty = ""
  • The other "_stripe_source_id" meta_value is correct

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..

adambware avatar Feb 27 '22 21:02 adambware

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

Maniac199 avatar May 17 '22 22:05 Maniac199

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.

kylercarlson avatar Jun 17 '22 18:06 kylercarlson

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

kasio99 avatar Aug 17 '22 02:08 kasio99

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.

mtg169 avatar Dec 07 '22 22:12 mtg169