0

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="https://www.paypal.com/sdk/js?client-id=AfGWAPJxdGbCj7b51a2mpoZQYI5y63txxxxxxxxIe1UDh2Vxcr05AFJxxxxNSCNDf8y-xopaJ6&vault=true&intent=subscription" data-sdk-integration-source="button-factory"></script>
<script>
  paypal.Buttons({
      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
</script>

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?

2 Answers 2

0

https://www.paypal.com/us/smarthelp/article/how-do-i-use-paypal's-auto-return-feature-to-redirect-customers-back-to-my-website-faq3651

paypal provide this auto redirect to merchant please try again may be it should work.

1
  • Thanks for your reply. I configured it but nothing. I think I must alter the script accordingly Commented Mar 10, 2022 at 6:47
0

This would redirect you to a specific page

 onApprove: function(data, actions) {
        actions.redirect('https://gutsycreatives.com/'); // You can add optional success message for the subscriber here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.