> For the complete documentation index, see [llms.txt](https://readysaas.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://readysaas.gitbook.io/docs/guides/payments-and-subscriptions/paypal.md).

# 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 <a href="#stripe-setup" id="stripe-setup"></a>

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/](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"

<figure><img src="https://1908511726-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT1c9BPzeUyd2bkOioywo%2Fuploads%2FYIKEI7rMjjiZiWhbKmkR%2Fimage.png?alt=media&amp;token=f39fd69b-48f2-4a55-8371-79824cd9aab0" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://1908511726-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT1c9BPzeUyd2bkOioywo%2Fuploads%2F3DjugCd4RCDhbrBxFkXm%2Fimage.png?alt=media&amp;token=536fe656-5406-492c-921d-11b539c6c0d2" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://1908511726-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT1c9BPzeUyd2bkOioywo%2Fuploads%2FJr0TRXouJTV2y2X1jUJZ%2Fimage.png?alt=media&amp;token=cbcccd64-444d-44c8-877d-c34cfcf3a6b0" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://1908511726-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT1c9BPzeUyd2bkOioywo%2Fuploads%2FuZdhg8U3rZDmv2VDYb5M%2Fimage.png?alt=media&amp;token=46ddab7b-a952-4c39-9fb5-33d7a96bbe65" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://1908511726-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT1c9BPzeUyd2bkOioywo%2Fuploads%2F4j69DfgrS00BYV4LkSO0%2Fimage.png?alt=media&amp;token=a904acc8-ab2c-43be-a1fb-32a2d215b7f6" alt=""><figcaption></figcaption></figure>

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.<br>

<figure><img src="https://1908511726-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT1c9BPzeUyd2bkOioywo%2Fuploads%2F6Mi6NokuYcAligUKGACT%2Fimage.png?alt=media&amp;token=94541954-efb3-4ec1-be6f-4f8418c7e964" alt=""><figcaption></figcaption></figure>

### Create a Subscription plan in Ready SaaS

Navigate to the admin dashboard and create a Plan object

<figure><img src="https://1908511726-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT1c9BPzeUyd2bkOioywo%2Fuploads%2F21FUBR1WzarrtneRjMD5%2Fimage.png?alt=media&amp;token=858ad050-f244-4f8c-98a9-6e77ecca502c" alt=""><figcaption></figcaption></figure>

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/><br>

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](/docs/guides/payments-and-subscriptions.md), the subscription management system follows the following lifecycle by reacting to Stripe's webhooks:&#x20;

* 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.

<figure><img src="https://1908511726-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT1c9BPzeUyd2bkOioywo%2Fuploads%2FF3nH7cdQIAZav3EsHnaT%2Fimage.png?alt=media&amp;token=4f9c6d7c-67f3-4906-8d04-4837208a8b5f" alt=""><figcaption></figcaption></figure>

Make sure to subscribe to all **Billing subscription** events

<figure><img src="https://1908511726-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT1c9BPzeUyd2bkOioywo%2Fuploads%2FLztLMrVb6V43ZjjFT4pO%2Fimage.png?alt=media&amp;token=ec3ae641-6c3f-4b0b-9e2a-f3b3f5216e1f" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://1908511726-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT1c9BPzeUyd2bkOioywo%2Fuploads%2FwZoI9S0JuadwLwU39k0l%2Fimage.png?alt=media&amp;token=25b24c73-7c00-400a-b7ed-8d399a677d66" alt=""><figcaption></figcaption></figure>

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