---
page_title: Txns API
product: API Reference
page_source: https://juspay.io/in/docs/api-reference/docs/cred-pay/txns-api
openapi: https://juspay.io/in/docs/api/swagger?document=https%3A%2F%2Fjuspay.io%2Fin%2Fdocs%2Fapi-reference%2Fdocs%2Fcred-pay%2Ftxns-api
llms_txt: https://juspay.io/in/docs/llms.txt
product_llms_txt: https://juspay.io/in/docs/api-reference/llms.txt
---

## API Version: default


# Txns API



Once the order creation is completed and the user is redirected to the payment page and selects CRED Pay for the payment, the /txns api is to be called. The curl is given below for the reference.

> **Error**
> 1. Collect Request will be triggered to `sdk_pg_params.phoneNumber`
> 2. Kindly pass phoneNumber encrypted using RSA PKCS1 method with [public key](https://docs.juspay.in/api-reference/docs/cred-pay/cred-pay-setup#Public-Key-for-phone-number-encryption) of juspay and append “enc-” as prefix.



> **Note**
> When the credAppPresent is true then the merchant needs to fire the intent_url provided in the response, Merchant can write a custom logic like when checkout_mode is intent then fire intent url else load juspay’s authentication.url.
> 
> Please refer to the [set up page](https://docs.juspay.in/api-reference/docs/cred-pay/cred-pay-setup#Fire-Intent-URL) for more details.

## Endpoints:
- Sandbox: https://sandbox.juspay.in/txns

- Production: https://api.juspay.in/txns

## Request Type: 
POST

## Content-Type: 
application/json

## Headers:

#### Content-Type:
application/x-www-form-urlencoded
- Tags: String, Mandatory

#### x-routing-id:
We recommend passing the customer_id as the x-routing-id. If the customer is checking out as a guest, you can pass an alternative ID that helps track the payment session lifecycle. For example, this could be an Order ID or Cart ID.

> **Warning**
> This ID is associated with the customer. It plays a key role in ensuring consistency and maintaining connections across different systems. If you fail to pass the same x-routing-id for the same customer in all related API calls, it could lead to issues with API functionality. Therefore, it’s crucial that you use the same x-routing-id for all requests tied to the same customer.


- Value: customer_1122
- Tags: String, Required
## Sample Code Snippets:
### Sample Request:

#### Request Code Snippet:

```request
curl --location --request POST 'https://api.juspay.in/txns' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'x-routing-id: customer_1122'\
--data-urlencode 'order_id=test_1610009874' \
--data-urlencode 'merchant_id=Symbol' \
--data-urlencode 'payment_method_type=WALLET' \
--data-urlencode 'payment_method=CRED' \
--data-urlencode 'redirect_after_payment=true' \
--data-urlencode 'format=json' \
--data-urlencode 'sdk_params=true' \
--data-urlencode
'sdk_pg_params={"platform":"web","os":"macOS","device":"desktop","countryCode":"+91","phoneNumber":"enc-<encrypted phonenumber>","credAppPresent":false,"metadata": {"abc":"123","def":"456"}}'

```

### Sample Response:

#### Collect Response:
```json
{
    "txn_uuid": "eulz7iRV1E1EAUjSFKb",
    "txn_id": "Symbol-test_1610009874-17",
    "status": "PENDING_VBV",
    "payment": {
            "sdk_params": {
                    "status": "OK",
                    "error_code": null,
                    "response": {
                        "checkout_mode": "collect",
                        "state": "FLOW_TRIGGERED",
                        "layout": {
                            "icon":
                            "https://d1sofudel0ufia.cloudfront.net/assets/cred_brand_logo_bg_black.png"
                            ,
                            "banner_text": "CRED offers you the most rewarding experience, pay seamlessly using your CRED coins. #killthebill",
                            "sub_text": "pay seamlessly using your CRED coins. #killthebill",
                            "cta_text": "Pay with CRED",
                            "title": "Pay with CRED"
                        },
                        "tracking_id": "Symbol-test_1610009874-17",
                        "intent_url": null,
                        "reference_id": "99a897c7-aaa3-495e-962e-314a317c79d9"
                    },
                    "error_description": null,
                    "error_message": null
                },
                "authentication": {
                        "url":
                        "https://api.juspay.in/v2/pay/start/Symbol/eulz7iRV1E1EAUjSFKb",
                        "method": "GET"
                }
            },
            "order_id": "test_1610009874"
        }
                
```

#### Intent Response:
```plaintext
{
    "txn_uuid": "eulz456781E1EAUjSFKb",
    "txn_id": "Symbol-test_1610009874-17",
    "status": "PENDING_VBV",
    "payment": {
        "sdk_params": {
            "status": "OK",
            "response": {
                "intent_url": "credpay:\/\/checkout?ref_id=0e57fe61-0e1e-401f-33c22e559441&is_collect=false&redirect_to=com.mid.customer.cred%3A%2F%2F",
                "reference_id": "b224accf-4a7c-4ba0-ba98-ef0bf8d4b505",
                "state": "FLOW_TRIGGERED",
                "checkout_mode": "intent",
                "tracking_id": "mid-AF9B6DSDG64883-1",
                "layout": {
                    "icon": "https:\/\/d704ayip06922.cloudfront.net\/prod-rewards-assets-data\/8271e0702a8911ecb92ec74c5090c4d1.png",
                    "sub_text": "unlock rewards and extra cashback",
                    "banner_text": "CRED offers you the most rewarding experience, pay seamlessly using your CRED coins.",
                    "cta_text": "CRED pay",
                    "title": "CRED pay"
                }
            }
        },
        "authentication": {
            "url": "https:\/\/api.juspay.in\/v2\/pay\/start\/mid\/mozWsjZpkNtx2zMuibf?cardIssuerBankName%3DCRED%26cardType%3DWALLET%26paymentMethod%3DCRED%26paymentMethodType%3DWALLET",
            "method": "GET"
        }
    },
    "order_id": "test_1610009874"
}

```

## Body Parameters:
### Basic Parameters:

#### order_id:
- Description: Merchant should pass the order_id
- Value: value
- Tags: String, Mandatory

#### merchant_id:
- Description: Merchant should pass the merchant_id
- Tags: String, Mandatory

#### payment_method_type:
- Description: Should be passed as “WALLET”
- Tags: String, Mandatory

#### payment_method:
- Description: Should be passed as “CRED”
- Tags: String, Mandatory

#### redirect_after_payment:
- Description: Should be passed as true(boolean)
- Tags: String, Mandatory

#### format:
- Description: Should be passed as json
- Tags: String, Mandatory

#### sdk_params:
- Description: Should be passed as true(boolean)
- Tags: String, Mandatory

#### sdk_pg_params.platform:
- Description: Possible values: android, web
- Tags: String, Mandatory

#### sdk_pg_params.os:
- Description: Possible values: android, iOS, windows, linux, macOS, unknown 

Please contact juspay team if you are facing any concern around it 
- Tags: String, Mandatory

#### sdk_pg_params.device:
- Description: Possible values: mobile, iPAD, desktop, tablet, unknown 

Please contact juspay team if you are facing any concern around it
- Tags: String, Mandatory

#### sdk_pg_params.countryCode:
- Description: Exact country code to be passed, For indian number, please pass “+91”
- Tags: String, Mandatory

#### sdk_pg_params.phoneNumber:
- Description: Must be encrypted using [juspay public key](https://docs.juspay.in/api-reference/docs/cred-pay/cred-pay-setup#Public-Key-for-phone-number-encryption) with RSA PKCS1 Encryption 

Required to trigger a collect request when the flow is collect and auto-fill the number in CRED redirect page when the flow is REDIRECT
- Tags: String, Mandatory

#### sdk_pg_params.credAppPresent:
- Description: Merchant need to pass it as true/false(boolean) basis on cred app present
- Tags: String, Mandatory

#### sdk_pg_params.metadata:
- Description: It is a json object, Merchant can use it to send extra data to CRED
- Tags: String
## API Responses:
### 200:

#### txn_uuid:
- Tags: String

#### txn_id:
- Tags: String

#### status:
- Tags: String

#### payment:
- Value:
  - **Sdk_params**:
    - Value:
      - **Status**:
        - Tags: String
      - **Error_code**:
        - Tags: String
      - **Response**:
        - Value:
          - **Checkout_mode**:
            - Tags: String
          - **State**:
            - Tags: String
          - **Layout**:
            - Value:
              - **Icon**:
                - Tags: String
              - **Banner_text**:
                - Tags: String
              - **Sub_text**:
                - Tags: String
              - **Cta_text**:
                - Tags: String
              - **Title**:
                - Tags: String
            - Tags: object
          - **Tracking_id**:
            - Tags: String
          - **Intent_url**:
            - Tags: String
          - **Reference_id**:
            - Tags: String
        - Tags: object
      - **Error_description**:
        - Tags: String
      - **Error_message**:
        - Tags: String
    - Tags: Object
  - **Authentication**:
    - Value:
      - **Url**:
        - Tags: String
      - **Method**:
        - Tags: String
    - Tags: object
- Tags: object

#### order_id:
- Tags: String


---

## See Also

- [Create Order](https://juspay.io/in/docs/api-reference/docs/cred-pay/create-order)
- [Get Order Status](https://juspay.io/in/docs/api-reference/docs/cred-pay/get-order-status)
