作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
假设客户提供信用卡信息,那么我可以创建一个一次性收费对象:
let tok = await stripe.tokens.create({
card: {
number: '4242424242424242',
exp_month: 12,
exp_year: 2020,
cvc: '123'
}
})
tok
允许我一次性收费。接下来我想创建一个客户 token 以供以后收费,API 是
const customer = await stripe.customers.create({
source: 'tok_mastercard',
email: 'paying.user@example.com',
});
但是,不清楚我应该将什么放入source
,假设 tok
是形式
const tok = {
"id": "tok_1DHGtNDubJ4bIrUdqXvAGo4m",
"object": "token",
"card": {
"id": "card_1DHGtNDubJ4bIrUd2OyUHWNw",
"object": "card",
"address_city": null,
"address_country": null,
"address_line1": null,
"address_line1_check": null,
"address_line2": null,
"address_state": null,
"address_zip": null,
"address_zip_check": null,
"brand": "Visa",
"country": "US",
"cvc_check": null,
"dynamic_last4": null,
"exp_month": 8,
"exp_year": 2019,
"fingerprint": "rhpDLcuYn3stjjKR",
"funding": "credit",
"last4": "4242",
"metadata": {},
"name": "Jenny Rosen",
"tokenization_method": null
},
"client_ip": null,
"created": 1538598261,
"livemode": false,
"type": "card",
"used": false
}
是source
然后tok.id
或 tok.card.id
,或者甚至是 tok
中的信息有没有?
最佳答案
基于https://stripe.com/docs/api/customers/create .
Source is a Token’s or a Source’s ID, as returned by Elements
因此在您的情况下源是 tok.id
。
关于javascript - Stripe : how to create a customer object given credit card information,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57342814/
我是一名优秀的程序员,十分优秀!