# Get Customer Details

- Sandbox: `GET https://sandbox.payme.io/api/buyers/{buyer_guid}`
- Production: `GET https://live.payme.io/api/buyers/{buyer_guid}`

## Credentials

- Header `PayMe-Merchant-Key` (required): Your unique seller UUID.

## Overview

You can access and fetch your buyer's details using this API endpoint. 

Your API request structure should look as follows:
```
https://<env>.payme.io/api/buyers/{buyer_guid}
```

The buyer guid is the unique ID fetched from either:
1. Capture Buyer Token API endpoint.
2. Tokens API endpoint.

### Authentication
You'll need to authenticate your request using the unique seller ID.

### Data
You'll be able to get the following data:
1. Card mask
2. Card brand
3. Card expiry date
4. Customer details

### Limitations
1. If you are sending a token (uuid) and not a buyer key you won't get the parameter `buyer_key` in your response.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `PayMe-Merchant-Key` | header | string | yes | Your unique seller UUID. |
| `buyer_guid` | path | string | yes |  |

## Code samples

### curl

```bash
curl -X GET 'https://sandbox.payme.io/api/buyers/<buyer_guid>' \
  -H 'PayMe-Merchant-Key: <PayMe-Merchant-Key>'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/buyers/<buyer_guid>", {
  method: "GET",
  headers: {
    "PayMe-Merchant-Key": "<PayMe-Merchant-Key>",
  },
});

console.log(await response.text());
```

### Python

```python
import requests

response = requests.get(
    "https://sandbox.payme.io/api/buyers/<buyer_guid>",
    headers={
        "PayMe-Merchant-Key": "<PayMe-Merchant-Key>",
    },
)

print(response.text)
```

### PHP

```php
<?php

$ch = curl_init('https://sandbox.payme.io/api/buyers/<buyer_guid>');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'PayMe-Merchant-Key: <PayMe-Merchant-Key>',
    ],
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
```

## Responses

### 200 — OK (success)

| Field | Type | Description |
| --- | --- | --- |
| `uuid` | string | Buyer uuid |
| `customer` | object | Customer's details |
| `customer.name` | string | Customer's name |
| `customer.email` | string | Customer's email |
| `customer.phone` | string | Customer's phone |
| `customer.social_id` | string | Customer's ID |
| `payment` | object |  |
| `payment.display` | string | The payment method number |
| `payment.expiry` | string | Buyer's card exp (MMYY). |
| `payment.brand` | string | Buyer's card brand. |
| `payment.club` | string | The credit card club |
| `payment.type` | string | Type of credit card |
| `payment.organization` | string | The credit card organization |
| `payment.origin_country` | string | The credit card country |
| `buyer_key` | string | Buyer key |

```json
{
  "uuid": "6ac45306-1755-45e4-8b74-f6de3ea2239b",
  "customer": {
    "name": "Ran Tester",
    "email": "TestTest@paymeservice.com",
    "phone": "05222222",
    "social_id": "123456789"
  },
  "payment": {
    "display": "411111******1111",
    "expiry": "0322",
    "brand": "Visa",
    "club": "",
    "type": "Credit",
    "organization": "",
    "origin_country": "US"
  },
  "buyer_key": "BUYER162-6264904Y-TIHEKYED-4QMCI837"
}
```
