Support » Plugin: WooCommerce Stripe Payment Gateway » Checkout page shows unrelated error when payment fails

  • Resolved Sumit P

    (@sumit_p)


    Hi,

    First of all thank you so much for this plugin. It makes accepting payments using Stripe easy.

    I am experiencing an issue. Stripe Plugin redirects user to Checkout page when payment fails but checkout page shows this strange error “There are some issues with the items in your cart. Please go back to the cart page and resolve these issues before checking out.”
    Below this message, it shows ‘Return to Cart’ button.

    This error message is nowhere near to the failed payment problem. According to me, one of the two things should be done in order to provide better user experience.

    1. User should be kept on Order Received page. This is where Stripe by default redirects user to. WC’s Order received template handles the condition when the payment is failed and shows appropriate message.

    2. If user is being redirected to Checkout page, then proper checkout page should be loaded and at the top there should be a message informing the user that payment has been declined/failed. This will reduce the friction for user in terms of completing the order.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Sumit P

    (@sumit_p)

    I am thinking of modifying <em>includes/class-wc-stripe-order-handler.php</em> file and make following changes in process_redirect_payment method.

    OLD:

    catch ( WC_Stripe_Exception $e ) {
            WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
    
            do_action( 'wc_gateway_stripe_process_redirect_payment_error', $e, $order );
    
            /* translators: error message */
            $order->update_status( 'failed', sprintf( __( 'Stripe payment failed: %s', 'woocommerce-gateway-stripe' ), $e->getLocalizedMessage() ) );
    
            wc_add_notice( $e->getLocalizedMessage(), 'error' );
            wp_safe_redirect( wc_get_checkout_url() );
            exit;
    }
    

    NEW:

    
    catch ( WC_Stripe_Exception $e ) {
            WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
    
            do_action( 'wc_gateway_stripe_process_redirect_payment_error', $e, $order );
    
            /* translators: error message */
            $order->update_status( 'failed', sprintf( __( 'Stripe payment failed: %s', 'woocommerce-gateway-stripe' ), $e->getLocalizedMessage() ) );
    }
    

    Last three lines from old catch blocks are removed

    After making these changes, user stays on Order Received (aka Thank you) page and it shows message, ‘Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.’ Below this message it shows two buttons i.e. My Account and Pay.

    I am open for better options because I know there is a risk of changes getting wiped out when a plugin is updated in the future. Also, let me know if there are any other potential problems/risks with this solution.

    Plugin Support Doug – a11n

    (@dougaitken)

    Automattic Happiness Engineer

    Hey there @sumit_p

    Thanks for detailing out your scenario and the work you’ve done with this.

    There are some issues with the items in your cart. Please go back to the cart page and resolve these issues before checking out

    I don’t see that error message coming from the Stripe extension but rather this error comes from the core WooCommerce plugin.

    Can you walk me through how to replicate this error message and scenario, please? That will help me direct you to where to report this or how to resolve it.

    Thanks,

    Plugin Support Elvira K

    (@treibalen)

    Hi there @sumit_p,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Checkout page shows unrelated error when payment fails’ is closed to new replies.