如何在 React 中的 Apple Pay Stripe 按钮中传递禁用属性

问题描述 投票:0回答:1

我在我的应用程序中添加了 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;
reactjs stripe-payments applepay
1个回答
0
投票

当您创建 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]);

[1] https://docs.stripe.com/stripe-js/elements/ payment-request-button?client=react#create- payment-request-instance

[2] https://docs.stripe.com/js/ payment_request/create#stripe_ payment_request-options-disableWallets

© www.soinside.com 2019 - 2024. All rights reserved.