Results 1 to 10 of 10

Thread: Paypal request and response - Web Site Pro Integration
      
   

  1. #1
    devvvy is offline Private First Class
    Join Date
    May 2009
    Posts
    6

    Default 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
    https://cms.paypal.com/cms_content/U...ationGuide.pdf

  2. #2
    devvvy is offline Private First Class
    Join Date
    May 2009
    Posts
    6

    Default 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?

  3. #3
    devvvy is offline Private First Class
    Join Date
    May 2009
    Posts
    6

    Default Re: Paypal request and response - Web Site Pro Integration


  4. #4
    Karen Mac's Avatar
    Karen Mac is offline General
    Join Date
    Apr 2006
    Location
    X marks the spot
    Posts
    8,337

    Default 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)



  5. #5
    devvvy is offline Private First Class
    Join Date
    May 2009
    Posts
    6

    Default 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.

  6. #6
    Karen Mac's Avatar
    Karen Mac is offline General
    Join Date
    Apr 2006
    Location
    X marks the spot
    Posts
    8,337

    Default 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)



  7. #7
    devvvy is offline Private First Class
    Join Date
    May 2009
    Posts
    6

    Default 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.

  8. #8
    Karen Mac's Avatar
    Karen Mac is offline General
    Join Date
    Apr 2006
    Location
    X marks the spot
    Posts
    8,337

    Default 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)



  9. #9
    devvvy is offline Private First Class
    Join Date
    May 2009
    Posts
    6

    Default 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...

  10. #10
    Karen Mac's Avatar
    Karen Mac is offline General
    Join Date
    Apr 2006
    Location
    X marks the spot
    Posts
    8,337

    Default Re: Paypal request and response - Web Site Pro Integration

    Quote 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)



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49