Paypal

Offering subscription plans with Paypal is very easy with Ready SaaS because all the hardest parts have been already implemented for you.

You just need to follow a few steps to retrieve your Paypal API keys and send webhooks to your Django app.

Paypal Setup

Follow these steps to setup Paypal subscription plans within your Ready SaaS project.

Paypal offers a sandbox environment and a production environment. Make sure you're using the correct one when building and for your live service respectively.

In this guide, I'll use the Paypal production version, but I encourage you to use their sandbox environment for local development.

1. Create a Paypal account

Go to https://paypal.com/ and create an account

2. Create a Paypal Plan

Navigate over to the Manage subscriptions section. You can do so by going to this link https://www.paypal.com/billing/plans or by using the menu in your Paypal account. Click on "Create Plan"

You'll be taken to this screen, where you'll most likely need to create a subscription product:

Fill out the form with the information about your product and click next

Once you select your newly created subscription product, choose Fixed Pricing for the kind of subscription plan

Provide a Plan name and description and then specify the pricing information.

My suggestion is that you set Unlimited billing cycles and turn off auto billing of outstanding payments, but you can set those values to what you prefer.

Now go to the newly created plan, grab the Plan ID and store it for later steps.

Create a Subscription plan in Ready SaaS

Navigate to the admin dashboard and create a Plan object

Define all the attributes of your plan and make sure to paste the Plan ID from the previous step as the external plan id so that the plan in Ready SaaS is linked to the Paypal plan you created.

Repeat this step with all additional plans you will offer (example: basic, startup, pro, premium, etc)

Api Keys

In order to connect with Paypal, you'll need to create a Paypal app and get the app's credentials into your Ready SaaS environment variables. Let's start by navigating over to Paypal's developer portal https://developer.paypal.com/

Click the "Create App" button, give your app a name and hit create.

Now you can add the client id and secret key as environment variables in your Ready SaaS project:

  • For your local instance of Ready SaaS, add them as PAYPAL_CLIENT_ID and PAYPAL_CLIENT_SECRET respectively within your .env file

  • For your production instance, add it as environment variables with the names PAYPAL_CLIENT_ID and PAYPAL_CLIENT_SECRET respectively

5. Webhooks

Ready SaaS uses Paypal webhooks In order for your app to know when a payment has been made. As mentioned in the Payments & Subscriptions section, the subscription management system follows the following lifecycle by reacting to Stripe's webhooks:

  • On Subscription Activated:

    Automatically provisions the subscription for the user, granting them access to the subscribed content or features.

  • On Payment Received:

    The system continues to provision the subscription and updates the subscription's end date to reflect the new billing cycle.

  • On Payment Failed:

    Marks the subscription as past due and triggers a notification to the customer to update their payment information.

To enable this functionality, you need to specify the webhook url within your Paypal app.

Within your Paypal app's settings, scroll to the bottom until you find the "Sandbox Webhooks" section.

Click on "Add Webhook"

Make sure you point the webhook to your Ready SaaS endpoint. By default the endpoint lives in /paypal/event but you can change it to any other path.

Make sure to subscribe to all Billing subscription events

And to the "Payment sale completed" event within Payments & Payouts

That's it! Click Save and you're all set to start processing Paypal subscriptions!

Last updated