PayPal integration in Bubble uses an HTML element to embed PayPal's Smart Payment Buttons and the API Connector to handle payment verification. The PayPal button renders in an HTML element, the user completes payment in a PayPal popup, and a JavaScript-to-Bubble bridge passes the transaction details back to a Bubble workflow that creates a payment record. This tutorial covers the full PayPal checkout flow.
Overview: PayPal Integration in Bubble
This tutorial shows how to accept PayPal payments in your Bubble app using PayPal's Smart Payment Buttons embedded in an HTML element.
Prerequisites
- A Bubble app with a checkout or payment flow
- A PayPal Business account with REST API credentials
- API Connector plugin installed
- Toolbox plugin for JavaScript-to-Bubble bridge (optional)
Step-by-step guide
Get PayPal API credentials
Get PayPal API credentials
Log into developer.paypal.com. Navigate to Apps & Credentials. Create a new app or use the default. Copy the Client ID and Secret for both Sandbox (testing) and Live environments. Store the Secret in the API Connector as a private parameter — never expose it client-side. The Client ID is safe for client-side use in the button embed.
Expected result: PayPal Client ID and Secret are available for both sandbox and production environments.
Embed PayPal Smart Payment Buttons
Embed PayPal Smart Payment Buttons
Add an HTML element where you want the PayPal button. Paste the PayPal SDK script and button rendering code. The SDK loads PayPal's button UI. In the createOrder function, specify the purchase amount. In the onApprove function, capture the payment and pass the transaction ID back to Bubble.
1<div id="paypal-button-container"></div>2<script src="https://www.paypal.com/sdk/js?client-id=YOUR_CLIENT_ID¤cy=USD"></script>3<script>4paypal.Buttons({5 createOrder: function(data, actions) {6 return actions.order.create({7 purchase_units: [{8 amount: { value: '29.99' }9 }]10 });11 },12 onApprove: function(data, actions) {13 return actions.order.capture().then(function(details) {14 // Pass to Bubble via Toolbox or custom state15 console.log('Transaction completed by ' + details.payer.name.given_name);16 });17 }18}).render('#paypal-button-container');19</script>Expected result: A PayPal button renders on the page that opens PayPal checkout when clicked.
Pass payment data back to Bubble workflows
Pass payment data back to Bubble workflows
Use the Toolbox plugin's 'JavaScript to Bubble' element to bridge PayPal's JavaScript callback with Bubble workflows. Create a JavascriptToBubble element with a trigger name like 'paypal_complete'. In the onApprove callback, call bubble_fn_paypal_complete(JSON.stringify(details)). Create a workflow on the JavascriptToBubble element that creates a Payment record with transaction_id, payer_email, amount, and status from the parsed JSON.
Expected result: Payment completion data flows from PayPal's JavaScript into a Bubble workflow that records the transaction.
Verify payments server-side via API
Verify payments server-side via API
For security, verify the payment on the server. Set up an API Connector call to PayPal's order details endpoint (GET https://api-m.paypal.com/v2/checkout/orders/ORDER_ID). Use OAuth authentication with your Client ID and Secret. After creating the Payment record, call this API to verify the amount and status match what the user reported. Only fulfill the order if the server-side verification confirms payment.
Pro tip: Never trust client-side payment data alone. Always verify with PayPal's API server-side before fulfilling orders.
Expected result: Payments are verified server-side through PayPal's API before orders are fulfilled.
Set up PayPal webhooks for ongoing events
Set up PayPal webhooks for ongoing events
In the PayPal developer dashboard, navigate to Webhooks and add a webhook URL pointing to a Bubble backend API workflow. Subscribe to events like PAYMENT.CAPTURE.COMPLETED and PAYMENT.CAPTURE.REFUNDED. Create the backend workflow to process these events — update payment status, handle refunds, and notify users.
Expected result: PayPal sends real-time event notifications to your Bubble backend for payment status changes.
Complete working example
1PAYPAL INTEGRATION — WORKFLOW SUMMARY2=======================================34CREDENTIALS:5 Client ID: used in HTML button embed6 Secret: API Connector private parameter7 Sandbox for testing, Live for production89BUTTON EMBED (HTML element):10 PayPal SDK → Smart Payment Buttons11 createOrder: set amount12 onApprove: capture + pass to Bubble1314PAYMENT RECORDING:15 JavascriptToBubble → trigger workflow16 Create Payment record:17 transaction_id, amount, payer_email, status1819SERVER VERIFICATION:20 API Connector → GET PayPal order details21 Verify amount + status match22 Only fulfill order if verified2324WEBHOOKS:25 PayPal dashboard → add webhook URL26 Backend workflow processes events27 Handle: completed, refunded, disputedCommon mistakes when integrating PayPal in Bubble
Why it's a problem: Trusting client-side payment data without server verification
How to avoid: Always verify payments server-side via PayPal's order details API before fulfilling orders
Why it's a problem: Using the PayPal Secret in client-side JavaScript
How to avoid: Keep the Secret only in API Connector private parameters and server-side backend workflows
Why it's a problem: Not testing with PayPal Sandbox before going live
How to avoid: Always test the full payment flow with Sandbox credentials and test accounts before switching to Live
Best practices
- Verify all payments server-side before fulfilling orders
- Use Sandbox credentials for development and testing
- Store PayPal Secret as a private API Connector parameter
- Set up webhooks for real-time payment event processing
- Create Payment records for every transaction as an audit trail
- Handle edge cases: cancelled payments, failed captures, disputes
- Display clear payment status to users after checkout
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I want to add PayPal checkout to my Bubble.io e-commerce app. How do I embed PayPal buttons, handle payment completion, verify payments server-side, and set up webhooks?
Add PayPal checkout to my order page. Embed a PayPal button that charges the order total. When payment completes, create a Payment record in my database. Verify the payment server-side before marking the order as paid.
Frequently asked questions
Can I use PayPal alongside Stripe in the same app?
Yes. Many apps offer both options. Display PayPal and Stripe buttons on checkout and let the user choose their preferred payment method.
Does PayPal charge transaction fees?
Yes. PayPal charges 2.9% + $0.30 per domestic transaction. International transactions have higher fees. Check PayPal's current pricing page for details.
Can I accept PayPal without a Business account?
No. PayPal's REST API and Smart Payment Buttons require a PayPal Business account. Personal accounts cannot receive payments through API integrations.
How do I handle PayPal refunds from Bubble?
Use the API Connector to call PayPal's refund endpoint. Pass the capture ID and refund amount. Update the Payment record status to 'refunded' after a successful API response.
Can RapidDev help integrate payment processing in my Bubble app?
Yes. RapidDev can integrate PayPal, Stripe, and other payment providers with proper verification, webhook handling, and transaction management in Bubble.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation