PayPal Payment Integration Errors in Bolt App
Your Bolt.new application's PayPal integration fails at various stages: the PayPal button doesn't render, orders fail to create, or payments are captured but never confirmed. Users see 'Something went wrong' messages, empty payment popups, or get charged without the order being recorded in your system.
PayPal integration involves multiple steps - loading the SDK, creating orders, capturing payments, and handling webhooks - and Bolt's AI-generated code often gets one or more steps wrong. The PayPal popup may flash and close immediately, or payments may succeed on PayPal's side but fail to record in your database.
This is particularly dangerous when payments are captured by PayPal but your app doesn't record the transaction, leaving you with money collected and no order created. The customer paid but got nothing, requiring manual refunds and damaging trust.
Error Messages You Might See
Common Causes
- Sandbox vs live credentials mismatch — Using sandbox client ID in production or live credentials in development, causing all transactions to fail
- PayPal SDK loaded with wrong client ID — The script tag loads the PayPal SDK with an undefined or incorrect client-id parameter
- Order creation returns invalid response — The createOrder callback doesn't return the order ID in the format PayPal expects
- Payment captured but not recorded — The onApprove handler captures the payment but fails to save the transaction to your database
- Currency mismatch — Order created with one currency but the PayPal account is configured for a different currency
- Webhook not configured — PayPal sends payment confirmation webhooks but your app has no endpoint to receive them
How to Fix It
- Verify credentials match environment — Use sandbox credentials (sb-...) for development and live credentials for production. Store them in environment variables and never mix them
- Load SDK correctly — Add the PayPal script with your client ID: <script src="https://www.paypal.com/sdk/js?client-id=${PAYPAL_CLIENT_ID}¤cy=USD"> and verify it loads without console errors
- Return order ID from createOrder — The createOrder function must return the order ID string: createOrder: async () => { const res = await fetch('/api/paypal/create-order'); const data = await res.json(); return data.id; }
- Record transaction in onApprove — After capturing payment, save to your database before showing success: onApprove: async (data) => { const capture = await fetch('/api/paypal/capture', { body: JSON.stringify({ orderId: data.orderID }) }); if (capture.ok) showSuccess(); }
- Set up webhooks for reliability — Configure PayPal webhooks in the developer dashboard to send PAYMENT.CAPTURE.COMPLETED events to your /api/paypal/webhook endpoint as a backup confirmation
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
How do I switch from PayPal sandbox to live?
In PayPal Developer Dashboard, create a live app under 'Live' tab to get production credentials. Replace your sandbox client ID and secret with the live ones. Update your environment variables and test with a real PayPal account before launching.
Why does the PayPal popup open and close immediately?
This usually means the createOrder function is throwing an error or not returning a valid order ID. Open browser DevTools console before clicking the PayPal button to see the error. Common causes: wrong API endpoint, missing client ID, or the createOrder function returning undefined instead of the order ID string.