# New POS Payment

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

## Credentials

- Request body field `seller_payme_id` (required): PayMe's unqiue seller ID

## Overview

Calling this method will "push" a payment request to the POS, synchronously awaiting the payment result.

## Parameters

This endpoint takes no path, query or header parameters.

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `seller_payme_id` | string | yes | PayMe's unqiue seller ID |
| `product_name` | string | yes | Product's description |
| `sale_price` | number | yes | Sale Price |
| `sale_type` | string | no | You can find all the sale types [Sale Types](/guides-and-use-cases-migrated/lists-statuses/sale-types). |
| `currency` | string | no | Sale currency. [3-letter ISO 4217 name](https://en.wikipedia.org/wiki/ISO_4217). |
| `transaction_id` | string | yes | Transaction ID |
| `sale_callback_url` | string | yes | Sale Callback URL |
| `payment` | object | yes |  |
| `payment.method` | string | yes | Payment method |
| `payment.pos_id` | string | yes | The ID you must choose for your POS. Must be a string of digits, between "001" and "999" |
| `customer` | object | no | The customer object is **not** mandatory. **If this object is added** to the request, it should include its **required fields**: name, email and phone. |
| `customer.name` | string | no | Customer name |
| `customer.email` | string | no | Customer email |
| `customer.zip_code` | string | no | Customer address zip code |
| `customer.phone` | string | no | Customer mobile phone number |
| `customer.social_id` | string | no | Customer social ID / national ID for additional verification |
| `language` | string | no | Customer language |

### Request example

```json
{
  "seller_payme_id": "MPLXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "product_name": "My Product",
  "sale_price": 10000,
  "currency": "USD",
  "transaction_id": "12345",
  "sale_callback_url": "https://www.example.com/payment/callback",
  "payment": {
    "method": "emv",
    "pos_id": "001"
  },
  "customer": {
    "name": "John Due",
    "email": "test@test.com",
    "phone": "+498963648018"
  },
  "language": "en"
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/sales' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "seller_payme_id": "MPLXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "product_name": "My Product",
  "sale_price": 10000,
  "currency": "USD",
  "transaction_id": "12345",
  "sale_callback_url": "https://www.example.com/payment/callback",
  "payment": {
    "method": "emv",
    "pos_id": "001"
  },
  "customer": {
    "name": "John Due",
    "email": "test@test.com",
    "phone": "+498963648018"
  },
  "language": "en"
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/sales", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "seller_payme_id": "MPLXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX",
    "product_name": "My Product",
    "sale_price": 10000,
    "currency": "USD",
    "transaction_id": "12345",
    "sale_callback_url": "https://www.example.com/payment/callback",
    "payment": {
      "method": "emv",
      "pos_id": "001"
    },
    "customer": {
      "name": "John Due",
      "email": "test@test.com",
      "phone": "+498963648018"
    },
    "language": "en"
  }),
});

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

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/sales",
    json={
        "seller_payme_id": "MPLXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX",
        "product_name": "My Product",
        "sale_price": 10000,
        "currency": "USD",
        "transaction_id": "12345",
        "sale_callback_url": "https://www.example.com/payment/callback",
        "payment": {
            "method": "emv",
            "pos_id": "001",
        },
        "customer": {
            "name": "John Due",
            "email": "test@test.com",
            "phone": "+498963648018",
        },
        "language": "en",
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "seller_payme_id": "MPLXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "product_name": "My Product",
  "sale_price": 10000,
  "currency": "USD",
  "transaction_id": "12345",
  "sale_callback_url": "https://www.example.com/payment/callback",
  "payment": {
    "method": "emv",
    "pos_id": "001"
  },
  "customer": {
    "name": "John Due",
    "email": "test@test.com",
    "phone": "+498963648018"
  },
  "language": "en"
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/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 |
| --- | --- | --- |
| `status_code` | integer | PayMe's payment status (success/failure) |
| `payme_status` | string | PayMe's payment status (success/failure) |
| `payme_sale_id` | string | PayMe's unique Sale ID |
| `payme_sale_code` | integer | PayMe's unique Sale code |
| `sale_created` | string | The date the sale was created (timestamp) |
| `payme_sale_status` | string | PayMe's sale status |
| `sale_status` | string | Sale status |
| `currency` | string | Sale currency. [3-letter ISO 4217 name](https://en.wikipedia.org/wiki/ISO_4217). |
| `transaction_id` | string | Transaction ID |
| `is_token_sale` | boolean | Was the card tokenized or not |
| `price` | integer | Payment price |
| `payme_signature` | string | PayMe's signature for the payment |
| `sale_description` | string | Sale description |
| `payme_transaction_id` | string | PayMe transaction ID |
| `payme_transaction_total` | string | Transaction total amount |
| `payme_transaction_card_brand` | string | The card brand |
| `payme_transaction_auth_number` | string | Transaction authorization number |
| `buyer_name` | string | Buyer's full name |
| `buyer_email` | string | Buyer's email address |
| `buyer_phone` | string | Buyer's phone number |
| `buyer_card_mask` | string | Card mask |
| `buyer_card_exp` | string | Buyer's card expiration date |
| `buyer_card_is_foreign` | boolean | Is the card foreign or domestic? (For IL Sellers only) |
| `buyer_social_id` | string | Buyer's social ID number |
| `installments` | integer | Number of installments used for the payment |
| `sale_paid_date` | string | Sale paid date |

```json
{
  "status_code": 0,
  "payme_status": "success",
  "status_error_code": 0,
  "payme_sale_id": "SALE1688-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "payme_sale_code": 12346578,
  "sale_created": "2023-06-29 13:33:54",
  "payme_sale_status": "authorized",
  "sale_status": "authorized",
  "currency": "ILS",
  "transaction_id": "string",
  "is_token_sale": false,
  "price": 100,
  "payme_signature": "db1c276**********c5b39",
  "sale_description": "bbb",
  "sale_deferred_months": null,
  "payme_transaction_id": "TRAN1688-034834SZ-OYNALKNE-DWOXFEUZ",
  "payme_transaction_total": "100",
  "payme_transaction_card_brand": "Mastercard",
  "payme_transaction_auth_number": "12345678",
  "payme_transaction_voucher": null,
  "payme_transaction_emv_uid": "2306**********102613",
  "payme_transaction_acquirer": "PayMe",
  "payme_transaction_auth_source": "CreditCompany",
  "payme_transaction_card_issuer": "Isracard",
  "payme_transaction_credit_type": "RegularCredit",
  "buyer_name": "First Name",
  "buyer_email": "test@example.com",
  "buyer_phone": "+15417543010",
  "buyer_card_mask": "532610******5846",
  "buyer_card_exp": "0426",
  "buyer_card_is_foreign": false,
  "buyer_social_id": "123456782",
  "installments": 1,
  "transaction_first_payment": "100",
  "transaction_periodical_payment": 0,
  "transaction_arn": "2306**********2613",
  "sale_paid_date": "2023-06-29 13:33:54",
  "sale_release_date": null,
  "sale_3ds": false,
  "redirect_url": null
}
```

### 500 — Internal Server Error (error)

| Field | Type | Description |
| --- | --- | --- |
| `status_code` | number | Status of the request (0 - success, 1 - error) |
| `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": "קישור משתמש לא נמצא",
  "status_additional_info": null,
  "status_error_code": 251
}
```
