Auto Draft
Örnek Ödeme Sayfası
$merchant_id,
‘user_ip’=>$user_ip,
‘merchant_oid’=>$merchant_oid,
’email’=>$email,
‘payment_amount’=>$payment_amount,
‘payment_type’=>$payment_type,
‘paytr_token’=>$paytr_token,
‘debug_on’=>$debug_on,
‘timeout_limit’=>$timeout_limit,
‘test_mode’=>$test_mode
);
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, “https://www.paytr.com/odeme/api/get-token”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1) ;
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vals);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
//XXX: DİKKAT: lokal makinanızda “SSL certificate problem: unable to get local issuer certificate” uyarısı alırsanız eğer
//aşağıdaki kodu açıp deneyebilirsiniz. ANCAK, güvenlik nedeniyle sunucunuzda (gerçek ortamınızda) bu kodun kapalı kalması çok önemlidir!
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = @curl_exec($ch);
if(curl_errno($ch))
{
die(“PAYTR EFT IFRAME connection error. err:”.curl_error($ch));
}
curl_close($ch);
$result=json_decode($result,1);/*
Başarılı yanıt örneği: (token içerir)
{“status”:”success”,”token”:”28cc613c3d7633cfa4ed0956fdf901e05cf9d9cc0c2ef8db54fa”}Başarısız yanıt örneği:
{“status”:”failed”,”reason”:”Zorunlu alan degeri gecersiz: merchant_id”}
*/
if($result[‘status’]==’success’)
{
$token=$result[‘token’];
}
else
{
die(“PAYTR EFT IFRAME failed. reason:”.$result[‘reason’]);
}
?>