I’m building a script which connects to a payment gateway (via a form with hidden inputs) and on that page I’m also creating a database record of the order.
At the moment the record is created when the user visits the page, which will duplicate the data if the user returns to alter any details. This doesn’t have much of a negative effect, other than duplicate data in the order management area (which is not marked as a complete order).
What I would like to do is create the database after the user confirms the order and somehow create, populate and submit the form to the Payment Gateway in the background.
It would be easier, but given the choice clients would like to know if they are losing customers at the point where they get directed elsewhere. It can also be a good indicator of a problem with the PSP, and this approach has saved me in the past.
I think you’d probably be best to either edit your OP or provide an updated post with exactly what you’re looking to do, because right now I’m confused as to what it is you’re trying to accomplish (your posts seem to be contradictory).
I’m using Sagepay Form, but I want to capture details of people who might just close the browser when they get to the payment page (this could help pick up problems). I’ll automatically delete these details after a month.
I thought that there was a way of creating and sending a form using the header() function?
Not sure what the confusion is, maybe I need to spell it out to some…
After the customer has seen the contents of the cart, added their name/address etc, they are direct to a script where they see all order details and then confirm the order.
As it stands the confirm button is actually a submit button for a form which contains only hidden inputs and is posted to the Payment Service Provider where they can take card details, approve/decline the order and send that information back to a specified page on the site where the database record is completed.
What I prefer to do is create part of the database record on the confirm page, so the client gets more information about where potential customers are aborting the checkout process, but if the decide to leave the confirm page to edit their details the database record is duplicated (not a huge problem).
I was trying to improve the script by having the confirm page’s submit button point to itself, create the database record after the customer has confirmed the order and then submit the details to the PSP (which would involve building and submitting a form) without further customer interaction.
I’m sure I’ve seen somewhere that I can do something like this with the header() function, and I was hoping that someone can point me in the right direction.