<?php
$pass='***************';
//Client's password
$params['action']='DEBIT_PREPARE';
$params['client_key']='******'; //Client's KEY
$params['order_id']='Platon_test_37254'.rand(100, 999);
$params['order_amount']='10.00';
$params['order_currency']='UAH';
$params['order_description']='test_by_Platon';
$params['card_number'] = '1111111111111111';
$params['card_exp_month'] = '11';
$params['card_exp_year'] = '1111';
$params['card_cvv2'] = '111';
$params['payer_first_name']='Jack';
$params['payer_last_name']='Anderson';
$params['payer_phone']='380962111111';
$params['payer_address']='NA';
$params['payer_country']='UA';
$params['payer_state']='NA';
$params['payer_city']='NA';
$params['payer_zip']='01001';
$params['payer_email']='test@test.com';
$params['payer_ip']='111.111.111.111';
$params['term_url_3ds']='https://google.com';
$params['signature'] = sha1($pass . strtolower(implode('', $params)));
$url = 'https://secure.platononline.com/p2p-debit/';
$tempData = array();
foreach ($params as $key => $value) {
$tempData[] = $key.'='.urlencode($value);
}
$crq = curl_init();
curl_setopt($crq, CURLOPT_URL, $url);
curl_setopt($crq, CURLOPT_HEADER, 0);
curl_setopt($crq, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($crq, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($crq, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($crq, CURLOPT_POSTFIELDS, implode('&', $tempData));
$result = curl_exec($crq);
if (curl_errno($crq)) {
echo 'ERROR: '.curl_error($crq);
}
curl_close($crq);
echo $result;
$moda = json_decode($result, true);
$pars['action']='DEBIT_RUN';
$pars['client_key']='7Y0Y8RCGG5*******';
$pars['trans_id']=$moda['trans_id'];
$pars['card_cvv2']='111';
$pars['signature']= sha1($pass . strtolower(implode('', $pars)));;
$temp = array();
foreach ($pars as $key => $value) {
$temp[] = $key.'='.urlencode($value);
}
$crq = curl_init();
curl_setopt($crq, CURLOPT_URL, $url);
curl_setopt($crq, CURLOPT_HEADER, 0);
curl_setopt($crq, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($crq, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($crq, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($crq, CURLOPT_POSTFIELDS, implode('&', $temp));
$res = curl_exec($crq);
if (curl_errno($crq)) {
echo 'ERROR: '.curl_error($crq);
}
curl_close($crq);
echo $res;
$respRedirect = json_decode($res, true);
echo $respRedirect['redirect_url'];
header('Location: '.$respRedirect['redirect_url']);
?> |