ReactJS:Stripe Google 和 Apple Pay

标签 reactjs stripe-payments applepay google-pay

我在我的 ReactJS 应用程序中使用 @stripe/react-stripe-js。

我的付款代码:

import React from 'react';
import {CardElement} from '@stripe/react-stripe-js';

const CARD_ELEMENT_OPTIONS = {
  style: {
    base: {
      'color': '#32325d',
      'fontFamily': 'inherit',
      'fontSmoothing': 'antialiased',
      'fontSize': '16px',
      '::placeholder': {
        color: '#aab7c4',
      },
    },
    invalid: {
      color: '#fa755a',
      iconColor: '#fa755a',
    },
  },
};

export default function CardInput() {
  return (
    <>
    <CardElement options={CARD_ELEMENT_OPTIONS} />
    </>
  );
}

这使得卡付款表单正常,但我不确定如何添加通过 Google 或 Apple Pay 结帐的选项。我已阅读 Stripe 文档,但不确定如何继续。谁能给我一些关于如何将其集成到应用程序中的建议?

最佳答案

Card Element 不提供接受 Google Pay 或 Apple Pay 的选项。如果您想使用电子钱包接受卡付款,您可以切换到使用付款元素,或单独实现付款请求按钮。

需要注意的重要一点是,仅当您使用 https 提供页面时才会显示接受 Google Pay 或 Apple Pay 的选项。您可以使用 ngrok 来测试这一点。

支付要素和卡要素比较:https://stripe.com/docs/payments/payment-card-element-comparison

快速入门(选择自定义付款流程):https://stripe.com/docs/payments/quickstart

接受付款:https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements&html-or-react=react#apple-pay-and-google-pay

付款请求按钮:https://stripe.com/docs/stripe-js/elements/payment-request-button?html-or-react=react

关于ReactJS:Stripe Google 和 Apple Pay,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71899884/

相关文章:

javascript - Reactjs 代码未显示在 HTML/CSS 网站中

javascript - 失去焦点时 react 组件 "closing"

reactjs - 使用 create react app 编译时 typescript 不会出错

javascript - 如果输入具有特定类别,则需要更改单选值

javascript - 是什么阻止浏览器请求由于不正确的 CORS 处理而被重定向?

nfc - Apple Pay 和支持 NFC 的信用卡在伦敦地铁等入住/退房场景中如何使用?

javascript - iframe 中的 Apple Pay 集成问题

javascript - 警告 : Failed prop type: The prop `value` is marked as required in `TextInput` , 但其值为 `undefined`

ruby-on-rails - 从 STRIPE 向公众公开客户 ID 或信用卡 ID 是否安全?

java - 如何正确创建 2 路 TLS 的 SSLSocketFactory? (适用于苹果支付)