D
D
Dmitry2016-03-22 06:34:39
PHP
Dmitry, 2016-03-22 06:34:39

How to accept and process XML from PrivatBank in Drupal 7?

Hello!
Can you tell me how difficult to create a Drupal 7 module I am describing?
There is an "Invoice" node, it has the following fields:
- field_payment_id
- field_payment_price
- field_payment_status
Based on these data, payment is generated in Privat24 by the form

<form method="POST" action="https://api.privatbank.ua/p24api/ishop">
      <input type="hidden" name="amt" value="<?php echo $field_payment_price ?>" />
      <input type="hidden" name="ccy" value="UAH" />
      <input type="hidden" name="merchant" value="12345" />
      <input type="hidden" name="order" value="<?php echo $field_payment_id ?>" />
      <input type="hidden" name="details" value="Детали платежя" />
      <input type="hidden" name="ext_details" value="Описание" />
      <input type="hidden" name="pay_way" value="privat24" />
      <input type="hidden" name="return_url" value="http://..." />
      <input type="hidden" name="server_url" value="http://..." />
      <button formtarget="_blank" class="privat" type="submit"></button>
  </form>

After the client makes a payment, the module, as I understand it, should send the following XML request
<?xml version="1.0" encoding="UTF-8"?>
    <request version="1.0">
        <merchant>
            <id>12345</id>
            <signature>d66d192cb123456788e08cfe1ca171535</signature>
        </merchant>
        <data>
            <oper>cmt</oper>
            <wait>0</wait>
            <test>0</test>
            <payment>
                <prop name="id" value="1234567" />
                <prop name="ref" value="P24A02509023364489" />
            </payment>
        </data>
    </request>

The request signature is calculated as follows (PHP): $sign=sha1(md5($data.$password)); $data - content of the given request tag; $password - merchant's personal password received during registration.
And from Privat24 there should be an answer:
<?xml version="1.0" encoding="UTF-8"?>
  <response version="1.0">
    <merchant>
      <id>12345</id>
      <signature>37aad972d7461234567893802230be38</signature>
    </merchant>
    <data>
      <oper>cmt</oper>
      <payment id="1234567" status="ok" message="Исполнен" ref="P24A02509023364480" />
    </data>
  </response>

Possible status values:
not found - payment not found;
ok - successful;
err - rejected;
snd - in processing
After the payment has been received (status="ok")
It is necessary to change the corresponding status in the node's $payment_status field in the node, in which the value of the $field_payment_id field corresponds to the incoming value
. Merchant id and other data are entered in the same place.
How complex can such a module be? Can you share some good advice on how to do this the easiest way? where to read the relevant documentation?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2016-03-22
@Sadchenko

Thank you. Yes, I have already shoveled and picked it more than once. But so far no results. I'll try again. Thank you.
Question Resolved!

A
Alexander N++, 2016-03-22
@sanchezzzhak

I think you need to find any payment and take it as a basis.
here it seems to be ready for Drupal
https://www.drupal.org/node/729116

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question