> For the complete documentation index, see [llms.txt](https://docs.2checkout.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.2checkout.com/get-started-with-the-2checkout-api/get-started-with-the-2checkout-api/authentication-and-use-cases/2checkout-api-use-cases/payment-flow-with-2pay-token.md).

# Payment flow with 2Pay token

The 2Pay tokens generated using the 2Pay.js library can be used to place orders by following the same general flow as credit card orders (including the need and handling for the 3DS authorization process).

## Availability

Available to all 2Checkout accounts.

## Requirements

Using the 2Pay.js library requires a mandatory SAQ-A questionnaire to be filled in by merchants that have over 20,000 transactions per year. Below this threshold, the SAQ-A questionnaire is not mandatory but recommended.

## Payment method object structure

<table><thead><tr><th width="190.60009765625">Parameter</th><th>Type / Description</th></tr></thead><tbody><tr><td><code>EesToken</code></td><td><strong>Required (string)</strong><br>The 2Pay token obtained by integrating the 2Pay.js library.</td></tr><tr><td><code>Vendor3DSReturnURL</code></td><td><strong>Required (string)</strong><br>The URL address to which customers are redirected after the 3DS details get validated by the bank and the order is successfully authorized.</td></tr><tr><td><code>Vendor3DSCancelURL</code></td><td><strong>Required (string)</strong><br>The URL address to which customers are redirected if the 3DS details were not validated or the order could not be authorized.</td></tr></tbody></table>

### 2Pay token validity

The security limitations imposed on the 2Pay token are:

* 10-minute time limit - orders can only be placed within 10 minutes after the token has been generated
* One order per token - once a token has been used to place an order (be it successful or not), then this is flagged as used and cannot be used again to place an order (a new token needs to be generated).

## 2Pay payment flow

The sensitive information that otherwise would have to be passed in the `PaymentDetails` node:

```json
 "PaymentDetails": {
    "Type": "CC",
    "Currency": "USD",
    "PaymentMethod": {
      "CardNumber": "4111111111111111",
      "CardType": "VISA",
      "ExpirationYear": "2023",
      "ExpirationMonth": "12",
      "HolderName": "Red Doe",
      "CCID": "123",
      "Vendor3DSReturnURL": "http://yoursuccessurl.com",
      "Vendor3DSCancelURL": "http://yourcancelurl.com"
    }
```

are now replaced by a token generated by the 2Pay.js library.

```json
"PaymentDetails":{
      "Type":"EES_TOKEN_PAYMENT",
      "Currency":"USD",
      "PaymentMethod":{
         "EesToken":"0cd06e64-ea85-4240-88f1-ab0edc298f08",
         "Vendor3DSReturnURL":"https:\/\/example.com",
         "Vendor3DSCancelURL":"https:\/\/example.com"
      }
```

By replacing the sensitive information like the credit card details with a 2Pay token, the overhead generated by handling this sensitive information and the PCI compliance requirements are greatly reduced.

### Request sample

The full JSON used to place an order with credit cards would look like:

```json
{
   "Language":"en",
   "Country":"US",
   "CustomerIP":"10.10.10.10",
   "Source":"Website",
   "ExternalCustomerReference":"externalCustomerId",
   "Currency":"USD",
   "MachineId":"123456789",
   "Items":[
      {
         "Code": "5DCB30C6B0",
         "Quantity":1
      }
   ],
   "BillingDetails":{
      "FirstName":"Customer First Name",
      "LastName":"Customer Last Name",
      "CountryCode":"US",
      "State":"California",
      "City":"San Francisco",
      "Address1":"Example Street",
      "Zip":"90210",
      "Email":"example@email.com"
   },
   "PaymentDetails":{
      "Type":"EES_TOKEN_PAYMENT",
      "Currency":"USD",
      "PaymentMethod":{
         "EesToken":"0cd06e64-ea85-4240-88f1-ab0edc298f08",
         "Vendor3DSReturnURL":"https:\/\/example.com",
         "Vendor3DSCancelURL":"https:\/\/example.com"
      }
   }
}
```

## 3D Secure flow

For more information on the 3DS flow please refer to [this](/get-started-with-the-2checkout-api/get-started-with-the-2checkout-api/authentication-and-use-cases/2checkout-api-use-cases/3d-secure-flow.md) article.

## Integration test cases

Using the test credit cards available [here](/test-your-integration/test-your-integration/test-payment-methods.md), follow the next steps:

1. Build a request in order to place a new order, with all the relevant information. Make sure that when the order is sent in the API the response contains an order object (order was placed successfully)
2. Handle the 3DS flows, both when 3DS is mandatory (and the shopper needs to be redirected to authorize the transaction), as well as where this is not needed (order is created with status **AUTHRECEIVED** or **COMPLETE**)
3. If you have any additional webhook integrations, make sure that the webhooks are correctly configured and that the notifications are received and processed successfully.&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.2checkout.com/get-started-with-the-2checkout-api/get-started-with-the-2checkout-api/authentication-and-use-cases/2checkout-api-use-cases/payment-flow-with-2pay-token.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
