Получение токена платежа
Для использования страницы оплаты или платежного виджета торговцу требуется создать токен платежа.
Запрос
Отправьте POST
запрос на https://checkout.pall-psp.com/ctp/api/checkouts
.
Запрос должен:
- иметь авторизацию типа Basic с ID и Secret key магазина как имя пользователя и пароль соответственно;
- иметь заголовки
Content-Type: application/json
,Accept: application/json
иX-API-Version: 2
; - использовать кодировку UTF-8.
|
Пример запроса
{
"checkout": {
"test": true,
"transaction_type": "payment",
"attempts": 3,
"settings": {
"return_url": "http://127.0.0.1:4567/return",
"success_url": "http://127.0.0.1:4567/success",
"decline_url": "http://127.0.0.1:4567/decline",
"fail_url": "http://127.0.0.1:4567/fail",
"cancel_url": "http://127.0.0.1:4567/cancel",
"notification_url": "http://your_shop.com/notification",
"button_next_text": "Вернуться в магазин",
"language": "en",
"customer_fields": {
"visible": ["first_name", "last_name"],
"read_only": ["email"]
},
"credit_card_fields": {
"holder": "Rick Astley",
"read_only": ["holder"]
}
},
"payment_method": {
"types": [
"credit_card",
"bank_transfer"
],
"bank_transfer": {
"account": "DE89370400440532013000"
},
"excluded_brands": [
"visa",
"google_pay"
]
},
"order": {
"currency": "GBP",
"amount": 4299,
"description": "Order description"
},
"customer": {
"address": "Baker street 221b",
"country": "GB",
"city": "London",
"email": "jake@example.com"
}
}
}
Пример запроса с дополнительным текстом и без перенаправления на результирующую страницу оплаты
{
"checkout": {
"test": true,
"transaction_type": "payment",
"attempts": 3,
"settings": {
"return_url": "http://127.0.0.1:4567/return",
"success_url": "http://127.0.0.1:4567/success",
"decline_url": "http://127.0.0.1:4567/decline",
"fail_url": "http://127.0.0.1:4567/fail",
"cancel_url": "http://127.0.0.1:4567/cancel",
"notification_url": "http://your_shop.com/notification",
"auto_return": 0,
"language": "en",
"customer_fields" : {
"visible" : ["first_name", "last_name"],
"read_only" : ["email"]
}
},
"order": {
"currency": "GBP",
"amount": 4299,
"description": "Order description",
"additional_data": {
"receipt_text": ["Первая строка", "Вторая строка"]
}
},
"customer": {
"address": "Baker street 221b",
"country": "GB",
"city": "London",
"email": "jake@example.com"
}
}
}
Пример запроса с информацией о продаже авиабилетов и тур путевок
{
"checkout": {
"test": true,
"transaction_type": "payment",
"attempts": 3,
"settings": {
"return_url": "http://127.0.0.1:4567/return",
"success_url": "http://127.0.0.1:4567/success",
"decline_url": "http://127.0.0.1:4567/decline",
"fail_url": "http://127.0.0.1:4567/fail",
"cancel_url": "http://127.0.0.1:4567/cancel",
"notification_url": "http://your_shop.com/notification",
"auto_return": 3,
"button_next_text": "Вернуться в магазин",
"language": "en",
"customer_fields" : {
"visible" : ["first_name", "last_name"],
"read_only" : ["email"]
}
},
"order": {
"currency": "GBP",
"amount": 4299,
"description": "Order description"
},
"customer": {
"address": "Baker street 221b",
"country": "GB",
"city": "London",
"email": "jake@example.com"
},
"travel": {
"airline": {
"agency_code": "03",
"agency_name": "Corel travel",
"ticket_number": "390 5241 025377 1",
"booking_number": "DKZVUA",
"restricted_ticked_indicator": "0",
"legs": [
{
"airline_code": "B2",
"stop_over_code": "X",
"flight_number": "A3 971",
"departure_date_time": "2014-05-26T05:15:00",
"arrival_date_time": "2014-05-26T07:30:00",
"originating_country": "RU",
"originating_city": "Moscow",
"originating_airport_code": "DME",
"destination_country": "Greece",
"destination_city": "Athems",
"destination_airport_code": "ATH",
"coupon": "coupon code",
"class": "C"
}
],
"passengers":[
{
"first_name": "KONSTANTIN",
"last_name": "IVANOV"
},
{
"first_name": "JULIA",
"last_name": "IVANOVA"
}
]
}
}
}
}
Пример запроса с auto_pay
: true
{
"checkout": {
"test": true,
"transaction_type": "payment",
"attempts": 3,
"iframe": true,
"settings": {
"return_url": "https://return-url",
"auto_pay": true,
"language": "en"
},
"payment_method": {
"types": [
"credit_card"
],
"credit_card": {
"token": "13dded21-ed69-4590-8bcb-db522a89735c"
}
},
"order": {
"currency": "USD",
"amount": 700,
"description": "auto payment"
},
"customer": {
"first_name": "John",
"last_name": "Doe"
}
}
}
Ответ
Параметры ответа копируют параметры запроса за исключением дополнительных:
|
Пример ответа
{
"checkout":
{
"token": "3241e439f8c87d941d92621a4bdc030d4c9a69c67f3b0cfe12de4a13cc34aa51",
"redirect_url": "https://checkout.pall-psp.com/v2/checkout?token=3241e439f8c87d941d92621a4bdc030d4c9a69c67f3b0cfe12de4a13cc34aa51"
}
}
Пример ответа об ошибке
{
"errors": {
"checkout": {
"settings": {
"fail_url": [
"is in invalid format"
]
},
"payment_method": {
"types": [
"must be an array"
]
}
}
},
"message": "fail_url is in invalid format, types must be an array"
}