meraproject/module/integration/kaspi/model.php

57 lines
1.6 KiB
PHP
Raw Permalink Normal View History

<?
namespace integration;
class Kaspi {
var $currency = 398;// Тенге
var $login = '';
public function __construct($login) {
$this->login = $login;
}
public function getPaymentLink($order_id,$amount,$approve_url,$cancel_url,$decline_url){
$soapUrl = "https://epay.fortebank.com/Exec";
$amount *= 100;
// GULMARKET02007489
$xml_post_string = ( "<?xml version='1.0' encoding='UTF-8'?>
<TKKPG>
<Request>
<Operation>CreateOrder</Operation>
<Language>RU</Language>
<Order>
<OrderType>Purchase</OrderType>
<Merchant>".$this->login."</Merchant>
<Amount>$amount</Amount>
<Currency>398</Currency>
<Description>Оплата заказа ".$order_id."</Description>
<ApproveURL>$approve_url</ApproveURL>
<CancelURL>$cancel_url</CancelURL>
<DeclineURL>$decline_url</DeclineURL>
</Order>
</Request>
</TKKPG>
");
/**/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $soapUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
$data = simplexml_load_string($response2);
$res = $data->Response->Order->URL."?OrderID=".$data->Response->Order->OrderID."&SessionID=". $data->Response->Order->SessionID;
return $res;
/**/
}
}