1

I am working on an authorize.net payment system, the problem I am facing is: if some user done with transaction once, and he clicks on reload page or reload tab, then his money is cut twice.

So I want to avoid this reload and transaction more than once until he does transaction from the beginning.

Also I am having problem with go forward and go back how to avoid last values for this.

4

4 回答 4

1

One easy trick is to use ajax call, so even if its reload the page, its only see the new status after the payment.

So what you do, you have a page that you show the current status of the payment, when the user click on the button to pay you send them request with ajax call - at the same time the button show a way message, after the end of the payment you reload the page, with the new information's.

In general you must have a unique number for each transaction, and a state flag of this transaction. You allow only one action per transaction. If the user press the key and go to the payment immediate you change the status of this transaction (using mutex to avoid the double submit even at that point) and after that you do not allow the same request aka reload the page.

The full process of payment is done in steps that are not allow to stop and go back (or repeat a step). In case that you need to go back you create a new process with new id and must repeat all the steps from the beginning. This way is done by paypal, amazon, google.

于 2012-05-28T08:01:02.063 回答
1

经典的解决方案是

  1. 您将数据保存在 page1.aspx
  2. 在 page2.aspx 上成功保存数据显示结果(重定向到 Page2.aspx )

因此,即使他刷新它也会重新加载 page2.aspx,并且您的交易不会被复制希望它有帮助:)

PS。您可能希望禁用/隐藏 Page1.aspx onclientclick 上的保存按钮,以便用户无法单击两次按钮。

于 2012-05-28T07:02:39.187 回答
1

如果您使用 asp.net C# 进行交易,请不要在付款后停留在同一页面上,这不是一个好习惯。收到服务器的成功响应后,立即重定向到支付成功页面。

即使您没有收到成功响应或交易失败,也不要停留在页面上,重定向到某个说明交易失败的页面。

也尽量不要在事务页面上存储数据(视图状态),也不要编写需要 !IsPostBack 块的代码。

阅读 authorize.net 的各种可用最佳实践,包括:

https://developer.authorize.net/integration/fifteenminutes/csharp

http://www.authorize.net/files/developerbestpractices.pdf

并写出最好的代码。

于 2012-05-28T07:10:06.303 回答
-2

将代码放在(!Page.IsPostback)块中,这样它只会发生一次。

于 2012-05-28T07:03:49.440 回答