I'm trying to find the best way to integrate Paypal "Buy Now" buttons in my website, but I'm quite lost with all the various Paypal integration techniques (hosted buttons, dynamic buttons, IPN, PDT, and other various APIs)
I would like to integrate the better/easiest solution for my need and also a secure one...
I don't really know where to go...
Many thanks in advance for your help!
The context :
I own a website that aims to be a "marketplace" to sell digital goods.
Some people (let's call them SELLERS) register to my website as "sellers" and upload some digital goods they want to sell. I generate for them online pages for each "product" they sell.
Some other people (let's call them BUYERS) also register to my websites as "buyers" only: they just want to buy these digital goods from various sellers.
My need :
I want to integrate on each product page the paypal button of the SELLER, so he will be paid directly. I don't want to be intermediate in the payment.
So I need to integrate on each product page a different button, depending on the seller for this product.
I also need for each product to specify dynamically a different price, depending on the product sold (price will be fixed by sellers on their back-office on my website)
When the transaction is complete (payment done by the buyer), I need to unlock the download of the product on the product page for this buyer. In fact I need to update my database to associate the product to this buyer, so when he come back on my website later, he always have the product he bought "unlocked".
What I already think about buttons :
1/ Dynamic HTML buttons
<form name="_xclick" action="https://www.paypal.com/fr/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="Digital good 1">
<input type="hidden" name="amount" value="12.99">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="item_number" value="internal_user_and_product_id">
<input type="hidden" name="business" value="seller@abusiness.com">
<input type="hidden" name="notify_url" value="https://mywebsite.com/paypal-ipn.php">
<input type="image" src="http://www.paypal.com/fr_FR/i/btn/x-click-but01.gif" border="0" name="submit">
</form>
It seems here that I just need to ask the seller its Paypal business email or ID, and dynamically generate a button for him and his product. I can also provide my IPN listener URL to unlock the product for the buyer in my database using the data passed through "item_number" upon complete transaction received. Quite simple.
BUT:
- this is NOT secure
(anybody can change the amount or paypal ID in HTML before to make the purchase)
- what happens if the seller provide an incorrect (mispelled) email address ?
(I tried to make a purchase with a test button and the fake email address "djfhsgfshdgfsd@dghe.com" and I was able to process the payment !! That was not te case with an incorrect business ID...)
2/ Paypal hosted buttons
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="PJM2WY8H648ZK">
<input type="hidden" name="item_name" value="Digital good 2">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="item_number" value="internal_user_and_product_id">
<input type="hidden" name="notify_url" value="https://mywebsite.com/paypal-ipn.php">
<input type="image" src="http://www.paypal.com/fr_FR/i/btn/x-click-but01.gif" border="0" name="submit">
<input type="image" src="https://www.paypalobjects.com/fr_FR/FR/i/btn/btn_buynow_LG.gif" border="0" name="submit">
<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
</form>
This would avoid fraud with the button hosted on Paypal.
BUT:
- I can't generate dynamically the button (like amount and currency).
This means that I will have to ask for sellers to generate themselves an hosted button for each item they want to sell, and set the correct price.
This also means that I will not be able to display on my website the price of the product ? Indeed, if the seller set 2USD in his Paypal hosted button but 1USD in my back-office, I will display 1USD in my website whereas the real price is 2USD...
- I'm not sure of which variables I can provide to override the hosted button.
I need at least the "notify_url" (IPN listener URL) and "item_number" (my product/buyer technical IDs)
Next...
I also have many interrogations for next steps, like IPN/PDT and what I can really do with these. but let's answer first the type of button I can use and integrate first!