Link to home
Start Free TrialLog in
Avatar of dgrafx
dgrafxFlag for United States of America

asked on

Sage Payment Solutions example code

Hello Guys
I'm looking for a simple example of submitting a payment for processing in ColdFusion.
Avatar of Coast Line
Coast Line
Flag of Canada image

are you saying you need an example of sage payment gateway only or any other will work
Avatar of dgrafx

ASKER

i'm looking for a getting started type of code - the company website doesn't have ColdFusion examples.
and as far as what - the code used to submit your payment request to them for processing.
do you need sagepay UK or US, i have a code for UK.
Avatar of dgrafx

ASKER

SagePay is UK
Sage Payment Solutions is US
what exactly you need.. please specify
Avatar of dgrafx

ASKER

The type of code I'm looking for is the submitting of payment data for processing - ya know credit card info and an amount - then a response.
Avatar of dgrafx

ASKER

Note: I do have a developers account but the company doesn't provide ColdFusion examples. So the meat of this question is the hope that someone has some example code that I can look at.
So all you need is charging a credit card - right

not specific to any any company or whatever, am i correct
Avatar of dgrafx

ASKER

yes - and getting a response
Avatar of dgrafx

ASKER

can you post the code here?

just remove an credit card or sensitive data of course.

thanks
I have been in the same boat developing classic asp and there was no direct help files for asp, only .NET and PHP.  However, they did have the raw xml files and was able to interpret what needed to be done.  I don't know ColdFusion, but will try to help as I have experience with payment gateways.  

I will take a moment to look up what code samples are available.  Are you well versed in CF where you can understand how to send and receive a POST?
Avatar of dgrafx

ASKER

Yes I am.
What I'm looking for is just a simple example.

Also I ran into an issue posting encrypted xml back to Sage.

You have experience with Sage you say?

Thanks
Not with sage.  Where on the site did you find your example?
>is there any private comment where i post it
All you need to do is strip your personal information.

>or let me see the idea, i will share the code
That would be a good idea.

All of this works the same, just in different languages.  As long as dgrafx is comfortable with the language we can work together to make this work.
Thank you myselfrandhawa.  

Some code is better than none, but we need to have a solution that can be posted publicly.  This will not only help dgrafx, but it will help every other person looking for the same solution.   When your code is linked from someplace else and is later not available, the solution no longer will work.  

Is there anything you can share?

He is using Sage.  We simply need to get the documentation and apply cf to what they show.  Typically this will be a SOAP call or direct post with a return of xml or an post back to a receiving page.
Hi Scott, as i have told him above also, his question is not very clear to me, I told him, i had the sagePay UK working for me but not for US, if he is looking into Sage Pay US, i may be not be able to help him but as far code sharing is concerned i can share that sage Pay UK Code too.

Let me know if that helps

Regards
I can't believe there is going to be a big difference.  I did sign up as a developer with that site to look at the code. But they take 24hrs to approve.  The other payment solutions I have used have the documentation ready to see.  It is frustrating they don't  have it open on their site.

If you can please strip out anything that is private and post the code it would be great start.   If you are just worried about your own code getting out, one way or another we will figure this out and the solution will be posted.  

Looking at your pastebin, I did not see anything that needed be be kept secret but I can appreciate when you figure something out like this it can be hard to let go an share.
ok, give me some time, i am stripping down the code and will paste on pastebin asap
Thank you!
here is the code:

http://pastebin.com/WQQKEcJK - it will not expire

the above will give you basic idea how to work with sagepay
Thank you.  Just a couple of things.  First, can you please paste this code in the thread.  You will see the word "Code" in the comment box.  If you click that, start and end code tags will appear and you can paste your code there.  That will give this affect
<div>
        <input type="hidden" name="VPSProtocol" value="2.23">
        <input type="hidden" name="TxType" value="PAYMENT">
        <input type="hidden" name="Vendor" value="#settings.SagepayVendorName#">
        <input type="hidden" name="Crypt" value="#ToBase64(tdata.crypt)#">
</div>

Open in new window

I am not a CF dev, but it looks like there are some areas that will need to be changed when going from Testing to Live.  Line 5 and lines 17 - 25

A security tip I have learned and practiced is to never put anything in a form unless you are ok with the user to change it even if it is a hidden value.  For instance, a name, address item_id and quantity are ok to have in  public facing form.   Anything like an amount, payment type etc should not be in the form even if "hidden" because of course they are not really hidden and somebody can make up their own form.

What I do is send the name, address, item_id/qty arrays,  and card info to my processing script which will then recalculate the total amount by first hitting the database with the item_id to get the price and tax info, multiply by the qty to get the line total and finally loop through all items to get the grand total and figure any tax, discounts.

Finally submitting the calculated info along with other data my processor needs via httppost.  

The only time it is acceptable to have an amount as a form field (hidden or not) in the form the user sees is if it is ok to have an account receivable balance.  In that case, remember to check for amounts greater than zero.
ASKER CERTIFIED SOLUTION
Avatar of Coast Line
Coast Line
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you myselfrandhawa.    

I had your post with the expiring link removed.
Avatar of dgrafx

ASKER

Hey guys !
Give me some time on this ...
The guy I'm doing some work for is out of the office for a bit and I need info from him to proceed ...
Avatar of dgrafx

ASKER

Thanks for the code. I haven't actually used it but when I get to it then this may save me some time ...