Hello!
I am having some issues with being able to style the Apple Pay button. I have been following the Apple documentation (Apple Pay on the Web | Apple Developer Documentation) and the Square documentation (https://developer.squareup.com/docs/web-payments/apple-pay#prerequisites-and-assumptions) and have hit a wall trying different things. I am using the react-square-web-payments-sdk in my React application. For context, I am building a simple checkout page for a service and payment is accepted via credit card and Apple Pay payments.
Specifically, I want to use the different Apple Pay button styles and types. Such as “-apple-pay-button-style: white;” or “-apple-pay-button-type: donate;”. I would also like to know how to disable the Apple Pay button. I need the button to be disabled when my site is processing a current payment (i.e. the user can’t pay twice by clicking the button after they’ve paid once or a payment is processing). The “button props” using the Credit Card tag works perfectly for that, but I can’t seem to find the same ideology for the Apple Pay tag.
Here is some of the code that could be useful:
import {
PaymentForm,
CreditCard,
ApplePay,
} from 'react-square-web-payments-sdk'
... other react code ...
return (
... other react & square code ...
<>
... other html code ...
const SquarePayment = () => {
<PaymentForm
... other payment form code ...
>
{/* Attempt 1 */}
<ApplePay
style={{
marginBottom: '1rem',
-webkit-appearance: '-apple-pay-button',
-apple-pay-button-type: 'donate',
-apple-pay-button-style: 'black'
}}
/>
{/* Attempt 2 */}
<ApplePay className='apple-pay-button' />
{/* Attempt 3 */}
<script src='https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js'></script>
<apple-pay-button
buttonstyle='black'
type='donate'
locale='en-US'
></apple-pay-button>
</PaymentForm>
</>
)
}
Here is the CSS for Attempt #2:
.apple-pay-button {
margin-bottom: 4rem;
height: 48px;
width: 100%;
display: inline-block;
-webkit-appearance: -apple-pay-button;
-apple-pay-button-type: donate;
-apple-pay-button-style: black;
}
I am a novice to using Square and working with React, I would appreciate any and all tips! Thanks!