Usually, we use a theme
which was provided stripe like the following.
style: {
paymentRequestButton: {
theme: "light-outline"
}
}
They have also provided some theme's like 'dark' | 'light' | 'light-outline'
My question is can we create a custom theme for this button.? eg: a blue colour theme
Or is there any workaround or script hack for changing the color of the button.?
You can customize the look and feel of Checkout in the Stripe Dashboard. Go to Branding Settings where you can: Upload a logo or icon. Customize the Checkout page's background color, button color, font, and shapes.
Can I customize the URL of a payment link? Stripe doesn't support the ability to customize the payment link URL, but you can use a 3rd-party URL shortener to redirect to the payment link instead.
If you use the Stripe Payments Plugin to handle eCommerce transactions, you can use the product link URL for both subscription and one-time payment products. This means you can create a custom button for your subscription products just like you can for your one-time payment products.
It is not possible to custom style the payment request button. However, you can use Stripe's payment request API with a custom button. The documentation only hints at this. Also, this should still be 100% PCI-compliant, as your application still never sees or touches any credit card information. I have a CodePen you can refer to as an example.
Essentially, just create whatever kind of button you want on your page. Then, bind the click event to paymentRequest.show
, where paymentRequest
is an instance of Stripe's PaymentRequest
. For example:
let stripe = Stripe('pk_test_abc123');
let paymentRequest = stripe.paymentRequest({
...
});
let button = document.getElementById('awesome-custom-button');
button.addEventListener('click', paymentRequest.show);
Then, when you get the token, simply call ev.complete('success')
before the end of the delegate function. For example:
paymentRequest.on('token', function (ev) {
// do whatever with the token
ev.complete('success');
});
The only slight hangup is that Apple dictates that the Apple Pay button must be styled a certain way, according to their HIG. The Stripe Elements payment request button handles this out of the box, but since you're no longer using the Elements button with this approach, you simply need to change your custom button manually. There's a number of ways you can do that. In my example code, I'm using Bootstrap and Fontawesome, so in the canMakePayment
delegate function:
if (result.applePay) {
button.className = 'btn btn-dark';
button.style.backgroundColor = '#000';
button.querySelector('.default').style.display = 'none';
button.querySelector('.applepay').style.display = 'inline';
}
In my button HTML, I have a span with a "default" class that contains the normal button content and another span with an "applepay" class that is hidden initially and contains the following HTML:
<span class="fa-lg">
<i class="fab fa-apple-pay" data-fa-transform="grow-12"></i>
</span>
<span class="sr-only">Purchase with Apple Pay</span>
I've been trying to do this as well, but the reference docs here at the very bottom seem to indicate the answer is "no".
Looks like beyond a type
, and theme
the only thing you can set is a height
: https://stripe.com/docs/stripe-js/reference#element-options
(Screenshot of relevant section below, in case it changes)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With