你可以做任何一个,你不/不应该混合这两种方法
基于Stripe doc here你可以使用
- Stripe 的 PaymentRequestButton
- 或者您可以使用 Stripe 作为网关直接与 Google Pay 集成。看看怎么做here;在教程的第 2 步中,搜索
stripe 以查找网关配置
const tokenizationSpecification = {
type: 'PAYMENT_GATEWAY',
parameters: {
"gateway": "stripe"
"stripe:version": "2018-10-31" // your stripe API version
"stripe:publishableKey": "pk_test_xxxx" // your stripe publishable key
}
};
对于选项 2,您基本上会得到一个类似 tok_xxxx 的 Stripe 令牌,代表来自 paymentData.paymentMethodData.tokenizationData.token 的 GooglePay 钱包,您可以使用 Stripe 的密钥 sk_test_xxxx 直接将令牌与 Stripe API 一起使用,例如创建收费following this
const stripe = require('stripe')('sk_test_xxxxx');
const charge = await stripe.charges.create({
amount: 2000,
currency: 'usd',
source: 'tok_obtained_from_google_pay_api',
description: 'My First Test Charge (created for API docs)',
});
仅供参考 token/charge API 不再推荐,您可以从 token 创建一个 payment_method,例如 this
const paymentMethod = await stripe.paymentMethods.create({
type: 'card',
card: {
token: 'tok_xxxxx',
},
});
并将其与 Stripe 一起使用 PaymentIntent API