How to implement Paypal with Coupon Code Payment

Viewed 30

I want to implement coupon function on checkout where user can enter coupon to get discount.

Stripe provides an ability to create coupons https://dashboard.stripe.com/test/coupons/create. But PayPal doesn’t have such feature. I googled how we can implement discounts with PayPal - we can only create custom plans for every promocode. Let me explain this: In the PayPal settings I have 6 plans (2 Basic and 4 Standard) https://share.cleanshot.com/NldyhL and I can easily change the price for every plan. But if the user will add the coupon code to the subscription we will need to create a custom plan for him (with another price). We can do it with code but you won’t have a clear interface to manage our subscription plans - you will have 6 of our general plans and a lot of plans which were created automatically for users with promo codes. So it can work but it will be harder to manage subscription plans.

What's the best way to use paypal with coupon code?

1 Answers

When a PayPal Subscribe button of the type at https://www.paypal.com/billing/plans is clicked , the createSubscription function is called. Normally it just calls actions.subscription.create with the plan_id to use

      createSubscription: function(data, actions) {
        return actions.subscription.create({
          plan_id: 'P-XXXXXXXXXXXXXXXXXXXXXXXX'
        });
      },

You can modify the plan being used by adding a plan object in addition to the plan_id, with different amounts for every cycle or for just some cycles (using a trial period). This is documented in the API reference for creating a subscription

Related