Refund a Card Payment
Localpayment enables you to process refunds for card payments, allowing you to return funds to customers' credit or debit cards through both API integration and the Dashboard interface. This guide covers the complete refund workflow for card transactions.
Before You Begin
Ensure you have:
Additional Refund Requirements:
- Sufficient balance in your Localpayment account to cover the refund amount.
- User role with refund permissions (see User Roles documentation).
- The original transaction must be in
Completedstatus. - The
externalIdof the original payment transaction.
Implementation Guide
Localpayment provides two methods for processing card refunds: API integration for automated processing and Dashboard for manual operations.
API Refund Processing
Programmatically process refunds through REST API for automated workflows and integration with your systems.
Dashboard Refund Processing
Manually process refunds through the Localpayment Dashboard with a user-friendly interface.
Direct Refunds for Card Payments
For card transactions, refunds are processed as Direct Refunds, meaning you only need the original transaction's externalId. No additional beneficiary or bank details are required since funds are returned to the original card used for payment.
Step 1: Process Refund via API
To refund a card payment through API, send aPATCH request to the Refund endpoint.
Key Request Parameters
The request requires several key parameters:
| Parameter | Description | Required |
|---|---|---|
externalId | The original transaction's externalId. | ✅ |
Example Request
Below is an example using curl:
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 API Credit Card"
}'See all available parameters in the request.
Step 2: Handle the Response
Successful Response
A successfully processed refund returns confirmation details:
{
"externalId": "d260ae17-0978-4429-bda1-8dfed9da6c6b",
"internalId": "53c91969-147e-4273-a659-ee5012ce9c83",
"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:
{
"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 |
Dashboard Refunds
Card refunds can also be processed through the Localpayment Dashboard 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 Dashboard, including step-by-step guidance and interface walkthroughs, please refer to the Dashboard Refunds Guide.
Approval Required: All refunds initiated through the Localpayment Dashboard require approval through the designated authorization workflow. Ensure you have the necessary user permissions before attempting Dashboard refunds.
Step 3: Track Refund Status
After initiating a refund, monitor its progress through these methods:
Webhooks (Recommended)
Receive real-time notifications when transaction status changes. Most efficient for production environments.
Status API Endpoint
Query transaction status programmatically. Useful for polling or recovering lost webhook notifications.
Dashboard View
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: For complete status code reference, see the Transaction Status documentation.
Testing Your Integration
Test Scenarios
Verify your integration handles these scenarios:
- Successful Refund: Process refund with valid
externalIdand sufficient funds. - Insufficient Funds: Attempt refund with inadequate account balance.
- Invalid Transaction: Try to refund non-existent
externalId. - Duplicate Refund: Attempt to refund already refunded transaction.
- Permission Validation: Test with users having different permission levels.
Next Steps
Updated about 10 hours ago
