I send ajax request to https://api.privatbank.ua/p24api/balance () . This api accepts an xml document. In the answer I receive invalid signature.
Display from Privatbank docs:
The request signature is calculated as follows (PHP): $ sign = sha1 (md5 ($ data. $ Password)); $ data - the content of the tag of this request; $ password - merchant personal password
Link to documentation: https://api.privatbank.ua/balance.html
How exactly do you need to format the contents of the data tag?
Signature calculation:
$pass="***************"; $data="<oper>cmt</oper><wait>0</wait><test>0</test><payment><prop name=\"cardnum\" value=\"*************\"></prop><prop name=\"country\" value=\"UA\"></prop></payment>"; $sign =sha1(md5($data.$pass)); and the Ajax request code itself:
var xml = '' + '<\?xml version="1.0" encoding="UTF-8"\?>'+ '<request version="1.0">'+ '<merchant>'+ '<id>mercaht-id</id>'+ '<signature>'+'<?$sign?>'+'</signature>'+ '</merchant>'+ '<data>'+ '<oper>cmt</oper>'+ '<wait>0</wait>'+ '<test>0</test>'+ '<payment id="">'+ ' <prop name="cardnum" value="cart-number" />'+ ' <prop name="country" value="UA" />'+ '</payment>'+ '</data>'+ '</request>'; function Privat24Info(){ var request = new XMLHttpRequest(); request.open("POST", "https://api.privatbank.ua/p24api/balance", false); request.send(xml); alert(request.responseText); } 
$datavariable and the<data>in thexmlvariable are different. At a minimum, the presence of spaces before the tags<prop>. - Yaant$dataand the corresponding substring inxmlmatch up to a byte. From the question in its current form, this is not a drop obvious ... - Yaant