Nets Easy - Checkout Flow Logic
The checkout flow used for this plugin can result in Pending orders existing in WooCommerce, where the payment has not been finalized in Nets. This is part of the general WooCommerce checkout flow, and it does not implicate that something is wrong.
Two different flows
Nets Easy for WooCommerce has two different checkout flows. The Embedded checkout flow and the Redirect checkout flow. These two flows can be changed in the plugin settings.
- Embedded flow is a solution where Nets Easy is embedded in the WooCommerce checkout page and partially replaces the standard checkout page.
- Redirect flow is a traditional payment flow where the regular WooCommerce checkout page is used and the customer is redirected to a payment window hosted by Nets to finalize the purchase.
Embedded checkout flow
- Customer navigates to the checkout page in WooCommerce. If Nets Easy is the selected (or default) payment method, an initialize session request is sent to Nets.
- Nets responds with a paymentId that is used do display the embedded checkout (via JavaScript) on the WooCommerce checkout page.
- When the customer identify herself in the Nets Easy checkout, a JS event is triggered. The Nets Easy for WooCommerce plugin is listening for this event, updates the customer in WooCommerce and recalculates the cart. If anything changes (like the selected shipping method), an update checkout request is sent to Nets.
- When the customer clicks the Pay button in Nets Easy, a pay-initialized JavaScript event is triggered by Nets.
- The standard WooCommerce checkout form is submitted by the Nets Easy plugin, with customer data that we receive from Nets, and a pending order is created in WooCommerce. This order has not yet been paid for and you should not change the status to Processing/Completed manually.
- If the order creation went well, the Nets Easy plugin responds with a true message in the JavaScript event (if something went wrong during the order creation process the plugin will respond with a false message and Nets will not finalize the purchase. Instead an error notice will be displayed for the customer).
- Provided that the Nets Easy plugin respond with a true message, Nets then finalizes the purchase in their system.
- When the purchase is completed by the customer, a payment-completed JavaScript event is triggered by Nets.
- The Nets Easy plugin redirects the customer to the confirmation URL.
- The Nets Easy plugin confirms the WC order and trigger the WooCommerce function
$order->payment_complete()
. WooCommerce then decides if the order status should be set to Processing or Completed (depending on the types of items in the order). - The WooCommerce order received page is rendered and displayed for the customer.
Redirect checkout flow
- Customer navigates to the checkout page in WooCommerce and enter address information in the checkout form fields.
- Customer selects Nets Easy as payment method and clicks the Place order button.
- A pending order is created in WooCommerce.
- Customer is redirected to Nets Easy payment window.
- Customer completes the purchase and get redirected back to the store.
- The Nets Easy plugin confirms the WC order and trigger the WooCommerce function
$order->payment_complete()
. WooCommerce then decides if the order status should be set to Processing or Completed (depending on the types of items in the order). - The WooCommerce order received page is rendered and displayed for the customer.