【问题标题】:Stripe: how to create a customer object given credit card informationStripe:如何在给定信用卡信息的情况下创建客户对象
【发布时间】:2019-08-03 23:42:38
【问题描述】:

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

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

tok允许我一次性收费。接下来我想为以后的费用创建一个客户令牌,API是

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

但是,假设tok 的格式为,我不清楚我应该在source 中输入什么

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 中的信息都没有?

【问题讨论】:

    标签: javascript node.js stripe-payments


    【解决方案1】:

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

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

    所以在你的情况下来源是tok.id

    【讨论】:

      猜你喜欢
      • 2016-05-06
      • 2014-02-20
      • 1970-01-01
      • 2016-08-08
      • 1970-01-01
      • 2021-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多