Vanilla JS 快速入门
Web 使用名为stripe-pwa-elements的自定义元素。请安装与之兼容的依赖库,并在启动过程中一次性注册这些元素,确保在展示 Stripe 用户界面之前完成这一操作。
npm install stripe-pwa-elements@^5.3.0
import { defineCustomElements } from 'stripe-pwa-elements/loader';
import { Stripe } from '@capacitor-community/stripe';
defineCustomElements();
await Stripe.initialize({
publishableKey: 'Your Publishable Key',
});
stripe-pwa-elements是一个模板库。如果你需要关于加载器的详细信息,请参考Stencil 文档。
Web 上的 PaymentSheet 和 PaymentFlow 展示银行卡模态窗口,不会渲染原生 Stripe PaymentSheet。Apple Pay 和 Google Pay 使用 Payment Request Button,要求 HTTPS。Web 会忽略多项原生专用选项,包括 defaultBillingDetails、billingDetailsCollectionConfiguration、enableApplePay 和 enableGooglePay。