stripe-payments - 在 Stripe api 中使用 Google Pay 响应令牌
问题描述
我已经按照 Google Pay 文档在我的页面上设置了 Google Pay 按钮,但是我陷入了最后一步,我需要按照 Google Pay 文档的描述将令牌响应从 Google Pay 发送到 Stripe。
为了执行支付,后端处理购买并将支付令牌发送给支付服务提供商。
我已经搜索了 Stripe 文档,但似乎找不到如何使用该令牌,但他们向我展示了如何使用 Stripe Payment Request Button来集成 Google Pay。那么,Stripe 是否支持来自 Google Pay api 的令牌,或者我是否需要使用 Stripe Payment Request Button来与 Google Pay 集成?
解决方案
你可以做任何一个,你不/不应该混合这两种方法
基于Stripe doc here您可以使用
- Stripe 的 PaymentRequestButton
- 或者,您可以使用 Stripe 作为网关直接与 Google Pay 集成。在此处查看如何操作;在教程的第 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
代表 GooglePay 钱包的 Stripe 令牌paymentData.paymentMethodData.tokenizationData.token
,您可以使用 Stripe 的密钥直接将令牌与 Stripe API 一起使用,例如在此之后sk_test_xxxx
创建费用
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)',
});
FYI token/charge
API 不再推荐,你可以payment_method
从token
这样的创建一个
const paymentMethod = await stripe.paymentMethods.create({
type: 'card',
card: {
token: 'tok_xxxxx',
},
});
并将其与 Stripe PaymentIntent API一起使用
推荐阅读
- java - 如何在 linux pc 上设置 Cordova 9.0.0?
- javascript - xhttp 帖子不起作用。var 未定义
- javascript - vuejs单元测试,默认安装说没有指定测试
- python - 测试登录用户是否看到未发布的问题
- c - 初始化指向 char 数组的指针时出现分段错误
- aws-glue - 如何访问分区 Athena 表的子目录中的数据
- windows - 仅集成图形可实现透明窗口
- mips - 将 C 阶乘代码转换为 MIPS 阶乘
- swift - Swift CustomReflectable 在分离的静态库中不起作用
- android - 当我以编程方式触发屏幕截图时,相机预览会在保存的屏幕截图中消失