> For the complete documentation index, see [llms.txt](https://moonie.gitbook.io/mooniepay/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://moonie.gitbook.io/mooniepay/payouts/retrieve-payout.md).

# Retrieve payout

Fetch the full details of an existing payout transaction. This endpoint returns the complete transaction object, including customer info, payment method, status, and your metadata.

***

### Endpoint

```
GET https://api.pay.movemoonie.com/v1/payouts/{transactionId}
```

***

### Path Parameter

| Parameter       | Description                                                                                |
| --------------- | ------------------------------------------------------------------------------------------ |
| `transactionId` | The MooniePay transaction ID (default) or your `external_id`. See `identifier_type` below. |

### Query Parameters

| Parameter         | Type     | Required | Description                                                                  |
| ----------------- | -------- | -------- | ---------------------------------------------------------------------------- |
| `identifier_type` | `string` | ❌        | How to look up the transaction. `transaction_id` (default) or `external_id`. |

#### Lookup by your own reference

If you stored your own `external_id` When initiating the payment, you can retrieve the transaction using it directly:

```
GET /v1/payouts/ORD-9876?identifier_type=external_id
```

***

### Code Examples

{% tabs %}
{% tab title="PHP" %}

```php
<?php

$publicKey      = 'pk_sandbox_payout_xxxxxxxxxxxx';
$secretKey      = 'your_secret_key_here';
$environment    = 'sandbox';
$timestamp      = time();
$transactionId  = 'TExxxxxxxxxxxx';

$method = 'GET';
$path   = "/v1/payouts/{$transactionId}";
$payload = ''; // GET — no body

$stringToSign = "{$publicKey}.{$timestamp}.{$method}.{$path}.{$payload}";
$signature    = hash_hmac('sha256', $stringToSign, $secretKey);

$ch = curl_init("https://api.pay.movemoonie.com{$path}");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        "Authorization: {$publicKey}",
        "X-TTUM-Timestamp: {$timestamp}",
        "X-TTUM-Signature: {$signature}",
        "X-TTUM-Environment: {$environment}",
    ],
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
```

{% endtab %}

{% tab title="Node.Js" %}

```javascript
const crypto = require('crypto');
const https  = require('https');

const publicKey     = 'pk_sandbox_payout_xxxxxxxxxxxx';
const secretKey     = 'your_secret_key_here';
const environment   = 'sandbox';
const timestamp     = Math.floor(Date.now() / 1000);
const transactionId = 'TExxxxxxxxxxxx';

const method  = 'GET';
const path    = `/v1/payouts/${transactionId}`;
const payload = '';

const stringToSign = `${publicKey}.${timestamp}.${method}.${path}.${payload}`;
const signature    = crypto.createHmac('sha256', secretKey).update(stringToSign).digest('hex');

https.get({
  hostname: 'api.pay.movemoonie.com', path,
  headers: {
    'Authorization': publicKey, 'X-TTUM-Timestamp': timestamp.toString(),
    'X-TTUM-Signature': signature, 'X-TTUM-Environment': environment,
  },
}, (res) => {
  let data = '';
  res.on('data', chunk => data += chunk);
  res.on('end', () => console.log(JSON.parse(data)));
});
```

{% endtab %}

{% tab title="Python" %}

```python
import hmac, hashlib, time, requests

public_key     = 'pk_sandbox_payout_xxxxxxxxxxxx'
secret_key     = 'your_secret_key_here'
environment    = 'sandbox'
timestamp      = int(time.time())
transaction_id = 'TExxxxxxxxxxxx'

method  = 'GET'
path    = f'/v1/payouts/{transaction_id}'
payload = ''

string_to_sign = f"{public_key}.{timestamp}.{method}.{path}.{payload}"
signature = hmac.new(secret_key.encode(), string_to_sign.encode(), hashlib.sha256).hexdigest()

response = requests.get(
    f'https://api.pay.movemoonie.com{path}',
    headers={
        'Authorization': public_key, 'X-TTUM-Timestamp': str(timestamp),
        'X-TTUM-Signature': signature, 'X-TTUM-Environment': environment,
    }
)
print(response.json())
```

{% endtab %}

{% tab title="cURL" %}

```shellscript
PUBLIC_KEY="pk_sandbox_payout_xxxxxxxxxxxx"
SECRET_KEY="your_secret_key_here"
ENVIRONMENT="sandbox"
TIMESTAMP=$(date +%s)
TRANSACTION_ID="TESxxxxxxxxxxxx"
METHOD="GET"
PATH="/v1/payouts/${TRANSACTION_ID}"

STRING_TO_SIGN="${PUBLIC_KEY}.${TIMESTAMP}.${METHOD}.${PATH}."
SIGNATURE=$(echo -n "$STRING_TO_SIGN" | openssl dgst -sha256 -hmac "$SECRET_KEY" | awk '{print $2}')

curl "https://api.pay.movemoonie.com${PATH}" \
  -H "Authorization: $PUBLIC_KEY" \
  -H "X-TTUM-Timestamp: $TIMESTAMP" \
  -H "X-TTUM-Signature: $SIGNATURE" \
  -H "X-TTUM-Environment: $ENVIRONMENT"
```

{% endtab %}
{% endtabs %}

***

### Response

#### Success — `200 OK`

This endpoint returns the **full transaction object**, including `fee`, `net_amount`, and `application` details that are not included in the initiate response.

```json
{
  "success": true,
  "data": {
    "transaction_id": "TE_XXXXXXXXXXXXXXX",
    "ref": "f83a0235-892b-44c0-bad5-a4e8f32ceb3d",
    "external_id": "your_mechant_transaction_id",
    "type": "payout",
    "status": "completed",
    "amount": 5000,
    "currency": "XAF",
    "description": "Order #1234 payment",
    "account_name": "Jane Doe",
    "account_number": "6XXXXXXX",
    "account_type": "mobile_money",
    "reason": null,
    "failed_code": null,
    "failed_at": null,
    "cancelled_at": null,
    "completed_at": "2024-06-10T12:00:05.000000Z",
    "customer": {
      "ref": "cus_ref_xxxxxxxx",
      "first_name": "Jane",
      "last_name": "Doe",
      "email": "jane@example.com",
      "metadata": {
        "user_id": "42"
      }
    },
    "payment_method": {
      "ref": "f83a0235-892b-44c0-bad5-a4e8f32ceb3d",
      "name": "MTN Mobile Money",
      "code": "MOMO_CM"
    },
    "metadata": {
      "order_id": "ORD-9876",
      "user_id": "42"
    },
    "created_at": "2024-06-10T12:00:00.000000Z",
    "updated_at": "2024-06-10T12:00:05.000000Z",
    "fee": 100,
    "net_amount": 4900,
    "fee_payer": "merchant",
    "application": {
      "id": "app_xxxxxxxx",
      "ref": "app_ref_xxxxxxxx",
      "name": "My Store"
    }
  }
}
```

#### Error Responses

| HTTP  | Code               | Reason                                                |
| ----- | ------------------ | ----------------------------------------------------- |
| `404` | `PAYOUT_NOT_FOUND` | No payout found for the given ID in this environment. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://moonie.gitbook.io/mooniepay/payouts/retrieve-payout.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
