| | |
| | | protected function initialize(): void |
| | | { |
| | | // TODO: Implement initialize() method. |
| | | add_action('woocommerce_review_order_before_submit', [$this, 'addToCheckout']); |
| | | add_action('wp_enqueue_scripts', [$this, 'enqueueOnCheckout']); |
| | | add_action('woocommerce_checkout_process', [$this, 'checkoutTurnstile']); |
| | | } |
| | | |
| | | public function getServiceDescription():string |
| | |
| | | } |
| | | return $result['success'] ?? false; |
| | | } |
| | | |
| | | public function enqueueOnCheckout():void |
| | | { |
| | | if (function_exists('is_checkout') && is_checkout()) { |
| | | self::enqueueTurnstileScripts(); |
| | | } |
| | | } |
| | | public function addToCheckout():void |
| | | { |
| | | self::renderTurnstile(); |
| | | } |
| | | public function checkoutTurnstile():void |
| | | { |
| | | $verified = $this->verifyTurnstile(); |
| | | if (!$verified && function_exists('wc_add_notice')) { |
| | | wc_add_notice('Security check failed. Please try again', 'error'); |
| | | return; |
| | | } |
| | | } |
| | | } |