How To Disable The Pay Later Button In PayPal
My next side project will involve an e-commerce aspect. Ultimately I’ll have server-side integration with Stripe, but for a Minimum Viable Product (“MVP”) I figured I’d implement a client-side solution with PayPal buttons.
I’m using the JavaScript version, and it was pretty easy to integrate in my website. Using the code provided it came out like this:
For my particular use-case, I did not want to have the “Pay Later” option there. I wanted to hide or disable the Pay Later button in the PayPal widget.
What I Tried
First I started looking into how to customize the widget by updating the code within the paypal.Buttons() JavaScript tag, but I could not figure it out.
One method suggested on Stack Overflow, that I didn’t try, was to use CSS to hide just the one button. But because this is displayed via iframe, I thought it be best to find the built-in way.
The Solution
Simply add in &disable-funding=credit in the part that references the external JavaScript file:
<script src="https://www.paypal.com/sdk/js?client-id=YOUR_ID&disable-funding=credit"></script>
Now it’ll look like this:
Paypal’s documentation has some more options on how to customize the widget.
Like this style of writing? 👍👍 Interested in creating a PHP web application and already know what a “variable” is and the concept of an “if” statement? Check out my book: Web Development for Intermediate Programmers — with PHP