custom gateway process_payment(), still kills order when its empty_cart() remov
-
Hi there,
working on a custom gateway, where the /checkout url is used to process the payment as well. This is made via an I-Frame, I have extended the payment gateway fine and calls my overriding function process_payment()
The requirement on the checkout… (review-order.php)
1) on checkout confirm details
2) process payment – order id is created and the page refreshed – we get to this stage
3) $session = new WC_Session_Handler(); is called and checks if(isset($session->order_awaiting_payment)) to show the i-frame – this never happens because the session gets expunged during the processing stage.It also kills the cart and the page is left blank, even though this is also commented out on the extended process. Debugging is on and there is no reason it should exit
My function for the gateway override:
public function process_payment( $order_id ) { global $woocommerce; #$order = wc_create_order(); /// //// - temp ou $order = new WC_Order( $order_id ); $order = wc_get_order( $order_id ); // Mark as on-hold (we're awaiting the cheque) $order->update_status('on-hold', __( 'Awaiting Confirmation of Funds', 'woocommerce' )); // Reduce stock levels ///$order->reduce_order_stock(); // Remove cart ///$woocommerce->cart->empty_cart(); // Return thankyou redirect - override return array( 'refresh' => true, 'reload' => false, 'result' => 'success', 'redirect' => $this->get_return_url($order), 'mn' => 'return_order' ); // } As you can see the empty_cart is commented out but it still empties the cart. I have put the same question on Stack Overflow since October. in process_checkout() function
$result = $available_gateways[ $this->posted[‘payment_method’] ]->process_payment( $order_id );
After this order is created in the back-end but the session and the cart is dead.
Some things spring to mind.
Nonce is failing it and the cart throws an exception and kills it in the default function wc_clear_cart_after_payment()there is some-kind of abstraction going on.
Right now I have been battling away at this for months. It seems simple but it is not.
Can anyone please help, I would be very grateful.
Thanks
Andi
- The topic ‘custom gateway process_payment(), still kills order when its empty_cart() remov’ is closed to new replies.