Reputation: 10805
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.
Upvotes: 1
Views: 1119
Reputation: 157
Place the code in (!Page.IsPostback)
block so that it will happens only once.
Upvotes: -2
Reputation: 7438
Never stay on the same page after you made payment if you are using asp.net C# for transaction, that is not the good practice. Redirect to successful payment page immediately after you get the success response from server.
Even if you don't get success response or transaction failed, don't stay on the page either, redirect to some page stating about the transaction failure.
Also try not store data (viewstate) on the transaction page and don't write such code that requires !IsPostBack block.
Read the various available best practices for authorize.net, including:
https://developer.authorize.net/integration/fifteenminutes/csharp
http://www.authorize.net/files/developerbestpractices.pdf
and write the best code.
Upvotes: 1
Reputation: 66641
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.
Upvotes: 1
Reputation: 449
well the classic solution is that
hence even if he refresh it'll be page2.aspx's reloading and your transaction will not be copied hope it helps :)
PS. You may want to disable/hide your save button on Page1.aspx onclientclick so user can't click twice the button.
Upvotes: 1