调至内容部分
创建账户
或
登录
Stripe 文档徽标
/
询问人工智能
创建账户
登录
开始
付款
财务自动化
平台和交易市场
资金管理
开发人员工具
开始
付款
财务自动化
开始
付款
财务自动化
平台和交易市场
资金管理
概览
关于 Stripe 支付
升级您的集成
支付分析
线上付款
概览查找您的用例Managed Payments
使用 Payment Link
构建结账页面
构建高级集成
构建应用内集成
支付方式
添加支付方式
    概览
    支付方式集成选项
    在管理平台中管理默认支付方式
    支付方式类型
    银行卡
    银行借记
    银行重定向
    银行转账
    贷记转账(来源)
    先买后付
    实时付款
    付款凭单
    钱包
      支付宝
      Amazon Pay
      Apple Pay
        最佳实践
        Cartes Bancaires with Apple Pay
        Apple Pay 经常性交易
        Apple Pay 商家令牌
        Apple Pay 责任转移、争议和退款
      Cash App Pay
      Google Pay
      GrabPay
      Link
      MB WAY
      MobilePay
      PayPal
      PayPay
      Revolut Pay
      Satispay
      Secure Remote Commerce
      Vipps
      微信支付
    按国家启用本地支付方式
    自定义支付方式
管理支付方式
用 Link 更快结账
支付接口
Payment Links
结账
Web Elements
应用内 Element
支付场景
自定义支付流程
灵活收单
编排
线下支付
Terminal
其他 Stripe 产品
Financial Connections
加密货币
Climate
首页付款Add payment methodsWallets

Apple Pay

允许客户在他们的 iPhone、iPad 或 Apple Watch 上用 Apple Pay 安全地付款。

复制页面

支持的设备

参考 Apple 的兼容性文档,了解哪些设备支持 Apple Pay。

Apple Pay 与大多数 Stripe 产品和功能兼容。Stripe 用户可以在 iOS 9 及更高版本的 iOS 应用程序以及 iOS 10 或 macOS Sierra 及以上版本的 Safari 网页上接受 Apple Pay。处理 Apple Pay 付款时没有额外费用,定价与其他银行卡交易一样。

Apple Pay 可由在受支持国家的参与银行那里开户的持卡人使用。有关更多信息,请参考 Apple 的参与银行文档。

  • 客户所在地

    印度以外的全球

  • 出示货币

    参见受支持的出示货币

  • 支付确认

    客户发起

  • 支付方式类型

    钱包

  • 经常性付款

    是(墨西哥除外)

  • 提现时间

    适用标准提现时间

  • Connect 支持

    是

  • 争议支持

    是

  • 手动捕获支持

    是

  • 退款/部分退款

    是 / 是

付款流程

以下是您的结账页面的 Apple Pay 付款流程演示:

Apple Pay 付款流程动画显示 Stripe 结账页面、Apple Pay 按钮和测试时的确认对话框。

使用 Stripe 和 Apple Pay 与应用内购买

对于实物商品、服务和某些其他东西的销售,您的应用程序可以接受 Apple Pay 或其他任何 Stripe 支持的支付方式。这些付款是通过 Stripe 处理的,只需支付 Stripe 的手续费。但是,数字产品、内容和某些其他东西的销售必须使用 Apple 的应用内购买。这些付款由 Apple 公司处理,会收取交易费。

有关哪些类型的销售必须使用应用内购买的更多信息,请参见 Apple App Store 审查指南。

接受 Apple Pay

Stripe 提供了多种添加 Apple Pay 的方法。有关集成的详细信息,请选择您最喜欢的方法:

您可以使用 Stripe React Native SDK,同时接受 Apple Pay 和传统信用卡付款。开始前,您需要注册 Apple Developer Program 并在您的服务器和应用程序中设置 Stripe。接下来,执行这些步骤:

  1. 注册 Apple Merchant ID
  2. 创建新的 Apple Pay 证书
  3. 用 Xcode 集成
  4. 在 StripeProvider 中设置您的 Apple Merchant ID
  5. 检查是否支持 Apple Pay
  6. 出示支付表单
  7. 向 Stripe 提交付款

注册 Apple Merchant ID

可通过在 Apple 开发人员网站注册新的标识符来获取 Apple 商家 ID。

在表单中填写描述和标识符。描述内容仅供您自己记录之用,之后可随时更改。Stripe 建议用您的应用的名称作为标识符(例如,merchant.com.{{YOUR_APP_NAME}})。

创建新的 Apple Pay 证书

为您的应用创建证书,以加密支付数据。

转到管理平台中的 iOS 证书设置,点击添加新应用程序,然后按照说明进行操作。

下载证书签名请求 (CSR) 文件,来从 Apple 获取安全证书,以便使用 Apple Pay。

必须用一个 CSR 文件发布具体的一个证书。如果您切换您的 Apple Merchant ID,则必须前往管理平台的 iOS 证书设置中获取一个新的 CSR 和证书。

集成 Xcode

将 Apple Pay 功能添加到您的应用程序。在 Xcode 中,打开您的项目设置,点击签名和功能选项卡,然后添加 Apple Pay 功能。此时,系统可能会提示您登入您的开发人员账户。选择您之前创建的商家 ID,您的应用程序就可以接受 Apple Pay 了。

