Code Duplication    Length = 12-12 lines in 2 locations

includes/legacy/class-wc-gateway-stripe.php 1 location

@@ 367-378 (lines=12) @@
364
			$maybe_saved_card = isset( $_POST['wc-stripe-new-payment-method'] ) && ! empty( $_POST['wc-stripe-new-payment-method'] );
365
366
			// This is true if the user wants to store the card to their account.
367
			if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_customer ) {
368
				$stripe_source = $stripe_customer->add_card( $stripe_token );
369
370
				if ( is_wp_error( $stripe_source ) ) {
371
					throw new Exception( $stripe_source->get_error_message() );
372
				}
373
374
			} else {
375
				// Not saving token, so don't define customer either.
376
				$stripe_source   = $stripe_token;
377
				$stripe_customer = false;
378
			}
379
		}
380
381
		// Use an existing token, and then process the payment

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

@@ 649-660 (lines=12) @@
646
			$maybe_saved_card = isset( $_POST['wc-stripe-new-payment-method'] ) && ! empty( $_POST['wc-stripe-new-payment-method'] );
647
648
			// This is true if the user wants to store the card to their account.
649
			if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_customer ) {
650
				$stripe_source = $stripe_customer->add_card( $stripe_token );
651
652
				if ( is_wp_error( $stripe_source ) ) {
653
					throw new Exception( $stripe_source->get_error_message() );
654
				}
655
			} else {
656
				// Not saving token, so don't define customer either.
657
				$stripe_source   = $stripe_token;
658
				$stripe_customer = false;
659
			}
660
		} elseif ( isset( $_POST['wc-stripe-payment-token'] ) && 'new' !== $_POST['wc-stripe-payment-token'] ) {
661
			// Use an existing token, and then process the payment
662
663
			$token_id = wc_clean( $_POST['wc-stripe-payment-token'] );