Pushkar Shirodkar
Pushkar Shirodkar

Reputation: 684

How to implement Paypal subscription in a vue application?

I am working on a project which needs to deducts a fixed amount from a user's account to a business account on monthly basis. I am trying to create a Paypal button client side (vue) for accepting subscriptions on monthly basis. The users deduction information on monthly basis shall be stored in a database. The user shall also provided an option to cancel the subscription. Any help would be greatly appreciated.

Upvotes: 3

Views: 1112

Answers (1)

Pushkar Shirodkar
Pushkar Shirodkar

Reputation: 684

Well i found out an answer after a little digging in the documentation provided at https://developer.paypal.com/docs/subscriptions/integrate and went through the steps they provided.

Steps

  1. Create a product through their API by providing access_token in the headers.
  2. After the product has been created, get product-Id from response and then create plan using the product_id in request body.
  3. After the plan has been successfully created copy Plan_id and replace the id in smart subscription button.

    paypal.Buttons({
    
      createSubscription: function(data, actions) {
    
            return actions.subscription.create({
    
                 'plan_id': 'P-your_plan_id'
    
    });
     onApprove: function(data, actions) {
    
        alert('You have successfully created subscription ' + data.subscriptionID);
    
             }
    
    
    }
    

Upvotes: 3

Related Questions