Создать платёжный запрос
POST
/payments/request
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");curl_easy_setopt(hnd, CURLOPT_URL, "https://api.ltesocks.io/v2/payments/request");
struct curl_slist *headers = NULL;headers = curl_slist_append(headers, "Authorization: Bearer <token>");headers = curl_slist_append(headers, "Content-Type: application/json");curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{ \"amount\": 10000, \"gateway_id\": \"000000000000\", \"currency\": \"btc\" }");
CURLcode ret = curl_easy_perform(hnd);using System.Net.Http.Headers;var client = new HttpClient();var request = new HttpRequestMessage{ Method = HttpMethod.Post, RequestUri = new Uri("https://api.ltesocks.io/v2/payments/request"), Headers = { { "Authorization", "Bearer <token>" }, }, Content = new StringContent("{ \"amount\": 10000, \"gateway_id\": \"000000000000\", \"currency\": \"btc\" }") { Headers = { ContentType = new MediaTypeHeaderValue("application/json") } }};using (var response = await client.SendAsync(request)){ response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);}package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.ltesocks.io/v2/payments/request"
payload := strings.NewReader("{ \"amount\": 10000, \"gateway_id\": \"000000000000\", \"currency\": \"btc\" }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>") req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.ltesocks.io/v2/payments/request")) .header("Authorization", "Bearer <token>") .header("Content-Type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString("{ \"amount\": 10000, \"gateway_id\": \"000000000000\", \"currency\": \"btc\" }")) .build();HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.body());OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");RequestBody body = RequestBody.create(mediaType, "{ \"amount\": 10000, \"gateway_id\": \"000000000000\", \"currency\": \"btc\" }");Request request = new Request.Builder() .url("https://api.ltesocks.io/v2/payments/request") .post(body) .addHeader("Authorization", "Bearer <token>") .addHeader("Content-Type", "application/json") .build();
Response response = client.newCall(request).execute();import axios from 'axios';
const options = { method: 'POST', url: 'https://api.ltesocks.io/v2/payments/request', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, data: {amount: 10000, gateway_id: '000000000000', currency: 'btc'}};
try { const { data } = await axios.request(options); console.log(data);} catch (error) { console.error(error);}const url = 'https://api.ltesocks.io/v2/payments/request';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"amount":10000,"gateway_id":"000000000000","currency":"btc"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")val body = RequestBody.create(mediaType, "{ \"amount\": 10000, \"gateway_id\": \"000000000000\", \"currency\": \"btc\" }")val request = Request.Builder() .url("https://api.ltesocks.io/v2/payments/request") .post(body) .addHeader("Authorization", "Bearer <token>") .addHeader("Content-Type", "application/json") .build()
val response = client.newCall(request).execute()use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://api.ltesocks.io/v2/payments/request";
let payload = json!({ "amount": 10000, "gateway_id": "000000000000", "currency": "btc" });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Authorization", "Bearer <token>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.post(url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request POST \ --url https://api.ltesocks.io/v2/payments/request \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "amount": 10000, "gateway_id": "000000000000", "currency": "btc" }'wget --quiet \ --method POST \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --body-data '{ "amount": 10000, "gateway_id": "000000000000", "currency": "btc" }' \ --output-document \ - https://api.ltesocks.io/v2/payments/requestАвторизация
Заголовок раздела «Авторизация»Тело запросаrequired
Заголовок раздела «Тело запросаrequired»Параметры платёжного запроса
Тип содержимогоapplication/json
object
amount
обязательно
Сумма платежа в центах
integer
Пример
10000gateway_id
обязательно
ID платёжного шлюза
string
Пример
000000000000currency
Только для криптовалютных шлюзов (если доступны)
string
Пример
btcОперация выполнена успешно
Тип содержимогоapplication/json
object
data
object
checkout_url
string
Пример
{ "data": { "checkout_url": "http://payer.stage/v1/checkout/693153d5ed55d27adf63714" }}Ошибка
Тип содержимогоapplication/json
object
error
обязательно
Текст ошибки
string
code
обязательно
Код ошибки
integer
Пример
{ "error": "example error", "code": 400}