Hi im rubbish at programming, but im trying....

Im trying to get a page to display the details posted to a form. Part of it is working and part of it isnt for some reason.

Ive declared a new value called "responsecode", responsecode = Request.Form("gtpay_tranx_status_code")
If the value posted to the form field "gtpay_tranx_status_code" is either "00" (double zero) or "001" then it should
run the first part of the code below:

If responsecode = "00" Then '001 is for VISA 00 for interswitch and MIGS

lblTranxDescription = "<font color=green><b>Transaction Completed Succesfully</b></font>"
lbltranxID = tranxid
lblDescription = "<font color=green><b>Payment Approved Succesfully</b></font>"
lbltraAmt = tra_amt

But for some reason although the responsecode is 00 it is not running that but jumping to the last part and shoing it as failed instead:

Else
lblTranxDescription = "<font color=red><b>Transaction Failed</b></font>"
lblError = responsecode
lbltranxID = tranxid
lblDescription = responsemessage
lbltraAmt = tra_amt

Please can someone point out what ive done wrong?
(Also is it possible to use CreateMHTMLBody "page.asp" to post itself to email or does it have to be another page?)
Im running out of time to get this working, thank you for your help.
Joe

================================================== ======================================

Recommended Answers

All 22 Replies

        <%

                    If Request.Form >"" Then

                        Dim responsecode 
                        responsecode = Request.Form("gtpay_tranx_status_code")
                        Dim responsemessage
                        responsemessage = Request.Form("gtpay_tranx_status_msg")

                        Dim tra_amt
                        tra_amt = Request.Form("gtpay_tranx_amt")
                        Dim tranxid 
                        tranxid = Request.Form("gtpay_tranx_id")
                        Dim cust_id
                        cust_id = Request.Form("gtpay_cust_id")
                        Dim tranx_memo
                        tranx_memo = Request.Form("gtpay_tranx_memo")
                        Dim echo_data
                        echo_data = Request.Form("gtpay_echo_data")

                      Dim lblTranxDescription
                      Dim lblDescription
                      Dim lbltraAmt

                        If responsecode = "00"  Then   '001 is for VISA  00 for interswitch and MIGS

                            lblTranxDescription = "<font color=green><b>Transaction Completed Succesfully</b></font>"
                            lbltranxID = tranxid
                            lblDescription = "<font color=green><b>Payment Approved Succesfully</b></font>"
                            lbltraAmt = tra_amt

                        Elseif responsecode = "001"  Then

                            lblTranxDescription = "<font color=green><b>Transaction Completed Succesfully</b></font>"
                            lbltranxID = tranxid
                            lblDescription = "<font color=green><b>Payment Approved Succesfully</b></font>"
                            lbltraAmt = tra_amt

                        Else
                            lblTranxDescription = "<font color=red><b>Transaction Failed</b></font>"
                            lblError = responsecode
                            lbltranxID = tranxid
                            lblDescription = responsemessage
                            lbltraAmt = tra_amt
                        End If

                    End If
    %>

I'm not following your code very well... but in any case, why dont you try to figure out what the actual value is of responsecode via a response.write or something similar so you can see its value through the process.

ive done that, and it is 00 which is why it should be showing the green Payment Aproved message rather than the Red Transaction failed...

In line 6, try this..

responsecode = "00"

see what happens.

That then behaves as if the transaction went through, it shows the green Payment Aproved message....

Can I ask, if I set up a CDO email script on the bottom of this page, can I use CreateHTML to email this same page back to myself or to another email address? Or can I only point this command to annother seperate page?

(Because once it is working I need to both display the response and email it too.)

That then behaves as if the transaction went through, it shows the green Payment Aproved message....

Then that means what is being stored in Request.Form("gtpay_tranx_status_code") is not the same as "00". Maybe you have a trailing space or something...

if I set up a CDO email script on the bottom of this page, can I use CreateHTML to email this same page back to myself or to another email address? Or can I only point this command to annother seperate page?

You would handle the email prior between lines 45-47. If you plan on redirecting the user to another page, that would need to occur after the emailing subroutine.

