@@ 103-126 (lines=24) @@ | ||
100 | * @param string $source_id |
|
101 | * @param object $source_object |
|
102 | */ |
|
103 | public function handle_add_payment_method_success( $source_id, $source_object ) { |
|
104 | if ( isset( $_POST[ 'wc-' . $this->id . '-update-subs-payment-method-card' ] ) ) { |
|
105 | $all_subs = wcs_get_users_subscriptions(); |
|
106 | $subs_statuses = apply_filters( 'wc_stripe_update_subs_payment_method_card_statuses', array( 'active' ) ); |
|
107 | $stripe_customer = new WC_Stripe_Customer( get_current_user_id() ); |
|
108 | ||
109 | if ( ! empty( $all_subs ) ) { |
|
110 | foreach ( $all_subs as $sub ) { |
|
111 | if ( $sub->has_status( $subs_statuses ) ) { |
|
112 | WC_Subscriptions_Change_Payment_Gateway::update_payment_method( |
|
113 | $sub, |
|
114 | $this->id, |
|
115 | array( |
|
116 | 'post_meta' => array( |
|
117 | '_stripe_source_id' => array( 'value' => $source_id ), |
|
118 | '_stripe_customer_id' => array( 'value' => $stripe_customer->get_id() ), |
|
119 | ), |
|
120 | ) |
|
121 | ); |
|
122 | } |
|
123 | } |
|
124 | } |
|
125 | } |
|
126 | } |
|
127 | ||
128 | /** |
|
129 | * Updates other subscription sources. |
@@ 113-136 (lines=24) @@ | ||
110 | * @param string $source_id |
|
111 | * @param object $source_object |
|
112 | */ |
|
113 | public function handle_add_payment_method_success( $source_id, $source_object ) { |
|
114 | if ( isset( $_POST[ 'wc-' . $this->id . '-update-subs-payment-method-card' ] ) ) { |
|
115 | $all_subs = wcs_get_users_subscriptions(); |
|
116 | $subs_statuses = apply_filters( 'wc_stripe_update_subs_payment_method_card_statuses', array( 'active' ) ); |
|
117 | $stripe_customer = new WC_Stripe_Customer( get_current_user_id() ); |
|
118 | ||
119 | if ( ! empty( $all_subs ) ) { |
|
120 | foreach ( $all_subs as $sub ) { |
|
121 | if ( $sub->has_status( $subs_statuses ) ) { |
|
122 | WC_Subscriptions_Change_Payment_Gateway::update_payment_method( |
|
123 | $sub, |
|
124 | $this->id, |
|
125 | array( |
|
126 | 'post_meta' => array( |
|
127 | '_stripe_source_id' => array( 'value' => $source_id ), |
|
128 | '_stripe_customer_id' => array( 'value' => $stripe_customer->get_id() ), |
|
129 | ), |
|
130 | ) |
|
131 | ); |
|
132 | } |
|
133 | } |
|
134 | } |
|
135 | } |
|
136 | } |
|
137 | ||
138 | /** |
|
139 | * Render a dummy element in the "Change payment method" form (that does not appear in the "Pay for order" form) |