---
page_source: https://docs.juspay.io/recon-and-settlement/docs/recon--settlement/payment-gateway-config
page_title: Payment Gateway Config
---


# **Configuration Guide** 



This guide helps you set up a **Payment Gateway Configuration**  for reconciling transaction data from those providers.The configuration ensures that uploaded PG files are correctly transformed, validated, and mapped to your database, covering **orders** , **refunds** , and **chargebacks**  (adjustments).


## PSP Config on Juspay Dashboard



[Video](https://dth95m2xtyv8v.cloudfront.net/tesseract/assets/dashboard/PSP%20Config.mov)




## **Configuration Breakdown:** 




### 1. Chargeback Configuration



In payment gateway reconciliation, **chargebacks**  (typically represented as adjustment entries in the settlement reports) need to be explicitly handled. These are not traditional payment or refund entries they're **disputes**  or **transaction reversals**  triggered post-settlement.

To ensure these records are properly accounted for during reconciliation, we define a configuration that enables the system to accurately detect, transform, and tag chargeback entries.


#### **1.1 Filters** 



This configuration applies to rows where the `type` field equals `"adjustment"`, indicating a chargeback.


#### Transaction Type: Adjustment Code Snippet:

```transaction type: adjustment
{
  "condition": "EQ",
  "field": "type",
  "value": "adjustment"
}

```



#### **1.2 Field Mapping** 



* Each configuration maps CSV column names to corresponding internal database field names.
  
  Eg: `fee_amount": "fee"`
  
  This means the `fee_amount` column in the CSV will be saved into the `fee` column in the database.


### 2. Global Configuration



`global_configuration:`**Add or Override Columns** 

Used to add or override columns such as `gateway`and `merchant_id` . If all transactions belong to the same merchant, this configuration ensures consistency across all records.

**What it does:** 

* Automatically adds or overrides two fields:
  
  * `gateway` is set to "`RAZORPAY`" for every row
  * `merchant_id` is set to "`reconDemo`"


### 3. Local Configuration



`local_configuration:`**Allows Processing Logic** 

This configuration section defines how to process different types of transactions such as `ORDER` and `REFUND` based on specific filter conditions.

* **Filters:** 
  
  Each block starts with a filter condition that determines which rows the configuration applies to.
  
  * **Configuration for** `ORDER`**Transactions:** 
    
    
    #### Transaction Type: Order Code Snippet:
    
    ```transaction type: order
    {
                  "condition": "EQ",
                  "field": "type",
                  "value": "payment"
               }
    
    ```
  * **Configuration for** `Refund`**Transactions:** 
    
    
    #### Transaction Type: Refund Code Snippet:
    
    ```transaction type: refund
    {
                  "condition": "EQ",
                  "field": "type",
                  "value": "refund"
               }
    ```


### 4. Validation



`validation:`**Ensuring Data Integrity** 

The validation section defines a set of **rules that your uploaded CSV data must pass**  before it's accepted for processing. These checks help ensure that the data is clean, complete, and correctly formatted.

When a file is uploaded, the system will automatically run the defined validations on the mapped columns from your CSV. If any of the validation checks fail, the corresponding row or file can be rejected, flagged, or corrected as per implementation.


#### **Validation Logic Breakdown** 




| Validation Type | Purpose |
|---|---|
| date_format_check | Validates date string format |
| duplicate_records_check | Ensures unique values for critical identifiers |
| nan_value_check | Ensures required fields are not empty or null |
| numeric_dtype_check | Confirms numeric fields contain valid numbers |
| pkey_check | Verifies uniqueness and presence for primary key field |
| scientific_value_check | Rejects exponential notation for consistency |


## Sample Code Snippets:
### Sample Code:

#### PSP Configuration Code Snippet:

```psp configuration
{
  "chargeback_configuration": [
     {
        "filters": [
           {
              "condition": "EQ",
              "field": "type",
              "value": "adjustment"
           }
        ],
        "mappings": {
           "dispute_id": "dispute_id",
           "entity": "entity_id",
           "fee_amount": "fee",
           "tax_amount": "tax",
           "txn_amount": "amount",
           "txn_date": "parsed_created_at",
           "txn_identifier": "order_id",
           "txn_status": "type"
        },
        "mutations": {
           "computations": [],
           "mutations": [
              {
                 "mutation_col": "txn_type",
                 "replacement": [
                    {
                       "filters": [],
                       "value": "CHARGEBACK"
                    }
                 ]
              }
           ]
        },
        "type": "CHARGEBACK"
     }
  ],
  "cluster": [
     "gateway"
  ],
  "global_configuration": {
     "mutations": {
        "computations": [],
        "mutations": [
           {
              "mutation_col": "gateway",
              "replacement": [
                 {
                    "filters": [],
                    "value": "RAZORPAY"
                 }
              ]
           },
           {
              "mutation_col": "merchant_id",
              "replacement": [
                 {
                    "filters": [],
                    "value": "reconDemo"
                 }
              ]
           }
        ]
     }
  },
  "local_configuration": [
     {
        "filters": [
           {
              "condition": "EQ",
              "field": "type",
              "value": "payment"
           }
        ],
        "mappings": {
           "fee": "fee",
           "payment_entity_txn_id": "entity_id",
           "payment_method": "method",
           "payment_method_type": "card_type",
           "settlement_amount": "parsed_credit",
           "settlement_currency": "settlement_currency",
           "settlement_date": "parsed_settled_at",
           "settlement_id": "settlement_id",
           "tax": "tax",
           "txn_amount": "amount",
           "txn_currency": "currency",
           "txn_date": "parsed_created_at",
           "txn_status": "type",
           "utr": "settlement_utr"
        },
        "mutations": {
           "computations": [],
           "mutations": [
              {
                 "mutation_col": "txn_type",
                 "replacement": [
                    {
                       "filters": [],
                       "value": "ORDER"
                    }
                 ]
              }
           ]
        },
        "type": "ORDER"
     },
     {
        "filters": [
           {
              "condition": "EQ",
              "field": "type",
              "value": "refund"
           }
        ],
        "mappings": {
           "fee": "fee",
           "payment_entity_txn_id": "entity_id",
           "payment_method": "method",
           "payment_method_type": "card_type",
           "settlement_amount": "parsed_debit",
           "settlement_currency": "settlement_currency",
           "settlement_date": "parsed_settled_at",
           "settlement_id": "settlement_id",
           "tax": "tax",
           "txn_amount": "amount",
           "txn_currency": "currency",
           "txn_date": "parsed_created_at",
           "txn_status": "type",
           "utr": "settlement_utr"
        },
        "mutations": {
           "computations": [],
           "mutations": [
              {
                 "mutation_col": "txn_type",
                 "replacement": [
                    {
                       "filters": [],
                       "value": "REFUND"
                    }
                 ]
              }
           ]
        },
        "type": "REFUND"
     }
  ],
  "preprocessing": false,
  "validation": {
     "check_fields": {
        "date_format_check": {
           "settlement_date": "%Y-%m-%dT%H:%M:%SZ",
           "txn_date": "%Y-%m-%dT%H:%M:%SZ"
        },
        "duplicate_records_check": [
           "payment_entity_txn_id",
           "txn_amount",
           "txn_date",
           "settlement_amount"
        ],
        "nan_value_check": [
           "payment_entity_txn_id",
           "txn_amount",
           "txn_date",
           "settlement_amount"
        ],
        "numeric_dtype_check": [
           "txn_amount",
           "settlement_amount"
        ],
        "pkey_check": [
           "payment_entity_txn_id"
        ],
        "scientific_value_check": [
           "payment_entity_txn_id",
           "txn_amount"
        ]
     },
     "checks": [
        "check_fields",
        "date_format_check",
        "nan_value_check",
        "numeric_dtype_check",
        "duplicate_records_check",
        "scientific_value_check",
        "pkey_check"
     ]
  }
}

```

