stripe_native 包使 Flutter 应用程序能够使用 Apple Pay 和 Google Pay 创建可收费的 Stripe 令牌。它提供原生支付表单集成,允许用户通过设备内置的支付系统安全地授权付款。在用户批准后,该包会收集一次性源令牌,用于 Stripe 交易。专为无缝结账体验设计,它利用平台特定 API,无需自定义 UI 实现。该包非常适合需要安全、原生支付流程且设置简单的应用程序。
适合场景
通过 Apple Pay 的一次性付款
通过 Google Pay 的一次性付款
Stripe 的安全令牌生成
原生结账集成
移动电子商务应用
应用内购买
主要特点
原生 Apple Pay 集成
原生谷歌支付集成
一次性源令牌收集
最小化UI自定义
平台特定的支付表单
安全支付处理
适合对象
电子商务移动应用
基于订阅的服务
需要安全支付的应用
使用 Stripe 的开发者
支持 Apple/Google Pay 的项目
使用建议
需要设置 Stripe 账户
仅限 iOS 和 Android
需要正确的商户配置
依赖设备支付功能的可用性
不适用于定期付款
不支持网页平台
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Stripe Native
Create chargeable stripe tokens using Apple and Google Pay.
This plugin will give you easy access to the Apple and Google Pay payment sheets. And provide one-time source tokens that are used to create a Stripe Charge.
Setup
Both (Required)
To begin one will need a Stripe project, from there collect a publishable key.
iOS (Required)
On the Apple Developer portal, one will need to create a merchant identifier. Then connect that identifier to the Stripe project.
From the Stripe dashboard, create a signing certificate to share with Apple, then upload the signed certificate to Stripe.
Lastly, open the apps' iOS module. Add the newly created identifier to the project's signing capabilities.
Android (Optional)
On the Google Play console, add the merchant identifier to the app capabilites. This makes the merchant known to Google Pay. With it, users will not see a warning saying this app is an unidentified merchant.
Functions
Set Publishable Key
Prior to calling native pay, set the publishable key.
On iOS the payment sheet spins and ends with a check or X depending on the result passed in. During the spinning, query an endpoint for a charge using the token. This function does not affect Android.
// call charge endpoint w/ tokenconst wasCharged = awaitAppAPI.charge(token, amount);
// then show success or failureStripeNative.confirmPayment(wasCharged);