如何保存客户的 Apple Pay 交易? [英] How do I save Apple Pay transaction on a customer?

查看:68
本文介绍了如何保存客户的 Apple Pay 交易?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中实施了 Apple Pay,它运行良好,但目前当我使用 Apple Pay 时,交易未链接到用户,当我在云代码中添加客户/用户参数时,我收到此错误.

I implemented Apple Pay into my app and it works fine, but currently when I use apple pay the transaction isn't linked to a user, when I add a customer/user parameter on my cloud code I get this error.

error:
type: "invalid_request_error"
message: "Customer cus_xxx does not have a linked card with ID tok_xxxx."
param: "card"
code: "missing"

Parse.Cloud.define("chargeApplePay", function(request, response){
Stripe.Charges.create({
amount: 100 * 100,
currency: "usd",
customer: request.params.idcustomer,
token: request.params.tokenid
},{
  success: function(httpResponse) {
    response.success("success");
  },
  error: function(httpResponse) {
    response.error(httpResponse)
    }
  });
});

推荐答案

不是传入 token 参数作为您创建的令牌的 ID,您可以在创建费用时完全省略此参数并只传入 customer 参数:https://stripe.com/docs/api/node#create_charge-customer

Instead of passing in a token parameter as the ID of the token you created, you could omit this parameter altogether when creating the charge and pass in only the customer parameter instead: https://stripe.com/docs/api/node#create_charge-customer

这假设您已经创建了一个客户并在收取此费用之前将该令牌保存为该客户的付款来源:https://stripe.com/docs/charges#saving-credit-稍后的卡片详细信息

This assumes that you already created a customer and saved that token as a payment source for that customer before making this charge: https://stripe.com/docs/charges#saving-credit-card-details-for-later

如果您确实想为该客户的特定卡收费(而不是记录中的默认卡),您可以将卡 ID (card_*) 作为 source 传入:https://stripe.com/docs/api/node#create_charge-source

If you do want to charge a specific card for that customer (as opposed to the default card on record), you'd pass in the card ID (card_*) as the source: https://stripe.com/docs/api/node#create_charge-source

这篇关于如何保存客户的 Apple Pay 交易?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