| @@ 331-348 (lines=18) @@ | ||
| 328 | * @param $amount_to_charge float The amount to charge. |
|
| 329 | * @param $renewal_order WC_Order A WC_Order object created to record the renewal payment. |
|
| 330 | */ |
|
| 331 | public function scheduled_subscription_payment( $amount_to_charge, $renewal_order ) { |
|
| 332 | $response = $this->process_subscription_payment( $amount_to_charge, $renewal_order ); |
|
| 333 | ||
| 334 | if ( is_wp_error( $response ) ) { |
|
| 335 | /* translators: error message */ |
|
| 336 | $renewal_order->update_status( 'failed', sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) ); |
|
| 337 | } |
|
| 338 | ||
| 339 | if ( ! empty( $response->error ) ) { |
|
| 340 | // This is a very generic error to listen for but worth a retry before total fail. |
|
| 341 | if ( isset( $response->error->type ) && 'invalid_request_error' === $response->error->type && apply_filters( 'wc_stripe_use_default_customer_source', true ) ) { |
|
| 342 | $this->retry_subscription_payment( $amount_to_charge, $renewal_order ); |
|
| 343 | } else { |
|
| 344 | /* translators: error message */ |
|
| 345 | $renewal_order->update_status( 'failed', sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $response->error->message ) ); |
|
| 346 | } |
|
| 347 | } |
|
| 348 | } |
|
| 349 | ||
| 350 | /** |
|
| 351 | * Remove order meta |
|
| @@ 244-261 (lines=18) @@ | ||
| 241 | * @param $amount_to_charge float The amount to charge. |
|
| 242 | * @param $renewal_order WC_Order A WC_Order object created to record the renewal payment. |
|
| 243 | */ |
|
| 244 | public function scheduled_subscription_payment( $amount_to_charge, $renewal_order ) { |
|
| 245 | $response = $this->process_subscription_payment( $amount_to_charge, $renewal_order ); |
|
| 246 | ||
| 247 | if ( is_wp_error( $response ) ) { |
|
| 248 | /* translators: error message */ |
|
| 249 | $renewal_order->update_status( 'failed', sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) ); |
|
| 250 | } |
|
| 251 | ||
| 252 | if ( ! empty( $response->error ) ) { |
|
| 253 | // This is a very generic error to listen for but worth a retry before total fail. |
|
| 254 | if ( isset( $response->error->type ) && 'invalid_request_error' === $response->error->type && apply_filters( 'wc_stripe_use_default_customer_source', true ) ) { |
|
| 255 | $this->retry_subscription_payment( $amount_to_charge, $renewal_order ); |
|
| 256 | } else { |
|
| 257 | /* translators: error message */ |
|
| 258 | $renewal_order->update_status( 'failed', sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $response->error->message ) ); |
|
| 259 | } |
|
| 260 | } |
|
| 261 | } |
|
| 262 | ||
| 263 | /** |
|
| 264 | * Remove order meta |
|