Skip to content
Advertisement

Laravel Paypal Api and Subscription plan integration. Problems of the self-taught beginner

The emotional part.

Hello stackoverflow community! Please do not be angry with me for possible stupid questions, the answers to which seem obvious to you. I am learning to program and my only opportunity is to do it myself. I want to understand how I can correctly change my intellection and realize how a real programmer thinks. I will be infinitely grateful if someone sees himself in me and can answer my naive questions.

I am working with web, developing projects with laravel (php) and love it so mutch. My projects now so quite large and functional, but when it comes to third API, I have a full brake. Some individual things when I read, I understand everything, but I cannot put it all together. The problem is that I do not understand someone else’s API and how to properly integrate it into my project.

Technical problem.

I need to connect simple Paypal Subscription plans to my website. As I understand it, a lot of what I read in the documentation is already deprecated. But I found out about this only after several hours of searching on stackoverflow. I realized that first thing I need, is to create plans manually (https://www.sandbox.paypal.com/billing/plans). But what to do now?

  • How can I make it so that an authorized user on my website after clicking the button, pays for a subscription, and all the data from paypal returnes to my site?
  • How can I find out on my website that current user has a subscription to papypal subscription plan?

All this about laravel of course. Considering that it is very difficult to find a simple answer, I understand that I have no experience with something obvious. But please, be kind, I have no one else to ask about all that. I started learning Laravel and don’t have a professional programmer background.

  • Is there a ready-made step-by-step guide on how to integrate paypal subscriptions in 2021?
  • What are the best laravel packages with solutions for paypal api i need to use in 2021?

I am very grateful to you for your time. Low bow for your help and answers.

Advertisement

Answer

To integrate PayPal Subscriptions, read the guide. First create a product (essentially a description of what you are selling), then create a plan (essentially the recurring profile information), then create a button that uses that plan (the thing for a payer to click on to give their approval, obviously)

You can crate these things via API calls, or manually in the account interface using links like the one you mentioned:

Once you have plan for the account you intend to use, you can create a button using the client_id of a REST application. This can be done following the instructions in the guide (above), or using a button generator by clicking on the meatballs menu to the right of a Plan name and choosing “Copy Code”.


To be notified of events when and/or after a user subscribes, such as payments being made, set up a webhook event listener for the event names you are interested in, notably PAYMENT.SALE.COMPLETED. The webhook event messages you receive will contain details about the subscription.

To reconcile new subscriptions and their future webhook events with particular “authorized” users, you may wish to include a custom_id as part of the button during each subscription’s creation, alongside the Plan ID. Details on this and other parameters are in the API reference, but since you will be creating subscriptions using a JS button this goes in the createSubscription function of that button.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement