...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?php
$url = "https://api.intellectmoney.ru/merchant/bankcardpayment"; //Url обращения к методу bankcardpayment
$cert_file = 'c://сertificate.pem'; //Путь к сертификату
$cert_password = 'password'; //Пароль к сертификату
//Набор параметров
$secretKey = 'secret';
$eshopId = '453271';
$invoiceId = '3053551762';
$pan = '55555555444444';
$expiredMonth = '10';
$expiredYear = '21';
$returnUrl = 'https://sait.ru/return_url.php';
$ipAddress = '127.0.0.1';
$cardHolder = 'TEST';
$cvv = '123';
// Формат формирования хэша
//eshopId::invoiceId::pan::cardHolder::expiredMonth::expiredYear::cvv::returnUrl::ipAddress::secretKey
// Формирование хэша
$hash = md5($eshopId . '::' . $invoiceId . '::' . $pan . '::' . $cardHolder . '::' . $expiredMonth . '::' . $expiredYear . '::' . $cvv . '::' . $returnUrl . '::' . $ipAddress . '::' . $secretKey);
// Массив обязательных параметров
$params = [
'eshopId' => $eshopId,
'invoiceId' => $invoiceId,
'pan' => $pan,
'cardHolder' => $cardHolder,
'expiredMonth' => $expiredMonth,
'expiredYear' => $expiredYear,
'returnUrl' => $returnUrl,
'ipAddress' => $ipAddress,
'cvv' => $cvv,
'hash' => $hash,
'debugexception' => "true"
];
// Отправляем запрос
echo (curlRequest($url, $params));
// Вспомогательная функция для отправки запросов
function curlRequest($url, $data) {
$queryString = http_build_query($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $queryString);
curl_setopt($ch, CURLOPT_SSLCERT, $cert_file);
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $cert_password);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
$result = curl_exec($ch);
curl_close($ch);
return $result;
} |
...