Avatar of Shawn
ShawnFlag for Canada asked on

display result/receipt

I am setting up the hosted payment solution with coldfusion. On my site I have a submit button that goes to another page on my website to insert client data into our database then post the required information to the merchant. I have managed to do the initial post to register the card and do the first payment transaction. The returned data is a little confusing (below). Would you have a simple example of retrieving the fields with data and displaying a receipt?

Any suggestions?

the code:
    <cfscript>
        keyArray = structKeyArray(response_struct);

        for( i=1; i LTE arrayLen(keyArray); i=i+1 )
        {
            if( (keyArray[i] eq "ResolveData") and (arrayLen(response_struct['ResolveData']) GT 0))
            {
                j=1;
                writeoutput("<br>*******************************************************************");
                writeoutput("<br><br>ResolveData");
                writeoutput("<br>----------------------------------------------------------------------");
                resolveDataKeyArray = structKeyArray(resolver_response_struct[j]);

                for( k=1; k LTE arrayLen(resolveDataKeyArray); k=k+1)
                {
                    if (structFind(resolver_response_struct[j], resolveDataKeyArray[k]) IS NOT "")
                    {
                        writeoutput( "<br>" & resolveDataKeyArray[k] & " is:_________" & structFind(resolver_response_struct[j], resolveDataKeyArray[k]) );
                    }
                }

                writeoutput("<br>*******************************************************************");
            }
            else
            {
                if (structFind(response_struct, keyArray[i]) IS NOT "")
                {
                    writeoutput( "<br>" & keyArray[i] & " is:_________" & structFind(response_struct, keyArray[i]) );
                }
            }
        }
    </cfscript>

the results:
TransDate is:_________2011-07-12
Complete is:_________true
AuthCode is:_________002889
ISO is:_________01
TransType is:_________00
ReceiptID is:_________RES_PURCH_0712201107:22:57
TransAmount is:_________1.00
CardType is:_________M
CvdResultCode is:_________null
ResSuccess is:_________true
*******************************************************************

ResolveData
----------------------------------------------------------------------
masked_pan is:_________5454***5454
note is:_________Your first payment will be $1000.55
phone is:_________yourphone
crypt_type is:_________7
cust_id is:_________testcustomer123
expdate is:_________1107
email is:_________youemail
*******************************************************************
AvsResultCode is:_________null
TransID is:_________143578-0_7
DataKey is:_________LfSCZBbHUJPgKXd0opkKEuUc4
Message is:_________APPROVED * =
PaymentType is:_________cc
ResponseCode is:_________027
TimedOut is:_________false
RecurSuccess is:_________null
ReferenceNum is:_________660021730010029080
TransTime is:_________02:22:57

Open in new window

Web ServersColdFusion Language

Avatar of undefined
Last Comment
Shawn

8/22/2022 - Mon
Brijesh Chauhan

Typically you would check if MESSAGE from the payment gateway, basically

Message is:_________APPROVED --- so if message is APPROVED, you will have a CFLOCATION to a page which shows the INVOICE.

NOTE - you would have a FORM which POSTS all the information to the gateway, so you can store this information LOCALLY before posting, if it is APPROVED then you can generate the invoice with the data saved locally, that way you don't have to worry about the data that is returned back.

If the message is NOT APPROVED or something else, they you can say that transaction was not approved.

The other thing that you would need from payment gateway is the TRANSACTION ID, which is typically used to VOID the transactions.

In your example above, you would have posted all the details, amount, phone number, customer name, etc, so before posting you can store them locally and use it to show the invoice from local database is the transaction is approved..

if Message is APPROVED
 
  cflocation to recipt page

else

 error message with code

end if
ASKER
Shawn

ok, seems clearer now. thank you. I'm on PST here so about ready to turn into a pumpkin. I'll do a little testing in the morning and come back.
ASKER
Shawn

ok, I understand your explanation and agree though what I need is help understanding how the data was pulled...or better how I can pull it to retrieve only the fields/data I need.  I am not very familiar with cfscript, keyArray = structKeyArray(response_struct).

If I know there is a response field "ReferenceNum' how would I get this? or how would I get a list of the fields?

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
SOLUTION
Brijesh Chauhan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
_agx_

> the returned data is a little confusing (below).

Is the code above a vendor example? If so, where's the rest of it, like the section that creates #response_struct#?

Is this a continuation of your other thread? Yesterday you thought the values were available in the URL scope and you were going to store it in your db. Has something changed?




Brijesh Chauhan

Try something as below.. to get results..