Ahh thank you for that, but lets say this page (with the code ive posted above is called mypage.asp can I use:

MailObj.CreateMHTMLBody "http://mywebsite.com/mypage.asp"

to email itself or do I have to pass all the values over in a string to another page and email that one?

Oh I see. I really haven't tried CreateMHTMLBody. I would generally build the body of the message using HTMLBody instead.

Sorry, classic asp is not something I work on lately. Most of the asp in my head is fading. I've been mainly working in asp.net for quite a while.

Im using it in the lines you said between the 2 end If statements on line 46:

AdminMailObj.CreateMHTMLBody "http://mysite.com/MyPage.asp"

AdminMailObj.Send
Set AdminMailObj = Nothing

It is emailing the page, but without any of the passed details displayed, that do show on the website page.
The transaction suceess or failure details are simply missing from the page that is emailed, yet they show on the page that is shown online...?

Any idea why this would be?

It is emailing the page, but without any of the passed details displayed, that do show on the website page.

yes, i didnt expect it to include anything filled out on the form. The reason is that while you are filling out the form, the page is local to your browser. The CreateMHTMLBody is simply taking an HTML page stored on the server and sending it out. This is good for scenarios where you want to prepare a message, that includes HTML and stored as a file so you dont have to reference all of that HTML in your code. I'm sure that you can reference this asp page and have dynamic data by passing URL parameters, say http://mysite.com/MyPage.asp?user=1

I should have indicated that in my last response. If your intention is to send out an email with the information that is contained in the form, I beleive your best option is to allow the post back, collect the values from the form, then create the email and include those form values.

ahh, ok so I need to create another page & send the values to it in a URL string and then email that page?

Given that I have various values stored on the page like for example resonsecode how do I add those to a URL string?

Ive tried this but it doesnt work:
<%
MailObj.CreateMHTMLBody "http://mywebsite.com/mypage2.asp?statuscode=responsecode"
%>

I also tried using:
MailObj.CreateMHTMLBody "http://mywebsite.com/mypage2.asp?statuscode= response.write responsecode "

But I suspect the spacing breaks the string? And it doesnt work either...

Yeah, that's not what I meant.

I would suggest that you use the HTMLBody property instead and build the content of the message manually. For example...

 MailObj.HTMLBody = "<h1>This is a message.</h1>"

You can continue to append to this variable and includes variables, etc...

what im trying to get my head round is how you include a response.write value inside the
<%

MailBody = "<% response.write responsecode %> "

%>

That wont work will it?

How do I put stored values in there?

cracked it I think: ?statuscode=" + responsecode + " &tranx_amt=" + tra_amt + " &gtpay_cust_id=" + cust_id + " &status_msg=" + responsemessage + " &tranx_id=" + tranxid + ""

Yeah, you have the idea now. This is how you include variables and text.

 var1 = "string"
 MailObj.HTMLBody = "<p>var1 has a value of " & var1 & "</p>"

In your example, if you are going to send parameters in the query string the target page needs code to accept those parameters and use them accordingly.

Please note that I have not tried what you are attempting to do with CreateMHTMLBody.

I'm curious if your approach will work.

Hi, yesy ive got it working now, using the example I showed above:

?statuscode=" + responsecode + " &tranx_amt=" + tra_amt + " &gtpay_cust_id=" + cust_id + " &status_msg=" + responsemessage + " &tranx_id=" + tranxid + ""

almost got this entire thing completed now, thanks so much for your patience and help.

How do I delete all these stored values at the bottom of the page so that a customer cant just click refresh on the page to load it all again, or more importantly so that there will be no danger of someone visiting and the old stored data is loaded instad of the new data.

Ive tried using Set responsecode = Nothing
But that doesnt seem to work?

I don't see you using any session variables and you are running these pages as classic ASP (.asp) right not asp.net? There's no viewstate in asp. Once you refresh the page, the form data and variables would clear

This is all in user session so someone else visiting the page would not have access to this session.

Once the page is closed then reopened, the form will be cleared. Your not saving those values client side or server side.

For the same form and values to be retained for a future visit by the same user, you would have to identify the user by either login or cookie and have previously stored the values in a data source to be able to show them back to the user.

Http is a stateless protocol. You actually have to do something on purpose to keep moving values between pages.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.