'How to import global $woocommerce in Stripe's webhooks.php

I'm building Stripe based checkout and I want to create new order by using Woocommerce functions whenever 'payment_intent.succeeded' event happens. Problem is that global $woocommerce returns null. How do I import global $woocommerce successfully so that I can create orders programmatically?

I have tried importing wp-load.php file as mentioned in other threads with similar question, but that didn't seem to work.



Sources

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

Source: Stack Overflow

Solution Source