## Authorize order payments

### cURL

```bash
curl --request POST \
  --url https://api.fabric.inc/v3/orders/actions/authorize-payments \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'x-fabric-channel-id: <x-fabric-channel-id>' \
  --header 'x-fabric-tenant-id: <x-fabric-tenant-id>' \
  --data '
{
  "force": false,
  "orders": [
    {
      "orderNumber": "309019176",
      "payments": [
        {
          "paymentCounter": 1
        }
      ]
    }
  ],
  "sync": false
}
'
```

### Python

```python
import requests

url = "https://api.fabric.inc/v3/orders/actions/authorize-payments"

payload = {
    "force": False,
    "orders": [
        {
            "orderNumber": "309019176",
            "payments": [{ "paymentCounter": 1 }]
        }
    ],
    "sync": False
}
headers = {
    "x-fabric-tenant-id": "<x-fabric-tenant-id>",
    "x-fabric-channel-id": "<x-fabric-channel-id>",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {
    'x-fabric-tenant-id': '<x-fabric-tenant-id>',
    'x-fabric-channel-id': '<x-fabric-channel-id>',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    force: false,
    orders: [{orderNumber: '309019176', payments: [{paymentCounter: 1}]}],
    sync: false
  })
};

fetch('https://api.fabric.inc/v3/orders/actions/authorize-payments', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### PHP

```php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.fabric.inc/v3/orders/actions/authorize-payments",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'force' => false,
    'orders' => [
        [
                'orderNumber' => '309019176',
                'payments' => [
                                [
                                                                'paymentCounter' => 1
                                ]
                ]
        ]
    ],
    'sync' => false
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json",
    "x-fabric-channel-id: <x-fabric-channel-id>",
    "x-fabric-tenant-id: <x-fabric-tenant-id>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

### Response

#### Success Response
- **Code**: 200
- **Response Body**:
```json
{
  "orders": [
    {
      "orderNumber": "309019176",
      "payments": [
        {
          "paymentCounter": 1
        }
      ]
    }
  ]
}
```

#### Error Responses
- **Code**: 400
- **Response Body**:
```json
{
  "errors": [
    {
      "message": "Invalid request",
      "type": "CLIENT_ERROR"
    }
  ],
  "message": "Bad request",
  "type": "CLIENT_ERROR"
}
```

- **Code**: 401
- **Response Body**:
```json
{
  "message": "Unauthorized request",
  "type": "CLIENT_ERROR"
}
```

- **Code**: 404
- **Response Body**:
```json
{
  "message": "Not found",
  "type": "CLIENT_ERROR"
}
```

- **Code**: 500
- **Response Body**:
```json
{
  "message": "Internal server error",
  "type": "SERVER_ERROR"
}
```

### Authorizations
- **Authorization**: Bearer authentication header of the form `Bearer <token>`.

### Headers
- **x-fabric-tenant-id**: Required for identifying the tenant making the request.
- **x-fabric-channel-id**: Required for identifying the sales channel.

### Body
- **force**: (boolean) Default is false. Ignore validation rules if set to true.
- **orders**: (array) Contains order information including `orderNumber` and `payments`.
- **sync**: (boolean) Default is false. Process the request in synchronous mode.
