Setting up payment routing by item

---
tags: [route]
---

| Background                                                                                                                                                                                                                                                                                                                                                                                                               |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Before starting this tutorial, make sure you understand the following topics from the [Quick start](doc:quick-start) section:<ul style={{ marginTop: "-5px", marginBottom: "-5px" }}><li>[Sandbox environments](doc:sandbox-environments) (especially about testing).</li><li>[Authentication](doc:authentication) (about authenticating using your API user and when you need a login versus a one-time-use token).</li></ul> |

After you understand the complexities of payment routing by item (see [How do I route all transactions with a specific item to a relationship?](doc:how-do-i-route-all-transactions-with-a-specific-item-to-a-relationship)), you are ready to set it up.

**To set up payment routing by item**

1. Work with [Integrations Support](page:contact-us) to set up your Nexio account and merchant accounts (MIDs) so that they are optimized for payment routing by item.

   In general, this means having a single API user with a MID that contains the specific relationship (merchant account provider, processor, or acquirer/bank) that applies for the item routing as well as one or more additional relationships for cases where that item is not in the request.

2. Open the Nexio Dashboard and log in.\
   For the sandbox: [https://dashboard.nexiopaysandbox.com](https://dashboard.nexiopaysandbox.com)\
   For production: [https://dashboard.nexiopay.com](https://dashboard.nexiopay.com)

3. Navigate to **Settings > Payment Routing**.

   The tab shows user accounts and the types of rules.

4. Locate the user account that you want to add to or modify item routing rules for. Click that row in the table.

   The Payment Routing Rules page displays.

5. Click **Add New Rule**. 

   The **Add Routing Rule** dialog displays.

6. Select **Item Routing** as the rule type and then select the MID you want to add this rule to.

   For example, select MID #1.

7. Specify one or more attributes for the item routing rule. 

   For example, if you have a CBD item in your catalog (where `data.cart.items[n].item` contains the text 'CBD') and want to route any transactions with that item to a specific gateway that is associated with MID #1, do the following:

   **Example Rule 1a:** 

If Item Contains CBD


<br/>You may also want to add a second rule in case the text is lowercase:

**Example Rule 1b:**

If Item Contains cbd


<br/>Alternately, you can create only one rule if you use a regular expression that matches on the letters "cbd" in the item, regardless of the case of any of the letters, such as the following:

**Example Rule 2:**

If Item RegEx(ECMAScript) [c|C][b|B][d|D]


8. You can then add more attributes if you want. For a rule with multiple attributes, the system only matches when ALL the specified attributes match.

9. When you are done creating the rule, click **Save**.

10. For the transaction request, configure the API as follows.

 Each payment request must include the following parameters for item routing: 

 * `data.amount`
 * `data.currency`
 * `data.cart.items[n]`