POST vs. GET

commbits <[email protected]> 28 Jun 2003 02:23:22 -0000
Newsgroups gmane.comp.web.oscommerce.devel
Message-ID <1562b1c3be485937f32cf31ac621869b@osCommerce-Forums>
This message was sent from: Development
http://forums.oscommerce.com/viewtopic.php?p=188609#188609
----------------------------------------------------------------

Firstly, you need to get rid of the quotes around MODULE_PAYMENT_BEANSTREAM_MERCHANT_ID at the following line, otherwise no merchantID is passed:
[quote]tep_draw_hidden_field('merchant_id', 'MODULE_PAYMENT_BEANSTREAM_MERCHANT_ID') . [/quote]

Then, we need to distinguish between POSTing and GETing to the Beanstream server.

When we GET our input there, we must call https://www.beanstream.com/scripts/payment/payment.asp?merchant_id=.....

When we POST, we must call  https://www.beanstream.com/scripts/process_transaction.asp

osCommerce is POSTing, but you are calling the GET URL in your script:
[quote]$this->form_action_url = 'https://www.beanstream.com/scripts/payment/payment.asp'; [/quote]

The drawback with the Beanstream POST method is that you must capture credit card information yourself. (Not recommended, unless you are using SSL and are willing to write additional error validation code.) However, if this is the way you want to go, simply change the call in your script to https://www.beanstream.com/scripts/process_transaction.asp.
Under this scenario, you will also require an "errorPage" hidden variable, containing a URL on your server where Beanstream will redirect your shopper in case there are errors in the transaction. You must then write your own validation code. (That wouldn't be the easiest thing to do in an osCommerce-integration fashion.)

The advantage of the GET method is that Beanstream is performing the credit card capture, AND the error validation. Under this scenario, you capture all information in osCommerce except credit card info, pass it to Beanstream (to save your shopper from the double-entry) in your own Beanstream-branded page at https://www.beanstream.com/scripts/payment/payment.asp and off you go! You would of course need to instruct osCommerce to mark the order is "processing" or "pending", until you know that the transaction has been approved. Approval is instantaneous, but it takes place AFTER we send the user away from osCommerce and the GET method does not return values, other than an e-mail message to the merchant and the shopper.

This is how you can use the GET method:
You need to convert from the osCommerce POST method to the GET method. Therefore, instead of sending the input directly to Beanstream (from your script above) send it instead to a different script on your server which would do the conversion.
The conversion part is straight forward: Simply read all $_POST[variables] and construct a long GET string.
A part of this code could be:
[code]$redir_url="https://www.beanstream.com/scripts/payment/payment.asp?merchant_id=" . $_POST[merchant_id] . "&trnAmount=" . ......[/code]

Then, simply redirect to this newly constructed URL using something like
[code]header("Location:" . $redir_url); [/code]
(Make sure you send nothing to the browser prior to the redirection command.)

I hope this solves your problem and good luck with your efforts.

One problem we are facing ourselves is that we have not yet managed to pass the order_id and we suspect that the order_id is created after we checkout. Any ideas anyone on why order_id is empty during the payment processing?

Thank you,

Al Poullis
COMMbits
Toronto-Canada