PayPal – How to Make a Donate Button Default to an Amount

paypal

How do I make a PayPal donate button default to $10 but enable users to change the amount?

Best Answer

Using this tutorial I made a textbox where the user is able to specify the amount they want to pay on a form I have complete control over, before I send them to a PayPal webpage to complete the transaction.

My gemfile:

gem 'paypal-sdk-adaptivepayments'

My Ruby payment code

  p = PayPalPayer.new
  amt = @buyamount.to_f
  trackingId = SecureRandom.uuid
  senderEmail = 'senderemail@emailaddress.com'
  receiverEmail = 'receiveremail@emailaddress.com'
  url = 'http://redirectotohereafterpaymentcomplets'
  pay = p.pay(senderEmail, receiverEmail, amt, url, trackingId)
  redirect pay[:url] //this takes the user to a page to complete the payment