title: How to get the Transaction ID using PayPal Express Checkout Integration (Client-side REST)
body: <p>I would like to get the transaction ID once the Paypal payment is succesfull.</p>
  
  <p>I am using <a href="https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/client-side-REST-integration/" rel="nofollow noreferrer">Paypal Express Checkout (Client-side REST)</a>.</p>
  
  <p>Please find below my code for the payment button.</p>
  
  <p>My objective is to be able to update the MySQL database to (1) confirm the order and (2) include the Paypal transaction ID next to it. This is what the orderconfirmed.php file will aim to do once it is called. For that I need to be able to get the TransactionID variable when the payment is succesfull </p>
  
  <pre><code>&lt;script&gt;
            paypal.Button.render({
  
                env: 'sandbox', // Or 'sandbox'
  
                client: {
                    sandbox:    'ABCD',
                    production: 'ABCD'
                },
  
                commit: true, // Show a 'Pay Now' button
  
                payment: function(data, actions) {
                    return actions.payment.create({
                        payment: {
  transactions: [
      {
          amount: { total: '0.01', currency: 'USD' },
              item_list: {
              items: [
                  {
                  name: 'hat',
                  description: 'Brown hat',
                  quantity: '1',
                  price: '0.01',
                  currency: 'USD'
                  }
              ]
          }
      }
  ]
                        },    
                    });
                },
  
                onAuthorize: function(data, actions) {
                    return actions.payment.execute().then(function(payment) {
  
                          document.querySelector('#confirmmessage').innerText = 'Thank you - Your payment has been processed';
                          document.querySelector('#paypal-button').style.display = 'none';
                          document.querySelector('#confirmdiv').style.display 
  
  = 'block';
  window.location.href = 'orderconfirmed.php?transactionID=HOW_TO_GET_THIS_FIELD';
                        });
                    }
  
                }, '#paypal-button');
            &lt;/script&gt;
  </code></pre>