Project / Support Center
Welcome, Guest. Please login or register. September 29, 2021, 02:41: AM
Home Help Search Login Register
D-Web Web Site Creator D - Web Web Site Creator On-line HTML Editor No Programming knowledge required. Web Global Net PayPal-Cart Shopping Cart System PayPal - Kart Shopping Cart System for E-Commerce over the internet, that's easy to use. Web Global Net Newsletter Manager Newsletter Manager On-line Newsletter Creator with Email Subscriber Management.
Ring Central Discount
Web Global Net Web Application & Web Development Project Center  |  Technical Issues  |  PayPal Related  |  Topic: explaining PayPal button code line by line 0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Send this topic Print
Author Topic: explaining PayPal button code line by line  (Read 386 times)
admin
Administrator
******
Offline Offline

Posts: 228


« on: May 24, 2021, 08:12: PM »

This is not a question but rather some insight on creating a button which you can edit on the fly without creating a new on Paypal for each item your selling.
 
A lot of people want to use a manual html/java code for buttons for that reason but cannot seem to find the info.
 
There is help on Paypal and Merchant Services and Web Development and after much searching and putting it all together I came up with a solution, an editable custom code of my own. Here is it explained below. I hope this helps some of you. For this example, I'm using a shopping cart button. With this code, Paypal automatically generates a standard shopping cart. You can use custom checkout pages or add your logo, banner, etc to the cart by setting it up in your account Profile. (this example is a fictional company)
 
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="sales@paypalemailaddress.com">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<input type="hidden" name="item_name" value="blue table">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="amount" value="365.00">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="shopping_url" value="http://www.yourdomain.com/product.html">
<input type="hidden" name="cancel_return" value="http://www.yourdomain.com/index.html">
<input type="hidden" name="return" value="http://www.yourdomain.com/thankyou.html">
<input type="image" name="addtocart" border="0" src="https://www.paypal.com/en_US/i/btn/btn_cart_SM.gif" alt="add this item to your shopping cart">
</form>
 
It all breaks down like this:
 
Code calls up Paypal server with instructions:
 
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="new">
 
This one tells Paypal who's getting paid (business variable). Instead of using your Paypal account email, it's better to use your merchant id number, located at the top of your Account Profile page under your name but you can use your email address and it will work to send the funds from the sale to your account:

<input type="hidden" name="business" value="sales@yourdomain.com">
 
This one tells PayPal that it's a shopping cart:
<input type="hidden" name="cmd" value="_cart">
 
This one instructs Paypal to add one (1) item to the shopping cart:
<input type="hidden" name="add" value="1">
 
This one gives the item description or title:
<input type="hidden" name="item_name" value="product name here">
 
This one tells Paypal that there is only 1 item and not to sell it again. For more than one item, adjust the "value."
<input type="hidden" name="quantity" value="1">
This one tells what price to charge the customer:
<input type="hidden" name="amount" value="395.00">
This one instructs how to charge shipping: (I offer free shipping so I use the "no_shipping" variable)
Value of "0" equals no shipping charges, customer address optional.
Value of "1" equals no shipping charges, do not collect customer address.
Value of "2" equals no shipping charges, customer address required.
<input type="hidden" name="no_shipping" value="2">
 
This one tells Paypal that the currency is United States Dollars:
<input type="hidden" name="currency_code" value="USD">
 
This one tells where to send the customer if they click "Continue Shopping" button in cart:
<input type="hidden" name="shopping_url" value="http://www.yourdomain.com/product.html?product_id=5">
 
This one tells where to send the customer if they cancel their purchase or checkout:
<input type="hidden" name="cancel_return" value="http://www.yourdomain.com/index.html">
 
This one tells where to send the customer after they complete their purchase and payment: It's a good idea to have a thank you or confirmation page that matches your site to bring the customer back to after checkout otherwise Paypal sends them to a Paypal page. I want them back on my site so I have a confirmation page set up.
<input type="hidden" name="return" value="http://www.yourdomain.com/thankyou.html">
 
This one tells where to find the "Add to Cart" or "Buy" button: (I'm using the Paypal small button here. To use your own button, simply change the image file address (src variable) to your location and image file)
<input type="image" name="addtocart" border="0" src="https://www.paypal.com/en_US/i/btn/btn_cart_SM.gif" alt="add this item to your shopping cart">

</form>
 
So now I have a working and workable button code which I can simply edit on the fly instead of creating new buttons on Paypal for each item.
 
If you need other code variables for different functions, you can find them here:
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websit...
 
Each function will be listed as an input(<input). To use the code you only need to edit/change the "Value" variable in each code. In my code each input is "hidden." The only one to be displayed will be the image unless your using selection drop down menus or other "option"s such as size, color, etc. Those variables are found at the link above also.
 
It's just that easy. For other button or checkout features, refer to the link above. All the variables will work on all types of buttons (shopping cart, buy now, subscribe, donate, etc).
 
I hope this helps some of you. If you want, you can copy my code and edit it with your account id, items, prices, etc.
« Last Edit: May 24, 2021, 10:07: PM by admin » Report to moderator   Logged

The Unknown Webmaster
Pages: [1] Go Up Send this topic Print 
Web Global Net Web Application & Web Development Project Center  |  Technical Issues  |  PayPal Related  |  Topic: explaining PayPal button code line by line « previous next »
Jump to:  


Login with username, password and session length
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!