PayPal Subscriptions and One-Off Payments in Bubble.io

Recently I had someone ask me how to setup PayPal subscriptions and PayPal once off charges in Bubble, similar to my Stripe Subscription series in Bubble. Since I don't have a video showing this off, I simply gave them a step-by-step overview on how they might do that.

So I decided to include that here so others can know how as well. And if I am able to get to doing a video, this post will be updated with a link to that, but for the meantime, I hope you find this helpful.

High level steps for setting up PayPal subscriptions and PayPal once off charges in Bubble.io

Before getting started, you'll want a decent understanding of the Bubble API connector to complete the below.

Setting up one-off payment charges in a checkout flow using PayPal:

1. Create a PayPal Developer account: If you haven't already, sign up for a PayPal Developer account to access the necessary API credentials and documentation.

2. Get API credentials: In your PayPal Developer account, navigate to the "My Apps & Credentials" section, and create a new app. You will receive a Client ID and Secret, which you'll use for authentication.

3. Install the API Connector plugin in Bubble: In your Bubble.io app editor, install the "API Connector" plugin.

4. Set up the PayPal API calls in Bubble: Configure the API Connector in Bubble to make the necessary calls to the PayPal API using your API credentials. For one-off payments, you will primarily need to create and execute payment transactions. The key API endpoints you'll need are:

a. Create a payment: Creates a payment request (check https://developer.paypal.com/docs/api/payments/v1/#payment_create)
b. Execute payment: Completes the payment transaction after the user has approved it (check https://developer.paypal.com/docs/api/payments/v1/#payment_execute)

Create the checkout flow in Bubble: Design your app's user interface for the checkout flow, including elements like a shopping cart, order summary, and a "Pay with PayPal" button.

Implement the payment process:

a. Call the "Create a payment" API endpoint when the user clicks the "Pay with PayPal" button.
b. Redirect the user to the approval_url provided in the response from the "Create a payment" call.
c. After the user approves the payment on the PayPal site, they will be redirected back to your app.
d. Capture the payment_id and payer_id from the URL and call the "Execute payment" API endpoint to complete the transaction.

Handle payment confirmations and errors: Display a confirmation message or handle errors depending on the transaction's success or failure.

Next, is an outline the steps for setting up subscription charges using PayPal:

1. Follow steps 1-4 from the one-off payment charges process.

2. Create PayPal plans and products: Before you can set up subscription charges, you need to create PayPal plans and products using the PayPal API. The key API endpoints you'll need are:

a. Create a product: Defines the subscription service or item you want to offer (check https://developer.paypal.com/docs/api/catalog-products/v1/#products_create)
b. Create a plan: Specifies the billing cycle, pricing, and other details for the product (check https://developer.paypal.com/docs/api/subscriptions/v1/#plans_create)

3. Set up the subscription flow in Bubble: Design your app's user interface for the subscription flow, including elements like a list of subscription plans, plan details, and a "Subscribe with PayPal" button.

Implement the subscription process:

a. Call the "Create a subscription" API endpoint when the user clicks the "Subscribe with PayPal" button (check https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create)
b. Redirect the user to the approval_url provided in the response from the "Create a subscription" call
c. After the user approves the subscription on the PayPal site, they will be redirected back to your app
d. Capture the subscription_id from the URL and store it in your Bubble database for future reference

Handle subscription confirmations and errors: Display a confirmation message or handle errors depending on the subscription's success or failure.

You'll also want to manage subscription lifecycle events as shown in this 6 part series so you'd implement additional API calls to manage subscription events such as cancellations, suspensions, and updates (check the complete API reference for subscriptions in PayPal's documentation: https://developer.paypal.com/docs/api/subscriptions/v1/)

And that's it! Easy 😉!