Avatar of sbickerstaff
sbickerstaff
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Paypal integration instructions

I have a custom shopping cart (coded in php) which lists individual items, quantities, item and total item prices, shipping and total amount.  I want to integrate PayPal but I'm having trouble figuring out the steps required.  I have the PayPal API and a PayPal Sandbox setup with a buyer and seller test account and signature setup and ready to go.

From what I can find out so far, I believe I need the following files:
SetExpressCheckout.php
GetExpressCheckoutDetails.php
DoExpressCheckoutPayment.php


Q1) Do I need a Website Payments Pro account or will the free business accounts work (i.e. website payments standard) or is the API independant of these two as long as the account type is 'business'?

Q2) Could anyone provide clear steps I need to follow once I have a shopping cart ready to checkout

I'm sorry I don't have any more details but if you need anything else, I will do my utmost to provide what I can.  I'm pretty familiar with PHP, but have never worked with APIs before.
PHPE-CommercePayPal

Avatar of undefined
Last Comment
Ray Paseur

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
sammySeltzer

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
sbickerstaff

ASKER
I've used the 'Add to cart' buttons before but these have to be generated manually per item and then the html code placed on the website.

My shopping cart is actually for a photo gallery and there could be thousands of items so I can't use that indicidual 'add to cart' button of paypal.  I will have all the items details, amounts, etc, stored but need some way to pass this information to PayPal to the show a summary and handle the payment.  I was reading something about Name Value Pairs (NVP).

I found the following piece of code, but not sure if it's valid anymore (up-to-date):
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="you@youremail.com" />
<input type="hidden" name="item_name" value="Item Name" />
<input type="hidden" name="currency_code" value="GBP" />


<!-- An internet URL where your customer will be returned after completing payment -->
<input type="hidden" name="return" value="http://www......" />
<!-- An internet URL where your customer will be returned after cancelling payment -->
<input type="hidden" name="cancel_return" value="http://www......" />
<!-- The internet URL of the 150 X 50 pixel image you would like to use as your logo -->
<input type="hidden" name="image_url" value="http://www......" />
<!-- Sets the background color of your payment pages. If set to "1," the background color will be black. This is optional; if omitted or set to "0," the background color will be white -->
<input type="hidden" name="cs" value="0" />

<input type="hidden" name="upload" value="1" />


<!-- (Required for item #x) Name of item #x in the cart. Must be alpha-numeric, with a 127 character limit -->
<input type="hidden" name="item_name_x " value="" />
<!-- Optional pass-through variable associated with item #x in the cart. Must be alpha-numeric, with a 127 character limit -->
<input type="hidden" name="item_number_x " value="" />
<!-- (Required for item #x) Price of the item #x -->
<input type="hidden" name="amount_x" value="" />
<!-- The cost of shipping the first piece (quantity of 1) of item #x 
<input type="hidden" name="shipping_x" value="" />
<!-- The cost of shipping each additional piece (quantity of 2 or above) of item #x 
<input type="hidden" name="shipping2_x" value="" />
<!-- The cost of handling for item #x 
<input type="hidden" name="handling_x" value="" />
<!-- First option field name for item #x. 64 character limit 
<input type="hidden" name="on0_x" value="" />
<!-- First set of option value(s) for item #x. 200 character limit. "on0_x" must be defined in order for "os0_x" to be recognized. 
<input type="hidden" name="os0_x" value="" />
<!-- Second option field name for item #x. 64 character limit
<input type="hidden" name="on1_x" value="" />
<!-- Second set of option value(s) for item #x. 200 character limit. "on1_x" must be defined in order for "os1_x" to be recognized. 
<input type="hidden" name="os1_x" value="" />


<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>

Open in new window

sammySeltzer

You have just misread my post.

Bear in mind that you are dealing with hidden forms.

So, you are still going to write your php code and do your loop, etc.

So, depending on how you write your code, thousands of your pictures will be dislayed online with Add to Cart buttons.

At the end of the day, your users will push Add to Cart once item at a time.

THey might order different quantities but it will add one item at a time.

THe code you posted shows that you want to upload your items.

Notice

 <input type="hidden" name="upload" value="1" />

Take a look this website and see how I handled Add to cart.

Click the Add to Cart button and see where it takes you.

If that's what you are trying to do, then original code I posted is what you need.

http://www.millenniumhealthproducts.com

Click on any Category and go from there.
sbickerstaff

ASKER
Apologies sammy,  I did miss read it.  When you mentioned the Add to cart button, i assumed it was where you go onto the paypal site and generate a button for each specific item and price and then add that code to my site (this would be unpractical for constantly updating content).

If it was possible, I'd prefer to keep using my own cart and when ready to checkout, then go to PayPal and pass over all the cart contents.  Do you know is this possible?

Otherwise, if this isn't possible, I would use their cart feature (and the code you provided).
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
sammySeltzer

I have not done the Checkout bit.

What we did was the add to cart and paypal handles the rest.

However, if you have already signed up for it, then they will send you html checkout code.
Ray Paseur

You can use PHP to generate the "add to cart" buttons. The free account will almost certainly meet your basic needs.  You will need the paid account if you want to use paypal in a brick-and-mortar store or if you want to take credit cards over the telephone.

A Google search for "PHP PayPal Integration" will turn up several good resources.  Example:
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/library_download_sdks

Given a choice between SOAP and Name-Value pairs, I would expect the latter to be a RESTful interface, so I would choose that and avoid SOAP.