Reputation: 6888
I would like to have a simple form with two textfields and a button:
When clicking on a button the default PayPal checkout appears with product id and an amount pre-populated. How do I achieve that with Javascript?
update
I would like to achieve this strictly using Javascript, no server side code such as PHP. It would work more like a generic PayPal button with two more textfields carrying product ID and amount.
update 2
Instead of searching for PayPal Javascript API, I should've searched for PayPal button custom amount. Looks like this will solve my question.
Passing price variable to PayPal with custom button
https://www.paypal.com/us/cgi-bin/webscr?cmd=_pdn_xclick_techview_outside
Upvotes: 2
Views: 10393
Reputation: 19356
Have a look at https://github.com/paypal/JavaScriptButtons
We've only recently released these, so they don't support all button types just yet (i.e. donations), but they'll work just fine for 'Buy now' buttons.
<script src="paypal-button.min.js?merchant=YOUR_MERCHANT_ID"
data-button="buynow"
data-name="My product"
data-amount="1.00"
></script>
Upvotes: 11