| @@ 131-150 (lines=20) @@ | ||
| 128 | * @since 3.1.0 |
|
| 129 | * @version 4.0.0 |
|
| 130 | */ |
|
| 131 | public function save_source_to_order( $order, $source ) { |
|
| 132 | parent::save_source_to_order( $order, $source ); |
|
| 133 | ||
| 134 | $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
| 135 | ||
| 136 | // Also store it on the subscriptions being purchased or paid for in the order. |
|
| 137 | if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) { |
|
| 138 | $subscriptions = wcs_get_subscriptions_for_order( $order_id ); |
|
| 139 | } elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) { |
|
| 140 | $subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id ); |
|
| 141 | } else { |
|
| 142 | $subscriptions = array(); |
|
| 143 | } |
|
| 144 | ||
| 145 | foreach ( $subscriptions as $subscription ) { |
|
| 146 | $subscription_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id(); |
|
| 147 | update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer ); |
|
| 148 | update_post_meta( $subscription_id, '_stripe_source_id', $source->source ); |
|
| 149 | } |
|
| 150 | } |
|
| 151 | ||
| 152 | /** |
|
| 153 | * Process the payment based on type. |
|
| @@ 291-310 (lines=20) @@ | ||
| 288 | * @since 3.1.0 |
|
| 289 | * @version 4.0.0 |
|
| 290 | */ |
|
| 291 | public function save_source_to_order( $order, $source ) { |
|
| 292 | parent::save_source_to_order( $order, $source ); |
|
| 293 | ||
| 294 | $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
| 295 | ||
| 296 | // Also store it on the subscriptions being purchased or paid for in the order |
|
| 297 | if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) { |
|
| 298 | $subscriptions = wcs_get_subscriptions_for_order( $order_id ); |
|
| 299 | } elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) { |
|
| 300 | $subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id ); |
|
| 301 | } else { |
|
| 302 | $subscriptions = array(); |
|
| 303 | } |
|
| 304 | ||
| 305 | foreach ( $subscriptions as $subscription ) { |
|
| 306 | $subscription_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id(); |
|
| 307 | update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer ); |
|
| 308 | update_post_meta( $subscription_id, '_stripe_source_id', $source->source ); |
|
| 309 | } |
|
| 310 | } |
|
| 311 | ||
| 312 | /** |
|
| 313 | * Don't transfer Stripe customer/token meta to resubscribe orders. |
|