在 Xcode 中启用 Apple Pay 功能

在 StripeProvider 中设置您的 Apple Merchant ID

在 StripeProvider 组件中,指定您成功注册的 Apple Merchant ID:

import { StripeProvider } from '@stripe/stripe-react-native'; function App() { return ( <StripeProvider publishableKey="
pk_test_TYooMQauvdEDq54NiTphI7jx
" merchantIdentifier="merchant.com.{{YOUR_APP_NAME}}" > // Your app code here </StripeProvider> ); }

检查是否支持 Apple Pay

在您的应用程序中显示 Apple Pay 此支付选项之前,请确定用户的设备支持 Apple Pay,并且他们的钱包中添加了银行卡:

import { PlatformPayButton, isPlatformPaySupported } from '@stripe/stripe-react-native'; function PaymentScreen() { const [isApplePaySupported, setIsApplePaySupported] = useState(false); useEffect(() => { (async function () { setIsApplePaySupported(await isPlatformPaySupported()); })(); }, [isPlatformPaySupported]); // ... const pay = async () => { // ... }; // ... return ( <View> {isApplePaySupported && ( <PlatformPayButton onPress={pay} type={PlatformPay.ButtonType.Order} appearance={PlatformPay.ButtonStyle.Black} borderRadius={4} style={{ width: '100%', height: 50, }} /> )} </View> ); }

创建 Payment Intent

服务器端

生成一个端点,创建一个具有 amount 和 currency 的 PaymentIntent。始终在服务器端决定扣款金额,这是一个可信的环境,客户端不行。这样可防止客户自己选择价格。

Command Line
curl
curl https://api.stripe.com/v1/payment_intents \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -d "amount"=1099 \ -d "currency"="usd"

客户端

创建一个从您的服务器请求 PaymentIntent 的方法:

function PaymentScreen() { // ... const fetchPaymentIntentClientSecret = async () => { const response = await fetch(`${API_URL}/create-payment-intent`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ some: 'value', }), }); const { clientSecret } = await response.json(); return clientSecret; }; // ... }

故障排除

如果您在尝试创建令牌时看到 Stripe API 出现错误,则很可能是您的 Apple Pay Certificate 有问题。如本页所述,您需要生成一个新证书并上传到 Stripe。请确保您使用的是从您的管理平台获得的 CSR,而不是您自己生成的那个。Xcode 经常错误地缓存旧的证书,所以除了生成新证书外,Stripe 建议创建一个新的 Apple Merchant ID。

如果您收到错误:

您尚未将您的 Apple 商家账户添加到 Stripe

您的应用程序好像正在发送用以前的(非 Stripe) CSR/Certificate 加密的数据。务必撤销您的 Apple Merchant ID 下任何不是由 Stripe 生成的证书。如果这样不能解决问题,请删除您的 Apple 账户中的商家 ID,然后重新创建它。然后,根据之前使用的相同(Stripe 提供的) CSR 创建一个新证书。您不需要将此新的证书上传到 Stripe。完成后,在您的应用程序中打开并关闭 Apple Pay Credentials,以确保正确刷新。

出示支付表单

在您的 PlatformPayButton 的 onPress 属性中,调用 confirmPlatformPayPayment,打开一个 Apple Pay 表单。要在支付表单上显示客户购物车中的项目,将项目作为参数传递。

注意

在您的那些处理客户操作的代码中,不要在显示支付表单前包含任何复杂或异步操作。如果用户操作不直接调用支付表单,Apple Pay 会返回一个错误。

import { confirmPlatformPayPayment } from '@stripe/stripe-react-native'; function PaymentScreen() { // ... see above const pay = async () => { const clientSecret = await fetchPaymentIntentClientSecret() const { error } = await confirmPlatformPayPayment( clientSecret, { applePay: { cartItems: [ { label: 'Example item name', amount: '14.00', paymentType: PlatformPay.PaymentType.Immediate, }, { label: 'Total', amount: '12.75', paymentType: PlatformPay.PaymentType.Immediate, }, ], merchantCountryCode: 'US', currencyCode: 'USD', requiredShippingAddressFields: [ PlatformPay.ContactField.PostalAddress, ], requiredBillingContactFields: [PlatformPay.ContactField.PhoneNumber], }, } ); if (error) { // handle error } else { Alert.alert('Success', 'Check the logs for payment intent details.'); console.log(JSON.stringify(paymentIntent, null, 2)); } }; // ... see above }

可选创建 Payment Method
客户端

可选经常性付款
客户端

可选订单跟踪
客户端

测试 Apple Pay

要测试 Apple Pay,必须使用真实的信用卡卡号和测试 API 密钥。Stripe 会识别到您处于测试模式,并返回一个成功的测试卡令牌供您使用,因此您可以在不收款的情况下使用真实卡来测试付款。

您无法将Stripe测试卡或 Apple Pay 测试卡保存到 Apple Pay 钱包来测试 Apple Pay。

另见

  • iOS 集成
  • 网页版 Apple Pay
  • Apple Pay 最佳实践
此页面的内容有帮助吗?
是否
需要帮助?联系支持。
加入我们的早期使用计划。
查看我们的更改日志。
有问题?联系销售。
LLM? Read llms.txt.
Powered by Markdoc