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

@@ 564-575 (lines=12) @@
561
			$maybe_saved_card = isset( $_POST['wc-stripe-new-payment-method'] ) && ! empty( $_POST['wc-stripe-new-payment-method'] );
562
563
			// This is true if the user wants to store the card to their account.
564
			if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_customer ) {
565
				$stripe_source = $stripe_customer->add_card( $stripe_token );
566
567
				if ( is_wp_error( $stripe_source ) ) {
568
					throw new Exception( $stripe_source->get_error_message() );
569
				}
570
			} else {
571
				// Not saving token, so don't define customer either.
572
				$stripe_source   = $stripe_token;
573
				$stripe_customer = false;
574
			}
575
		} elseif ( isset( $_POST['wc-stripe-payment-token'] ) && 'new' !== $_POST['wc-stripe-payment-token'] ) {
576
			// Use an existing token, and then process the payment
577
578
			$token_id = wc_clean( $_POST['wc-stripe-payment-token'] );