title: Adding Discount-coupon-code in PayPal checkout
body: <p>I'm building a WordPress website and there I've already integrated PayPal checkout. Now, I want to add a discount coupon code to the checkout page. How can I achieve this with some modification in the below code?</p>
  <pre class="lang-js prettyprint-override"><code>
  
    
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt; &lt;!-- Ensures optimal rendering on mobile devices --&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt; &lt;!-- Optimal Internet Explorer compatibility --&gt;
    
  
    
      &lt;!-- Include the PayPal JavaScript SDK; replace &quot;test&quot; with your own sandbox Business account app client ID --&gt;
      &lt;script src=&quot;https://www.paypal.com/sdk/js?client-id=&lt;test-id&gt;;currency=USD&quot;&gt;&lt;/script&gt;
  
      &lt;!-- Set up a container element for the button --&gt;
      &lt;div id=&quot;paypal-button-container&quot;&gt;&lt;/div&gt;
  
      &lt;script&gt;
        paypal.Buttons({
  
          // Sets up the transaction when a payment button is clicked
          createOrder: function(data, actions) {
            return actions.order.create({
              purchase_units: [{
                amount: {
                  value: '77.44' // Can reference variables or functions. Example: `value: document.getElementById('...').value`
                }
              }]
            });
          },
  
          // Finalize the transaction after payer approval
          onApprove: function(data, actions) {
            return actions.order.capture().then(function(orderData) {
              // Successful capture! For dev/demo purposes:
                  console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
                  var transaction = orderData.purchase_units[0].payments.captures[0];
                  alert('Transaction '+ transaction.status + ': ' + transaction.id + '\n\nSee console for all available details');
  
              // When ready to go live, remove the alert and show a success message within this page. For example:
              // var element = document.getElementById('paypal-button-container');
              // element.innerHTML = '';
              // element.innerHTML = '&lt;h3&gt;Thank you for your payment!&lt;/h3&gt;';
              // Or go to another URL:  actions.redirect('thank_you.html');
            });
          }
        }).render('#paypal-button-container');
  
      &lt;/script&gt;
    
  </code></pre>