专业网站建设品牌,十四年专业建站经验,服务6000+客户--广州京杭网络
免费热线:400-963-0016      微信咨询  |  联系我们

PayPal IPN接口集成经验分享

当前位置:网站建设 > 技术支持
资料来源:网络整理       时间:2023/2/14 0:20:36       共计:3644 浏览

如果你的系统需要得知PayPal支付的最终结果(成功、失败),那么PayPal的IPN接口是最简单的解决方案。

  IPN通知示意图     下面分享一下我的经验:   1)如何申请PayPal IPN接口?   你只需要拥有一个普通的PayPal账户即可,IPN接口不需要单独申请开通。     2)准备工作:申请一个沙盒账户。   在系统开发阶段,我们不需要用真实的PayPal账户来测试。 到https://developer.paypal.com注册一个开发人员账户(免费)。 登录系统,添加一个虚拟卖家(例如,seller_1316102076_biz@qq.com)和一个买家(例如,buyer_1316102290_per@qq.com)。   3)制作一个订单表单。
  1. <form action="https://www.sandbox.paypal.com/cgi-bin/websc" method="post">  
  2.   <input type="hidden" name="business" value="seller_1316102076_biz@qq.com">  
  3.   <input type="hidden" name="item_name" value="海底捞优惠券">  
  4.   <input type="hidden" name="amount" value="30">  
  5.   <input type="hidden" name="no_note" value="1">  
  6.   <input type="hidden" name="return"  value="http://adsl.redicecn.com/order.php?status=ok">  
  7.   <input type="hidden" name="cancel_return" value="http://adsl.redicecn.com/">  
  8.   <input type="hidden" name="custom" value="1">  
  9.   <input type="hidden" name="notify_url" value="http://adsl.redicecn.com/ipn.php">  
  10.     
  11.   <input type="hidden" name="cmd" value="_xclick">  
  12.   <input type="hidden" name="currency_code" value="CAD">  
  13.   <input type="hidden" name="charset" value="utf-8" />  
  14.   <input type="hidden" name="rm" value="1" />  
  15.  <input type="submit" value="支付" />  
  16.   </form>  
  17. 解释一下几个重要的参数:   business = 收款者的PayPal账户 cmd = 立即购买按钮(_xclick),PayPal 购物车(_cart) return = 支付成功后跳转地址 cancel_return = 取消支付后跳转地址 notify_url = 接收通知的接口(在第4部中我们实现该接口) rm = PayPal跳转到return和cancel_return时的方式 (1=get, 2=post) currency_code = 货币单位(美元-USD,加币-CAD)   item_name = 商品的描述信息 amount = 商品的总额 custom = 自定义值(可以存放订单编号,PayPal的通知消息中将包含该参数)。 charset = 指定参数采用的字符编码(设置不正确在PayPal账单上将显示乱码,特别是商品描述。)   关于这些参数的更详细说明请参考这里:http://paypal.ebay.cn/integrationcenter/list__center_2.html 。 另外需要注意的是,用沙盒账户测试时表单提交的地址用https://www.sandbox.paypal.com/cgi-bin/websc,正式使用时用https://www.paypal.com/cgi-bin/webscr。     4)写一个通知接口,用于接收PayPal返回的消息(判断支付状态)。 各个版本的接口实例这里都有,https://cms.paypal.com/ca/cgi-bin/?&cmd=_render-content&content_ID=developer/library_code_ipn_code_samples。   下面是一个PHP的例子: ipn.php
  18. 解释一下几个重要的参数:   business = 收款者的PayPal账户 cmd = 立即购买按钮(_xclick),PayPal 购物车(_cart) return = 支付成功后跳转地址 cancel_return = 取消支付后跳转地址 notify_url = 接收通知的接口(在第4部中我们实现该接口) rm = PayPal跳转到return和cancel_return时的方式 (1=get, 2=post) currency_code = 货币单位(美元-USD,加币-CAD)   item_name = 商品的描述信息 amount = 商品的总额 custom = 自定义值(可以存放订单编号,PayPal的通知消息
版权说明:
本网站凡注明“广州京杭 原创”的皆为本站原创文章,如需转载请注明出处!
本网转载皆注明出处,遵循行业规范,如发现作品内容版权或其它问题的,请与我们联系处理!
欢迎扫描右侧微信二维码与我们联系。
·上一条:paypal IPN 接口小结 | ·下一条:Paypal的IPN示例

Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有    粤ICP备16019765号 

广州京杭网络科技有限公司 版权所有