Update: This is NOT a duplicate of How do I send a POST request with PHP?. The solutions there don\'t work for me, they just output the result of the request, I don\'t w
I have one solution for you that will work either 99% of the time or 100% of the time depending on how you implement it. All you need to do is process the form with AJAX. I know you want a Javascript free way of doing this but it is the simplest way. If you use the jQuery library the documentation and SO answers are so easy to follow you wound not have to write much code. Just modify some. Here is the concept:
1) Page loads as normal with the forms action pointing to the payment processing website. Since you are using Javascript (jQuery) to submit the form you would have replaced the submit buttons html like so:
2) Swap out the forms action value. Before the actual AJAX code that will send the form behind the scenes to be processed, use something similar to this code to change the action to your own PHP page:
$('#formIdHere').attr('action', 'yourPHPpageAndPathHere.php');
This code is for jQuery but it should be easy to change to plain JavaScript if you need. Now also make sure your AJAX code does not reset the form. Many copy and past codes kindly do this for you.
3) (Optional) At this stage the form has been sent to your PHP page and you are done doing what you need to with it. You now have two options:
If you need to make sure the data was correct or need to alter some of it do that now. If the forms data fails your process (altered data for example) send back a FALSE and move on to number 4. If you need to change things that is a simple process. Send back all the data that needs updating in an array and loop through it in the same AJAX code that started this process. Using Javascript you can change the forms values.
[Code missing because I think you can figure this out if you need to do that. If not comment and when I have time I will post an example]
4) Swap back the forms action. Your AJAX processing is done. Traditionally it wipes the form and displays a message. If you choose the option from above that sends a FALSE to stop submission in case there was bad data, just return false from the AJAX script now (maybe display something before that return saying the form was not sent).
$('#formIdHere').attr('action', 'paymentUrlHere');
Now that the payment URL is back in place and any data was updated if you need to go that route, submit the form like it normally should (or would) be. IN jQuery this can be as simple as:
$('#formIdHere').submit();
And I think that covers it. At this point the user is out of your hands and was sent to the payment processing website with a normal POST. You even had the chance to alter data from the form if needed.
OH PS - Here is what I meant about the 99% and 100% way at the start of this post. 100% is the example I gave you here. No one can send the form without making it to your own PHP page first. The 99% solution would be to but the normal submit html in the page like so:
Then using Javascript stop the default submit action and follow my steps 1-4. That way if someone disables javascript (or is on a device that blocks it) the form still sends to the payment processor at least. Up to you what you want to do.