dphnn333971 2014-02-09 11:20
浏览 21
已采纳

PHP PayPal结账

I'm trying to develop a checkout system for a customer site, and I want to know the best way to do this. Please let me know of any alternatives to what I've tried below.

Currently I have:

1) Items in cart saved to $_SESSION variable

2) When a user presses 'checkout', they are taken to a page with an invisible form that POSTs the information saved in $_SESSION to https://www.paypal.com/cgi-bin/webscr

3) When payment is confirmed, they are redirected to confirm.php on the site that triggers an email to the client and the store containing the information from the cart (stored in $_SESSION) and the address data passed back (as I cannot pass all of the attribute information in the cart to paypal in the first POST) from PayPal.

The issue with my solution is that it doesn't appear to work on mobile safari, iPads, iPhones or older systems. So I'm looking for an alternative, or for a way for the data to remain persistent, as the emails sent out at the end contain no data when performed from one of these devices.

  • 写回答

1条回答 默认 最新

  • dsh8009271 2014-02-09 11:41
    关注

    Using a database you can store the entire cart as temporal or incomplete before calling the PayPal payment, and then get all the info via confirm.php, modify the state of the cart, etc.

    Also in your PayPal account you can activate automatic IPN upon every payment.

    An IPN is a listener that runs on your site and makes calls to paypal. You can find a lot of examples of these on the web.

    The idea is that you pass all the fields you want on the PayPal form, and paypal will send it back using the IPN call.

    In the PayPal form you can add a custom hidden input:

    <input type="hidden" name="cart_id" value="<?php echo $id ?>">
    

    And in the IPN listener you will get cart_id = 4, so you can automatically know which cart payment is done, and which user the cart belongs, change the cart status and email user.

    Hope this helps you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。