Paypal request and response - Web Site Pro Integration

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • devvvy
    Private First Class

    • May 2009
    • 6

    Paypal request and response - Web Site Pro Integration

    To execute a simple NVP Operation to paypal such as:
    Code:
    https://www.sandbox.paypal.com/webscr
    &cmd=_express-checkout&token=tokenValue
    &AMT=amount
    &CURRENCYCODE=currencyID
    &RETURNURL=return_url
    &CANCELURL=cancel_url
    Should I initiate an AJAX request? It is stated in REF doc below that:
    Code:
    Executing NVP API Operations
    You execute an PayPal NVP API operation by submitting an HTTP POST request to a PayPal
    API server.
    For instance:
    Code:
    http://www.w3schools.com/ajax/ajax_xmlhttprequest.asp
                
                <html>
                    <body>
                    <script type="text/javascript">
                    function SubmitOrderToPaypal()
                    {
                        var xmlhttp;
                        var strUrl;
    
                        strCmd = "https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=tokenValue&AMT=amount
    &CURRENCYCODE=currencyID&RETURNURL=return_url&CANCELURL=cancel_url";
    
                        if (window.XMLHttpRequest)
                          {
                          // code for IE7+, Firefox, Chrome, Opera, Safari
                          xmlhttp=new XMLHttpRequest();
                          }
                        else if (window.ActiveXObject)
                          {
                          // code for IE6, IE5
                          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                          }
                        else
                          {
                          alert("Your browser does not support XMLHTTP!");
                          }
                        xmlhttp.onreadystatechange=function()
                        {
                        if(xmlhttp.readyState==4)
                          {
                          document.myForm.time.value=xmlhttp.responseText;
                          }
                        }
                        xmlhttp.open("POST",strURL,true);
                        xmlhttp.onreadystatechange=handleResponse;
                        xmlhttp.send(null);
                    }
    
                function handleResponse()
                {
                if (xmlhttp.readyState==4)
                  {
                   // TODO: How to parse Paypal response? Is this how response from Paypal is communicated? 
    document.getElementById("txtPaypalResponse").innerHTML=xmlhttp.responseText;
                  }
                }
                    </script>
    
                    <form name="myForm">
    <input type="image" name="submit" onclick="SubmitOrderToPaypal();" border="0"
    src="https://www.paypal.com/en_US/i/btn/btn_buynow_**.gif"
    alt="PayPal - The safer, easier way to pay online">
                    </form>
                    </body>
                </html>
    And now, how can I retrieve response from PayPal?

    Many thanks

    REF:
    Web Site Pro Integration Guide
  • devvvy
    Private First Class

    • May 2009
    • 6

    #2
    Re: Paypal request and response - Web Site Pro Integration

    Seems like Paypal response is also in form of POST/NVP formatted query string:
    Code:
    Interpret the Response
    PayPal processes your request and posts back a reponse in NVP format. Add code to your web
    application to do the following tasks:
    1. Receive the HTTP post response, and extract the NVP string.
    2. URL-decode the parameter values as described in “URL-Encoding” on page 14.
    3. Take appropriate action for successful and failed reponses.
    So my javascript function above "handleResponse" should basically parse response query string? How did they do it without AJAX?

    Comment

    • devvvy
      Private First Class

      • May 2009
      • 6

      #3
      Re: Paypal request and response - Web Site Pro Integration

      Paypal doc here: https://cms.paypal.com/us/cgi-bin/?c..._documentation

      Comment

      • Karen Mac
        General

        • Apr 2006
        • 8332

        #4
        Re: Paypal request and response - Web Site Pro Integration

        What are you trying to integrate to? This isnt a button code that you just generate.. this is for incorporation to a database driven cart system.

        Karen

        VodaHost

        Your Website People!
        1-302-283-3777 North America / International
        02036089024 / United Kingdom
        291916438 / Australia

        ------------------------

        Top 3 Best Sellers

        Web Hosting - Unlimited disk space & bandwidth.

        Reseller Hosting - Start your own web hosting business.

        Search Engine & Directory Submission - 300 directories + (Google,Yahoo,Bing)


        Comment

        • devvvy
          Private First Class

          • May 2009
          • 6

          #5
          Re: Paypal request and response - Web Site Pro Integration

          thanks, and yes my app/shopping cart is database driven but i don't see how this has to do with above code fragment.

          I'm using "Pro Integration" as supposed to "Standard Integration" - I *think* [Am I right?] it allows Direct Payment - i.e. accept credit card without leaving my site.

          Now, with Pro Integration {whether "Direct Payment API" or "Express"} you'd need to send request to Paypal and receive response from Paypal. I suppose you're NOT going to navigate away from your site [Am I right?], which is why AJAX comes in. Send a request via POST, then AJAX handler will invoke "handleResponse" (then parse response query string to stripped out Paypal Name-value pairs response code). Now, this should be same whether your cart items are hard coded on your webpage or dynamically rendered as driven by database.

          Comment

          • Karen Mac
            General

            • Apr 2006
            • 8332

            #6
            Re: Paypal request and response - Web Site Pro Integration

            So.. what are you using for your site? This will determine how you set up the AJAX handler. If you are using blue voda then you will have to have this CUSTOM done and use a data base driven system for the cart to sum totals, hold those totals and checkout on your site and transmit the information to paypal. This can be done on a form for EACH and every product.. but again.. you will need special programming for this.

            You will also need ssl and dedicated ip.
            Karen

            VodaHost

            Your Website People!
            1-302-283-3777 North America / International
            02036089024 / United Kingdom
            291916438 / Australia

            ------------------------

            Top 3 Best Sellers

            Web Hosting - Unlimited disk space & bandwidth.

            Reseller Hosting - Start your own web hosting business.

            Search Engine & Directory Submission - 300 directories + (Google,Yahoo,Bing)


            Comment

            • devvvy
              Private First Class

              • May 2009
              • 6

              #7
              Re: Paypal request and response - Web Site Pro Integration

              Thanks and sorryi just got started with paypal

              after reading for a day I think I know how to do standard integration/request/IPN and encrypted website payments now... i would have hoped paypal doc be more straight forward in certain places.

              Couple of examples which don't compile (bad ref to capicom dll or needing a header buffer.h from OpenSSL). And "Encrypt button code" in their doc was so misleading because it really is form hidden param which you're encrypting in Website Payment Encryption, not button code. And doc don't get me started fast it was overall a time consuming experience forsomething simple. Particularly their code samples is a waste of time glad i found samples (documented too) elsewhere so I don't need to re-engineer the wheel.

              and why you say you need fix IP? Can I use dynamic ip with mapped domain?

              Anyway thanks.

              Comment

              • Karen Mac
                General

                • Apr 2006
                • 8332

                #8
                Re: Paypal request and response - Web Site Pro Integration

                In order to process credit cards onsite it is a REQUIREMENT. You must have dedicated ip for encryption and ssl. You also must comply with PCI requirements set forth by the credit card industry itself for accepting and recieving payment for your services or products. This requires a background investigation and a credit check! Since you have paypal pro set up.. i suggest you read their information on what is required for maintaining their services for ONSITE payments

                Theres much more to it than simply integrating it and jumping on the band wagon

                Karen

                VodaHost

                Your Website People!
                1-302-283-3777 North America / International
                02036089024 / United Kingdom
                291916438 / Australia

                ------------------------

                Top 3 Best Sellers

                Web Hosting - Unlimited disk space & bandwidth.

                Reseller Hosting - Start your own web hosting business.

                Search Engine & Directory Submission - 300 directories + (Google,Yahoo,Bing)


                Comment

                • devvvy
                  Private First Class

                  • May 2009
                  • 6

                  #9
                  Re: Paypal request and response - Web Site Pro Integration

                  great so this is actually compliance issue.

                  Thanks for tip, I'm now doing Standard Integration as supposed to Direct Payments and have spotless credit record (up to now!)

                  biz registration will come soon. SSL and perhaps dedicated IP after...

                  Comment

                  • Karen Mac
                    General

                    • Apr 2006
                    • 8332

                    #10
                    Re: Paypal request and response - Web Site Pro Integration

                    Originally posted by devvvy View Post
                    great so this is actually compliance issue.

                    Thanks for tip, I'm now doing Standard Integration as supposed to Direct Payments and have spotless credit record (up to now!)

                    biz registration will come soon. SSL and perhaps dedicated IP after...
                    Well its not just compliance.. you have to protect peoples financial information. You will be taking their credit card information which can be stolen and used elsewhere if you dont encrypt it.. which is why you need the dedicated ip and ssl. If your site gets nailed and your customers credit information is used for purchases elsewhere.. YOU ARE LIABLE.. and you could be subject to criminal prosecution.. thats why there are agreements in place for doing business with credit cards and you SIGN THEM.

                    Karen

                    VodaHost

                    Your Website People!
                    1-302-283-3777 North America / International
                    02036089024 / United Kingdom
                    291916438 / Australia

                    ------------------------

                    Top 3 Best Sellers

                    Web Hosting - Unlimited disk space & bandwidth.

                    Reseller Hosting - Start your own web hosting business.

                    Search Engine & Directory Submission - 300 directories + (Google,Yahoo,Bing)


                    Comment

                    Working...
                    X