[英]I want to implement paypal integration in my codeigniter code .But What i need is that only one function i.e payment confirmation or verification
I am working with web services on codeigniter framework .My friend working on android app development is using everything of paypal payment gateway as of its own.he asked me to just build one service of paypal that is , payment confirmation or verification. 我正在使用Codeigniter框架上的Web服务。我从事Android应用程序开发的朋友正在使用Paypal付款网关的所有功能。他要求我只构建Paypal的一项服务,即付款确认或验证。 I have uploaded payment library onto my server but i am not getting exact code of payment verification on net.
我已经将付款库上传到我的服务器上,但是我没有在网上获得确切的付款验证代码。
When you make payment in the paypal you should get the payment_status from the paypal site 当您在Paypal中付款时,您应该从Paypal网站上获得payment_status
Response 响应
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.....
If failed you will get 如果失败,你会得到
FAIL 403
This is used for verify process after transaction id is return. 这用于返回事务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'];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.