How to update order status when payment completed using Direct Debit?

Hi Guys,

This article will showcase on updating order status when our webhook received paid_out or Confirmed status from the gocardless .

Note: This will be applicable if you are using WooCommerce gocardless plugins  on your WordPress environment.

//add gocardless pending submission status when direct debit payment is completed
add_filter( 'woocommerce_payment_complete_order_status_processing', 'update_gocardless_status_when_payment_complete' );

/**
* @param int $order_id order id
* @return string
*/
public function update_gocardless_status_when_payment_complete( $order_id ) {
    $order = wc_get_order( $order_id );
	$payment_gateway = $order->get_payment_method();
	if( "gocardless" === $payment_gateway ) {
		$order->set_status( 'completed' );
	  	$order->save();
	} 
}

Let me know if you have any question or queries, I would be more than happy to help you.

Thanks

Advertisements

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: