# Pay Sale

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

## Credentials

- Request body field `seller_payme_id` (required): Our unique seller ID

## Overview

**This endpoint can be used only if you are using our Direct Integration method.**

This endpoint allows you to pay on a sale you created.


By sending this request, a few actions occur: the sale is processed, the buyer is charged, and you receive an asynchronous response with the sale data.

You can find more information in the following guide - [Direct API - How to create and pay sale](/guides-and-use-cases-migrated/integrations/direct-api-how-to-create-and-pay-sale).

## 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 | Our unique seller ID |
| `sale_price` | string | yes | Sale final price. For example, if the price is 50.75 (max 2 decimal points) the value that needs to be sent is 5075. Note that the minimum value is 500. |
| `currency` | string | yes | Sale currency. [3-letter ISO 4217 name](https://en.wikipedia.org/wiki/ISO_4217). |
| `installments` | string | yes | Amount of installments for the sale. |
| `language` | string | no | The language of the response and callback. |
| `sale_callback_url` | string | no | Callback response to your page regarding call to our API. Default value is taken from the Merchant's settings. Note that you may not send a "localhost" URL as value |
| `sale_return_url` | string | yes | Once the payment was completed successfully, the user will be redirected to this URL |
| `capture_buyer` | number | no | Flag for requesting the buyer's token for this payment (0 - do not capture token, 1 - capture token). For additional information see Tokens explanation below |
| `buyer_key` | string | yes | Buyer key for an instant-payment with the token. This key is received through the use of capture_buyer. Note that this attribute cannot co-exist with the capture_buyer parameter in the same request |
| `payme_sale_id` | string | yes | Our unique sale ID |
| `credit_card_number` | number | yes | The card the transaction will be paid with. |
| `credit_card_exp` | string | yes | The expiration date of the card used to pay for the transaction (MM/YY) |
| `credit_card_cvv` | string | yes | The CVV of the card used to pay for the transaction. (3/4 digit code) |

### Request example

```json
{
  "seller_payme_id": "string",
  "sale_price": "string",
  "currency": "string",
  "installments": "string",
  "language": "string",
  "sale_callback_url": "string",
  "sale_return_url": "string",
  "capture_buyer": 0,
  "buyer_key": "string",
  "payme_sale_id": "string",
  "credit_card_number": 0,
  "credit_card_exp": "string",
  "credit_card_cvv": 0
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/pay-sale' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "seller_payme_id": "string",
  "sale_price": "string",
  "currency": "string",
  "installments": "string",
  "language": "string",
  "sale_callback_url": "string",
  "sale_return_url": "string",
  "capture_buyer": 0,
  "buyer_key": "string",
  "payme_sale_id": "string",
  "credit_card_number": 0,
  "credit_card_exp": "string",
  "credit_card_cvv": 0
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/pay-sale", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "seller_payme_id": "string",
    "sale_price": "string",
    "currency": "string",
    "installments": "string",
    "language": "string",
    "sale_callback_url": "string",
    "sale_return_url": "string",
    "capture_buyer": 0,
    "buyer_key": "string",
    "payme_sale_id": "string",
    "credit_card_number": 0,
    "credit_card_exp": "string",
    "credit_card_cvv": 0
  }),
});

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

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/pay-sale",
    json={
        "seller_payme_id": "string",
        "sale_price": "string",
        "currency": "string",
        "installments": "string",
        "language": "string",
        "sale_callback_url": "string",
        "sale_return_url": "string",
        "capture_buyer": 0,
        "buyer_key": "string",
        "payme_sale_id": "string",
        "credit_card_number": 0,
        "credit_card_exp": "string",
        "credit_card_cvv": 0,
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "seller_payme_id": "string",
  "sale_price": "string",
  "currency": "string",
  "installments": "string",
  "language": "string",
  "sale_callback_url": "string",
  "sale_return_url": "string",
  "capture_buyer": 0,
  "buyer_key": "string",
  "payme_sale_id": "string",
  "credit_card_number": 0,
  "credit_card_exp": "string",
  "credit_card_cvv": 0
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/pay-sale');
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` | number | Status of the capture request (0 - success, 1 - error) |
| `payme_status` | string | PayMe's payment status (success/failure) |
| `payme_sale_id` | string | PayMe's unique Sale ID |
| `payme_sale_code` | number | 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 |
| `transaction_id` | string | Transaction ID |
| `is_token_sale` | boolean | Was the card tokenized or not |
| `price` | number | Payment price |
| `payme_signature` | string | PayMe's signature for the payment |
| `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 |
| `payme_transaction_voucher` | string | PayMe's transaction voucher |
| `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` | number | Number of installments used for the payment |
| `sale_paid_date` | string | Sale paid date |

```json
{
  "status_code": 0,
  "redirect_url": null,
  "payme_status": "string",
  "status_error_code": 0,
  "payme_sale_id": "string",
  "payme_sale_code": 0,
  "sale_created": "string",
  "payme_sale_status": "string",
  "sale_status": "string",
  "currency": "string",
  "transaction_id": "string",
  "is_token_sale": true,
  "price": 0,
  "payme_signature": "string",
  "payme_transaction_id": "string",
  "payme_transaction_total": "string",
  "payme_transaction_card_brand": "string",
  "payme_transaction_auth_number": "string",
  "payme_transaction_voucher": "string",
  "buyer_name": "string",
  "buyer_email": "string",
  "buyer_phone": null,
  "buyer_card_mask": "string",
  "buyer_card_exp": "string",
  "buyer_card_is_foreign": true,
  "buyer_social_id": null,
  "installments": 0,
  "sale_paid_date": "string",
  "sale_release_date": null
}
```

### 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": 0,
  "status_error_details": "string",
  "status_additional_info": "string",
  "status_error_code": 0
}
```
