The PayPal button does not appear
- Check that the client ID in your HTML matches the client ID in the .env file.
- Make sure to use sandbox credentials for development and production credentials for live.
404 Page Not Found error
Make sureindex.html is in the public folder. Express serves static files from there.
Invalid Client error
The client ID and secret don’t match, or there’s a mix of sandbox and production credentials. PayPal provides separate credentials for sandbox and production. Make sure your client ID and secret are both from the same environment.Multipage and modular app issues
If your app uses PayPal buttons across multiple pages or a modular JavaScript architecture, errors typically stem from one root cause: the SDK instance isn’t accessible where your code expects it. The following errors are related symptoms of the same scoping problem.window.paypalSdkInstance is undefined
This browser console error means the SDK instance was created but never exposed outside of onLoad().
In the file where you define onLoad() (usually paypal-init.js or index.html), add the following two lines after creating the instance:
createPayPalOneTimePaymentSession.
PayPal button appears on one page but not others
These symptoms indicate the SDK instance isn’t accessible to pages other than the one where it was initialized:- Buttons work on your main page but not on product, cart, or checkout pages
- Console shows errors about an undefined SDK instance
window.paypalSdkInstance during initialization and ensure it persists across route changes.
A typical file structure for multipage apps looks like this:
SDK initialization timing errors
These symptoms indicate your code is trying to accesswindow.paypalSdkInstance before onLoad() has finished creating it:
- Buttons appear intermittently
- Buttons work sometimes but fail on page load
- Errors occur randomly
window.paypalSdkInstance directly:
- If the SDK is already loaded, it runs immediately.
- If the SDK is still loading, it waits for the
paypalReadyevent dispatched inonLoad().
Debugging checklist
On the page where buttons aren’t appearing, open the browser console and run:false:
window.paypalisfalse: the SDK script isn’t loading on this page.window.paypalSdkInstanceisfalse:onLoad()isn’t running, orwindow.paypalSdkInstance = sdkInstanceis missing.