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

@@ 511-522 (lines=12) @@
508
			$maybe_saved_card = isset( $_POST['wc-stripe-new-payment-method'] ) && ! empty( $_POST['wc-stripe-new-payment-method'] );
509
510
			// This is true if the user wants to store the card to their account.
511
			if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_customer ) {
512
				$stripe_source = $stripe_customer->add_card( $stripe_token );
513
514
				if ( is_wp_error( $stripe_source ) ) {
515
					throw new Exception( $stripe_source->get_error_message() );
516
				}
517
518
			} else {
519
				// Not saving token, so don't define customer either.
520
				$stripe_source   = $stripe_token;
521
				$stripe_customer = false;
522
			}
523
		}
524
525
		// Use an existing token, and then process the payment