Last post Mar 17, 2014 10:09 PM by Ericzh
Mar 11, 2014 12:11 PM|SerenGoch|LINK
Hi there All
If anyone has any ideas on the following I would be most greatful as I can't work out what I'm doing wrong (if anything) at the moment.
We have a checkout process that redirects to a specific aspx page on our site. There is an HttpHandler associated with the page that:
1) catches the request
2) reads values from a session variable
3) builds an HttpWebRequest pointing to the Payment Gateway we want to use
4) Gets the response and writes it to the browser
When we were in testing mode, all seems to work OK but once we've been switched to live it no longer works. Apparently the rules applied to live requests are more stringent and the provider is reporting that our requests do not have an Http Referrer, which
they then check against the list of allowed URLs on the account.
I get the same result both on my local development PC and on a staging server.
The Handler seems to be working, in that it intercepts the request, builds the payment gateway request and sends it and I know from test that it contains the post fields that I add to it.
I am setting the referer property but I was wondering if there was something about the fact that I was creating the HttpWebRequest from within an HttpHandler that meant that any referrer that I set would not be passed on for some reason.
The key code from within ProcessRequest in the HttpHandler is this bit:
HttpWebRequest paymentRequest = WebRequest.Create(PaymentUtils.GlobalIrisGlobalIrisUrl()) as HttpWebRequest;
paymentRequest.Method = "POST";
paymentRequest.ContentType = "application/x-www-form-urlencoded";
string PostData = "MERCHANT_ID=" + MerchantId + "&ACCOUNT=" + Account + "&ORDER_ID=" + OrderId + "&AMOUNT=" + Amount + "&CURRENCY=" + Currency + "&TIMESTAMP=" + TransactionDate + "&SHA1HASH=" + SHA1Hash+"&AUTO_SETTLE_FLAG="+AutoSettle+"&COMMENT1="+Comment1;
byte bytes = System.Text.Encoding.ASCII.GetBytes(PostData);
paymentRequest.ContentLength = bytes.Length;
Stream os = paymentRequest.GetRequestStream();
os.Write(bytes, 0, bytes.Length); //Push it out there
paymentRequest.Referer = PaymentUtils.GlobalIrisReturnUrl() + "/Payment/PaymentRequest.aspx";
HttpWebResponse resp = paymentRequest.GetResponse() as HttpWebResponse;
string result = "";
Stream str_response = resp.GetResponseStream();
StreamReader reader = new StreamReader(str_response);
result = reader.ReadToEnd();
Essentially what I need to be able to do is to POST a Form with data to the Payment Gateway and I chose the HttpHandler route after some research.
Does anyone know of anything that would interfere with the referer?
Thanks in advance.
Mar 17, 2014 10:09 PM|Ericzh|LINK
Essentially what I need to be able to do is to POST a Form with data to the Payment Gateway