Code Duplication    Length = 25-26 lines in 2 locations

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

@@ 282-306 (lines=25) @@
279
	 * @param WC_Subscription $subscription An instance of a subscription object
280
	 * @return array
281
	 */
282
	public function add_subscription_payment_meta( $payment_meta, $subscription ) {
283
		$source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_source_id', true );
284
285
		// For BW compat will remove in future.
286
		if ( empty( $source_id ) ) {
287
			$source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', true );
288
289
			// Take this opportunity to update the key name.
290
			WC_Stripe_Helper::is_pre_30() ? update_post_meta( $subscription->id, '_stripe_source_id', $source_id ) : update_post_meta( $subscription->get_id(), '_stripe_source_id', $source_id );
291
		}
292
293
		$payment_meta[ $this->id ] = array(
294
			'post_meta' => array(
295
				'_stripe_customer_id' => array(
296
					'value' => get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', true ),
297
					'label' => 'Stripe Customer ID',
298
				),
299
				'_stripe_source_id' => array(
300
					'value' => $source_id,
301
					'label' => 'Stripe Source ID',
302
				),
303
			),
304
		);
305
		return $payment_meta;
306
	}
307
308
	/**
309
	 * Validate the payment meta data required to process automatic recurring payments so that store managers can

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

@@ 352-377 (lines=26) @@
349
	 * @param WC_Subscription $subscription An instance of a subscription object
350
	 * @return array
351
	 */
352
	public function add_subscription_payment_meta( $payment_meta, $subscription ) {
353
		$source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_source_id', true );
354
355
		// For BW compat will remove in future.
356
		if ( empty( $source_id ) ) {
357
			$source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', true );
358
359
			// Take this opportunity to update the key name.
360
			WC_Stripe_Helper::is_pre_30() ? update_post_meta( $subscription->id, '_stripe_source_id', $source_id ) : update_post_meta( $subscription->get_id(), '_stripe_source_id', $source_id );
361
		}
362
363
		$payment_meta[ $this->id ] = array(
364
			'post_meta' => array(
365
				'_stripe_customer_id' => array(
366
					'value' => get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', true ),
367
					'label' => 'Stripe Customer ID',
368
				),
369
				'_stripe_source_id' => array(
370
					'value' => $source_id,
371
					'label' => 'Stripe Source ID',
372
				),
373
			),
374
		);
375
376
		return $payment_meta;
377
	}
378
379
	/**
380
	 * Validate the payment meta data required to process automatic recurring payments so that store managers can