W
W
WQ132018-09-25 10:41:49
PHP
WQ13, 2018-09-25 10:41:49

Acquiring TWPG, who dealt with?

Good afternoon. Who has experience in integrating the site and TWPG Acquiring.
The technology itself is described here: https://drive.google.com/file/d/1wNnLV7zq6t_d__y3u...
At the request of the bank, you need to generate a certificate according to the following instructions and send it to the bank, in response I received two files with the following message from the bank:
" the bank's root certificate is banktestca.crt and your merchant's root certificate is 2059055.crt, these must be used when creating a TLS connection between your site and the test TWPG."
With this, I already have an SSL certificate on the site for visitors. And this certificate is needed to communicate with TWPG
at the bottom of the document there is an example ....

function PostQW($hostname,$port,$data){

$fp = fsockopen($hostname, $port, $errno, $errstr, 30);

// Заголовок HTTPS-запроса
$headers = 'POST '.$path.' HTTP/1.0\r\n';
$headers .= 'Host: '.$hostname.'\r\n';
$headers .= 'Content-type: application/x-www-form-urlencoded\r\n';
$headers .= 'Content-Length: '.strlen($data).'\r\n\r\n';

and here the question is what HTTP header should be written to indicate the paths to these crt certificates?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WQ13, 2018-09-25
@floog

Understood...

// корневой сертификат банка
  $caFile = dirname(__FILE__) . '/bank.crt';

  // сертификат торговца
  $certFile =  dirname(__FILE__) .  '/user.crt';

  // ключ сертификата
  $keyFile =  dirname(__FILE__) .  '/user.key';

  // пароль ключа (если есть)
  $privateCertPass = 'password';

  $serverURI = 'https://192.168.0.0:5555/Exec';
  
  // исходящее xml_сообщение
  $xml = '<?xml version="1.0" encoding="UTF-8"?>';
  $xml .= '<TKKPG>';
  $xml .= '<Request>';
  $xml .= '<Operation>CreateOrder</Operation>';
  $xml .= '<Language>RU</Language>';
  $xml .= '<Order>';
  $xml .= '<OrderType>Purchase</OrderType>';
  $xml .= '<Merchant>2000001</Merchant>';
  $xml .= '<Amount>15000</Amount>';
  $xml .= '<Currency>810</Currency>';
  $xml .= '<Description>Test</Description>';
  $xml .= '<ApproveURL>http://192.168.0.1:81/test_stores/test/get_result_post.php</ApproveURL>';
  $xml .= '<CancelURL>http://192.168.0.1:81/test_stores/test/get_result_post.php</CancelURL>';
  $xml .= '<DeclineURL>http://192.168.0.1:81/test_stores/test/get_result_post.php</DeclineURL>';
  $xml .= '</Order>';
  $xml .= '</Request>';
  $xml .= '</TKKPG>';
  
  $ch = curl_init($serverURI);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_SSLCERT, $certFile);
  curl_setopt($ch, CURLOPT_CAINFO, $caFile);
  
  curl_setopt($ch, CURLOPT_SSLKEY, $keyFile);
  curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $privateCertPass);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_VERBOSE, 1);
  
  // ответ TWPG
  $xmlResponse = curl_exec($ch);
  
  // 0 - успешное выполнение запроса
  echo 'CURL status: ' . curl_errno($ch) . '<br>';
    echo 'CURL status description: ' . curl_error($ch);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question