<cfif structKeyExists(response_struct,'ResolveData')> 

	<cfoutput> SUCESS -> #response_struct.ResSuccess# </cfoutput>
   
	<cfoutput> MESSAGE -> #resolver_response_struct[1].Message# </cfoutput>
    
    <cfoutput> ReferenceNum -> #resolver_response_struct[1].ReferenceNum# </cfoutput>
    
</cfif>

Open in new window

ASKER
Shawn

>>Is the code above a vendor example? If so, where's the rest of it, like the section that creates #response_struct#?
yes. see below and in the attachments.

>>Is this a continuation of your other thread?
this is the next step.
>>Yesterday you thought the values were available in the URL scope and you were going to store it in your db. Has something changed?
the first step data was passed through the url to register the credit card via the hosted page. we are returned a key rather than storing the credit card through the url.
this step is a server to server involving that key to retrieve the credit card and process the payment.


the part above the posted cfscript:
	<cfinclude template="mpgAPIFunctions.cfm">

	<cfset mytime = TimeFormat(Now(), 'hh:mm:ss')>
	<cfset myday = DateFormat(Now(),'mmddyyyy')>
	<cfset OrderID = '#myday##mytime#'>

	<cfscript>
		order_id = "RES_PURCH_" & OrderID;
		data_key = data_key;
		amount = "1.00";
		crypt_type = "7";
		myTxn = formResPurchaseCCArray( data_key, order_id, amount, crypt_type );

		//if sent will be submitted, otherwise cust_id from profile will be used
		cust_id = "customer 2";
	</cfscript>

	<CF_mpgAPI_CF5 host="https://esqa.moneris.com/gateway2/servlet/MpgRequest" store_id="store1" api_token="yesguy" txn_array="#myTxn#" cust_id="#cust_id#">

Open in new window

mpgAPI-CF5.txt
mpgAPIFunctions.txt
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
_agx_

Right, but that original code looks like a debugging sample. You don't actually have to use all cryptic variable indexes and structFind's to display the results. As long as you know the keys you want to display, just reference them by name

ie   TransDate is:_________ #response_struct['TransDate']#

There might be a few complex objects, but you can see most of the #response_struct# key names at the bottom of mpgAPI-CF5-1.txt.

      caller.response_struct['ReceiptID'] = ....
      caller.response_struct['ReferenceNum'] = ....
      caller.response_struct['ResponseCode'] = ...
ASKER
Shawn

>>code looks like a debugging sample.
yep, agreed.

thx. I'll play around and get back shortly.
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Brijesh Chauhan

hey Shawnaraxi

I had already pointed out the use of response_struct which contains the records, comment ID 36175167 ..


<cfif structKeyExists(response_struct,'ResolveData')> 

	<cfoutput> SUCESS -> #response_struct.ResSuccess# </cfoutput>
   
	<cfoutput> MESSAGE -> #resolver_response_struct[1].Message# </cfoutput>
    
    <cfoutput> ReferenceNum -> #resolver_response_struct[1].ReferenceNum# </cfoutput>
    
</cfif>

Open in new window


Any reason WHY you didn't want to SPLIT points ?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
_agx_

> MESSAGE -> #resolver_response_struct[1].Message#
> ReferenceNum -> #resolver_response_struct[1].ReferenceNum#

Actually message and reference number values are in response_struct, not resolver_response_struct.

     caller.response_struct['Message'] = ...
     caller.response_struct['ReferenceNum'] = ...

But I've no problem with whatever Shawnaraxi decides.
ASKER
Shawn

brijeshchauhan. I tried it and it was throwing an error...turns out it was because "reference number values are in response_struct, not resolver_response_struct".

I am happy to split the points if we can reopen the question. My aplogies...your answers and explanations were helpful.
Brijesh Chauhan

@Shawnaraxi,

thanks for your response, just knowing that my comments were helpfull is good enough... !!!!! No need to reopen the question ... !

-Brij

Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
Shawn

Brij, apoligies again. Yes your comments were more than helpful. On top of my solution I now have a better understanding of structures and keys.
_agx_

@Shawnaraxi - If you want to reopen and reassign, it's totally fine with me :)
ASKER
Shawn

thanks agx. I did a request for attention asking to reopen. I think that's where you do it.???
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
_agx_

Yep, that's the place. As soon as a moderator sees it, they'll reopen the question. Then you can reallocate.
ASKER
Shawn

will do.  

more questions to come I'm sure. :-D
ASKER
Shawn

thanks again!
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.