我正在使用codeigniter框架上的web服务。我的Android应用程序开发工作的朋友正在使用paypal支付网关的所有内容。我要求我建立一个paypal服务,即支付确认或验证。我已将支付库上传到我的服务器上,但我没有在网上获得确切的支付验证码。
答案 0 :(得分:0)
当您在PayPal中付款时,您应该从paypal网站获取payment_status
响应
SUCCESS
mc_gross=1.00
protection_eligibility=Partially+Eligible+-+INR+Only
address_status=unconfirmed
tax=0.00
payment_date=07%3A40%3A51+Aug+06%2C+2013+PDT
payment_status=Completed
charset=windows-1252
first_name=Sureshkumar
etc.....
如果失败,你会得到
FAIL 403
这用于事务id返回后的验证过程。
$tx=$_REQUEST['tx'];
$paypal_url='https://www.paypal.com/cgi-bin/webscr?cmd=_notify-synch&tx='.$tx.'&at=token here';
$curl = curl_init($paypal_url);
$data = array(
"cmd" => "_notify-synch",
"tx" => $tx,
"at" => "token here"
);
$data_string = json_encode($data);
curl_setopt ($curl, CURLOPT_HEADER, 0);
curl_setopt ($curl, CURLOPT_POST, 1);
curl_setopt ($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 1);
$headers = array (
'Content-Type: application/x-www-form-urlencoded',
'Host: www.paypal.com',
'Connection: close'
);
curl_setopt ($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt ($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
$lines = explode("\n", $response);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
$first_name=$keyarray['first_name'];
$last_name=$keyarray['last_name'];
$payment_status=$keyarray['payment_status'];
$business=$keyarray['business'];
$payer_email=$keyarray['payer_email'];
$payment_gross=$keyarray['payment_gross'];
$mc_currency=$keyarray['mc_currency'];
}