如何在客户上保存Apple Pay交易?

时间:2016-06-21 18:06:38

标签: stripe-payments cloud-code

我将Apple Pay实施到我的应用程序中并且工作正常,但是当我使用apple pay时,交易没有链接到用户,当我在我的云代码上添加客户/用户参数时,我收到此错误。

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)
    }
  });
});

1 个答案:

答案 0 :(得分:0)

您可以在创建费用时完全省略此参数,而不是传入Comparator<Integer> reverse = Collections.reverseOrder(); SortedSet<Integer> set = new TreeSet<>(reverse); //same thing here 参数作为您创建的令牌的ID,而只传入token参数: https://stripe.com/docs/api/node#create_charge-customer

这假定您已经创建了一个客户并在收取此费用之前将该令牌保存为该客户的付款来源: https://stripe.com/docs/charges#saving-credit-card-details-for-later

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