0

Our payment gateway and CRM and not supported by WooCommerce by default as a plugin, so I need to add custom code that sends data to our CRM and payment gateway whenever a customer places an order, then reject or accept the order depending on the payment gateway API response.

Where and how in the Woo code should I be intercepting the order submission?

1 Answer 1

0

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…

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.