Code Duplication    Length = 20-20 lines in 2 locations

includes/compat/class-wc-stripe-compat.php 1 location

@@ 198-217 (lines=20) @@
195
	 * @since 3.1.0
196
	 * @version 4.0.0
197
	 */
198
	public function save_source_to_order( $order, $source ) {
199
		parent::save_source_to_order( $order, $source );
200
201
		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
202
203
		// Also store it on the subscriptions being purchased or paid for in the order
204
		if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) {
205
			$subscriptions = wcs_get_subscriptions_for_order( $order_id );
206
		} elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) {
207
			$subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id );
208
		} else {
209
			$subscriptions = array();
210
		}
211
212
		foreach ( $subscriptions as $subscription ) {
213
			$subscription_id = WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id();
214
			update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer );
215
			update_post_meta( $subscription_id, '_stripe_source_id', $source->source );
216
		}
217
	}
218
219
	/**
220
	 * Process_subscription_payment function.

includes/compat/class-wc-stripe-sepa-compat.php 1 location

@@ 112-131 (lines=20) @@
109
	 * @since 3.1.0
110
	 * @version 4.0.0
111
	 */
112
	public function save_source_to_order( $order, $source ) {
113
		parent::save_source_to_order( $order, $source );
114
115
		$order_id  = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
116
117
		// Also store it on the subscriptions being purchased or paid for in the order
118
		if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) {
119
			$subscriptions = wcs_get_subscriptions_for_order( $order_id );
120
		} elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) {
121
			$subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id );
122
		} else {
123
			$subscriptions = array();
124
		}
125
126
		foreach ( $subscriptions as $subscription ) {
127
			$subscription_id = WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id();
128
			update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer );
129
			update_post_meta( $subscription_id, '_stripe_source_id', $source->source );
130
		}
131
	}
132
133
	/**
134
	 * Process_subscription_payment function.