Code Duplication    Length = 20-20 lines in 2 locations

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.

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

@@ 180-199 (lines=20) @@
177
	 * @since 3.1.0
178
	 * @version 4.0.0
179
	 */
180
	public function save_source_to_order( $order, $source ) {
181
		parent::save_source_to_order( $order, $source );
182
183
		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
184
185
		// Also store it on the subscriptions being purchased or paid for in the order
186
		if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) {
187
			$subscriptions = wcs_get_subscriptions_for_order( $order_id );
188
		} elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) {
189
			$subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id );
190
		} else {
191
			$subscriptions = array();
192
		}
193
194
		foreach ( $subscriptions as $subscription ) {
195
			$subscription_id = WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id();
196
			update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer );
197
			update_post_meta( $subscription_id, '_stripe_source_id', $source->source );
198
		}
199
	}
200
201
	/**
202
	 * Process_subscription_payment function.