| @@ 608-610 (lines=3) @@ | ||
| 605 | if ( ( $user_id && $this->saved_cards && $maybe_saved_card && 'reusable' === $source_object->usage ) || $force_save_source ) { |
|
| 606 | $response = $customer->add_source( $source_object->id ); |
|
| 607 | ||
| 608 | if ( ! empty( $response->error ) ) { |
|
| 609 | throw new WC_Stripe_Exception( print_r( $response, true ), $this->get_localized_error_message_from_response( $response ) ); |
|
| 610 | } |
|
| 611 | } |
|
| 612 | } elseif ( $this->is_using_saved_payment_method() ) { |
|
| 613 | // Use an existing token, and then process the payment. |
|
| @@ 635-637 (lines=3) @@ | ||
| 632 | if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_save_source ) { |
|
| 633 | $response = $customer->add_source( $stripe_token ); |
|
| 634 | ||
| 635 | if ( ! empty( $response->error ) ) { |
|
| 636 | throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message ); |
|
| 637 | } |
|
| 638 | } else { |
|
| 639 | $source_id = $stripe_token; |
|
| 640 | $is_token = true; |
|
| @@ 155-157 (lines=3) @@ | ||
| 152 | $args = $this->generate_customer_request( $args ); |
|
| 153 | $response = WC_Stripe_API::request( apply_filters( 'wc_stripe_create_customer_args', $args ), 'customers' ); |
|
| 154 | ||
| 155 | if ( ! empty( $response->error ) ) { |
|
| 156 | throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message ); |
|
| 157 | } |
|
| 158 | ||
| 159 | $this->set_id( $response->id ); |
|
| 160 | $this->clear_cache(); |
|