You should try woocommerce_checkout_process
action hook where the billing provider's API response, should return an error notice to reject and stop the checkout process…
This hook is located in WC_Checkout
process_checkout()
method and it's before the order creation. The data is accessible through $_POST
or through $posted_data = WC()->checkout->get_posted_data();
WC_Checkout
method.
Or woocommerce_checkout_order_processed
action hook where the order is already created (meaning that the order data is accessible through 3 arguments: $order_id
, $posted_data
and $order
) but before payment… To stop the process the billing provider's API response should: throw new Exception()
…
So anyway the solution is one of the WC_Checkout
available hooks…