| @@ 662-673 (lines=12) @@ | ||
| 659 | $maybe_saved_card = isset( $_POST['wc-stripe-new-payment-method'] ) && ! empty( $_POST['wc-stripe-new-payment-method'] ); |
|
| 660 | ||
| 661 | // This is true if the user wants to store the card to their account. |
|
| 662 | if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_customer ) { |
|
| 663 | $stripe_source = $stripe_customer->add_card( $stripe_token ); |
|
| 664 | ||
| 665 | if ( is_wp_error( $stripe_source ) ) { |
|
| 666 | throw new Exception( $stripe_source->get_error_message() ); |
|
| 667 | } |
|
| 668 | } else { |
|
| 669 | // Not saving token, so don't define customer either. |
|
| 670 | $stripe_source = $stripe_token; |
|
| 671 | $stripe_customer = false; |
|
| 672 | } |
|
| 673 | } elseif ( isset( $_POST['wc-stripe-payment-token'] ) && 'new' !== $_POST['wc-stripe-payment-token'] ) { |
|
| 674 | // Use an existing token, and then process the payment |
|
| 675 | ||
| 676 | $token_id = wc_clean( $_POST['wc-stripe-payment-token'] ); |
|
| @@ 369-380 (lines=12) @@ | ||
| 366 | $maybe_saved_card = isset( $_POST['wc-stripe-new-payment-method'] ) && ! empty( $_POST['wc-stripe-new-payment-method'] ); |
|
| 367 | ||
| 368 | // This is true if the user wants to store the card to their account. |
|
| 369 | if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_customer ) { |
|
| 370 | $stripe_source = $stripe_customer->add_card( $stripe_token ); |
|
| 371 | ||
| 372 | if ( is_wp_error( $stripe_source ) ) { |
|
| 373 | throw new Exception( $stripe_source->get_error_message() ); |
|
| 374 | } |
|
| 375 | ||
| 376 | } else { |
|
| 377 | // Not saving token, so don't define customer either. |
|
| 378 | $stripe_source = $stripe_token; |
|
| 379 | $stripe_customer = false; |
|
| 380 | } |
|
| 381 | } |
|
| 382 | ||
| 383 | // Use an existing token, and then process the payment |
|