我在我的应用程序中添加了 Apple pay 按钮,但我想在 stripe-js 的 ButtonElement 中传递一个禁用属性。
<PaymentRequestButtonElement options={{
paymentRequest,
disableMultipleButtons: true,
style: {
paymentRequestButton: {
type: "buy",
theme: "dark",
height: "48px",
},
},
}} />
我正在使用 Elements 容器来显示下面的按钮:
<Elements stripe={stripePromiseUS} options={STRIPE_OPTIONS}>
{props.children}
</Elements>
这也是我的 STRIPE_OPTIONS :
export const STRIPE_OPTIONS = {
mode: 'setup',
currency: 'usd',
paymentMethodCreation: 'manual',
} as StripeElementsOptions;
当您创建 paymentRequest 实例[1]时,您可以提供要禁用的钱包列表[2]。
const [paymentRequest, setPaymentRequest] = useState(null);
useEffect(() => {
if (stripe) {
const pr = stripe.paymentRequest({
country: 'US',
currency: 'usd',
total: {
label: 'Demo total',
amount: 1099,
},
requestPayerName: true,
requestPayerEmail: true,
disableWallets: ['applePay'] # add this line
});
}
}, [stripe]);
[2] https://docs.stripe.com/js/ payment_request/create#stripe_ payment_request-options-disableWallets