> This is Payabli documentation. For a complete page index, fetch https://docs.payabli.com/llms.txt — append .md to any page URL for lightweight markdown. For section-level indexes, query parameters, and other AI-optimized access methods, see https://docs.payabli.com/ai-agents.md

# Refund transaction

GET https://api-sandbox.payabli.com/api/MoneyIn/refund/{transId}/{amount}

This endpoint is deprecated. Use it only to refund transactions originally created with the legacy endpoints. New integrations should use the [Refund endpoint](/developers/api-reference/moneyinV2/refund-a-settled-transaction), which only works on transactions created with [Make a transaction](/developers/api-reference/moneyinV2/make-a-transaction) or [Authorize](/developers/api-reference/moneyinV2/authorize-a-transaction).

Refund a transaction that has settled and send money back to the account holder. If a transaction hasn't been settled, void it instead.

Reference: https://docs.payabli.com/developers/api-reference/moneyin/refund-a-settled-transaction

## Authentication

- `Authorization` header (bearer token, required)
- `requestToken` header (required) — Long-lived API token sent in the `requestToken` header. See [API token authentication](/developers/api-tokens).

## Servers

- `https://api-sandbox.payabli.com/api` (Sandbox, default)
- `https://api.payabli.com/api` (Production)

## Request

### Path parameters

- `amount` (double, required) — Amount to refund from original transaction, minus any service fees charged on the original transaction. The amount provided can't be greater than the original total amount of the transaction, minus service fees. For example, if a transaction was \$90 plus a \$10 service fee, you can refund up to \$90. An amount equal to zero will refund the total amount authorized minus any service fee.
- `transId` (string, required) — ReferenceId for the transaction (PaymentId).

## Response

### 200

Ok

- `responseText` (string, required) — Response text for operation: 'Success' or 'Declined'.
- `isSuccess` (boolean, required) — Boolean indicating whether the operation was successful. A `true` value indicates success. A `false` value indicates failure.
- `responseData` (object, required)
  - `authCode` (string, required) — Authorization code for the transaction.
  - `expectedProcessingDateTime` (datetime, required, nullable) — The expected time that the refund will be processed.
  - `customerId` (long, required, nullable) — The Payabli-generated unique ID for the customer.
  - `cvvResponseText` (string, required, nullable) — This field isn't applicable to refund operations.
  - `methodReferenceId` (string, required, nullable) — This field isn't applicable to refund operations.
  - `referenceId` (string, required) — The transaction identifier in Payabli.
  - `resultCode` (integer, required) — Result code for the operation. Value `1` indicates a successful operation, values `2` and `3` indicate errors. A value of `10` indicates that an operation has been initiated and is pending.
  - `resultText` (string, required) — Text description of the transaction result
  - `avsResponseText` (string, optional) — This field isn't applicable to refund operations.
- `pageidentifier` (string, optional) — Auxiliary validation used internally by payment pages and components.

## Examples

**Response**

```json
{
  "responseText": "string",
  "isSuccess": true,
  "responseData": {
    "authCode": "string",
    "expectedProcessingDateTime": "2024-01-15T09:30:00Z",
    "customerId": 1,
    "cvvResponseText": "string",
    "methodReferenceId": "string",
    "referenceId": "string",
    "resultCode": 1,
    "resultText": "string",
    "avsResponseText": "string"
  },
  "pageidentifier": "string"
}
```

**SDK Code**

```typescript
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient({
        clientId: "YOUR_CLIENT_ID",
        clientSecret: "YOUR_CLIENT_SECRET",
    });
    await client.moneyIn.refund("transId", 1.1);
}
main();

```

```python
from payabli import payabli

client = payabli(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
)

client.money_in.refund(
    trans_id="transId",
    amount=1.1,
)

```

```java
package com.example.usage;

import io.github.payabli.api.PayabliApiClient;

public class Example {
    public static void main(String[] args) {
        PayabliApiClient client = PayabliApiClient.withCredentials("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")
            .build()
        ;

        client.moneyIn().refund("transId", 1.1);
    }
}
```

```ruby
require "payabli"

client = Payabli::Client.new(api_key: "YOUR_API_KEY_HERE")

client.money_in.refund(
  trans_id: "transId",
  amount: 1.1
)

```

```csharp
using PayabliApi;
using System.Threading.Tasks;

public partial class Examples
{
    public async Task Example() {
        var client = new PayabliApiClient(
            clientId: "YOUR_CLIENT_ID",
            clientSecret: "YOUR_CLIENT_SECRET"
        );

        await client.MoneyIn.RefundAsync(
            "transId",
            1.1
        );
    }

}

```

```go
package example

import (
    context "context"

    client "github.com/payabli/sdk-go/client"
    option "github.com/payabli/sdk-go/option"
)

func do() {
    client := client.NewClient(
        option.WithClientCredentials(
            "YOUR_CLIENT_ID",
            "YOUR_CLIENT_SECRET",
        ),
    )
    client.MoneyIn.Refund(
        context.TODO(),
        "transId",
        1.1,
    )
}

```

```php
<?php

namespace Example;

use Payabli\PayabliClient;

$client = new PayabliClient(
    clientId: 'YOUR_CLIENT_ID',
    clientSecret: 'YOUR_CLIENT_SECRET',
);
$client->moneyIn->refund(
    'transId',
    1.1,
);

```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/MoneyIn/refund/transId/1.1")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```