> For the complete documentation index, see [llms.txt](https://aplazo.gitbook.io/aplazo-integrations/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aplazo.gitbook.io/aplazo-integrations/api-reference/online-api/request-a-refund.md).

# Request a refund

## Environments

{% tabs %}
{% tab title="Development" %}
<https://merchant.aplazo.net/api>
{% endtab %}

{% tab title="Production" %}
<https://merchant.aplazo.mx/api/>
{% endtab %}
{% endtabs %}

## Request a refund for a specific cart

> Refunds can be partial or total but must be equal or less than the total loan amount.

```json
{"openapi":"3.0.3","info":{"title":"Aplazo Online API","version":"1.0.0"},"servers":[{"url":"https://merchant.aplazo.net/api"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}},"paths":{"/loan/refund-from-cart":{"post":{"summary":"Request a refund for a specific cart","description":"Refunds can be partial or total but must be equal or less than the total loan amount.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["cartId","totalAmount","reason"],"properties":{"cartId":{"type":"string","description":"The unique identifier of the cart associated with the loan."},"totalAmount":{"type":"number","description":"The amount to be refunded. Must be less than the total loan amount."},"reason":{"type":"string","description":"The reason for the refund."}}}}}},"responses":{"200":{"description":"Refund request was successfully created.","content":{"application/json":{"schema":{"type":"object","properties":{"refundId":{"type":"integer","description":"Aplazo identifier for the refund request."},"merchantId":{"type":"integer","description":"Aplazo merchant ID."},"cartId":{"type":"string","description":"Cart ID from the merchant system."},"refundStatus":{"type":"string","description":"Status of the refund.","enum":["REQUESTED","REJECTED","REFUNDED"]},"refundDate":{"type":"string","format":"date-time","description":"Timestamp when the refund was requested."}}}}}}},"tags":["Refunds"]}}}}
```

## Response Examples

### Success

<details>

<summary><mark style="color:green;">200</mark> - Successfully requested a refund</summary>

{% code overflow="wrap" %}

```bash
curl --location 'https://merchant.aplazo.net/api/loan/refund-from-cart' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token here>' \
--data '{    
    "cartId":  "3201" ,    
    "totalAmount": 150,    
    "reason":  "Wrong shoe size"
}'
```

{% endcode %}

```json
{
    "refundId": 25759,
    "merchantId": 2633,
    "cartId": "3201",
    "refundStatus": "REQUESTED",
    "refundDate": "2025-01-06T18:13:31.406721093"
}
```

</details>

### Errors

<details>

<summary><mark style="color:red;">500</mark> - Cart not found</summary>

{% code overflow="wrap" %}

```bash
curl --location 'https://merchant.aplazo.net/api/loan/refund-from-cart' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token here>' \
--data '{    
    "cartId":  "non-existant-cart" ,    
    "totalAmount": 150,    
    "reason":  "Refund_reason"
}'
```

{% endcode %}

```json
{
    "timestamp": "2025-01-06T18:20:20.811+00:00",
    "status": 500,
    "error": "Internal Server Error",
    "message": "",
    "path": "/api/loan/refund-from-cart"
}
```

</details>
