Jump to content
Killersites Forums

Shopping Cart with Paypal

Recommended Posts

Hello everyone.

I am trying to build a shopping cart which use Paypal as payment method.

Because it seems Paypal doesn't allow to create a preconfigured account, I created one manually.

Then I login it, choose Merchant Services > Buy Now Button and fill in all the required fields.

And here is the code I received:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="NEAZGFF87L2HL">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">


It seems different with the one I saw in Jon Lebensold's videos.

<FORM action='' method='post'>
<input type ='HIDDEN' name ='business' value=''>
<input type ='HIDDEN' name ='cmd' value='_cart'>
<input type ='HIDDEN' name ='upload' value='1'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='lc' value='US'>  
<input type='image' name='submit' src='https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif' alt=' pay online with PayPal '>    


And one more thing, how to change from buy one item at the same time to multiple items?

Thanks in advance.


EDIT: I am sorry for not paying attention. It seems someone with same problem as mine posted that question.

Link to post
Share on other sites

For your quantity question, take a look here: http://stackoverflow.com/questions/5865444/paypal-buy-now-button-dropdown-quantites


It looks like PayPal does allow you to set a "quantity" variable (most likely through a hidden field in the form?) that you could use to buy more than one item at a time. Unfortunately I'm not all that experienced with PayPal, so I'm not sure what the exact code is, but hopefully I've pointed you in the right direction.

Link to post
Share on other sites

Thank you very much, Ben.

Well, after searching and testing, I found out that the code in Jon's project files is still useful.

For those of you who got the same problem as mine, here is the solution:

1. Create 2 dummy accounts: one for selling and one for buying as Jon said. (For example, seller@gmail.com and buyer@gmail.com)


2. Modify your shopping cart so that is looks like the code below: (Supposed that your cart's items stored in $items variable)

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="seller@gmail.com">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">  
<?php for ($i = 0; $i < count ($items); $i++) : ?>
// Display $item, not shown here
<input type="hidden" name="item_name_<?php echo $i; ?>" value="<?php echo $items[i]['name']; ?>">
<input type="hidden" name="quantity_<?php echo $i; ?>" value="<?php echo $items[i]['quantity']; ?>">
<input type="hidden" name="amount_<?php echo $i; ?>" value="<?php echo $items[i]['amount']; ?>">
<?php endfor; ?>
<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" alt=" pay online with PayPal ">    

Well, it is exactly as what Jon guided us. We just need to ignore the part creating the code for Buy now button because as Ben said, PayPal has changed their forms

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...