AdobeStock_455007340

Using PayPal In ColdFusion Applications

The PayPal Integration Center provides SDKs that can be used to accept PayPal payments from within your applications. ColdFusion MX 7 is a supported platform (it uses the Java SDK), and a ColdFusion Component is also included (it uses the Java APIs, and exposes simple high-level methods that can be invoked from within your code). Sample CFM code is also included.

18 responses to “Using PayPal In ColdFusion Applications”

  1. simeon Avatar
    simeon

    Jared also has a good library over on his site for dealing with paypal.
    http://www.web-relevant.com/web-relevant/index.cfm?fuseaction=main.paypalmx

  2. Jared Rypka-Hauer Avatar
    Jared Rypka-Hauer

    Thanks Sim!
    Ben, the sample code that comes from PayPal has never run for me… there are several steps involved with getting it to run with CFMX, often including altering the AXIS version that CFMX is using system-wide. The problem with that is the fact that unless you’re working with a dedicated server and are brave enough to dig into it’s gutz, you probably won’t be able to use the PayPal SDK with CFMX.
    It’s compiled against AXIS 1.3, and CFMX comes with an incompatible version.
    PayPalMX is built around the standard PayPal UI and their PDT and IPN technologies that use form posts and URL variables to get and validate data about transactions. For PDT, that happens when the buyer is returned to the seller’s website. IPN is an asynchronous process wherein PayPal formulates a POST and sends it to a specific URL on your site to be re-packaged and sent back to them. They then pass back a pass/fail message if the transaction was good or not.
    My intention for the next version of PayPalMX is to build wrappers with a combination of Java and CFCs to enable the non-invasive use of the correct version of AXIS with CFMX and the PayPal web-services API so that people can avail themselves of this very, very powerful tool from PayPal without having to unzip JAR files and edit their contents or swap files out of their web-inf folders.
    Incidentally, use of the PayPal Pro service (required for to use the API) costs $20/month. Much cheaper than a merchant account, but still something that needs to be considered.
    Thanks!
    J

  3. Ben Forta Avatar
    Ben Forta

    Thanks for the comments guys. Someone just e-mailed me to ask about PayPal, which is why I made the post, and your added input is appreciated.
    — Ben

  4. stylo Avatar
    stylo

    The IPN code never seems to work either, see this forum for the appalling CF help (i.e., zero):
    http://paypaldev.org/forum.asp?FORUM_ID=22
    I always got an invalid response because it wasn’t sending back the data exactly as received for some unknown reason. I gave up.
    This is just one example of why coldfusion has such poor pickup, I think. All the other code types work and are supported. I really don’t understand why MM doesn’t have a tiny team that actively seeks out and works on tools and issues like this, much like Mozilla has a team that works with banks and such to ensure compatability. They should be pumping out basic tools and kits and integration code for all manner of needs.

  5. Steve Avatar
    Steve

    Agreement with Stylo and Adam. I’m on the cusp of adding a Payment gateway to our site (on a budget) and I’m having a difficult time finding an appropriate solution.
    The funny thing is, we were investigating going with Verisign Payflow Link in order to "get away from Paypal". Then.. whaddayaknow… Paypal goes and buys Verisign Payments. Now I feel like waiting to see what sort of payment portal emerges from the union.

  6. Jared Rypka-Hauer Avatar
    Jared Rypka-Hauer

    But it’s not Adobe’s product. PayPal SHOULD be doing better research and producing better code for their SDK. It strikes me as very strange to suggest Adobe should write an SDK for PayPal… like people demanding an airline start providing parachutes. It sends the wrong message… if they’re going to package the PayPal API (which I remind you is written to an incmpatible AXIS implementation), why not Google’s API, MSN, Yahoo, Flex, hell let’s just dump all the other APIs in the world into the CF goodie bag.
    I can say I know from being in communication with PayPal that some Adobe names we’d all recognize have helped them iron out the innards of their CF SDK, it just didn’t work out very well anyway. 🙂
    Laterz…

  7. Adam Reynolds Avatar
    Adam Reynolds

    Stylo has a good point. Adobe should be providing code sets/examples for the Paypal API, other payment gateways (worldpay), and possibly even the ebay API.
    Adobe should actually be going to these companies and working with them to get it right. It may actually be a good return on investment.
    Adam

  8. Mike Collins Avatar
    Mike Collins

    I just happen to see this today, its a tutorial with using CF and Paypal. http://tutorial23.easycfm.com/
    Pablo’s new venture may interest you as well –
    http://www.freecoldfusionhosting.com

  9. stylo Avatar
    stylo

    But it’s not Adobe’s product. It sends the wrong message…
    -no, not having basic code is sending the wrong message and thus people don’t use Adobe’s product, cf. It’s like using early Mozilla with your bank, didn’t work, so went back to IE. Done. Today people just use php because there is code and help. It would be great if everyone thought to provide a cf solution first, but they don’t and often don’t provide one at all. Thus Adobe should have an active team providing solutions.
    >>I just happen to see this today, its a tutorial with using CF and Paypal. http://tutorial23.easycfm.com/
    -yeah, and the code doesn’t work 🙁

  10. silroc Avatar
    silroc

    I’m getting PayPal’s IPN to post back VARIFIED with the URL hardcoded, but for some reason I get a Connection Timeout when using the URL in a cfhttp call inside a .cfm file. I also tried a cfhttp request on another website with the same result. Since this message is a cf result message, I’m beginning to think it’s a cf issue. Could it be a webserver or java configuration issue? Please visit this link for details. Any clues/thoughts/suggestions may help!
    http://www.easycfm.com/forums/viewmessages.cfm?Forum=12&Topic=8735

  11. Mike Collins Avatar
    Mike Collins

    I remember a recent timeout issue with cfhttp. We were using milliseconds instead of seconds. Depending on your version you may not have the fix. Try using 10000 for a 10 second timeout.
    Also, I haven’t spent much time with using Paypal. If you have a brief description of the issue I can look into getting it addressed. I agree it does seem important that we have a working example. So far I see an issue with Axis version. Has anyone tried using a later Axis version with CFMX?

  12. silroc Avatar
    silroc

    Thanks for the post but putting in 10000 didn’t get it either. If I have the cfhttp timeout set to 60 seconds, should I have to wait 60 seconds before getting the Connection Timeout error message? It comes back immediately, even when I set it to 10000.

  13. silroc Avatar
    silroc

    Problem solved! Ya!
    FYI, what I ended up doing was reinstalling coldfusion, updating my existing install without first manually stopping cf from windows control panel/admin tools/services. The cf install program seems to handle this. CFHTTP works beautifully now.
    Thanks for the responses.

  14. Ryan Avatar
    Ryan

    PayPals ColdFusion SDK worked great.

  15. Rusty Avatar
    Rusty

    Which SDK. they say that that they don’t use an SDK anymore. Everything is CFHTTP

  16. nagarjuna Avatar
    nagarjuna

    Thanks for the code Ben

  17. Steve Avatar
    Steve

    I finally got IPN to work reliably using this code. Nothing else would work.
    <cfset x = GetHttpRequestData()>
    <cfset str="cmd=_notify-validate&" & x.content>
    <cfhttp URL="https://www.paypal.com/cgi-bin/webscr?#str#&quot; METHOD="GET" RESOLVEURL="false">
    </cfhttp>
    <!— Process Response—>
    <cfif #CFHTTP.FileContent# is "VERIFIED">
    <!— Your code to process transaction —>
    <cfelseif #CFHTTP.FileContent# is "INVALID">
    <!— Your code to handle INVALID response —>
    </cfelse>
    <!— Your code to handle other issues —>
    </cfif>

  18. DonH Avatar
    DonH

    I find it interesting how many people have trouble with this. I used the easycfm version right off the bat and it worked no problem.
    Of course that was years ago and I have modified it many times since then.
    I do agree that documentation for ColdFusion integration with PayPal is severely lacking. I’ve done most of it by trial and lots of errors.

Leave a Reply