这是代码片段。该代码以前运行良好,但是在添加BillTo之后出现异常。
transactionRequest.setBillTo(billTo);
当我要求发布帐单地址时,我已经添加了这一行。这行是必需的,还是发布具有帐单地址的json就足够了
private void callPaymentApi(String token) {
CreateTransactionRequestParent createTransactionRequestParent = new CreateTransactionRequestParent();
CreateTransactionRequest createTransactionRequest = new CreateTransactionRequest();
MerchantAuthentication merchantAuthentication = new MerchantAuthentication();
merchantAuthentication.setName(API_LOGIN_ID);
merchantAuthentication.setTransactionKey(TRANSACTION_KEY);
createTransactionRequest.setMerchantAuthentication(merchantAuthentication);
createTransactionRequest.setRefId(REF_ID);
TransactionRequest transactionRequest = new TransactionRequest();
transactionRequest.setTransactionType(TRANSACTION_TYPE);
transactionRequest.setAmount(amount);
Payment payment = new Payment();
OpaqueData opaqueData = new OpaqueData();
opaqueData.setDataDescriptor(DATA_DESCRIPTOR);
opaqueData.setDataValue(token);
payment.setOpaqueData(opaqueData);
BillTo billTo = new BillTo();
billTo.setFirstName(st_billing_firstname);
billTo.setLastName(st_billing_lastname);
billTo.setAddress(st_billing_address);
billTo.setCity(st_billing_city);
billTo.setState(st_billing_state);
billTo.setZip(st_billing_zipcode);
transactionRequest.setBillTo(billTo);
transactionRequest.setPayment(payment);
}
这是我要发布的json。以前可以付款。但是在json中添加了billto之后,就会出现异常。
{
"createTransactionRequest":{
"merchantAuthentication":{
"name":"36GEWCYzFr9p",
"transactionKey":"74xLQ5dfa5Jsq6gc79Ta"
},
"refId":12321456,
"transactionRequest":{
"transactionType":"authCaptureTransaction",
"amount":0.99,
"payment":{
"opaqueData":{
"dataDescriptor":"COMMON.ACCEPT.INAPP.PAYMENT",
"dataValue":"eyJjb2RlIjoiNTsdwBfMlr8wNjAwMDUyREZCMDExNTI4RjIwQTAzNUQyNjQ3MjU2MDdEODJENEQxQjVDRTU3Nzc5MEFCMzVFNTZDNTMzMUFGMkJGMjIyQTAzNzJDQkRCMEVCNTRERDU4QkJGQjUzQkFDQjEyQTQ1IiwidG9rZW4iOiI5NTQzNDY5MjczMzMzNjAyNzAzNzAxIiwidiI6IjEuMssSJ9"
}
},
"billTo":{
"firstName":"Fgfhff",
"lastName":"Ghhfhfufgug",
"address":"Xhnnn",
"city":"A",
"state":"A",
"zip":"6866868"
}
}
}
}