2

I would like to have a simple form with two textfields and a button:

  • product id
  • amount
  • Checkout

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

Community
  • 1
  • 1
Ska
  • 6,658
  • 14
  • 53
  • 74
  • 3
    So, you would like... What have you tried so far? – sdespont Mar 29 '13 at 19:08
  • I tried finding any sort of documentation about it but no luck. – Ska Mar 29 '13 at 19:16
  • You didn't find any paypal tutorial? http://www.saaraan.com/2012/07/paypal-expresscheckout-with-php / http://www.dailymotion.com/video/xvtlja_tutoriel-video-php-paypal-express-checkout_lifestyle#.UVXpXKucHhU – sdespont Mar 29 '13 at 19:20
  • 2
    I didn't say I didn't find ANY, i.e. "ANY", meaning ANY, paypal tutorial. I said I didn't find a documentation on how to do that with JS. I see a link you sent is PHP, not really what I wanted. It would be more as a version of generic PayPal checkout button with two more textfields. – Ska Mar 29 '13 at 19:25
  • 1
    I see you're posting more PHP links. Thank you, but that was not my question. – Ska Mar 29 '13 at 19:26

1 Answers1

11

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>
Robert
  • 19,326
  • 3
  • 58
  • 59
  • Does anyone know if parameters can be modified to let user choose Quantity of products on Paypal dialog? – Svet Nov 29 '16 at 15:12