dongshadu2546 2017-07-14 05:54
浏览 44
已采纳

如何在使用支付网关时确认付款是否成功?

This is how payment gateways works as I understand.

  1. We send necessary POST Request to Payment Gateway (2checkouts, Paypal, etc).

  2. Payments handle by Payments Getaway.

  3. Then Payment Getaway send us POST parameters . Assume that Payment Getaway return parameters to example.com/return.php page.

I know that they send POST parameter like status or something. We can take it to verify the Payments.

So what we do is, we write a codes in example.com/return.php page to verify the payment.

But what happen if any user/hacker send all POST parameters (I mean as Payment Gateway send) to example.com/return.php page.

How should I handle about this?

  • 写回答

1条回答 默认 最新

  • douyan8961 2017-07-14 07:13
    关注

    You are supposed to verify that you get your POST parameters from the source you expect it to come from. In the case of Paypal, let's use their Instant Payment Notification (or IPN) as an example.

    Looking at their IPN docs, they suggest:

    Check email address to make sure that this is not a spoof

    However, more importantly, you should look at:

    verify_sign = AtkOfCXbDm2hu0ZELryHFjY-Vb7PAUvS6nMXgysbElEn9v-1XcmSoGtf

    Before you can trust the contents of the message, you must first verify that the message came from PayPal. To verify the message, you must send back the contents in the exact order they were received and precede it with the command _notify-validate, as follows:

    This means that, when you receive an IPN to example.com/return.php page, which can be at any time and not in the normal flow of a HTTP request / response that your end-user will be triggering, you then send this information back to PayPal and get them to verify that what you received was both correct and from them.

    PayPal will then send one single-word message, either VERIFIED, if the message is valid, or INVALID if the messages is not valid.

    So in your hypothetical example of someone sending spoofed data to your endpoint, PayPal would verify it as invalid anyway, and then you can go about what you need to do to make sure it doesn't happen again (logging, IPTables etc).

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

报告相同问题?

悬赏问题

  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多