stripe-archive / react-stripe-elements

Moved to stripe/react-stripe-js.
https://github.com/stripe/react-stripe-js
MIT License
3.03k stars 319 forks source link

A custom PaymentRequestButtonElement #530

Closed garyfagan closed 4 years ago

garyfagan commented 4 years ago

I'm using the PaymentRequestButtonElement and want to understand more about how I can go about customising this? I want to show either a customised Apple Pay or Google Pay button based on what result is returned from the canMakePayment method?

Referring to the docs: https://stripe.com/docs/stripe-js/elements/payment-request-button#styling-the-element

Using your own button If you wish to design your own button instead of using the paymentRequestButton Element, you may show your custom button based on the result of paymentRequest.canMakePayment(). Then, use paymentRequest.show() to display the browser interface when your button is clicked.

I've searched high and low for answers and code examples on how I might go about this. Any help would be greatly appreciated.

hofman-stripe commented 4 years ago

Hi,

First, paymentRequest.canMakePayment() can currently only tell you if the method is Apple Pay, or something else. It cannot tell you if it's Google Pay, and it's not possible to request and brand the button specifically for Google Pay.

As to how to design and implement your own button, that would depend on the framework you use. As long as you call paymentRequest.show() in the click handler, it should work just fine.

That said, this question is not specific to this React wrapper library. If you need more help or have further questions related to your integrations, please reach out to Stripe Support.