PluginProbe
Pay with Vipps and MobilePay for WooCommerce / 6.3.1
Pay with Vipps and MobilePay for WooCommerce v6.3.1
6.3.1 6.2.6 6.3.0 6.2.5 6.2.4 6.2.3 6.2.2 6.2.1 6.2.0 6.1.10 6.1.9 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1.0 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 All 190 releases
← All changes | recurring/includes/wc-vipps-recurring-api.php +21 -4 6.1.7 → 6.3.1 View file →
@@ -542,12 +542,29 @@
542 542 if ( $status < 300 && $status > 199 ) {
543 543 return $body;
544 544 }
545 545
546 - // Rate limiting, temporary error
547 - if ( $status === 429 ) {
548 - $error_msg = __( "We hit Vipps/MobilePay's rate limit, we will retry later.", 'woo-vipps' );
549 - throw new WC_Vipps_Recurring_Temporary_Exception( $error_msg );
546 + // A transport error or a retryable HTTP response does not tell us whether a
547 + // state-changing request reached Vipps/MobilePay. Treat it as temporary so
548 + // callers can retry with the same idempotency key instead of failing the order.
549 + if ( $status === 0 || in_array( $status, [ 408, 425, 429 ], true ) || $status >= 500 ) {
550 + $error_msg = trim( (string) $default_error );
551 + if ( ! $error_msg ) {
552 + $error_msg = sprintf( 'HTTP %d', $status );
553 + }
554 +
555 + $localized_msg = __( 'Vipps/MobilePay is temporarily unavailable. Please try again.', 'woo-vipps' );
556 + if ( $status === 429 ) {
557 + $localized_msg = __( "We hit Vipps/MobilePay's rate limit. Please try again shortly.", 'woo-vipps' );
558 + }
559 +
560 + $log_body = is_array( $body ) ? json_encode( $body ) : $body;
561 + WC_Vipps_Recurring_Logger::log( sprintf( 'HTTP Response Temporary Error (%s): %s (%s) with request body: %s. The response was: %s', $status, $error_msg, $endpoint, $request_body, $log_body ) );
562 +
563 + $exception = new WC_Vipps_Recurring_Temporary_Exception( $error_msg, $localized_msg );
564 + $exception->response_code = $status;
565 +
566 + throw $exception;
550 567 }
551 568
552 569 // error handling
553 570 $error_msg = $default_error ?? '';