java - Quickbooks API - 如何使用存储的信用卡创建费用

标签 java quickbooks-online intuit-partner-platform

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

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

我尝试使用其 ID 检索存储的卡,然后在费用中使用返回的卡详细信息,但没有成功。
所以我想知道如何使用存储的信用卡创建费用,而不需要每次都提供明确的卡详细信息。

UPDATE

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

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 提示它无效。

最佳答案

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

您将获得一个唯一的id值。

使用此 API 端点创建费用:

确保 cardOnFile你通过id您从第一次 API 调用返回的值。

您当前的代码不正确。你应该经过的地方cardOnFile作为参数,您传递 card节点(需要完整的卡号,而不是卡 id 值)。具体来说,这一行是不正确的:

charge.setCard(card);

关于java - Quickbooks API - 如何使用存储的信用卡创建费用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47979320/

相关文章:

python - 在 Mac 上以编程方式连接到 Quickbooks Online

quickbooks - 通过一个 Oauth 连接使用多个 QuickBooks Online 公司 (QBO v3)

quickbooks - 调用 intuit.ipp.anywhere.setup() 的最佳实践?

java - 我在哪里/如何找到使用 QuickBooks API v3 创建发票所需的税务引用代码?

Java 类构造函数 this.id = id 或 this.setId(id)

java - 我可以使用 org.eclipse.core.variables... 来定义其他扩展的属性吗

java - 在 java servlet 的 init 中唯一标识服务器的好方法是什么

java - 获取 Java 源文件夹中的所有资源

api - 如何获取 Intuit Data Services (IDS) 测试版功能?