【问题标题】:Quickbooks API - How to create a charge using stored credit cardQuickbooks API - 如何使用存储的信用卡创建费用
【发布时间】:2017-12-27 00:43:19
【问题描述】:

我想知道如何使用存储的信用卡创建费用。
使用 /card api 我已成功将卡片存储在 QuickBooks Online 中并收到卡片 ID 作为回报。 现在我想对存储的卡进行收费。为了创建费用,我看到有两种方法可以提供卡详细信息。

  1. 提供明确的卡详细信息,例如卡号、到期日期等。
  2. 通过使用卡令牌。但即使是为了检索卡令牌,我们也需要向 /tokens api 调用提供明确的卡详细信息。

我尝试使用它的 ID 检索存储的卡,然后在 Charge 中使用退回的卡详细信息,但它不起作用。
所以我想知道如何通过使用存储的信用卡而不需要每次都提供明确的信用卡详细信息来创建费用。

更新

我尝试了以下测试代码,但它给了我“card.number is invalid”错误。

public Charge createCharge(Context context, String requestId) {
        String uri = "https://sandbox.api.intuit.com/quickbooks/v4/payments/charges";
        PaymentService paymentService = new PaymentService();
        Charge charge = new Charge();
        CreditCard card = null;
        try {
            card = paymentService.getCreditCard(context, getRequestId(), "https://sandbox.api.intuit.com/quickbooks/v4/customers/{customer_id}/cards/{card_id}");
        } catch (Exception e) {
            e.printStackTrace();
        }
        charge.setCard(card);
        charge.setAmount(new BigDecimal(10.55));
        charge.setCurrency("USD");

        try {
            charge = paymentService.createCharge(context, getRequestId(), charge, uri);
            return charge;
        } catch (Exception e) {
        }
}

Error com.intuit.ipp.exception.BadRequestException: ERROR CODE:PMT-4000, ERROR MESSAGE:card.number is invalid., ERROR DETAIL:card.number, MORE ERROR DETAIL:HttpStatusCode=400; Type=invalid_request; MoreInfo=Credit/Debit card number format, InfoLink=https://developer.intuit.com/v2/docs?redirectID=PayErrors

我使用卡 ID 检索到的卡中的卡号(显然)被混淆了,格式为“xxxxxxxxxxxx1111”,因此 /charges api 抱怨它无效。

【问题讨论】:

    标签: java quickbooks-online intuit


    【解决方案1】:

    使用此 API 端点存储卡片详细信息(“创建卡片”):

    您会得到一个唯一的 id 值。

    使用此 API 端点创建费用:

    确保为 cardOnFile 传递从第一个 API 调用返回的 id 值。

    您当前的代码不正确。在您应该将 cardOnFile 作为参数传递的地方,您将传递 card 节点(它需要一个完整的卡号,而不是一张卡 id 值)。特别是这一行是不正确的:

    charge.setCard(card);

    【讨论】:

    • 感谢基思的回复。我想我以前尝试过这种方法,但没有成功。但我会再试一次并回来。
    • 我更新了我的帖子,并附上了使用存储卡创建费用的结果。
    • @ivish 我已经更新了我的答案以指出您的代码不正确的地方。
    • 我现在可以成功创建费用了。谢谢
    猜你喜欢
    • 1970-01-01
    • 2020-09-10
    • 1970-01-01
    • 2011-01-01
    • 2013-07-10
    • 1970-01-01
    • 2016-03-09
    • 2013-08-30
    • 2016-10-16
    相关资源
    最近更新 更多