Paypal Custom Payment Amount

Viewed 2061

I would like to direct my clients to a payment site that allows them to enter the custom invoice amount. I am using the basic Paypal checkout code, however the amount is defaulting to $1. I would like to add a text box to set the amount.

The current value is set to 1 in the code below, is there a way to change this to a manual entry?

    <div id="paypal-button-container"></div>
    <script src="https://www.paypal.com/sdk/js?client-id=Aff- 
    dCcKoLWR548gVo8w9nNu1F7Lx0Poo8I1STNdRuxvRYyv3JDrcNqcg3snh7SRmY9BMZdJXm1Ih95y&currency=USD" data-sdk- 
 integration-source="button-factory"></script>
   <script>
   paypal.Buttons({
      style: {
          shape: 'rect',
          color: 'gold',
          layout: 'vertical',
          label: 'pay',

      },
      createOrder: function(data, actions) {
          return actions.order.create({
              purchase_units: [{
                  amount: {
                      value: '1'
                  }
              }]
          });
      },
      onApprove: function(data, actions) {
          return actions.order.capture().then(function(details) {
              alert('Transaction completed by ' + details.payer.name.given_name + '!');
          });
      }
     }).render('#paypal-button-container');`enter code here`
    </script> 
1 Answers

You can use Javascript to get the amount from somewhere else on your site.

value: document.getElementById('myAmountInput').value

Or similar.

Related