Troubleshooting the Embedded checkout flow

Last modified:

The checkout flow in Nexi Checkout is constructed in a way that a WooCommerce order will be created first (in Pending status), then the Nexi order is placed, and finally the WooCommerce order is updated to Processing status. This flow is more compatible with other WooCommerce plugins.

This checkout flow also means that Pending orders can be visible in WooCommerce, where the payment has not been finalized in Nexi (for example card payment where there was not enough funds on the card). This is part of the general WooCommerce checkout flow, and it does not implicate that something is wrong. It is just a new scenario for the Nexi Checkout payment gateway.

I see pending orders in WooCommerce, is something wrong?

As mentioned above – you can have pending orders in WooCommerce with Nexi Checkout as the payment method without any errors in your store. These might just be orders not finalized by the customer.

However, if you want to troubleshoot this a bit closer, here’s how you do it.

  • Make sure that you have turned on Logging in the plugin settings.
  • The logs can be found by navigating to WooCommerce  Status  Logs.

Order creation step by step

Order creation step by step and how to debug and follow it in the log

Some of these events happen one time in the order creation, while others can happen multiple times. We have added a note to each event on whether you should expect to find it in the log once or several times.

1. Create order (POST)

"id":"nexi-order-id","type":"POST","title":"Create order"

When the customer first visits the checkout page, a new Nexi checkout session is created. This session will remain, and will be re-used until it has been cleared. Along with the session, a Nexi payment ID is created to identify this specific session.

Note that the “reference” (order reference) for the order is here set to “1”. This will be updated in step 13.

This event should happen once.

2. Address changed is triggered

"Frontend JS nexi-order-id: Address changed is triggered."

This event is triggered when a customer enters or updates the billing details in the Nexi iframe.

This event can happen more than once.

3. Get order admin (GET)

"id":"nexi-order-id","type":"GET","title":"Get order ( admin )"

Triggered whenever the “Pay” button is clicked in the Nexi iframe, as we attempt to retrieve the current order from Nexi. If the payment is either cancelled or fails, the event may be triggered again as the customer clicks the “Pay” button once again.

This event can happen more than once.

4. ProcessWooCheckout triggered and checkout form about to be submitted

"processWooCheckout triggered and checkout form about to be submitted for Nets payment ID nexi-order-id"

Triggered whenever a payment is initialized in the Nexi iframe by clicking the “Pay” button. If the payment is either cancelled or fails, the event may be triggered again as the customer clicks the “Pay” button once again.

This event can happen more than once.

5. Pay initialized is triggered

Frontend JS nexi-order-id: Pay initialized is triggered with payment id: nexi-order-id"

As the event above; triggered whenever a payment is initialized in the Nexi iframe by clicking the “Pay” button. If the payment is either cancelled or fails, the event may be triggered again as the customer clicks the “Pay” button once again.

This event can happen more than once.

6. Received customer data from Nets Easy

"Frontend JS nexi-order-id: Received "customer data" from Nets Easy"

This will be logged if the customer data has been successfully received from Nexi. As for the two previous events, if the payment is either cancelled or fails, the event may be triggered again as the customer clicks the “Pay” button once again.

This event can happen more than once.

7. Successfully placed order

"Frontend JS nexi-order-id: Successfully placed order."

This will be logged when the order is successfully submitted to Nexi. An order with the status of “pending payment” is now also created in WooCommerce.

The payment however is not completed at this stage, and as for the events above, this may be logged several times if the payment is either cancelled or fails, and the customer clicks the “Pay” button once again.

This event can happen more than once.

8. Payment created webhook listener hit

"Payment created webhook listener hit {\"id\":\"nexi-order-id\",\"merchantId\":merchant-id

This will be logged once, as your store receives a callback from Nets regarding a payment being created. An action is then scheduled that will further process the order (see step 14).

This event should happen once.

9. Confirmation endpoint hit for order

“order-id: Confirmation endpoint hit for order."

This event is triggered as the user is redirected to the order confirmation page. It will be triggered each time the confirmation page is navigated to or refreshed after that, as long as the needed identifying Nexi parameters are still included in the URL.

This event can happen more than once.

10. Confirm the Nexi order from the confirmation page

“order-id: Confirm the Nexi order from the confirmation page."

This event is triggered once as the confirmation page is first hit, and the order is confirmed in WooCommerce. The Nexi checkout session is then cleared.

This event should happen once.

11. Payment completed is triggered

