You can use a 2Pay.js token to place orders via APIv6 by following the flow below.
How to use a 2Pay.js token
Placing orders using 2Pay.js tokens in API works like a normal credit card order. Once a token has been obtained using the 2Pay.js library, this can be used to place an order by using API version 6.
In order to do this, the payment type used in the payment details of the placeOrder call must be EES_TOKEN_PAYMENT and the token must be specified in the payment method object.
// Order payment details $CartObj->PaymentDetails = new stdClass(); $CartObj->PaymentDetails->Type = "EES_TOKEN_PAYMENT"; $CartObj->PaymentDetails->Currency = $defaultCurr; $CartObj->PaymentDetails->CustomerIP = '220.127.116.11'; // Order payment method $CartObj->PaymentDetails->PaymentMethod = new stdClass(); $CartObj->PaymentDetails->PaymentMethod->EesToken = "cdefa07d-0595-4469-8aa8-c54d2edd445f"; $CartObj->PaymentDetails->PaymentMethod->Vendor3DSReturnURL = "https://example.com"; $CartObj->PaymentDetails->PaymentMethod->Vendor3DSCancelURL = "https://example.com";
If a token is invalid, then an HTTP 400 response containing the INVALID_EES_TOKEN error code is returned. In this case, a new token must be generated via the 2Pay.js library.
Once payment is placed successfully, then the standard processing flow of any credit card payment will continue. For transactions that require 3-D Secure for authorization, the standard flow needs to be followed; this can be found here.