我想知道如何使用存储的信用卡创建费用。 使用/ card api我已成功将卡存储在QuickBooks Online中并收到卡片ID作为回报。现在我想针对存储的卡创建一个电荷。为了创建费用,我看到有两种方法可以提供卡片详细信息。
我尝试使用它的Id检索存储的卡,然后使用Charge中返回的卡详细信息,但它不起作用。 所以我想知道如何使用存储的信用卡创建费用,而不是每次都要求提供明确的卡详细信息。
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”,因此/ charge api会抱怨它无效。
使用此API端点存储卡详细信息(“创建卡”):
你得到一个独特的id
值。
使用此API端点创建费用:
确保cardOnFile
传递了从第一次API调用中返回的id
值。
您当前的代码不正确。如果您应该将cardOnFile
作为参数传递,那么您将通过card
节点(它需要一个完整的卡号,而不是卡id
值)。特别是这一行不正确:
charge.setCard(卡);