phpwordpresspaypalwoocommercewoocommerce-bookings

WooCommerce Paypal Standard Gateway - IPN Received but order status stuck on 'processing'


I have a Wordpress setup with WooCommerce using the standard Paypal Gateway. Payments are being received and going through fine. Paypal IPN is being received by the site and marked as "Completed" for an order, but the order status remains unchanged in WooCommerce and still reads as "Processing".

10-04-2016 @ 11:04:18 - Received valid response from PayPal
10-04-2016 @ 11:04:18 - Found order #1303
10-04-2016 @ 11:04:18 - Payment status: completed

woocommerce order status

Other things entered into Paypal gateway settings:

Paypal Return URL:

Paypal Notification URL:

Other Related Woo Plugins installed:


I'm a little stumped as what else to try, as the IPN is obviously being recieved but for whatever reason the WooCommerce is not updating the order status with this information. There are some PHP Notices regarding unrelated points in other templates but not anything that should be interfering with WooCommerce. Any help or ideas to try would be much appreciated!


Solution

  • Thanks for the reply, I did see the auto complete plugin but the client In hand required this to be a manual method. I managed to figure out a method that works for Paypal standard payment, based off the below resource:

    http://codecharismatic.com/run-your-own-damn-code-after-paypal-calls-woocommerce-back/

    <?php
    /**
    * Auto Complete Woocommerce 'processing' orders
    */
    
    add_action( 'valid-paypal-standard-ipn-request', 'handle_paypal_ipn_response', 50, 1 );
    
    function handle_paypal_ipn_response( $formdata ) {
    
        if ( !empty( $formdata['invoice'] ) && !empty( $formdata['custom'] ) ) {
    
            if( $formdata['payment_status'] == 'Completed' ) {
    
                // decode data
                $order_data = json_decode($formdata['custom'], true);
    
                // get order
                $order_id = ($order_data) ? $order_data['order_id'] : '';
                $order = new WC_Order( $order_id );
    
                // got something to work with?
                if ( $order ) {
    
                    if ($order->post->post_status == 'wc-processing'){
    
                        // Status success
                            WC_Gateway_Paypal::log( 'Changing order #' . $order->id . ' status from processing to completed');
                          $order->update_status( 'completed' );
    
                    } else {
    
                        // Status fail
                            WC_Gateway_Paypal::log( 'Status fail, order #' . $order->id . ' status is set to ' . $order->post->post_status . ', not processing');
    
                    }
    
                } else {
    
                    // Order fail
                        WC_Gateway_Paypal::log( 'Fail, no order found');
    
                }
    
            } else {
    
                // Payment fail
                    WC_Gateway_Paypal::log( 'Payment status fail, not completed');
    
            }
        }
    
    
    }