我想知道如何使用存储的信用卡创建费用。
使用/card api 我已成功将卡存储在 QuickBooks Online 中并收到返回的卡 ID。
现在我想对存储的卡进行收费。为了创建费用,我发现有两种提供卡详细信息的方法。
- 提供明确的卡详细信息,例如卡号、有效期等。
- 通过使用卡 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/