# Purchase

The following documentation outlines the API endpoints and their respective functionalities for validating and processing in-app purchases using Telegram invoices.

## CreateTelegramInvoice

This function is used to create a Telegram invoice link.

#### URL:

```
POST /api/{titleTemplateId}/{titleId}/Client/Purchase/CreateTelegramInvoice  
```

#### Request Parameters:

* `CreateInvoiceRequest` (JSON body): The request payload containing the invoice details.

#### JSON Body:

* `title` (string): The title of the invoice.
* `description` (string): The description of the invoice.
* `payload` (string): The payload of the invoice.
* `provider_token` (string): The provider token.
* `currency` (string): The currency of the invoice.
* `prices` (array): The list of prices in the specified currency.

#### Responses:

* **200 OK**: Returns the Telegram invoice link.
* **400 Bad Request**: Returns an error message if the request is invalid.

#### Example Usage:

```javascript
fetch('https://api.idosgames.com/api/{titleTemplateId}/{titleId}/Client/Purchase/CreateTelegramInvoice', {    
    method: 'POST',    
    headers: {    
        'Content-Type': 'application/json'    
    },    
    body: JSON.stringify({    
        title: 'Game Purchase',    
        description: 'In-game currency purchase',    
        payload: 'unique-payload',    
        provider_token: 'provider-token',    
        currency: 'USD',    
        prices: [{ label: '100 Coins', amount: 1000 }]    
    })    
})    
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```

#### Response Example:

```json
{  
    "ok": true,  
    "result": "https://t.me/invoice_link"  
}  
```

***
