Stripe Payments - 将现有卡添加到客户

Stripe Payments - Add existing card to customer

我有一个为客户收取费用的 Squarespace 应用程序,但是 Squarespace 不创建客户对象,它只是存储费用。

我的目标:当用户进行购买时,创建一个附带订阅计划的客户对象,以便我们可以对卡进行定期收费。

我可以通过条带测试 API 提取一个费用列表,每个费用都有一个 source 其中包含一个卡片令牌。因此,据我所知,我应该能够创建一个客户并传入源或源 ID,它会将源添加到该客户。

我的代码如下所示:

customer = Stripe::Customer.create(
  :email => customerEmail,
  :plan => customerPlanId,
  :source => charge[:source],
  :description => customerName
)

我正在条纹沙箱中执行此操作。我可以清楚地看到存储在 charge 中的源对象中的卡,但是 stripe 抛出错误:

`handle_api_error': No such token: card_19NXFMKm5fnTITnyYdk6shyj (Stripe::InvalidRequestError)

提前致谢!

当你create a customersource参数时,它应该是令牌ID("tok_..."),而不是卡ID。

有关详细信息,请参阅此 Whosebug 答案: