U
U
ualegioner2014-12-05 10:51:51
PHP
ualegioner, 2014-12-05 10:51:51

API privat24, mobile top-ups. Where did I go wrong?

https://api.privatbank.ua/api-privat24/directfill.html
here is what I wrote:

<?php
$data = '
    <oper>cmt</oper>
    <wait>0</wait>
    <test>1</test>
      <payment id="">
        <prop name="service_code" value="RPMTSU" />
        <prop name="phone" value="%2B38066ххххххх" />
        <prop name="amt" value="5.00" />
      </payment>
';
$password="большая тайна";
$sign=sha1(md5($data.$password));

$xml='<?xml version="1.0" encoding="UTF-8"?>
<request version="1.0">
  <merchant>
    <id>111111</id>
    <signature>'.$sign.'</signature>
  </merchant>
  <data>'
    .$data.
  '</data>
</request>';

$ch = curl_init("https://api.privatbank.ua/p24api/directfill");

curl_setopt($ch, CURLOPT_POST,           true );
curl_setopt($ch, CURLOPT_POSTFIELDS,     $xml ); 
curl_setopt($ch, CURLOPT_HTTPHEADER,     array('Content-Type: text/plain')); 

$result=curl_exec ($ch);

print($xml);

print_r($result);
 $info=curl_getinfo($ch);
curl_close($ch); 
?>

thank.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
ualegioner, 2014-12-06
@ualegioner

everything is very simple, the error was that the $data variable needs to be written in this form (enter everything in one line):

$data = '<oper>cmt</oper><wait>0</wait><test>1</test><payment id=""><prop name="service_code" value="RPMTSU" /><prop name="phone" value="%2B38066ххххххх" /><prop name="amt" value="5.00" /></payment>';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question