# Get card details by token

- Sandbox: `POST https://sandbox.payme.io/api/buyer-token-to-card-number`
- Production: `POST https://live.payme.io/api/buyer-token-to-card-number`

## Credentials

No credentials are documented for this endpoint.

## Overview

This endpoint can be used only if you are PCI compliant and allow to handle raw credit card infromation. 

This end-point is used for receiving the full credit card data by sending a request with the buyer token.

Please note that in the response you won't receive CVV details, as we don't save it due to regulation.

## Parameters

This endpoint takes no path, query or header parameters.

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `seller_payme_id` | string | no | Our unique seller ID. |
| `buyer_uuid2` | string | no | Buyer's public key |
| `buyer_key` | string | no | Buyer's private key |

### Request example

```json
{
  "seller_payme_id": "MPL1DEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "buyer_uuid2": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  "buyer_key": "BUYER111-XXXXXXXX-XXXXXXXX-XXXXXXXX"
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/buyer-token-to-card-number' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "seller_payme_id": "MPL1DEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "buyer_uuid2": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  "buyer_key": "BUYER111-XXXXXXXX-XXXXXXXX-XXXXXXXX"
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/buyer-token-to-card-number", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "seller_payme_id": "MPL1DEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
    "buyer_uuid2": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    "buyer_key": "BUYER111-XXXXXXXX-XXXXXXXX-XXXXXXXX"
  }),
});

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

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/buyer-token-to-card-number",
    json={
        "seller_payme_id": "MPL1DEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
        "buyer_uuid2": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "buyer_key": "BUYER111-XXXXXXXX-XXXXXXXX-XXXXXXXX",
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "seller_payme_id": "MPL1DEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "buyer_uuid2": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  "buyer_key": "BUYER111-XXXXXXXX-XXXXXXXX-XXXXXXXX"
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/buyer-token-to-card-number');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);

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

echo $response;
```

## Responses

### 200 — OK (success)

| Field | Type | Description |
| --- | --- | --- |
| `buyer_key` | string | Buyer's unique token. |
| `buyer_card_number` | string | Buyer's card mask. |
| `buyer_card_exp_month` | string | Buyer's card exp (MMYY). |
| `buyer_card_exp_year` | string | Credit card expiration date |

```json
{
  "buyer_key": "BUYER111-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "buyer_card_number": "532**********846",
  "buyer_card_exp_month": "04",
  "buyer_card_exp_year": "26",
  "status_code": 0
}
```
