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

# Refund an APM Payment

Localpayment enables you to process refunds for Alternative Payment Methods (APMs) through both API integration and the Business Portal interface. This guide covers the complete refund workflow for APM transactions using the data-required refunds flow.

## Before You Begin

Ensure you have:

> [card] [API Credentials](https://docs.localpayment.com/docs/api-keys-and-environments.md)
>
> Valid API credentials and access token for authentication.

> [card] [Account Setup](https://docs.localpayment.com/docs/make-your-first-test-payment.md)
>
> Proper account setup for your target country and business verification.

> [card] [IP Whitelisting](https://docs.localpayment.com/docs/dashboard-whitelist-your-ips.md)
>
> Whitelist your server IP addresses for API access.

> [card] [Webhook Endpoint](https://docs.localpayment.com/docs/webhooks.md)
>
> Set up a webhook URL to receive payment notifications.

### Additional Refund Requirements:

* Sufficient balance in your Localpayment account to cover the refund amount.
* User role with refund permissions (see [User Roles](https://docs.localpayment.com/docs/user-roles-and-permissions.md) documentation).
* The original transaction must be in `Completed` status.
* The `externalId` of the original payment transaction.
* Complete beneficiary information for data-required refunds.

***

## Implementation Guide

Localpayment provides two methods for processing APM refunds: API integration for automated processing and Business Portal for manual operations.

> [card] [API Refund Processing](https://docs.localpayment.com/reference/refund-a-payin.md)
>
> Programmatically process refunds through REST API for automated workflows and integration with your systems.

> [card] [Business Portal Refund Processing](https://docs.localpayment.com/docs/dashboard-create-manual-refund.md)
>
> Manually process refunds through the Localpayment Business Portal with a user-friendly interface.
>
> **Note:** All Business Portal refunds require approval.

***

## Data-Required Refunds for APMs

APM refunds are processed as Data-Required Refunds, meaning you need both the original transaction's `externalId` and complete beneficiary information. Unlike direct refunds, this flow requires additional payer and bank details since QR payments involve specific beneficiary information that must be verified.

> [!WARNING]
>
> **Important**:
>
> Only full refunds are permitted for APM transactions. Partial refunds are not supported.

***

## Country-Specific Requirements

APM refunds have specific requirements and limitations depending on the country and payment method. Below are the key country-specific considerations:

> [tab] QR (Argentina)
>
> * **Refund Flow**: Data-required refunds with full beneficiary information.
> * **Document Types**: Supported Argentine document types (CUIL, DNI, etc.).
> * **Processing**: Refunds processed through local Argentine banking networks.

> [tab]

***

## Step 1: Process Refund via API

To refund a APM payment through API, send a `PATCH` request to the [Refund](https://docs.localpayment.com/reference/refund-a-payin.md) endpoint.

### Key Request Parameters

The request requires several key parameters:

| Parameter | Description | Required |
| - | - | - |
| `externalId` | The original transaction's externalId | ✅ |
| `comment` | Optional note about the refund reason | ❌ |
| `beneficiary` | Recipient details including bank information | ✅ |
| `beneficiary.type` | Beneficiary type (`INDIVIDUAL` or `COMPANY`) | ✅ |
| `beneficiary.name` | First name of the beneficiary | ✅ |
| `beneficiary.lastName` | Last name of the beneficiary | ✅ |
| `beneficiary.document.type` | Document type of the beneficiary | ✅ |
| `beneficiary.document.id` | Document ID of the beneficiary | ✅ |
| `beneficiary.bank.name` | Name of the beneficiary's bank | ✅ |
| `beneficiary.bank.code` | Bank code | ✅ |
| `beneficiary.bank.account.type` | Account type | ✅ |
| `beneficiary.bank.account.number` | Account number of the beneficiary | ✅ |

### Example Request

Below is an example using `curl`:

```bash curl theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl --request PATCH \
  --url 'https://api.stage.localpayment.com/api/payin/{{externalId}}/refund' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <your_access_token>' \
  --data '{
    "comment": "Refund APM",
    "beneficiary": {
      "type": "INDIVIDUAL",
      "name": "John",
      "lastName": "Doe",
      "document": {
        "type": "CUIL",
        "id": "20961504870"
      },
      "bank": {
        "name": "BANCO INDUSTRIAL S.A.",
        "code": "322",
        "account": {
          "type": "C",
          "number": "3220001805117354710015"
        }
      }
    }
  }'
```

See all [available parameters](https://docs.localpayment.com/reference/refund-a-payin.md) in the request.

***

## Step 2: Handle the Response

### Successful Response

A successfully processed refund returns confirmation details:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "externalId": "1c364061-1f3d-4b94-c270-bf915c22e8f5",
  "internalId": "8a9abd31-31e0-429a-32a6-cca8b9e1e536",
  "status": {
    "code": "902",
    "description": "REFUNDED",
    "detail": "The payin was refunded"
  }
}
```

### Key Response Fields

| Parameter | Description | Use Case |
| - | - | - |
| `externalId` | Your reference for the original transaction. | Reconciliation and tracking. |
| `internalId` | Localpayment's unique refund identifier. | Support and audit purposes. |
| `status.code` | Refund status code (`902` for successful refund). | Status monitoring. |

### Error Response

When a refund request fails, you'll receive error information:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "status": {
    "code": "400",
    "description": "ERROR",
    "detail": "Invalid operation"
  }
}
```

### Common Error Scenarios

| Error | Description | Solution |
| - | - | - |
| Insufficient Funds | Your Localpayment account balance is insufficient to cover the refund amount | Add funds to your Localpayment account or wait for pending settlements to clear |
| Transaction Not Found | The provided `externalId` does not exist or is invalid | Verify the externalId is correct and the transaction exists in your transaction history |
| Invalid Status | The original transaction is not in a refundable state (must be `Completed`) | Check the transaction status and ensure it has been successfully processed before attempting refund |
| Permission Denied | Your user role lacks necessary refund permissions | Contact your account administrator to grant appropriate refund permissions for your role |
| Duplicate Refund | Attempting to refund an already refunded transaction | Verify the transaction hasn't been refunded previously by checking the refund status |
| Invalid Amount | Attempting a partial refund when only full refunds are allowed | Process refund for the full transaction amount only |

***

## Business Portal Refunds

APM refunds can also be processed through the Localpayment Business Portal interface. This method provides a visual workflow for managing refunds and is particularly useful for:

* **Occasional refunds** that don't require API automation.
* **Administrative oversight** where approval workflows are needed.
* **Quick refund processing** without development resources.

For detailed instructions on processing refunds through the Business Portal, including step-by-step guidance and interface walkthroughs, please refer to the [Business Portal Refunds Guide](https://docs.localpayment.com/docs/dashboard-create-manual-refund.md) .

> [!WARNING]
>
> **Approval Required**:
>
> All refunds initiated through the Localpayment Business Portal require approval through the designated authorization workflow. Ensure you have the necessary user permissions before attempting Business Portal refunds.

***

## Step 3: Track Refund Status

After initiating a refund, monitor its progress through these methods:

> [card] [Webhooks (Recommended)](https://docs.localpayment.com/docs/webhooks.md)
>
> Receive real-time notifications when transaction status changes. Most efficient for production environments.

> [card] [Status API Endpoint](https://docs.localpayment.com/reference/get-transaction-status.md)
>
> Query transaction status programmatically. Useful for polling or recovering lost webhook notifications.

> [card] [Business Portal View](https://docs.localpayment.com/docs/dashboard-overview.md)
>
> Visual interface for monitoring transactions. Great for manual oversight and detailed transaction analysis.

### Common Refund Status Codes

| Code | Status | Description |
| :- | :- | :- |
| `400` | `ERROR` | Refund request failed due to validation errors or invalid parameters. |
| `902` | `REFUNDED` | The payin was successfully refunded. |

> [!NOTE]
>
> **Complete Reference**
>
> View all status codes in our [Transaction Status Documentation](https://docs.localpayment.com/reference/transaction-status-error-codes).

***

## Testing Your Integration

### Test Scenarios

Verify your integration handles these scenarios:

1. **Successful Refund**: Process refund with valid `externalId` and sufficient funds.
2. **Insufficient Funds**: Attempt refund with inadequate account balance.
3. **Invalid Transaction**: Try to refund non-existent `externalId`.
4. **Duplicate Refund**: Attempt to refund an already refunded transaction.
5. **Permission Validation**: Test with users having different permission levels.

***

## Next Steps

> [card] [View transaction status](https://docs.localpayment.com/reference/get-transaction-status.md)
>
> Check the current status of transactions and refunds using the Transaction
> Status API.

> [card] [Configure webhooks](https://docs.localpayment.com/docs/webhooks.md)
>
> Set up webhooks to receive real-time notifications for refund status
> changes.

> [card] [Review user roles](https://docs.localpayment.com/docs/user-roles-and-permissions.md)
>
> Manage user permissions and roles for refund processing capabilities.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.