gpt4 book ai didi

javascript - Stripe : how to create a customer object given credit card information

转载 作者:搜寻专家 更新时间:2023-11-01 00:34:36 26 4
gpt4 key购买 nike

假设客户提供信用卡信息,那么我可以创建一个一次性收费对象:

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.idtok.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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com