dqmg80654 2013-07-01 20:47
浏览 28
已采纳

我想保存到mysql数据库,发送电子邮件然后做一个帖子,所有使用一个按钮[关闭]

I have a shopping cart and want to send an email confirming the order before forwarding the data to the payment system, for example PayPal.

Client put items in shopping cart and when ready I show a confirmation page with all details of the order. There is a button, Go to pay, that make a post to the selected payment system.

But before the post is executed, I would like to update the order data in my MySql table and also send a "Thank-you-for-the-order" email.

My first idea was to post to my server, update the table, send the email and do a curl to the payment system. But then they don't get transferred to the payment system in their browser to complete the payment.

Any suggestions how to solve this?

  • 写回答

1条回答 默认 最新

  • dongyi6668 2013-07-01 21:20
    关注

    How you should probably do things

    EDIT: Although I'm leaving this section here for now, I did make a false assumption about your process, so perhaps the next section is more beneficial

    I have not used online payment systems in any of my own projects, but I just took a look at the PayPal docs to confirm something. The payment process seems to go like this:

    1. Get user order and payment details
    2. Pass payment details to Paypal
    3. Direct the user to the approval URL so that the user can approve the payment
    4. They are redirected to your site by PayPal, with a payment ID
    5. You then confirm the payment by querying PayPal with the payment ID

    Most payment systems I've encountered online have had a similar process (from what I can see as an enduser). From what you're saying, it seems like you want to email the user and update your database at step 2, when you have not confirmed that a payment actually took place. I would suggest that instead, you perform the table update and email during step 5.

    So wait until whatever payment system you are using has confirmed the order, and update at that point, as part of the same process in which you query PayPal to confirm the order (And you can make sure your actions depend on them having actually paid you!)

    How you can do what you're asking to do

    Going back to the guts of your question though. If you do want to execute your own server side code while directing them to the external system, I'd suggest you send an Ajax request when they submit the form. This will call the script where you do your work in the background, and the user will still be redirected to the payment provider.

    Edit: I should mention the snippet here is using jQuery

    $("#myForm").submit(function(e) {
    
        // Do your ajax stuff here
    
    
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题