# List Sales

- Sandbox: `POST https://sandbox.payme.io/api/get-sales`
- Production: `POST https://live.payme.io/api/get-sales`

## Credentials

- Request body field `payme_client_key` (required): PayMe Partner Key

## Overview

You can retreive data on different sales processed by your sellers using this endpoint. 


#### Query pagination (more than 500 results)

If you are sending a query and expect to receive more than 500 results, make sure you use this function of Query Pagination. 

```json
{
  "seller_payme_id": "MPL1DEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  ...
  "page_size": 100, // Max allowed page size is 500
  "page": 1
}
```

## Parameters

This endpoint takes no path, query or header parameters.

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payme_client_key` | string | yes | PayMe Partner Key |
| `seller_payme_id` | string | no | Our unique seller ID (MPL). If you are a partner, you can use multiple seller_payme_id attributes to retreive data for these specific sellers |
| `seller_id` | string | no | Merchant's unique seller ID for correlation with us |
| `sale_payme_code` | string | no | Our unique sale code |
| `sale_payme_id` | string | no | Our unique sale ID |
| `sale_created` | string | no | Exact creation date and time for which to retrieve sales. ISO-8601 formatted |
| `sale_created_min` | string | no | Earliest creation date and time for which to retrieve sales. ISO-8601 formatted |
| `sale_created_max` | string | no | Latest date and time for which to retrieve sales. ISO-8601 formatted |
| `sale_status` | string | no | Sale status. All statuses are available [Sale Statuses](/guides-and-use-cases-migrated/lists-statuses/sale-statuses). For multiple statuses use array format like` ["initial","validated"]` |
| `sale_price` | number | no | Sale final price. For example, if the price is 50.75 (max 2 decimal points) the value that needs to be sent is 5075 |
| `sale_currency` | string | no | Sale currency. [3-letter ISO 4217 name](https://en.wikipedia.org/wiki/ISO_4217). |
| `sale_auth_number` | string | no | Sale authorization number from the credit company |
| `buyer_card_mask` | string | no | Buyer's credit card mask |
| `buyer_card_last_four_digits` | string | no | Buyer's credit card last four digits |
| `buyer_email` | string | no | Buyer's eMail address |
| `buyer_name` | string | no | Buyer's full name |
| `buyer_phone` | string | no | Buyer's phone number |
| `buyer_social_id` | string | no | Buyer's social id (For Israeli sellers only) |
| `buyer_card_is_foreign` | boolean | no | Is the buyer's credit card foreign |

### Request example

```json
{
  "payme_client_key": "XXXXXXXX",
  "transaction_id": "12345"
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/get-sales' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "payme_client_key": "XXXXXXXX",
  "transaction_id": "12345"
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/get-sales", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "payme_client_key": "XXXXXXXX",
    "transaction_id": "12345"
  }),
});

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

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/get-sales",
    json={
        "payme_client_key": "XXXXXXXX",
        "transaction_id": "12345",
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "payme_client_key": "XXXXXXXX",
  "transaction_id": "12345"
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/get-sales');
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 |
| --- | --- | --- |
| `items_count` | number | Number of items |
| `items` | array |  |
| `items[].seller_payme_id` | string | Our unique seller ID |
| `items[].seller_id` | string | Merchant's unique seller ID for correlation with us |
| `items[].sale_payme_id` | string | Our unique sale ID |
| `items[].sale_payme_code` | string | Our unique sale code |
| `items[].transaction_id` | string | PayMe's unique transaction ID |
| `items[].sale_created` | string | Exact creation date and time for which to retrieve sales. ISO-8601 formatted |
| `items[].sale_status` | string | Sale status. All available Sale statuses |
| `items[].sale_currency` | string | Currency the transaction was processed in |
| `items[].sale_price` | number | Sale final price. For example, if the price is 50.75 (max 2 decimal points) the value that needs to be sent is 5075 |
| `items[].sale_price_after_fees` | number | Sale amount including fees |
| `items[].sale_description` | string | What was the goods/services the buyer paid for |
| `items[].sale_installments` | number | Number of installments used for the purchase` |
| `items[].sale_vat` | string | VAT added to the sale |
| `items[].sale_paid_date` | string | The date the sale was paid |
| `items[].sale_auth_number` | string | Sale authorization number from the credit company |
| `items[].sale_release_date` | string | The expected date the funds will be available in the seller's balance |
| `items[].sale_fees` | object |  |
| `items[].sale_fees.sale_processing_fee` | string | Total processing fee |
| `items[].sale_fees.sale_processing_charge` | string | Processing charge |
| `items[].sale_fees.sale_discount_fee` | string | Discount fee |
| `items[].sale_fees.sale_rapid_settlement_fee` | string | Rapid settlement fee |
| `items[].sale_fees.sale_market_fee` | string | Sale's market fee |
| `items[].sale_buyer_details` | object |  |
| `items[].sale_buyer_details.buyer_card_mask` | string | Buyer's credit card mask |
| `items[].sale_buyer_details.buyer_card_expiry` | string | Expiration date |
| `items[].sale_buyer_details.buyer_card_brand` | string | Card brand |
| `items[].sale_buyer_details.buyer_card_is_foreign` | boolean | Card is foreign or domestic 'true' for foreign, 'false' for domestic. |
| `items[].sale_buyer_details.buyer_name` | string | Buyer's first and last name |
| `items[].sale_buyer_details.buyer_email` | string | Buyer's email |
| `items[].sale_buyer_details.buyer_phone` | string | Buyer's phone |
| `items[].sale_buyer_details.buyer_social_id` | string | Buyer's social ID |
| `items[].sale_invoices` | array | Invoice generated unique ID |
| `status_code` | number | 0 for Sucessful requests, 1 for Failed requests |

```json
{
  "items_count": 1,
  "items": [
    {
      "seller_payme_id": "XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX",
      "seller_id": "12345",
      "sale_payme_id": "XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX",
      "sale_payme_code": "12345678",
      "transaction_id": "12345",
      "sale_created": "2016-01-01 15:15:15",
      "sale_status": "completed",
      "sale_currency": "USD",
      "sale_price": 10000,
      "sale_price_after_fees": 8970,
      "sale_description": "A duck",
      "sale_installments": 1,
      "sale_vat": "0.17",
      "sale_paid_date": "2016-01-01 15:16:15",
      "sale_auth_number": "01A2B3C",
      "sale_release_date": "2016-01-08 15:15:15",
      "sale_error_code": "",
      "sale_error_text": "",
      "sale_fees": {
        "sale_processing_fee": "3.50",
        "sale_processing_charge": "1.20",
        "sale_discount_fee": "0.50",
        "sale_rapid_settlement_fee": "0.30",
        "sale_market_fee": "0.00"
      },
      "sale_buyer_details": {
        "buyer_card_mask": "458045******4580",
        "buyer_card_expiry": "1022",
        "buyer_card_brand": "Visa",
        "buyer_card_is_foreign": true,
        "buyer_name": "First Last",
        "buyer_email": "buyer@example.com",
        "buyer_phone": "0540000000",
        "buyer_social_id": "000000001"
      },
      "sale_invoices": []
    }
  ],
  "status_code": 0
}
```

### 500 — Internal Server Error (error)

| Field | Type | Description |
| --- | --- | --- |
| `status_code` | number |  |
| `status_error_details` | string |  |
| `status_additional_info` | string |  |
| `status_error_code` | number |  |

```json
{
  "status_code": 1,
  "status_error_details": "שירות לא נמצא",
  "status_additional_info": "payme_client_key",
  "status_error_code": 200
}
```
