LLMS_Controller_Orders::confirm_pending_order()

Confirm order form post User clicks confirm order or gateway determines the order is confirmed


Description Description

Executes payment gateway confirm order method and completes order. Redirects user to appropriate page / post


Return Return

(void)


Top ↑

Source Source

File: includes/controllers/class.llms.controller.orders.php

	public function confirm_pending_order() {

		if ( 'POST' !== strtoupper( getenv( 'REQUEST_METHOD' ) ) || empty( $_POST['action'] ) || 'confirm_pending_order' !== $_POST['action'] || empty( $_POST['_wpnonce'] ) ) { return; }

		// nonce the post
		wp_verify_nonce( $_POST['_wpnonce'], 'confirm_pending_order' );

		// ensure we have an order key we can locate the order with
		$key = isset( $_POST['llms_order_key'] ) ? $_POST['llms_order_key'] : false;
		if ( ! $key ) {
			return llms_add_notice( __( 'Could not locate an order to confirm.', 'lifterlms' ), 'error' );
		}

		// lookup the order & return error if not found
		$order = llms_get_order_by_key( $key );
		if ( ! $order || ! $order instanceof LLMS_Order ) {
			return llms_add_notice( __( 'Could not locate an order to confirm.', 'lifterlms' ), 'error' );
		}

		// ensure the order is pending
		if ( 'llms-pending' !== $order->get( 'status' ) ) {
			return llms_add_notice( __( 'Only pending orders can be confirmed.', 'lifterlms' ), 'error' );
		}

		// get the gateway
		$gateway = LLMS()->payment_gateways()->get_gateway_by_id( $order->get( 'payment_gateway' ) );

		// pass the order to the gateway
		$gateway->confirm_pending_order( $order );

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.





Permalink: