A
A
alpa_kz2018-04-20 06:47:15
API
alpa_kz, 2018-04-20 06:47:15

How to avoid being redirected to the bank's website to pay for goods on our side of the online store?

I need to install online payment on the online store, the payment system from epay, so that the payment goes through, I need to send the data https://testpay.kkb.kz/jsp/process/logon.jsp, an example of the data can be seen at the link , how you can avoid redirection , and immediately pay on our website, thought through AJAX

$('#form').submit(function(e) {
        e.preventDefault()
        // console.log($(this).serialize())
        $.ajax({
            url: 'https://testpay.kkb.kz/jsp/process/logon.jsp',
            method: 'POST',
            data: $(this).serialize(),
            async: true,
            success(data){
                console.log('success')
                console.log(data)
            },
            error(data){
                console.log('error')
                console.log(data)
            }
        })
    })

get the response status and from this they resend the data they need, but gives
Failed to load https://testpay.kkb.kz/jsp/process/logon.jsp: Redirect from ' https://testpay.kkb.kz/jsp/ process/logon.jsp ' to ' https://testpay.kkb.kz/jsp/process/payment.jsp?oid... ' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' pay.aida.market ' is therefore not allowed access.
tried to send via curl
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");

require_once("kkbcsign.class.php");
$kkb = new KKBSign();
$kkb->invert();
$kkb->load_private_key("cert.prv", "1q2w3e4r");
$merchant = '<merchant cert_id="%certificate%" name="%merchant_name%"><order order_id="%order_id%" amount="%amount%" currency="%currency%"><department merchant_id="%merchant_id%" amount="%amount%"/></order></merchant>';
$merchant = preg_replace('/\%certificate\%/', 		MERCHANT_CERT_ID , 	$merchant);
$merchant = preg_replace('/\%merchant_name\%/', 	MERCHANT_NAME , 	$merchant);
$merchant = preg_replace('/\%order_id\%/', 			ORDER_ID, 			$merchant);
$merchant = preg_replace('/\%currency\%/', 			CURRENCY, 			$merchant);
$merchant = preg_replace('/\%merchant_id\%/', 		MERCHANT_ID, 		$merchant);
$merchant = preg_replace('/\%amount\%/', 			AMOUNT,				$merchant);
$merchant_sign = '<merchant_sign type="RSA">'.$kkb->sign64($merchant).'</merchant_sign>';
$xml = "<document>".$merchant.$merchant_sign."</document>";
$xml = base64_encode($xml);
$Signed_Order_B64 = $xml;
$email = '[email protected]';  
$Language = "rus";
$BackLink = "https://testpay.kkb.kz/jsp/client/pay.jsp";
$PostLink = "http://pay.aida.market/postlink";
$FailureBackLink = "https://testpay.kkb.kz/jsp/client/pay.jsp";
$template = "default.xsl";


function request($url, $postdata = null, $cookiefile = 'tmp/cookie.txt'){

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_CERTINFO, true);
  curl_setopt($ch, CURLOPT_COOKIESESSION, true);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3");
  curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);
  curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

  if($postdata){
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata );
  }

  $html = curl_exec($ch);
  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  echo $code;
  if(!$html ){
    $error = curl_error($ch).'('.curl_errno($ch).')';
    echo '---error----';
    echo $error;
  }
  curl_close($ch);
  return $html;
}

file_put_contents("tmp/cookie.txt",'');
request('https://testpay.kkb.kz/jsp/process/logon.jsp',"Signed_Order_B64=".$Signed_Order_B64."&[email protected]&Language=rus&BackLink=https://testpay.kkb.kz/jsp/client/pay.jsp&PostLink=http://pay.aida.market/postlink&FailureBackLink=https://testpay.kkb.kz/jsp/client/pay.jsp&template=default.xsl");
echo $html;

302---error---- OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 0(56)
Why such an error? help solve this problem? maybe someone faced such a problem? I just don’t want to redirect clients to the bank’s website (? It’s important for me to find out which site he redirected me to the correct one or to the one that I have an error in the data, if I redirected to the site with the correct data, then take the last step to make a payment, help someone with what maybe I can't figure it out

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question