简体   繁体   English

条纹:如何在给定信用卡信息的情况下创建客户对象

[英]Stripe: how to create a customer object given credit card information

Suppose the customer give the credit card information, then I can create a onetime charge object with: 假设客户提供了信用卡信息,那么我可以创建一个一次性收费对象:

let tok = await stripe.tokens.create({
    card: {
     number: '4242424242424242',
    exp_month: 12,
    exp_year: 2020,
    cvc: '123'
  }
})

tok allow me a one time charge. tok允许我一次充电。 Next I would like to create a customer token for later charges, the API is 接下来,我想为以后的收费创建一个客户令牌,该API是

  const customer = await stripe.customers.create({
    source: 'tok_mastercard',
    email: 'paying.user@example.com',
  });

However, it's not clear what I should put into source , assuming tok is of form 但是,不清楚我应该在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
}

Is source then tok.id or tok.card.id , or is the information even in the tok at all? 然后是source tok.idtok.card.id ,还是信息甚至在tok中?

Base on the https://stripe.com/docs/api/customers/create . 基于https://stripe.com/docs/api/customers/create

Source is a Token’s or a Source’s ID, as returned by Elements

So source is tok.id in your case. 因此,在您的情况下,源是tok.id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM