title: How to redirect after an execution of a paypal payment?
body: <p>I followed the instructions on how to add the smart payment buttons from PayPal (<a href="https://developer.paypal.com/docs/checkout/integrate/" rel="nofollow noreferrer">https://developer.paypal.com/docs/checkout/integrate/</a>) by using the SDK API. Everything works fine except that I can't redirect the buyer after the execution of the payment.</p>
  
  <p>The JS code in the HTML page looks like this: </p>
  
  <pre><code>paypal.Buttons({
          createOrder: function (data, actions) {
              return actions.order.create({
                  purchase_units: [{
                      amount: {
                          value: price
                      }
                  }]
              });
          },
          onApprove: async function (data, actions) {
              return actions.order.capture().then(function (details) {
                  alert('success!');
                  return fetch('/paypal-transaction-complete', {
                      method: 'post',
                      headers: {
                          'content-type': 'application/json'
                      },
                      body: JSON.stringify({
                          orderID: data.orderID,
                      })
                  });
              });
          }
      }).render('#paypal-button-container');
  </code></pre>
  
  <p>On the server side I execute it with async functions and wait for the promise by using the arrow functions:</p>
  
  <pre><code>app.post('/paypal-transaction-complete', function (req, res) {
      paypalRequestHandler.handleRequest(req, res)
          .then(() =&gt; {
              res.redirect('/'); // not working
          }).catch(err =&gt; {
          console.log(err);
          res.sendStatus(500);
      });
  });
  
  </code></pre>
  
  <p>I'm wondering why it's not redirecting, I can do stuff like console.log() but it just won't redirect the buyer.</p>