'Display a order failed custom notice after redirecting back to checkout page in Wordpress plugin

I want to display a cancelled order custom notice as a strip on top of checkout page (like we generally see the order success message from Wordpress). I need to display When the customer is redirected back from the gateway page to checkout and there this notice should display "Sorry your order get failed for some reason! Please try again". I will attach a piece of code below for better understanding. enter image description here. Is there any single line code which we can include in between this code shown in image?

Please refer this article here Display a success custom notice after Placing an Order in WooCommerce

Note: I just need exact same thing for cancelled order. Please help anyone.

Update: Can someone please check why the code isn't displaying a failed order status in red strip? What did I missed? updated code below:

else if($Status=='05')   
{
     $result['result'] = 'denied';
     $order->update_status('Pending payment', "Payment Declined");
     $curl = home_url('/checkout');
     wp_redirect($curl);
     exit();
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source