我想知道如何使用存储的信用卡进行收费。
使用/ card api,我已经成功地将卡存储在QuickBooks Online中,并获得了卡ID作为回报。
现在,我想对存储的卡进行收费。对于创建费用,我看到有两种提供卡详细信息的方法。
提供明确的卡详细信息,例如卡号,有效期等。
通过使用卡令牌。但是,即使要检索卡令牌,我们也需要向/ 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抱怨它无效。
最佳答案
使用以下API端点存储卡详细信息(“创建卡”):
https://developer.intuit.com/docs/api/payments/cards
您将获得唯一的id
值。
使用以下API端点创建费用:
https://developer.intuit.com/docs/api/payments/charges
确保为cardOnFile
传递从第一个API调用返回的id
值。
您当前的代码不正确。您应该在传递cardOnFile
作为参数的地方,传递的是card
节点(该节点需要完整的卡号,而不是卡的id
值)。特别是这一行是不正确的:
charge.setCard(card);
关于java - Quickbooks API-如何使用存储的信用卡创建费用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47979320/