Results 1 to 11 of 11

Thread: Sample code for Paypal interface for shopping cart?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Sample code for Paypal interface for shopping cart?

    I'm looking for some sample code that will help me implement a Paypal shopping cart and payment methods. I've looked at the Paypal site and acquired my authentication key but trying to implement this is harder than I thought. I need help!

    Thanks,
    Blake

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Sample code for Paypal interface for shopping cart?

    What technology are you using? JavaScript, jQuery, Angular, etc.?
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Sample code for Paypal interface for shopping cart?

    Javascript & JQuery
    Blake

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Sample code for Paypal interface for shopping cart?

    Are you familiar with submitting REST requests? Both Javascript and jQuery provide some method of submitting the request, though I find it simpler in jQuery.

    If not, that will be the first thing you need to read up on. Here is an example:
    Code:
    $.ajax({ 
        type: "GET",
        dataType: "jsonp",
        url: "https://api.sandbox.paypal.com/v1/payment-experience/web-profiles/",
        beforeSend: function (xhr) {
            xhr.setRequestHeader ("Authorization", "Bearer my-access-token-here");
        },
        success: function(data){        
          console.log(data);
        }
    });
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Sample code for Paypal interface for shopping cart?

    At what point should this code be executed?
    Blake

  6. #6
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Sample code for Paypal interface for shopping cart?

    That particular endpoint returns a web profile I believe. As far as when a REST request would be made, it all depends on when you need the data. Think of the process in events: do you need the data when the webpage loads, when the user clicks on an element (like a button), etc.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Sample code for Paypal interface for shopping cart?

    Well, the flow...to me...is simple. The user will click on a incrementer/decrementer control to add to the cart for any item. Once they are finished shopping, they will click on the "Cart" icon which should take them to a new page where they can continue checking out. So, I'm not real sure what you mean when you say "it all depends on when you need the data".

    Thanks,
    Blake

  8. #8
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Sample code for Paypal interface for shopping cart?

    Just to clarify, are you wanting to build a shopping cart or are you wanting to integrate paypal into your existing shopping cart feature?
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Sample code for Paypal interface for shopping cart?

    Well, I believe Paypal has a shopping cart. I'm not crazy about it's design and would prefer to use my own but I've never written a shopping cart app. That's why I'm hoping to find some sample code.
    Blake

  10. #10
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Sample code for Paypal interface for shopping cart?

    I think that you're mistaken. I believe (though not 100%) that Paypal has third parties that have a shopping cart that is already integrated with Paypal.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Sample code for Paypal interface for shopping cart?

    If I can build the cart myself, I will. I'm just not sure how to integrate that into Paypal? The only thing I would need to pass into Paypal that I can think of would be the item, it's price, and the quantity. I'm sure there is more stuff behind the scenes...
    Blake

Posting Permissions

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



Click Here to Expand Forum to Full Width