javascript – Add Paypal button redirect to a specific page after completing


I have created a new page on my WordPress site to test the paypal payment flow. I have subscription based products. Attached code is for the paypal subscription button code.

 <div id="paypal-button-container-P-91F08612M1573283BMIUWMOA"></div>
<script src="" data-sdk-integration-source="button-factory"></script>
      style: {
          shape: 'rect',
          color: 'gold',
          layout: 'vertical',
          label: 'subscribe'
      createSubscription: function(data, actions) {
        return actions.subscription.create({
          /* Creates the subscription */
          plan_id: 'P-91xxxxxxxxxxxxxxx'
      onApprove: function(data, actions) {
        alert(data.subscriptionID); // You can add optional success message for the subscriber here
  }).render('#paypal-button-container-P-91F08612M1573283BMIUWMOA'); // Renders the PayPal button

My outcome was success and it shows this message. Click here for the image

On completion, I just get an order number pop-up and then it stays on the same page. (check the image) What I want now is to redirect my user to a specific page after successful payment. I already set the URL auto return path from paypal but it won’t working. See my paypal configuration from the below image. Paypal config

How can I redirect user by adjusting the code? Will I be able to make that change?

Havishka Halangoda 2 years 2022-03-10T00:21:55-05:00 0 Answers 0 views 0

Leave an answer