Drupal 7 – How to set order complete with a JS response.

I have a checkout page with integration to Checkout.js.

I have set everything up so the user fills the form with informations such as credit card, name, email and this information is sent to checkout.js api.

After that the API responds with a payment_token and a redirect to a “/success” page. When this happens i want to set the order as complete.

How to set order complete with the JS response, how to reference to the correct order/shopping cart?

What is the best way to do this in Drupal 7 so that I wont have any security problems with it?

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed