## Afriex SDK

### TypeScript

```typescript
const poolAccount = await afriex.paymentMethods.listPoolAccounts({
  customerId: "customer-id",
  country: "NG",
});
```

```bash
curl --request GET \
  --url https://sandbox.api.afriex.com/api/v1/payment-method/pool-account \
  --header 'x-api-key: <api-key>'
```

```python
import requests

url = "https://sandbox.api.afriex.com/api/v1/payment-method/pool-account"

headers = {"x-api-key": "<api-key>"}

response = requests.get(url, headers=headers)

print(response.text)
```

```javascript
const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};

fetch('https://sandbox.api.afriex.com/api/v1/payment-method/pool-account', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://sandbox.api.afriex.com/api/v1/payment-method/pool-account",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "x-api-key: <api-key>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

url := "https://sandbox.api.afriex.com/api/v1/payment-method/pool-account"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("x-api-key", "<api-key>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}
```

```java
HttpResponse<String> response = Unirest.get("https://sandbox.api.afriex.com/api/v1/payment-method/pool-account")
  .header("x-api-key", "<api-key>")
  .asString();
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://sandbox.api.afriex.com/api/v1/payment-method/pool-account")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'

response = http.request(request)
puts response.read_body
```

### Response Data

200

```json
{
  "data": {
    "paymentMethodId": "69c2804b30314b491e48b305",
    "channel": "VIRTUAL_BANK_ACCOUNT",
    "customerId": "6929843e2c4653277440acc0",
    "reference": "6929843e2c4653277440acc0",
    "institution": {
      "institutionName": "UBA"
    },
    "accountName": "TEST",
    "accountNumber": "12345678",
    "countryCode": "NG"
  }
}
```

### Description
Returns the business’s pool account for a given country. A pool account is a shared, Afriex-managed account that customers pay into; Afriex reconciles incoming funds to the merchant using the `reference` returned on this response. **Important:** Pool accounts are **only active in production** and do **not work on staging/dev**.

### How the call works
1. Call this endpoint with `country` (required). Optionally pass `customerId` to scope the response to a specific end-user.
2. Afriex returns the pool account (account name, account number, institution) as a `PaymentMethod`, along with a `reference`.
3. Share the account details with your customer so they can pay in. When Afriex receives the inbound funds, it uses the `reference` to attribute the deposit on your account.

### The `reference` field
Every response includes a `reference` string. Persist it alongside the deposit you expect and use it to reconcile incoming pool deposits. When you pass a `customerId`, the response `reference` matches it, so the deposit can be attributed back to that customer on your side.

### Currency is derived from country
Unlike dedicated virtual accounts, this endpoint does not take a `currency` parameter. The currency is determined by the country code (for example, `NG` resolves to `NGN`). Pool accounts are only available in countries where Afriex operates a pool; an unsupported country code returns a `400`.

### Authorizations
- **x-api-key**: Static business API key issued from the dashboard. A business can provision multiple API keys, each scoped to a configurable set of permissions (e.g., read transactions, create deposits, etc). Permissions are chosen per key at creation time in the dashboard and may be revoked by deleting the key. Requests made with a key that does not include the permission required by the target endpoint will be rejected with a `403 Forbidden` response; an unrecognised, malformed, or revoked key returns `401 Unauthorized`. Manage your keys and their permissions under Developer → API keys in the dashboard.

### Query Parameters
- **country**: (required) ISO 3166-1 alpha-2 country code. Example: `"NG"`
- **customerId**: optional customer ID to associate with this account.
- **amount**: optional positive amount. Accepted but ignored.
- **reference**: optional merchant-supplied reference. Accepted but ignored.

### Response
200

application/json

Pool account returned successfully.
