# Capture Sale

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

## Credentials

No credentials are documented for this endpoint.

## Overview

This endpoint enable you to execute the sale after authorization (`generate-sale` with `sale_type` = "authorize").

For more information, go to the [Capture Sale (Authorization) Guide](/guides-and-use-cases-migrated/payments/capture-sale).

## Parameters

This endpoint takes no path, query or header parameters.

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payme_client_key` | string | no | PayMe Partner Key. |
| `seller_payme_id` | string | no | MPL. Your private key in PayMe system. |
| `payme_sale_id` | string | no | Our unique sale ID |

### Request example

```json
{
  "payme_client_key": "XXXXXXXX",
  "seller_payme_id": "MPL1DEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "payme_sale_id": "SALEDEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX"
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/capture-sale' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "payme_client_key": "XXXXXXXX",
  "seller_payme_id": "MPL1DEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "payme_sale_id": "SALEDEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX"
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/capture-sale", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "payme_client_key": "XXXXXXXX",
    "seller_payme_id": "MPL1DEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
    "payme_sale_id": "SALEDEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX"
  }),
});

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

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/capture-sale",
    json={
        "payme_client_key": "XXXXXXXX",
        "seller_payme_id": "MPL1DEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
        "payme_sale_id": "SALEDEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "payme_client_key": "XXXXXXXX",
  "seller_payme_id": "MPL1DEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "payme_sale_id": "SALEDEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX"
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/capture-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` | integer | Status of the request (0 - success, 1 - error) |
| `payme_status` | string | Status of the request (success, error) |
| `payme_sale_id` | string | Our unique sale ID. |
| `payme_sale_code` | integer | Sale code |
| `sale_created` | string | The date the sale was created (timestamp) |
| `payme_sale_status` | string | Sale status. You can find all the sale statuses [Sale Statuses](/guides-and-use-cases-migrated/lists-statuses/sale-statuses). |
| `sale_status` | string | Sale status. You can find all the sale statuses [Sale Statuses](/guides-and-use-cases-migrated/lists-statuses/sale-statuses). |
| `currency` | string | Sale currency. [3-letter ISO 4217 name](https://en.wikipedia.org/wiki/ISO_4217). |
| `transaction_id` | string | The transaction ID. |
| `is_token_sale` | boolean | Indicates if the sale paid with token. |
| `price` | integer | The sale 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": "SALEDEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "payme_sale_code": 1111111,
  "sale_created": "2023-06-22 14:01:47",
  "payme_sale_status": "completed",
  "sale_status": "completed",
  "currency": "ILS",
  "transaction_id": "12345",
  "is_token_sale": false,
  "price": 150000,
  "payme_signature": "93a1ca34ed43bc00c62b9f467c40be8e",
  "sale_description": "Computer",
  "sale_deferred_months": null,
  "payme_transaction_id": "TRANDEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "payme_transaction_total": "150000",
  "payme_transaction_card_brand": "Mastercard",
  "payme_transaction_auth_number": "8906759",
  "payme_transaction_voucher": "111111",
  "payme_transaction_emv_uid": null,
  "payme_transaction_acquirer": "PayMe",
  "payme_transaction_auth_source": "VoiceMail",
  "payme_transaction_card_issuer": "Isracard",
  "payme_transaction_credit_type": "RegularCredit",
  "buyer_name": "Test User",
  "buyer_email": "test@payme.io",
  "buyer_phone": "9725254448888",
  "buyer_card_mask": "532610******5846",
  "buyer_card_exp": "0426",
  "buyer_card_is_foreign": false,
  "buyer_social_id": "123456789",
  "installments": 1,
  "transaction_first_payment": 150000,
  "transaction_periodical_payment": 0,
  "transaction_arn": null,
  "sale_paid_date": "2023-06-22 14:04:28",
  "sale_release_date": null,
  "sale_3ds": false
}
```
