# Resolve Secured Hash

- Sandbox: `GET https://sandbox.payme.io/api/sales/payme_sale_id/3ds/hash`
- Production: `GET https://live.payme.io/api/sales/payme_sale_id/3ds/hash`

## Credentials

- Header `PayMe-Merchant-Key` (optional): The MPL of the seller.

This end-point is used for our MPI / 3D secure as-a-service funtionality. 

You can use this endpoint in order to resolve the secured hash sent from PayMe.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `PayMe-Merchant-Key` | header | string | no | The MPL of the seller. |

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status_code` | number | yes | Status of the action (0 - success) |
| `xid` | string | no | The XID generated by the credit card issuer |
| `eci` | string | no | The ECI generated by the credit card issuer |
| `cavv` | string | no | The CAVV generated by the credit card issuer |
| `payme_sale_id` | string | no | PayMe unique sale ID |

### Request example

```json
{
  "status_code": 0,
  "xid": "NjZjYzUyZDJmMDQ0NDEzN2FiNGE=",
  "eci": "05",
  "cavv": "AAACBDaFQCAjBBUAJ4VAAAAAAAA=",
  "payme_sale_id": "SALE1587-486438YT-JLHBOZLR-AJJTULHT"
}
```

## Code samples

### curl

```bash
curl -X GET 'https://sandbox.payme.io/api/sales/payme_sale_id/3ds/hash' \
  -H 'Content-Type: application/json' \
  -H 'PayMe-Merchant-Key: <PayMe-Merchant-Key>' \
  --data-raw '{
  "status_code": 0,
  "xid": "NjZjYzUyZDJmMDQ0NDEzN2FiNGE=",
  "eci": "05",
  "cavv": "AAACBDaFQCAjBBUAJ4VAAAAAAAA=",
  "payme_sale_id": "SALE1587-486438YT-JLHBOZLR-AJJTULHT"
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/sales/payme_sale_id/3ds/hash", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "PayMe-Merchant-Key": "<PayMe-Merchant-Key>",
  },
  body: JSON.stringify({
    "status_code": 0,
    "xid": "NjZjYzUyZDJmMDQ0NDEzN2FiNGE=",
    "eci": "05",
    "cavv": "AAACBDaFQCAjBBUAJ4VAAAAAAAA=",
    "payme_sale_id": "SALE1587-486438YT-JLHBOZLR-AJJTULHT"
  }),
});

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

### Python

```python
import requests

response = requests.get(
    "https://sandbox.payme.io/api/sales/payme_sale_id/3ds/hash",
    headers={
        "PayMe-Merchant-Key": "<PayMe-Merchant-Key>",
    },
    json={
        "status_code": 0,
        "xid": "NjZjYzUyZDJmMDQ0NDEzN2FiNGE=",
        "eci": "05",
        "cavv": "AAACBDaFQCAjBBUAJ4VAAAAAAAA=",
        "payme_sale_id": "SALE1587-486438YT-JLHBOZLR-AJJTULHT",
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "status_code": 0,
  "xid": "NjZjYzUyZDJmMDQ0NDEzN2FiNGE=",
  "eci": "05",
  "cavv": "AAACBDaFQCAjBBUAJ4VAAAAAAAA=",
  "payme_sale_id": "SALE1587-486438YT-JLHBOZLR-AJJTULHT"
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/sales/payme_sale_id/3ds/hash');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'PayMe-Merchant-Key: <PayMe-Merchant-Key>',
    ],
    CURLOPT_POSTFIELDS => $body,
]);

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

echo $response;
```

## Responses

### 200 — OK (success)

| Field | Type | Description |
| --- | --- | --- |
| `status_code` | number | Status of the action (0 - success, 1 - failure) |
| `payme_sale_id` | string | PayMe unique sale ID |

```json
{
  "status_code": 1,
  "status": "N",
  "payme_sale_id": "SALE1587-486438YT-JLHBOZLR-AJJTULHT"
}
```

### 400 — Bad Request (error)

| Field | Type | Description |
| --- | --- | --- |
| `status_code` | number | Status of the request (1 - failure) |
| `status_error_details` | string | Error message |
| `status_additional_info` | string | Additional error information |
| `status_error_code` | number | Our unique error code |

```json
{
  "status_code": 1,
  "status_error_details": "Validation error",
  "status_additional_info": "eyJpdiI6Ilp...",
  "status_error_code": 20
}
```
