Подключаю апи по приватбанку, оплата частями, там требуется такие заголовки:
Accept: application/json;
Accept-Encoding: UTF-8;
Content-Type: application/json; charset=UTF-8;
URL
https://payparts2.privatbank.ua/ipp/v2/payment/create
Тип запроса
POST
Как мне в форме пост запроса сделать application/json ?
Пробовал через ajax отправлять, пишет такое:
net::ERR_ABORTED
Content-type: application/json;
Re: Content-type: application/json;
Код: Выделить всё
var event = { //типа массив из нужных полей, который в json пойдет
storeId: storeIds,
orderId: orderIds,
amount: amounts,
partsCount: partsCounts,
merchantType: merchantTypes,
scheme: schemes,
products: {
name: names,
count: counts,
price: prices},
redirectUrl: redirectUrl,
responseUrl: responseUrls,
signature: signatures,
};
var json = JSON.stringify(event);
$.ajax({
contentType: 'application/json; charset=utf-8',
dataType: 'jsonp',
url: 'https://payparts2.privatbank.ua/ipp/v2/payment/create/',
type: 'post',
crossDomain: true,
data:json,
success: function (data)
{ console.log(data); }
});
Код: Выделить всё
Request URL:https://payparts2.privatbank.ua/ipp/v2/payment/create/?callback=jQuery21403314409153560096_1519216439896&str=%7B%22storeId%22%3A%227D31BE56B32D4C94A00C%22%2C%22orderId%22%3A%2221334%22%2C%22amount%22%3A%222000%22%2C%22partsCount%22%3A%225%22%2C%22merchantType%22%3A%22II%22%2C%22products%22%3A%7B%22name%22%3A%22%D1%82%D0%B5%D0%BA%D1%81%D1%82%22%2C%22count%22%3A%221%22%2C%22price%22%3A%222000%22%7D%2C%22redirectUrl%22%3A%22http%3A%2F%2Ftehnohata.ua%2Fsite%2Fprivat24%22%2C%22responseUrl%22%3A%22http%3A%2F%2Ftehnohata.ua%2Fsite%2Fprivat24%22%2C%22signature%22%3A%22a0m0ltTX%2BkPVUjWt33wtBhGruCA%3D%22%7D&_=1519216439897
Request Method:GET
Status Code:500
Remote Address:77.111.244.28:8000
Referrer Policy:no-referrer-when-downgrade
cache-control:no-cache, no-store, max-age=0, must-revalidate
content-language:ru-RU
content-type:text/html;charset=UTF-8
date:Wed, 21 Feb 2018 12:34:08 GMT
expires:0
pragma:no-cache
server:nginx
status:500
strict-transport-security:max-age=31536000 ; includeSubDomains
x-content-type-options:nosniff
x-frame-options:DENY
x-xss-protection:1; mode=block
Re: Content-type: application/json;
$.ajax({processData: false, ...}). Jquery препроцессит значение параметра data как form/urlencoded, эта опция отключает это. Странно, что банк 500 выдает, видимо у них валидацич не доделана. Сюда бы не js-код запроса а полный запрос вместе с телом.