@@ -2692,13 +2692,15 @@ protected function handle_saving_payment_method( WC_Order $order, $payment_metho
2692
2692
// If the payment method object is a Link payment method, use Link as the payment method type.
2693
2693
if ( isset ( $ payment_method_object ->type ) && WC_Stripe_Payment_Methods::LINK === $ payment_method_object ->type ) {
2694
2694
$ payment_method_type = WC_Stripe_Payment_Methods::LINK ;
2695
+ $ payment_method_instance = $ this ->get_payment_method_instance ( $ payment_method_type );
2695
2696
} elseif ( $ this ->spe_enabled && isset ( $ payment_method_object ->type ) ) {
2696
2697
// When SPE is enabled, use the payment method type from the payment method object
2697
2698
$ payment_method_type = $ payment_method_object ->type ;
2699
+ $ payment_method_instance = $ this ->get_payment_method_instance ( $ payment_method_type );
2700
+ } else {
2701
+ $ payment_method_instance = $ this ->payment_methods [ $ payment_method_type ];
2698
2702
}
2699
2703
2700
- $ payment_method_instance = $ this ->get_payment_method_instance ( $ payment_method_type );
2701
-
2702
2704
// Searches for an existing duplicate token to update.
2703
2705
$ found_token = WC_Stripe_Payment_Tokens::get_duplicate_token ( $ payment_method_object , $ customer ->get_user_id (), $ this ->id );
2704
2706
@@ -2736,6 +2738,17 @@ public function set_payment_method_id_for_order( WC_Order $order, string $paymen
2736
2738
$ order ->save_meta_data ();
2737
2739
}
2738
2740
2741
+ /**
2742
+ * Set the payment metadata for payment method id for subscription.
2743
+ *
2744
+ * @param WC_Subscription $order The order.
2745
+ * @param string $payment_method_id The value to be set.
2746
+ */
2747
+ public function set_payment_method_id_for_subscription ( $ subscription , string $ payment_method_id ) {
2748
+ $ subscription ->update_meta_data ( '_stripe_source_id ' , $ payment_method_id );
2749
+ $ subscription ->save_meta_data ();
2750
+ }
2751
+
2739
2752
/**
2740
2753
* Set the payment metadata for customer id.
2741
2754
*
@@ -2749,6 +2762,19 @@ public function set_customer_id_for_order( WC_Order $order, string $customer_id
2749
2762
$ order ->save_meta_data ();
2750
2763
}
2751
2764
2765
+ /**
2766
+ * Set the payment metadata for customer id for subscription.
2767
+ *
2768
+ * Set to public so it can be called from confirm_change_payment_from_setup_intent_ajax()
2769
+ *
2770
+ * @param WC_Stripe_Order $order The order.
2771
+ * @param string $customer_id The value to be set.
2772
+ */
2773
+ public function set_customer_id_for_subscription ( $ subscription , string $ customer_id ) {
2774
+ $ subscription ->update_meta_data ( '_stripe_customer_id ' , $ customer_id );
2775
+ $ subscription ->save_meta_data ();
2776
+ }
2777
+
2752
2778
/**
2753
2779
* Set the payment metadata for the selected payment type.
2754
2780
*
0 commit comments