# Merchant Payment Gateway

##

Our payment gateway is designed for businesses and merchants who are willing to receive payments in cryptocurrency. We provide API solutions for integrating our payment system on your website.&#x20;

Our system is suitable for applications from basic to advanced levels. CityPay payment gateway provides various capabilities from reading data to generating payment page.&#x20;

Our API provides these functionalities:

| API NAME                 | Description                                                |
| ------------------------ | ---------------------------------------------------------- |
| Create order             | Generates payments URL for your customer.                  |
| Get order information    | Lists all order for your user ID, or finds specific order. |
| Create deposit           | Generates payments URL for depositing cryptocurrency.      |
| Get payments information | Sends information about transactions.                      |
| Get IP addresses         | Sends CityPays IP addresses.                               |


# API Overview

## Overall Description

How API works:

1. Call [Create Order](/endpoint/create-order-1#documentation) API method to create an order in the CityPay system.&#x20;
2. CityPay checks validity of request by checking [authentication ](/introduction/api-authentication)parameters.
   * &#x20;If request is valid, CityPay responds with 200 HTTP status and returns payment URL. If you  receive 200 status, buyer should be redirected to payment URL.
   * &#x20;If request is not valid, CityPay returns [error ](/introduction/errors)HTTP statuses.
3. &#x20;After the buyer pays for the order,  CityPay will send [status ](/endpoint/order-status)code to your [callback URL](/endpoint/payment-callback).  If buyer cancels order CityPay will send status code to your callback URL.&#x20;

{% hint style="warning" %}
Please note that payment notifications are sent using **POST** method
{% endhint %}

## Limits and Quotas

| Type                  | **Description**                                                                                                                                                                                                                                                                                                                                                                     |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Orders                | <p> <strong>500 per hour per userid</strong> (contact support to increase)<br>This default value is the number of orders that can be created per hour. Reaching the limit will prevent further orders to be created before the hourly timer resets.</p>                                                                                                                             |
| Public API endpoints  | <p><strong>200 per minute and 10,000 per hour per IP address</strong><br>Applies to API methods that do not require authentication, such as Get Exchange Rate and List Exchange Rates (note that CoinGate exchange rates are updated every 60 seconds, therefore it is not recommended to call the API more often than every 60 seconds to retrieve the latest exchange rates).</p> |
| Private API endpoints | **200 per minute and 1,000 per hour per API App** (contact support to increase)                                                                                                                                                                                                                                                                                                     |

## API Requests

API Requests are used to query the CityPay API (examples: [Create Order](/endpoint/create-order-1), [Get Order](/endpoint/get-orders#getorder)).

API Request attributes:

* Action - Which API method was queried.
* Response - HTTP status returned by CityPay.
* Parameters - Parameters used to query the CityPay API.
* Response - Parameters returned by CityPay.

## Payment Callbacks&#x20;

Payment Callback is a response which includes information about recent payment and order status. Callbacks are sent by CityPay to indicated callback URL. Call back URL can be entered from CityPay user cabinet.

Payment Callback attributes:

* **Response Status** - HTTP status returned by merchant.
* **Response Data** - Data body returned by merchant.
* **Callback Params** - Parameters sent by CityPay to merchant's callback URL.


# API Authentication

To access API from your system you need to whitelist your IP and create access token. Use access token when sending call using [Create order ](/endpoint/create-order-1)or [Deposit ](/endpoint/deposite#create-deposite)methods.&#x20;

Authentication token are created from customer cabinet. Customer ID is displayed in customer cabinet, under company name.

To add an access token, follow the steps outlined below.

1. Navigate to the Products tab in the left sidebar of your dashboard.
2. Select the 'Order' option. In this section, you should find a table listing all existing access tokens.
3. Above this table, look for the 'add' button and click on it, which will bring up a form requiring the following details:
   * **Token Name**: This is simply a unique identifier for your access token.
   * **Token Type**: This is the payment method facilitated by the token, chosen from a dropdown menu. For example, if you want to use Binance Pay exclusively, ensure you've activated the auto-exchange feature from your dashboard first. Then, during the token creation process, select Binance Pay as the token type.
   * **Currency**: Any orders created using this token will default to this selected currency.
   * **IP Whitelist**: You'll need to specify the IP addresses that will be allowed to make requests. The system will filter requests based on these IPs.
   * **Callback URLs**: These are the URLs where you'll receive information about the order from Citypay. Make sure to specify all necessary callback URLs.
   * **Expiration Date**: This refers to the expiry date of the token, given in Unix timestamp format.

Follow these steps carefully to ensure the successful addition of a new access token to your account. After successfully creating the token, it's crucial that you copy and securely store it. Please note that the token will only be displayed once, and you won't be able to retrieve it again.


# Error Codes

CityPay API error responses

The most common API error code responses are described below.

Please note that error codes described bellow are general errors, for specific method errors see error responses for each method.

| HTTP Status                 | Reason              | Description                      |
| --------------------------- | ------------------- | -------------------------------- |
| 401 (Unauthorized)          | BadCredentials      | API credentials are not correct  |
| 404 (Not Found)             | PageNotFound        | Page, action or record not found |
| 404 (Not Found)             | RecordNotFound      | Record not found                 |
| 422 (Unprocessable Entity)  | UnsupportedInput    | API credentials are not valid    |
| 500 (Internal Server Error) | InternalServerError | Server error                     |

Response example:

JSON

```
{
    "status": "error",
    "status_code ": 404,
    "message": {
        "customer_id": "Invalid customer_id"
    }
}
```


# Create Order

## Description

The orders are placed using create order API method. Payment URL is generated after successful call. Buyer should be redirected to payment URL. On this page buyer can see the payment amount, select the desired payment currency and complete the payment.

## Create Order

<mark style="color:green;">`POST`</mark> `https://v2-listener.citypay.io/api/generateOrder`

#### Path Parameters

| Name          | Type    | Description                                  |
| ------------- | ------- | -------------------------------------------- |
| customer\_id  | string  | Your account's ID                            |
| access\_token | string  | Access token issued by CityPay               |
| order\_id     | integer | Order ID                                     |
| order\_token  | integer | Unique token for order given by you          |
| amount        | number  | The price set by the merchant in double type |

{% tabs %}
{% tab title="200 Order was successfully created " %}

```javascript
{
    "status": 1,
    "status_code ": 201,
    "message": {
        "id": 441,
        "payment_url": "https://v2-order.citypay.io/invoice?token=2334232323233232323",
        "token": "2334232323233232323"
    }
}
```

{% endtab %}

{% tab title="422 Invalid parameters" %}

```javascript
{
    "status": "error",
    "status_code ": 422,
    "message": {
        "amount": "The amount field is required."
    }
}
```

{% endtab %}
{% endtabs %}


# Get Order information

### Description

Get order method is used for searching a specific order by using its order token. &#x20;

## getOrder

<mark style="color:blue;">`GET`</mark> `https://v2-order-api.citypay.io/order/ordertoken/`

This method allows you to get Order information.

{% tabs %}
{% tab title="200 Order was successfully found." %}

```javascript
{
    "status": 1,
    "data": {
        "companyName": "Company",
        "id": 1893,
        "customerId": 099,
        "token": "ordertoken",
        "coin": "Bitcoin",
        "coinBaseName": "btc",
        "exchangeRate": 9205.6,
        "amountFiat": "100",
        "amount": 0.00000109,
        "dueDate": null,
        "currency": {
            "id": 2,
            "currency": "US Dollar",
            "abbreviation": "USD"
        },
        "createdAt": "2020-07-14 10:01",
        "createdAtMiliseconds": 1594718753000,
        "type": "Order",
        "expiresAt": 17991482,
        "expirationTime": 3600000,
        "email": null,
        "address": "3AxYawtkGxsnTfy6KxswzAFNDiGRuw1dH3",
        "status": {
            "code": "IN_PROGRESS",
            "label": "IN_PROGRESS"
        },
        "urls": {
            "cancelUrl": "https://citypay.io/access",
            "successUrl": "https://citypay.io/access",
            "callbackUrl": "https://citypay.io/access"
        },
        "transactions": 
        [
                      
         {
                "id": 957,
                "hash": "efda5c2e4c23949e9f823d5d158dccb2f263660251acef2330246cd2ca4f03ea",
                "hashUrl": "https://live.blockcypher.com/btc-testnet/tx/efda5c2e4c23949e9f823d5d158dccb2f263660251acef2330246cd2ca4f03ea",
                "amount": {
                    "base": 0.00006527,
                    "total": 0.00026108,
                    "underPaid": -0.00004368,
                    "overPaid": 0.00004368
                },
                "amountFiat": {
                    "base": "0.60",
                    "total": "2.40",
                    "underPaid": "-0.40",
                    "overPaid": "0.40"
                },
                "createdAt": "2020-07-14 08:29",
                "createdAtMiliseconds": 1594715393000
            },
            {
                "id": 958,
                "hash": "81b5bccf9d51bd69bac2c86209122ce6168af0060c6ff5d7eb1577dcba03894f",
                "hashUrl": "https://live.blockcypher.com/btc-testnet/tx/81b5bccf9d51bd69bac2c86209122ce6168af0060c6ff5d7eb1577dcba03894f",
                "amount": {
                    "base": 0.00006527,
                    "total": 0.00026108,
                    "underPaid": -0.00004368,
                    "overPaid": 0.00004368
                },
                "amountFiat": {
                    "base": "0.60",
                    "total": "2.40",
                    "underPaid": "-0.40",
                    "overPaid": "0.40"
                },
                "createdAt": "2020-07-14 08:37",
                "createdAtMiliseconds": 1594715828000
            },
            {
                "id": 959,
                "hash": "ac676c614681ad347c4089885723d0a1dfc706a194fa0b2d3430821400c98b11",
                "hashUrl": "https://live.blockcypher.com/btc-testnet/tx/ac676c614681ad347c4089885723d0a1dfc706a194fa0b2d3430821400c98b11",
                "amount": {
                    "base": 0.00006527,
                    "total": 0.00026108,
                    "underPaid": -0.00004368,
                    "overPaid": 0.00004368
                },
                "amountFiat": {
                    "base": "0.60",
                    "total": "2.40",
                    "underPaid": "-0.40",
                    "overPaid": "0.40"
                },
                "createdAt": "2020-07-14 08:49",
                "createdAtMiliseconds": 1594716578000
            },
            {
                "id": 960,
                "hash": "810341cce867b28793672303774fa2d5b6ea3c8772f09f27932ada08e4cfda3b",
                "hashUrl": "https://live.blockcypher.com/btc-testnet/tx/810341cce867b28793672303774fa2d5b6ea3c8772f09f27932ada08e4cfda3b",
                "amount": {
                    "base": 0.00006527,
                    "total": 0.00026108,
                    "underPaid": -0.00004368,
                    "overPaid": 0.00004368
                },
                "amountFiat": {
                    "base": "0.60",
                    "total": "2.40",
                    "underPaid": "-0.40",
                    "overPaid": "0.40"
                },
                "createdAt": "2020-07-14 08:57",
                "createdAtMiliseconds": 1594717028000
            }
        ]        
        
    }
}
```

{% endtab %}

{% tab title="404 Could not find an order." %}

```javascript
{
    "status": "error",
    "status_code ": 404,
    "message": {
        "order": "order not found"
    }
}
```

{% endtab %}
{% endtabs %}


# Deposit

### Description

The deposit page URL is generated by sending a call to create s deposit method. The payment URL is generated after a successful call. You should redirect the buyer to that payment URL. On this page, the buyer can see address, select the desired payment currency, and make transactions.

## Create Deposit

<mark style="color:green;">`POST`</mark> `https://v2-listener.citypay.io/api/generateDeposit`

This method allows you to create a deposit.

#### Path Parameters

| Name           | Type    | Description                                    |
| -------------- | ------- | ---------------------------------------------- |
| customer\_id   | string  | Your account's ID                              |
| access\_token  | string  | Token generated by CityPay for granting access |
| deposit\_id    | string  | Deposit ID                                     |
| deposit\_token | integer | Unique identification for your customer        |

{% tabs %}
{% tab title="200 Deposit was created" %}

```javascript
{
    "status": 1,
    "status_code ": 201,
    "message": {
        "id": 7,
        "payment_url": "https://v2-order.citypay.io/deposit?token=22332334232323232323",
        "token": "22332334232323232323"
    }
}
```

{% endtab %}

{% tab title="404 Customer not found" %}

```javascript
{
    "status": "error",
    "status_code ": 404,
    "message": {
         "message": "customer_id not found !"
    }
}
```

{% endtab %}
{% endtabs %}


# Order Status

### Description

The order statuses are returned by CityPay callback for identifying the current state of order in question.&#x20;

| Status           | Description                                                                            |
| ---------------- | -------------------------------------------------------------------------------------- |
| In-progress      | The buyer has opened the payment page and has selected cryptocurrency.                 |
| Paid/Unconfirmed | The buyer has fully paid the order amount, but six confirmations are not received yet. |
| Confirmed        | The buyer has fully paid the order amount and 5+ confirmations are received.           |
| Underpaid        | The buyer hasn't fully paid the order amount.                                          |
| Overpaid         | The buyer has paid more than the order amount.                                         |
| Expired          | The buyer did not pay any amount and the order time has expired.                       |
| Canceled         | The buyer has canceled the order by clicking on the cancel button.                     |

Statuses are received by payment callback. You can use them to determine whether a payment was received or not and what are its conditions. &#x20;

When the order is created you will receive a call from our [callback ](/endpoint/payment-callback#the-order-callback)service. the newly created orders have In-progress status. In-progress status remains unchanged until the order expires, or is paid/overpaid or is canceled.&#x20;

If your customer makes a payment you will receive a new call from our callback, with the indication of the corresponding status. If the status remains In-progress, that means that customer hasn't yet paid the full amount.&#x20;

You can determine order expiration or underpayment by calculating the expiration time using the call to the creation time.&#x20;


# Payment Callback

## Description

The callback URL will be used for sending updates and statuses of payments. The callback URL is indicated from the customer's cabinet on the configuration page.

### The order callback

The information about order status changes and new transactions will be sent to the callback URL.

{% hint style="warning" %}
&#x20;Callback data is sent in the **POST** method in JSON format.
{% endhint %}

CityPay callback sends data as it is described below:

| Name                        | Value                                                                                                    |
| --------------------------- | -------------------------------------------------------------------------------------------------------- |
| type                        | order callback                                                                                           |
| action                      | The information about the type of change: receive new transaction, order creation, receive confirmation. |
| status                      | CityPay Order [status ](/endpoint/order-status)for the moment you received the callback.                 |
| order\_id                   | Unique ID of order, given by CityPay.                                                                    |
| client\_order\_id           | Custom order ID of the merchant. Should be used to identify order or invoice number.                     |
| transaction\_id             | Transaction id of the last transaction of this order.                                                    |
| received\_amount\_in\_coins | Amount of the last transaction in coins                                                                  |
| received\_amount\_in\_fiat  | Amount of the last transaction in fiat                                                                   |
| fiat\_currency              | Order's fiat currency.                                                                                   |
| crypto\_currency            | Order's cryptocurrency.                                                                                  |
| created\_at                 | Invoice creation time.                                                                                   |
| order\_token                | Unique token created by the customer.                                                                    |
| order\_expiration           | The time in minutes from order creation to its expiration.                                               |
| exchange\_rate              | The exchange rate for the moment transaction was received                                                |

You will receive calls in the three cases. First when an order will be generated and currency is chosen. Second when payment is received, and third when the status is changed. Note you won't receive calls for expired status.

### The deposit callback

The information about deposit transactions and their confirmation status are sent using this callback.

| Name             | Value                                                                |
| ---------------- | -------------------------------------------------------------------- |
| type             | deposit callback                                                     |
| action           | receive\_transaction/confirmation                                    |
| transaction\_id  | unique identification of the transaction                             |
| received\_amount | the amount received during the transaction                           |
| status           | Pending (0-5 confirmations); Confirmed (5+ confirmations)            |
| crypto\_currency | cryptocurrency id                                                    |
| exchange\_rate   | The exchange rate at the moment of transactions                      |
| crated\_at       | date transaction was sent                                            |
| deposit\_token   | the unique string which is given by the customer to the transaction. |


# Exchange rates

Exchange rates API to get latest rates from CityPay

The instruction to get CityPay exchange rates are described in the link located below:

<https://markets-api.citypay.io/#/>


# IP Addresses

Get IP addresses of CityPay servers

### Description

To get callback calls from our IP address, you need to white list it in the first place. For this reason we created this method which can get CityPay IP addresses for you.&#x20;

## getServerIPS

<mark style="color:blue;">`GET`</mark> `https://api.citypay.io/api/generateAddress/getServerIPS`

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```javascript
{
    "51.28.22.114,35.156.68.160,31.156.140.163"
}
```

{% endtab %}
{% endtabs %}


# Sandbox

Guide for testing above listed endpoints

For testing, you will need to create a sandbox account on <https://test.citypay.io/>.

To test each endpoint you will need to add "test-" at the begging of all URLs. For example, if the endpoint URL is <https://v2-listener.citypay.io/> the sandbox URL would be [https://test-v2-listener.citypay.io/](https://v2-listener.citypay.io/)


# Log in

Use this method to authorize your requests

To obtain the access token, please visit citypay.io and create an access token on the products/order&#x20;

## Log in

<mark style="color:green;">`POST`</mark> `https://v2-order-api.citypay.io/orders/api/login/orders/api/login`&#x20;

#### Request Body

| Name  | Type   | Description                  |
| ----- | ------ | ---------------------------- |
| token | string | The string for authorization |

{% tabs %}
{% tab title="200 " %}

```
{
    "success": true,
    "data": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbiI6ImNjNzNlY2EyMmYwNTk2NTg5YWE0OGQ5Nzg2ZDNhNTgxIiwiaWF0IjoxNjE3Nzg2NTM1fQ.jrIgwkZtjVabi6g6lmFw5yXvnJL06bIVi6h43KVcIdY",
    "message": null
}
```

{% endtab %}
{% endtabs %}


# Generate Order

Use this endpoint to generate orders

## Create order

<mark style="color:green;">`POST`</mark> `https://v2-listener.citypay.io/api/generateOrder`

#### Request Body

| Name          | Type    | Description                        |
| ------------- | ------- | ---------------------------------- |
| customer\_id  | number  | Your user ID                       |
| access\_token | string  | The access token for authorization |
| order\_id     | string  | Order Id in your system            |
| order\_token  | string  | Random string                      |
| amount        | integer | The order amount                   |

{% tabs %}
{% tab title="200 " %}

```
{
    "success": true,
    "message": null,
    "data": {
        "id": 2876,
        "payment_url": "https://v2-order.citypay.io/order/token1",
        "token": "token1"
    }
}
```

{% endtab %}
{% endtabs %}


# Choose crypto

Use this method to chose the payment currency for your order

## Choose Crypto

<mark style="color:green;">`POST`</mark> `https://qa-v2-order-api.citypay.io/orders/api/:token`

#### Headers

| Name          | Type   | Description                             |
| ------------- | ------ | --------------------------------------- |
| bearer\_token | string | token is obtained from the login method |

#### Request Body

| Name | Type   | Description                   |
| ---- | ------ | ----------------------------- |
| coin | string | write the cypto currency code |

{% tabs %}
{% tab title="200 " %}

```
{
    "status": 1,
    "data": {
        "companyName": "Company 1",
        "id": 2876,
        "customerId": 115,
        "token": "token1",
        "coin": "Bitcoin",
        "coinBaseName": "btc",
        "exchangeRate": 50795.91,
        "amountFiat": "5.00",
        "amount": 0.00009843,
        "dueDate": null,
        "currency": {
            "id": 2,
            "currency": "US Dollar",
            "abbreviation": "USD"
        },
        "createdAt": "2021-04-07 09:15",
        "createdAtMiliseconds": 1617786773000,
        "type": "Order",
        "expiresAt": 1617790551102,
        "expirationTime": 3600102,
        "email": null,
        "address": "2N5FN3p5fT7mFzpDKXmuE9xxf2xBfzwuVWx",
        "qrCode": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKQAAACkCAYAAAAZtYVBAAAAAklEQVR4AewaftIAAAYgSURBVO3BQY4cy5LAQDLQ978yR0tfJZCoaineHzezP1jrEoe1LnJY6yKHtS5yWOsih7UucljrIoe1LnJY6yKHtS5yWOsih7UucljrIoe1LnJY6yKHtS7yw4dU/qaKf0nljYpJZap4Q+VJxaTyN1V84rDWRQ5rXeSw1kV++LKKb1J5ovKkYlKZKiaVqeKNiknlDZWp4knFGxXfpPJNh7UucljrIoe1LvLDL1N5o+KNiknlDZWp4knFb6r4m1TeqPhNh7UucljrIoe1LvLD/3MVk8pUMalMFZPKVDGpvKEyVfwvO6x1kcNaFzmsdZEf/uNUpopJZar4RMU3qUwVT1Smiv8lh7UucljrIoe1LvLDL6v4TRWTylQxqfymijcqnlRMKpPKVPFGxU0Oa13ksNZFDmtd5IcvU/mbVKaKSWWqmFSmikllqphUpopJZaqYVKaKSWWqmFTeULnZYa2LHNa6yGGti/zwoYp/qeJJxRsqn1CZKiaVqWJS+aaK/5LDWhc5rHWRw1oX+eFDKlPFpDJVTCpTxaQyVTxRmSomlaliUpkqJpVPVEwqTyomlW9SmSqeqEwV33RY6yKHtS5yWOsi9gcfUHlSMalMFW+ofKJiUpkqJpW/qWJSeaNiUnlSMak8qZhUpopPHNa6yGGtixzWusgPX1YxqXxC5Y2KSeUNlaniEypTxRsVT1QmlScVNzusdZHDWhc5rHWRH/6yikllqpgqJpU3KiaVqeINlTcqJpVPVDypmFSeqEwVT1R+02GtixzWushhrYvYH3xA5UnFpPKkYlJ5UvEvqXyiYlKZKt5QeaNiUpkqJpUnFZ84rHWRw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8UTlDZWp4psOa13ksNZFDmtd5IcvU/mbVN5QmSomlanijYonKlPFGypPKp6oTBWfUJkqPnFY6yKHtS5yWOsi9gdrXeKw1kUOa13ksNZFDmtd5LDWRQ5rXeSw1kUOa13ksNZFDmtd5LDWRQ5rXeSw1kUOa13ksNZF/g+ftRRAv2iUjgAAAABJRU5ErkJggg==",
        "status": {
            "code": "IN_PROGRESS",
            "label": "IN_PROGRESS"
        },
        "urls": {
            "callbackUrl": "https://qa.citypay.io/access",
            "successUrl": "https://qa.citypay.io/access",
            "cancelUrl": "https://qa.citypay.io/access"
        },
        "transactions": []
    }
}
```

{% endtab %}
{% endtabs %}


# Get Order

Use this method to get order information

## Get URL

<mark style="color:blue;">`GET`</mark> `https://v2-order-api.citypay.io/orders/api/:token`

This endpoint allows retrieving order information.

#### Headers

| Name          | Type   | Description                    |
| ------------- | ------ | ------------------------------ |
| bearer\_token | string | Use log in to get bearer token |

{% tabs %}
{% tab title="200 " %}

```
 “success”: true,
  “data”: {
    “companyName”: string,
    “id”: number,
    “customerId”: number,
    “token”: string,
    “coin”: null,
    “coinBaseName”: null,
    “exchangeRate”: null,
    “amountFiat”: string,
    “amount”: null,
    “dueDate”: null,
    “currency”: {
      “id”: number,
      “currency”: string,
      “abbreviation”: string
    },
    “createdAt”: date,
    “createdAtMiliseconds”: number,
    “type”: string,
    “expiresAt”: number,
    “expirationTime”: number,
    “email”: string,
    “qrCode”: string,
    “status”: {
      “code”: string,
      “label”: string
    },
    “coins”: [
      {
        “id”: number,
        “name”: string,
        “code”: string,
        “basename”: string
      }
    ],
    “urls”: {
      “callbackUrl”: string,
      “successUrl”: string,
      “cancelUrl”: string
    }
  },
  “message”: null
}
```

{% endtab %}
{% endtabs %}


# Update order rates

Use this method to get new exchange rates in every minute

## Update Exchange rate

<mark style="color:blue;">`GET`</mark> `https://v2-order-api.citypay.io/orders/api/:token/rates`

This method should be used when you need to update the exchange rates in UI, the exchange rates are updated every minute and after the new transaction.&#x20;

#### Headers

| Name          | Type   | Description                                  |
| ------------- | ------ | -------------------------------------------- |
| bearer\_token | string | The token is obtained from the log-in method |

{% tabs %}
{% tab title="200 " %}

```
{
    "success": true,
    "data": {
        "companyName": "company 1",
        "id": 2876,
        "customerId": 115,
        "token": "lasha2ssasa",
        "coin": "Bitcoin",
        "coinBaseName": "btc",
        "exchangeRate": 51052.068,
        "amountFiat": "5.00",
        "amount": 0.00009794,
        "dueDate": null,
        "currency": {
            "id": 2,
            "currency": "US Dollar",
            "abbreviation": "USD"
        },
        "createdAt": "2021-04-07 09:15",
        "createdAtMiliseconds": 1617786773000,
        "type": "Order",
        "expiresAt": 1617789766607,
        "expirationTime": 2815607,
        "email": null,
        "address": "2N5FN3p5fT7mFzpDKXmuE9xxf2xBfzwuVWx",
        "qrCode": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKQAAACkCAYAAAAZtYVBAAAAAklEQVR4AewaftIAAAZESURBVO3BQY4cSRLAQDLQ//8yV0c/JZCoam1o4Gb2B2td4rDWRQ5rXeSw1kUOa13ksNZFDmtd5LDWRQ5rXeSw1kUOa13ksNZFDmtd5LDWRQ5rXeSw1kV++JDK31TxRGWq+CaVNyomlaniDZUnFZPK31TxicNaFzmsdZHDWhf54csqvknljYonKlPFJyqeqEwVT1TeqHij4ptUvumw1kUOa13ksNZFfvhlKm9UfJPKVDGpTBWTylTxROWJypOKv0nljYrfdFjrIoe1LnJY6yI//MeoPFF5ojJVTCpTxZOKSWWqeKIyVfyXHda6yGGtixzWusgP/zEVT1SmijcqJpU3KiaVqWKqmFSmiv+Sw1oXOax1kcNaF/nhl1X8JpUnFU9U3qiYKiaVJyqfqJhUpoo3Km5yWOsih7UucljrIj98mcr/U8WkMlVMKlPFpPJEZaqYVKaKSeWJylTxCZWbHda6yGGtixzWusgPH6r4f6r4RMUnKiaVqeJJxaQyVXyi4l9yWOsih7UucljrIj98SGWqeKIyVUwqTyomlScVb6g8UXlS8f+kMlVMKlPFTQ5rXeSw1kUOa13E/uCL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PKn4xGGtixzWushhrYv88CGVv6liqphU3lB5UvFE5YnKVPGk4ptUpoonFW9UfNNhrYsc1rrIYa2L/PBlFd+k8kRlqnhS8QmVqWJSmSomlb+p4l9yWOsih7UucljrIj/8MpU3Kt6omFQ+UfGJiknlScWk8qRiUplU/mWHtS5yWOsih7Uu8sM/TmWqeENlUnlSMam8UfFGxRsVk8o3Vfymw1oXOax1kcNaF/nhH1cxqUwVn6j4TSpvqEwV/08qU8UnDmtd5LDWRQ5rXeSHX1bxN1U8UfmEyidU3lCZKp6oTBW/qeKbDmtd5LDWRQ5rXeSHL1P5m1TeqHiiMqk8qZhUpopJ5UnFGypTxaTypGJSmSomlanimw5rXeSw1kUOa13E/mCtSxzWushhrYsc1rrIYa2LHNa6yGGtixzWushhrYsc1rrIYa2LHNa6yGGtixzWushhrYsc1rrI/wCTSBF2AF2zAwAAAABJRU5ErkJggg==",
        "status": {
            "code": "IN_PROGRESS",
            "label": "IN_PROGRESS"
        },
        "urls": {
            "callbackUrl": "https://qa.citypay.io/access",
            "successUrl": "https://qa.citypay.io/access",
            "cancelUrl": "https://qa.citypay.io/access"
        },
        "transactions": []
    },
    "message": null
}
```

{% endtab %}
{% endtabs %}


# Get Order History

Use this method to get all orders created by the logged in user

## Get Orders

<mark style="color:blue;">`GET`</mark> `https://v2-order-api.citypay.io/orders/api`

#### Query Parameters

| Name  | Type   | Description                         |
| ----- | ------ | ----------------------------------- |
| page  | number | The page of the list                |
| limit | number | The number of the items on one page |

#### Headers

| Name          | Type   | Description          |
| ------------- | ------ | -------------------- |
| bearer\_token | string | Authentication token |

{% tabs %}
{% tab title="200 " %}

```
{
    "statusCode": 200,
    "data": {
        "items": [
            {
                "id": 2876,
                "token": "token 1",
                "createdAtMiliseconds": 1617786773000,
                "amount": "5.00",
                "status": {
                    "code": "IN_PROGRESS",
                    "label": "IN_PROGRESS"
                },
                "currency": {
                    "id": 2,
                    "currency": "US Dollar",
                    "abbreviation": "USD"
                }
            }
        ],
        "meta": {
            "totalCount": 1,
            "pagesCount": 1,
            "currentPage": 0,
            "nextPage": null
        }
    }
}
```

{% endtab %}
{% endtabs %}


