09th Nov 2009

Paypal shopping cart integration using HTML for Beginners

In online payment paradigm Paypal is one of the best and popular online payment services. Through this article I will share my experience with you about integration of online payment services.

Novice developer may find this post very useful.

I have used following methods for the online payment integration in my shopping cart.

In development process you need to create paypal testing account for that create paypal sandbox account for the testing purpose.

Step 1: https://developer.paypal.com/
Step 2: Create new account
Step 3: Paypal will send you activation link in your email inbox.
Step 4: Login in sandbox
Step 5: Create Test Accounts for buyer and seller accounts

Go to the Test Account page in paypal. Basically you need to type of account for your site integration
1.Buyer Account
2.Merchant Account.

Select country “United States”.
If you want to create buyer account choose Account Type: Buyer
Fill the form accordingly. Keep your login and password some where.
Click on “Show Advanced Options”.
Choose what card you want to use when will do online purchase for testing.
Set Account Balance.

Create seller account in same way as above.

Paypal gives you many ways to integrate your site with but here I will explain one method for the integration.

Simple Integration
==================
In simple integration with your site you need to know some predefined html variable created by paypal.

Not all the HTML variables I shown here but some of the important that I showed here out of other it is depend on your merchant account and situation.

Ref: https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables

set following html variable as hidden in your Buy Now button page in your shopping cart page.

Replace all the value as per given instructions under the value attribute.
<FORM name=”redirectoPaypal” METHOD=”POST” ACTION=”https://www.sandbox.paypal.com/cgi-bin/webscr” />
<INPUT TYPE=”hidden” name=”CMD” value=”_xclick” />
<INPUT TYPE=”hidden” name=”amount” value=”shopping cart total amount of selected items” />
<INPUT TYPE=”hidden” name=”item_name” value=”shopping cart item description or name” />
<INPUT TYPE=”hidden” name=”item_number” value=”selected item number” />
<INPUT TYPE=”hidden” name=”quantity” value=”selected item quantity” />
<INPUT TYPE=”hidden” name=”currency_ code” value=”USD” />
<INPUT TYPE=”hidden” name=”invoice” value=”invoice number” />
<INPUT TYPE=”hidden” name=”business” value=”your merchant paypal login id” />
<INPUT TYPE=”hidden” name=”return” value=”site url for success page” />
<INPUT TYPE=”hidden” name=”cancel_return” value=”site url for cancel paypal payment page” />
</FORM>

more explanation of html variables.
“CMD” is use for shopping cart do not change it.
“business” in testing set seller account id here after complete testing change to real merchant account id.
“return” is page url of your site paypal will redirect on this page with some extra variable such as transaction id. just debug with var_dump($_GET)
and use.
“cancel_return” is page url of your site. paypal will redirect on this page if user will denied to confirm the payment.

put above code in your page and test it.
when your set-up working successfully. change the action url to “https://www.paypal.com/cgi-bin/webscr” for live.

API Integration
================
coming soon……

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • HackerNews
  • Ping.fm
  • Posterous
  • Propeller
  • Reddit
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks

7 Responses to “Paypal shopping cart integration using HTML for Beginners”

  1. Kostin Says:

    Предлагаю Вам зайти на сайт, с огромным количеством информации по интересующей Вас теме. Для себя я нашел много интересного.

  2. Savannah Says:

    How do you manage the taxes in Magento? I mean how do you apply the discounts.. Any tips?

  3. devdattmehta Says:

    Magento is a framework all the functionality integrated in admin panel.

  4. idiot Says:

    can u plz provide the C#.net paypal integration code

  5. idiot Says:

    hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

  6. sosiska Says:

    Да,хорошо. Кладу 5.

  7. anti-impotence-levitra Says:

    That’s exactly what I was looking for! Thank you!

Leave a Reply