---
page_source: https://docs.juspay.io/agoda-integration/docs/order/payments-api
page_title: Payments API
---

## API Version: default


# Payments API



This is a Server-to-Server API that takes order and payment instrument parameters as an input and creates an order in the Juspay system.

Amount and order id are the mandatory fields, the contact details like email, phone number, customer id's are conditional and depends on the underlying payment gateway/ aggregator used.  

'UDF' is used to pass any additional information that is required to be stored at Juspay for any analysis or other operations. In some cases, these UDFs are passed to the downstream gateways as well. 

Juspay supports 10 UDFs (UDF1 to UDF10). The values passed in UDFs are reflected back in the order status response and in webhooks back to the merchant. If there are any special characters that need to be passed in UDF values, please use UDF 6 to 10 for passing the same. UDF 1 to 5 can be used to pass values which do not have any special characters.

‘Metadata’ is used to send custom params to the payment aggregators, irrespective of default parameters, The supported parameters

Note: Auth api key should be Base64 encoded.## Endpoints:
- Production: https://api.juspay.in/orders

## Request Type: 
POST

## Content-Type: 
application/json

## Authorization:

#### Basic Auth:
Consists of two parts.

* Username: API Key obtained from Juspay dashboard
* Password: Empty string
- Value: <p>Example:- <br> Basic MUQ2QUxxxxxxxxxxxxU5QTIxQzNFNTQwNkFDMEZCOg==</p>
- Tags: Base64 Encoded username:password, required
## Headers:

#### x-merchantid:
Merchant ID provided by Juspay
- Value: <p>Example:- <br>merchant-id</p>
- Tags: string, required

#### version:
Pass the date in YYYY-MM-DD format
- Value: <p>Example:- <br>2023-01-01</p>
- Tags: string

#### Content-Type:
application/x-www-form-urlencoded
- Tags: String
## Sample Code Snippets:
### Sample Request:

#### Request Code Snippet:

```request
curl --location 'https://api.juspay.in/txns' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic xxx==' \
--data-urlencode 'merchant_id=:merchant_id' \
--data-urlencode 'payment_method_type=WALLET' \
--data-urlencode 'payment_method=GOPAY' \
--data-urlencode 'redirect_after_payment=true' \
--data-urlencode 'format=json' \
--data-urlencode 'order.order_id=:order_id' \
--data-urlencode 'order.amount=100' \
--data-urlencode 'order.currency=IDR' \
--data-urlencode 'order.customer_id=test123' \
--data-urlencode 'order.customer_phone=9164326296'

```

### Sample Response:

#### Example Response (Having POST As The Method):
```json
{
  "order_id": ":order_id",
  "txn_id": ":txn_id",
  "status": "PENDING_VBV",
  "payment": {
    "authentication": {
      "method": "POST",
      "url": "https://wallet-url.com/payment-path/start",
      "params": {
        "key1": "v1",
        "key2": "v2",
        "key3": "v3"
      }
    }
  }
}
```

#### Example Response (Having GET As The Method):
```json
{
  "order_id": ":order_id",
  "txn_id": ":txn_id",
  "status": "PENDING_VBV",
  "payment": {
    "authentication": {
      "method": "GET",
      "url": "https://wallet-url.com/payment-path/start?hello=world"
    }
  }
}

```

## Body Parameters:
### Parameters:

#### Order object:
- Description: [Order object](https://docs.juspay.in/api-reference-global/docs/order/order-object)``pertaining to the order you are creating. 
- Tags: string, Required

#### merchant_id:
- Description: ID of the merchant_account that you hold with us.
- Tags: string, Required

#### payment_method_type:
- Description: The actual payment_method_type that was selecetd by the user. You can refer each payment_method_type documentation to get the possible values.Payment_method_type can be `WALLET, CARD, NB`
- Tags: string, Required

#### payment_method:
- Description: The actual payment method that was selected by the user. You can refer each payment_method_type documentation to get the possible values.
- Tags: string, Required

#### redirect_after_payment:
- Description: This is a boolean variable and accepts true/false. We recommend that you set this to true. If set to `true`, then the user is redirected to the `return\_url` configured for the order. If set to `false`, then the user will be stopped at the response page from the gateway. Your client should be able to read the page/title to infer that the user has completed the transaction.
- Tags: string, Required

#### format:
- Description: If it is set to `json`, then the response will be HTTP 200 with a JSON formatted text. Otherwise, the response is HTTP 302 with the Location attribute having the destination URL.
- Tags: string, Required

#### order.currency:
- Description: ISO string of the currency. Default value: INR
- Tags: String, Required

#### payment_channel:
- Description: Allowed values = WEB, MWEB , ANDROID , IOS
- Tags: String
## API Responses:
### 200:

#### order_id:
- Description: :order_id
- Tags: string

#### txn_id:
- Description: :txn_id
- Tags: string

#### status:
- Description: PENDING_VBV
- Tags: string

#### payment:
- Value:
  - **Authentication.method**:
    - Tags: string
  - **Authentication.url**:
    - Tags: String
  - **Authentication.params**:
    - Description: Only when you have POST as the authentication method
    - Value:
      - **Key1**:
        - Tags: String
      - **Key2**:
        - Tags: String
      - **Key3**:
        - Tags: String
    - Tags: Object
- Tags: object
### 400:

#### status:
- Description: error
- Tags: string

#### error_message:
- Description: Order timed out
- Tags: string

#### error_code:
- Description: invalid_request
- Tags: string
