/** * Returns true if on the pay page and this is the currently selected gateway * * @since 1.0 * @return mixed true if on pay page and is currently selected gateways, false if on pay page and not the selected gateway, null otherwise */ public function is_pay_page_gateway() { if (SV_WC_Plugin_Compatibility::is_checkout_pay_page()) { $order_id = SV_WC_Plugin_Compatibility::get_checkout_pay_page_order_id(); if ($order_id) { $order = new WC_Order($order_id); return $order->payment_method == $this->get_id(); } } return null; }
/** * Force tokenization for pre-orders * * @since 1.0 * @see SV_WC_Payment_Gateway::tokenization_forced() * @param boolean $force_tokenization whether tokenization should be forced * @return boolean true if tokenization should be forced, false otherwise */ public function pre_orders_tokenization_forced($force_tokenization) { // pay page with pre-order? $pay_page_pre_order = false; if ($this->is_pay_page_gateway()) { $order_id = SV_WC_Plugin_Compatibility::get_checkout_pay_page_order_id(); if ($order_id) { $pay_page_pre_order = WC_Pre_Orders_Order::order_contains_pre_order($order_id) && WC_Pre_Orders_Product::product_is_charged_upon_release(WC_Pre_Orders_Order::get_pre_order_product($order_id)); } } if (WC_Pre_Orders_Cart::cart_contains_pre_order() && WC_Pre_Orders_Product::product_is_charged_upon_release(WC_Pre_Orders_Cart::get_pre_order_product()) || $pay_page_pre_order) { // always tokenize the card for pre-orders that are charged upon release $force_tokenization = true; } return $force_tokenization; }