本文介绍了整合贝宝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功整合PayPal帐户。一切工作正常。但我希望当付款成功转移然后重定向到我的网站。另一个问题如何从贝宝获得回应?
这里是我的贝宝形式。谢谢

 `< form action =https://sandbox.paypal.com/cgi-bin/webscrmethod = 后 > 
< input type =hiddenname =businessvalue [email protected]>
< input type =hiddenname =cmdvalue =_ xclick-subscriptions>
< input type =hiddenname =item_namevalue =Alice's Weekly Digest>
< input type =hiddenname =item_numbervalue =DIG Weekly>
< input type =hiddenname =currency_codevalue =USD>
< input type =hiddenname =notify_urlvalue =http://localhost/check.php>
< input type =hiddenname =returnvalue =http://google.co.in>
< input type =hiddenname =a3value =5.00>
< input type =hiddenname =p3value =1>
< input type =hiddenname =t3value =M>

< input type =imagename =submitborder =0src =btn_subscribe_LG.gifalt =PayPal - 更安全,更简单的网上付款方式>
< img alt =border =0width =1height =1src =https://www.paypal.com/en_US/i/scr/pixel.gif> ;
< / form>


解决方案

请仔细阅读以下内容:



您需要的是PAYPAL IPN,即时付款通知,付款完成后发送至用户的网站。



或者您也可以在您的购物车中设置IPN路径,PayPal将发送此类通知:

 < input type =hiddenname =notify_urlvalue =site.com/ipn/index.php /> 
< input type =hiddenname =returnvalue =site.com/ipn/index.php/>

但是,您需要在paypal上登录您的商家帐户才能手动指定ipn并自动返回网址。在网站付款偏好和即时支付通知部分下的个人资料标签。



以下我添加了成功付款后发送到您网站的示例ipn代码:

  //从PayPal系统读取帖子并添加'cmd'
$ req ='cmd = _notify-validate';
$ b foreach($ _POST as $ key => $ value){
$ value = urlencode(stripslashes($ value));
$ req。=& $ key = $ value;
}

//发回PayPal系统以验证
$ header。=POST / cgi-bin / webscr HTTP / 1.0 \r\\\
;
$ header。=Content-Type:application / x-www-form-urlencoded \r\\\
;
$ header。=Content-Length:。 strlen($ req)。 \r\\\
\r\\\
;
$ fp = fsockopen('ssl://www.sandbox.paypal.com',443,$ errno,$ errstr,30);

//将变量赋值给局部变量
$ item_name = $ _POST ['item_name'];
$ item_number = $ _POST ['item_number'];
$ payment_status = $ _POST ['payment_status'];
$ payment_amount = $ _POST ['mc_gross'];
$ payment_currency = $ _POST ['mc_currency'];
$ txn_id = $ _POST ['txn_id'];
$ receiver_email = $ _POST ['receiver_email'];
$ payer_email = $ _POST ['payer_email'];
$ b $ if(!$ fp){
// HTTP ERROR
} else {
fputs($ fp,$ header。$ req);
while(!feof($ fp)){
$ res = fgets($ fp,1024);
if(strcmp($ res,VERIFIED)== 0){
//检查payment_status已完成
//检查txn_id以前没有处理过
/ /检查receiver_email是您的主要PayPal电子邮件
//检查payment_amount / payment_currency是否正确
//进程支付
}
否则if(strcmp($ res,INVALID )== 0){
//记录手动调查
}
}
fclose($ fp);
}
?>

您需要在通知网页上添加此代码。您在购物车的通知网址字段中提到的返回页面

 < input type =hiddenname =notify_url value =site.com/ipn/index.php/> 

将这段代码放入 site.com/ipn/index.php



让我们以购物车为例:

 < form action =https://sandbox.paypal.com/cgi-bin/webscrmethod =post> 
< input type =hiddenname =businessvalue [email protected]>
< input type =hiddenname =cmdvalue =_ xclick-subscriptions>
< input type =hiddenname =item_namevalue =Alice's Weekly Digest>
< input type =hiddenname =item_numbervalue =DIG Weekly>
< input type =hiddenname =currency_codevalue =USD>
< input type =hiddenname =notify_urlvalue =http://localhost/check.php>
< input type =hiddenname =returnvalue =http://google.co.in>
< input type =hiddenname =a3value =5.00>
< input type =hiddenname =p3value =1>
< input type =hiddenname =t3value =M>

< input type =imagename =submitborder =0src =btn_subscribe_LG.gifalt =PayPal - 更安全,更简单的网上付款方式>
< img alt =border =0width =1height =1src =https://www.paypal.com/en_US/i/scr/pixel.gif> ;
< / form>

在这种情况下,您的paypal将发送ipn的通知网址是 http:/ /localhost/check.php



因此,将该代码放入 check.php 页。收到ipn后,你可以进一步使用它进入你的数据库等。



或访问此链接以获取paypal ipn监听器的概述:





希望这会有所帮助。

I have successfully integrate paypal account. all is working fine. But I want when the payment successfully transfer then redirect to my site. another question how to get response from paypal? here is my paypal form. Thanks

   `<form action="https://sandbox.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="business" value="[email protected] ">
    <input type="hidden" name="cmd" value="_xclick-subscriptions">
    <input type="hidden" name="item_name" value="Alice's Weekly Digest">
    <input type="hidden" name="item_number" value="DIG Weekly">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="notify_url" value="http://localhost/check.php">
    <input type="hidden" name="return" value="http://google.co.in">
    <input type="hidden" name="a3" value="5.00">
    <input type="hidden" name="p3" value="1">
    <input type="hidden" name="t3" value="M">

    <!-- Display the payment button. -->
    <input type="image" name="submit" border="0" src="btn_subscribe_LG.gif" alt="PayPal - The safer, easier way to pay online">
    <img alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif" >
</form>
解决方案

Just go through this:

What you want is PAYPAL IPN, INSTANT PAYMENT NOTIFICATION which is sent to user's website after payment is completed.

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro

or you can also set path to IPN in your cart where paypal will send notification like this:

<input type="hidden" name="notify_url" value="site.com/ipn/index.php" />
<input type="hidden" name="return"     value="site.com/ipn/index.php"/>

But you'll need to login to your merchant account on paypal to manually specify the ipn and auto return url. in website payment preferences and instant payment notifications section under profile tab.

Following i've added the sample ipn code which is sent to your website after successfull payment:

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
?>

You need to add this code on your notify url page. the return page you mention in notify url field of shopping cart i.e.

<input type="hidden" name="notify_url" value="site.com/ipn/index.php" />

Put this code in site.com/ipn/index.php

Lets take an example of your shopping cart:

<form action="https://sandbox.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="business" value="[email protected] ">
    <input type="hidden" name="cmd" value="_xclick-subscriptions">
    <input type="hidden" name="item_name" value="Alice's Weekly Digest">
    <input type="hidden" name="item_number" value="DIG Weekly">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="notify_url" value="http://localhost/check.php">
    <input type="hidden" name="return" value="http://google.co.in">
    <input type="hidden" name="a3" value="5.00">
    <input type="hidden" name="p3" value="1">
    <input type="hidden" name="t3" value="M">

    <!-- Display the payment button. -->
    <input type="image" name="submit" border="0" src="btn_subscribe_LG.gif" alt="PayPal - The safer, easier way to pay online">
    <img alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif" >
</form>

In this case your notify url where paypal will send ipn is http://localhost/check.php.

So put that code in check.php page. After recieving the ipn you can further use it to enter in your database etc.

or visit this link to get an overview of paypal ipn listener:

https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNImplementation

Hope this helps.

这篇关于整合贝宝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 17:43