<?php

function verifyPayline($url,$api,$trans_id,$id_get)
{
	$ch = curl_init();
	curl_setopt($ch,CURLOPT_URL,$url);
	curl_setopt($ch,CURLOPT_POSTFIELDS,"api=$api&id_get=$id_get&trans_id=$trans_id");
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
	$res = curl_exec($ch);
	curl_close($ch);
	return $res;
}

$itemID = get_id(2);

require_once ROOT_PATH.'/zipmarket/apps/users/models/deposit.class.php';
$cms = new deposit();

$RefNum  = isset($_POST['trans_id']) ? $_POST['trans_id'] : '';
$ResNum  = isset($_POST['id_get'])   ? $_POST['id_get']   : '';
$OrderID = isset($_REQUEST['oID'])   ? $_REQUEST['oID']   : '';

$order_info = $cms->get($OrderID);

if($order_info)
{
	$api = $meta['payline_api']; //'adxcv-zzadq-polkjsad-opp13opoz-1sdf455aadzmck1244567';
	$result = verifyPayline('http://payline.ir/payment-test/gateway-result-second', $api, $RefNum, $ResNum);
	if ($result == '1')
	{
		$cms->depositIsPay($OrderID);
		refresh('http://' . $config['domain'] . '/' . $languageURL . 'users/deposit/success/' . $OrderID . '/');
	}
}

refresh('http://' . $config['domain'] . '/' . $languageURL . 'users/deposit/');