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