> ## Documentation Index
> Fetch the complete documentation index at: https://knowledge.uportal360.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Return Payment Service

**Return Payment Service:**

* The return payment service is used to post reverse card and ACH transactions (This is a different service from API Return).
* This service handles single and bulk requests.
* The bulk request can be done through the `vf_bulkReturnPmt` :

<img src="https://mintcdn.com/uas-knowledge/8Q89_Tp4HGTyQ5PT/images/image-424.png?fit=max&auto=format&n=8Q89_Tp4HGTyQ5PT&q=85&s=c89ab37139aaeadb5e7eff2b22beed4c" alt="" width="939" height="495" data-path="images/image-424.png" />

The CSV file has to contain the following structure:

<img src="https://mintcdn.com/uas-knowledge/8Q89_Tp4HGTyQ5PT/images/image-426.png?fit=max&auto=format&n=8Q89_Tp4HGTyQ5PT&q=85&s=68157cfcb6eceb9ae9b6712a364da1e8" alt="" width="828" height="58" data-path="images/image-426.png" />

Obs - The chargeback and ACH have the same CSV structure, the only difference is that for ACH returns, the column New Transaction ID has to match the Trans ID column.

* The single transaction return can be done from the original transaction record:
* **Chargeback:** Click `Return PMT Apex` and the page below will be displayed:

<img src="https://mintcdn.com/uas-knowledge/8Q89_Tp4HGTyQ5PT/images/image-430.png?fit=max&auto=format&n=8Q89_Tp4HGTyQ5PT&q=85&s=dc9c3af7c3c0fc55cca258a17e58ad47" alt="" width="792" height="362" data-path="images/image-430.png" />

* **ACH:** Click `Return PMT Apex` and the page below will be displayed: <img src="https://mintcdn.com/uas-knowledge/8Q89_Tp4HGTyQ5PT/images/image-432.png?fit=max&auto=format&n=8Q89_Tp4HGTyQ5PT&q=85&s=8abfb78640df1ff2de6b6d1b53e09fb3" alt="" width="813" height="201" data-path="images/image-432.png" />

**LOGIC:**

1. **Finding the Original Payments:**

Using the original tran\_Id field, the query finds the original transactions that were processed in the past 60 days. The reason for the 60-day limit is to avoid any duplicate IDs being reversed from old transactions.

2. **Payment Gateway Code:**

The code will query the Payment Gateway Code object based on the reject code from the CSV file or dropdown selection on the vf page.

3. **Handling Loan Issues:**

**Closed Loans:** If a loan is closed (and the status is **not**`UAS - Transfer Account`), the method `reopenContract` in the `ContractService` class reopens the loan and creates the new statement.

**Transfer Account Loans:** If the loan status is `UAS - Transfer Account`, accounting needs to manually review the transaction and the contract.

4. **STMT Handling:** If a contract is in active status and does not have a current STMT, the method `createCurrentStmt` in the `contractService` class.
5. **Create Rev Transaction:**

The new return trans will be created based on the original transaction.

Based on the Payment Gateway Code, an NSF fee transaction will be created.

If needed, a reverse payment map will be created for the transaction.

6. **Create Case:**

The case will be created based on the Payment Gateway Code object, the `Create Case` field will either create a “Dispute” case or a “Chargeback” case.

7. **Buckets:**

After transactions are inserted, the `returnPaymentDlqEval` code will evaluate if a bucket is needed for the current STMT.

**Running Locally:**

POST request: [https://test-api.uportal360.com/reversePayment](https://test-api.uportal360.com/reversePayment)

Body:

```
{
    "records":
    [
        {
            "settlementDate":"2025-01-27",

            "rejectCode":"10.4",

            "partialAmount":null,

            "originalTransId":"3913077345",

            "newTransId":"CB02502640602",

            "amountToReverse":62.41
        }
    ]
}
```

**Things to look for:**

* Return code
* Original transaction processed date
* Return amount
* Possible duplicate trans ID

**Additional Services Used:**

* `contractService` : Used for reopening contracts and creating current statements.
* `pmtMapService` : Used for generating reverse payment maps.
* `returnPaymentDlqEval` : Used for triggering delinquency evaluation.

## History

| Change Date | Changed By        | Summary of Change |
| ----------- | ----------------- | ----------------- |
| 2025-02-06  | Felipe Dos Santos | Created Article   |
