html – 整合paypal

前端之家收集整理的这篇文章主要介绍了html – 整合paypal前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已成功整合paypal帐户.一切都很好.但我希望当付款成功转移然后重定向到我的网站.另一个问题如何从贝宝获得回应?
这是我的贝宝形式.谢谢
  1. `<form action="https://sandBox.paypal.com/cgi-bin/webscr" method="post">
  2. <input type="hidden" name="business" value="savife_1314264698_biz@gmail.com ">
  3. <input type="hidden" name="cmd" value="_xclick-subscriptions">
  4. <input type="hidden" name="item_name" value="Alice's Weekly Digest">
  5. <input type="hidden" name="item_number" value="DIG Weekly">
  6. <input type="hidden" name="currency_code" value="USD">
  7. <input type="hidden" name="notify_url" value="http://localhost/check.PHP">
  8. <input type="hidden" name="return" value="http://google.co.in">
  9. <input type="hidden" name="a3" value="5.00">
  10. <input type="hidden" name="p3" value="1">
  11. <input type="hidden" name="t3" value="M">
  12.  
  13. <!-- Display the payment button. -->
  14. <input type="image" name="submit" border="0" src="btn_subscribe_LG.gif" alt="PayPal - The safer,easier way to pay online">
  15. <img alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif" >
  16. </form>

解决方法

请仔细阅读:

您想要的是PAYPAL IPN,即时付款通知,在付款完成后发送到用户的网站.

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

或者您也可以在购物车中设置IPN路径,paypal将发送通知,如下所示:

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

但是您需要在paypal上登录您的商家帐户才能手动指定ipn和自动返回网址.在配置文件选项卡下的网站付款首选项和即时付款通知部分

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

  1. // read the post from PayPal system and add 'cmd'
  2. $req = 'cmd=_notify-validate';
  3.  
  4. foreach ($_POST as $key => $value) {
  5. $value = urlencode(stripslashes($value));
  6. $req .= "&$key=$value";
  7. }
  8.  
  9. // post back to PayPal system to validate
  10. $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
  11. $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  12. $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
  13. $fp = fsockopen ('ssl://www.sandBox.paypal.com',443,$errno,$errstr,30);
  14.  
  15. // assign posted variables to local variables
  16. $item_name = $_POST['item_name'];
  17. $item_number = $_POST['item_number'];
  18. $payment_status = $_POST['payment_status'];
  19. $payment_amount = $_POST['mc_gross'];
  20. $payment_currency = $_POST['mc_currency'];
  21. $txn_id = $_POST['txn_id'];
  22. $receiver_email = $_POST['receiver_email'];
  23. $payer_email = $_POST['payer_email'];
  24.  
  25. if (!$fp) {
  26. // HTTP ERROR
  27. } else {
  28. fputs ($fp,$header . $req);
  29. while (!feof($fp)) {
  30. $res = fgets ($fp,1024);
  31. if (strcmp ($res,"VERIFIED") == 0) {
  32. // check the payment_status is Completed
  33. // check that txn_id has not been prevIoUsly processed
  34. // check that receiver_email is your Primary PayPal email
  35. // check that payment_amount/payment_currency are correct
  36. // process payment
  37. }
  38. else if (strcmp ($res,"INVALID") == 0) {
  39. // log for manual investigation
  40. }
  41. }
  42. fclose ($fp);
  43. }
  44. ?>

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

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

将此代码放在site.com/ipn/index.PHP

让我们举一个购物车的例子:

  1. <form action="https://sandBox.paypal.com/cgi-bin/webscr" method="post">
  2. <input type="hidden" name="business" value="savife_1314264698_biz@gmail.com ">
  3. <input type="hidden" name="cmd" value="_xclick-subscriptions">
  4. <input type="hidden" name="item_name" value="Alice's Weekly Digest">
  5. <input type="hidden" name="item_number" value="DIG Weekly">
  6. <input type="hidden" name="currency_code" value="USD">
  7. <input type="hidden" name="notify_url" value="http://localhost/check.PHP">
  8. <input type="hidden" name="return" value="http://google.co.in">
  9. <input type="hidden" name="a3" value="5.00">
  10. <input type="hidden" name="p3" value="1">
  11. <input type="hidden" name="t3" value="M">
  12.  
  13. <!-- Display the payment button. -->
  14. <input type="image" name="submit" border="0" src="btn_subscribe_LG.gif" alt="PayPal - The safer,easier way to pay online">
  15. <img alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif" >
  16. </form>

在这种情况下,paypal将发送ipn的通知URL是http://localhost/check.PHP.

所以将该代码放在check.PHP页面中.收到ipn后,您可以进一步使用它进入您的数据库等.

或者访问此链接获取paypal ipn listener的概述:

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

希望这可以帮助.

猜你在找的HTML相关文章