# Refund a payment

Source: https://developers.swell.is/backend-api/payments/refund-a-payment

## Arguments

- `amount` (currency, required): Amount to refund up to payment `amount_refundable`.
- `method` (string): Optionally refund the payment using a different method. Defaults to the original payment method.
- `reason` (boolean): The reason of the refund.
- `reason_message` (string): A brief message describing the reason for the refund.

## Example request

`POST /payments/:id/refunds`

**cURL**

```bash
$ curl https://api.swell.store/payments/5cae685b20a54174dd968afa/refunds \
  -u store-id:secret-key \
  -d amount=50
```

**Node**

```javascript
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');

await swell.post('/payments/{id}/refunds', {
  id: '5cae685b20a54174dd968afa',
  amount: 50,
});
```

**PHP**

```php
<?php $swell = new \Swell\Client('store-id', 'secret-key');

$swell->post('/payments/{id}/refunds', [
  'id' => '5cae685b20a54174dd968afa',
  'amount' => 50
]);
```

## Example response

```json
{
  "id": "5cae042722984c53002096ab",
  "amount": 50,
  "card": {
    "brand": "Visa",
    "last4": "4242",
    "exp_month": 10,
    "exp_year": 2029,
    "token": "card_XfqLq5nRdOdu7vTvoeKufafN",
    "cvc_check": "pass",
    "zip_check": "pass",
    "address_check": "pass"
  },
  "currency": "USD",
  "date_created": "2019-04-01T00:00:00.000Z",
  "gateway": "stripe",
  "method": "card",
  "number": "103352",
  "order_id": "5cae685b20a54174dd968077",
  "parent_id": "5cae685b20a54174dd968afa",
  "status": "success",
  "success": true,
  "transaction_id": "re_1XNhqtFAeoMUkt5CitcnPNAa"
}
```