"Frontend JS nexi-order-id: Payment completed is triggered with payment id: nexi-order-id"

An event triggered by Nexi, when the payment of the order is successfully completed.

This event should happen once.

12. Get order admin (GET)

"id":"nexi-order-id","type":"GET","title":"Get order ( admin )"

Logged as we get the order, to ensure it exists and no other errors are returned from Nexi before proceeding.

This event should happen once.

13. Update order reference

"id":"nexi-order-id","type":"PUT","title":"Update order reference"

This event is triggered once as the WooCommerce order is confirmed, and the Nexi order reference is updated.

This event should happen once.

14. Execute Payment created API callback

"Execute Payment created API callback. Payment ID:nexi-order-id. Order number: 1. Amount: order-amount"

This is logged as the scheduled payment created follow-up action (scheduled in step 8) is executed. After this, we’ll check if the order is already processed, or needs to be set to confirmed/completed.

This event should happen once.

15. Aborting Payment created API callback

"Aborting Payment created API callback. Order wc-order-id(order-id) already processed."

This is logged if the order is already confirmed in WooCommerce.

This event should happen once.

16. Order Management – Get order admin (GET)

"id":"nexi-order-id","type":"GET","title":"Get order ( admin )"

Logged as we attempt to get the order from Nexi in preparation of order activation, to make sure no errors are returned from Nexi and that the order is not already completed.

This event should happen once.

17. Order management – Activate order (POST)

"id":"nexi-order-id","type":"POST","title":"Activate order"

The order status in WC was set to “Completed”. We’ll issue a request to Nexi to update the order status to “Capture” in their system.

This event should happen once.

Additional Order Management logs

Cancel an order

1. Order Management – Get order admin (GET)

"id":"nexi-order-id","type":"GET","title":"Get order ( admin )"

Logged as we attempt to get the order from Nexi to confirm this as an existing order that isn’t already cancelled, before cancelling the order.

This event should happen once.

2. Order Management – Cancel order (POST)

"id":"nexi-order-id","type":"POST","title":"Cancel order"

The order status in WC was set to “Cancelled”. We’ll issue a request to Nexi to update the order status to “Reversal” in their system.

This event should happen once.

Refund an order

1. Order Management – Refund order (POST)

"id":null,"type":"POST","title":"Refund order"

The order status in WC was set to “Refunded” (fully or partially). We’ll issue a request to Nexi to update the order status to “Refund” in their system.

This event should happen once.

Errors that might happen

  1. Checkout error
    If the order creation didn’t go as expected you might see a Checkout error. This is caused by WooCommerce validation NOT being successful (e.g., coupon errors, subscription that require login or no stock). This should happen between step 5 and step 7.
  2. AJAX error
    If the order creation didn’t go as expected you might see a AJAX error in the log. If you see the AJAX error you need to talk to your developer or the support. This is most likely caused by a third party plugin, or other code. This should happen in step 5.

    An AJAX error can occur if the request to validate the Woo checkout fails to be sent or received. That is, the request is never sent, or a reply is never received. Unlike a checkout error, no validation has occurred. As a result of this, no Woo order will be created.

WooCommerce Subscriptions and recurring orders

When an initial subscription order is created the logs will be the same as for the Embedded flow above. The only difference is that the completePaymentButtonText is changed to “Subscribe” on the checkout page for subscription orders.

For more information on subscriptions with Nexi Checkout, please see the Nexi Checkout Subscription support section of this documentation.

Recurring token

When purchasing a subscription product the log will also create a subscription ID/recurring token in step 12. Get order admin (GET) in the order creation step by step guide. This token is added to the WooCommerce order.

The following will also be logged in step 12:

…"subscription\":{\"id\":\"your-subscription-id\"...

This request is made whenever Nexi notifies us about a change that occurred. We need to retrieve the updated form data from them in such cases. It’s important to note that this type of request can occur multiple times. 

Process Renewal order log flow

1. Charge subscription (POST)

"id":"nexi-order-id","type":"POST","title":"Charge subscription"

Logged as the charge of a scheduled subscription payment is sent to Nexi.

This event should happen once, at a given moment.

Change payment via the My Account page

1. Create order (POST)

"id":"nexi-order-id","type":"POST","title":"Create order"

A new zero amount order is created to update the payment method on the subscription.

This event should happen once.

Manage Subscription

When handling the subscription order via My account as a customer or via backend as an administrator, for example Suspend, Cancel, Reactivate or Change address on the subscription, nothing will be logged.