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,
Printable View
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,
What technology are you using? JavaScript, jQuery, Angular, etc.?
Javascript & JQuery
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);
}
});
At what point should this code be executed?
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.
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,
Just to clarify, are you wanting to build a shopping cart or are you wanting to integrate paypal into your existing shopping cart feature?
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.
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.
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...