Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

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.
0
sbickerstaff
Asked:
sbickerstaff
  • 3
  • 2
1 Solution
 
sammySeltzerCommented:
I think it depends on what you want to do.

If you wish to use their "Add to Cart" feature, then you would something exactly like this:


		<form name="_xclick" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
          <input type="hidden" name="cmd" value="_cart">
          <input type="hidden" name="business" value="someemail@somedomain.com">
          <input type="hidden" name="item_name" value="<%=rs("cname")%>">
          <input type="hidden" name="amount" value="<%= formatCurrency(cprice,2) %>">
          <input type="hidden" name="currency_code" value="USD">
   		<table>
	 		<tr>
	 			<td>Quantity: <input maxLength="6" Name="quantity" size=2 value="1" style="height: 2.2em; border: 1px solid Black; background: ButtonFace;">
	 			<input type="hidden" name="fproductid" value="<%=id%>">
          <input type="image" src="images/button_in_cart.jpg" border="0" name="submit" alt="PayPal">
          <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"></td>
	 		</tr>
		</table>
          <input type="hidden" name="add" value="1">

Open in new window


Notice this line below:

          <input type="hidden" name="add" value="1">

It lets paypal's integration bit know you are using their "Add to Cart" feature.

They will handle checkout from there.

To add "Continue Shopping" feature, you would need to be sure to login to your merchant section, perform a series of fillings and they would grab your domain name for redirecting to your website.

If you wish to use your own "Add to Cart" but you want to use Paypal's checkout feature, then use same code except instead of

<input type="hidden" name="add" value="1">

you would have something like

<input type="hidden" name="checkout" value="1">


More information here:

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_paypal_shopping_cart
0
 
sbickerstaffAuthor Commented:
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

0
 
sammySeltzerCommented:
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
sbickerstaffAuthor Commented:
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).
0
 
sammySeltzerCommented:
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.
0
 
Ray PaseurCommented:
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.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now