| @@ 634-636 (lines=3) @@ | ||
| 631 | if ( ( $user_id && $this->saved_cards && $maybe_saved_card && 'reusable' === $source_object->usage ) || $force_save_source ) { |
|
| 632 | $response = $customer->add_source( $source_object->id ); |
|
| 633 | ||
| 634 | if ( ! empty( $response->error ) ) { |
|
| 635 | throw new WC_Stripe_Exception( print_r( $response, true ), $this->get_localized_error_message_from_response( $response ) ); |
|
| 636 | } |
|
| 637 | } |
|
| 638 | } elseif ( $this->is_using_saved_payment_method() ) { |
|
| 639 | // Use an existing token, and then process the payment. |
|
| @@ 661-663 (lines=3) @@ | ||
| 658 | if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_save_source ) { |
|
| 659 | $response = $customer->add_source( $stripe_token ); |
|
| 660 | ||
| 661 | if ( ! empty( $response->error ) ) { |
|
| 662 | throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message ); |
|
| 663 | } |
|
| 664 | $source_id = $response; |
|
| 665 | } else { |
|
| 666 | $source_id = $stripe_token; |
|
| @@ 165-167 (lines=3) @@ | ||
| 162 | $args = $this->generate_customer_request( $args ); |
|
| 163 | $response = WC_Stripe_API::request( apply_filters( 'wc_stripe_create_customer_args', $args ), 'customers' ); |
|
| 164 | ||
| 165 | if ( ! empty( $response->error ) ) { |
|
| 166 | throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message ); |
|
| 167 | } |
|
| 168 | ||
| 169 | $this->set_id( $response->id ); |
|
| 170 | $this->clear_cache(); |
|