Closed gilbert-n closed 7 years ago
Hi @gilbert-n,
Could you try changing the following lines of code and see if it fixes the issue?
Result result = gateway.transaction().sale(trRequest);
to Result<Transaction> result = gateway.transaction().sale(trRequest);
Transaction transaction = result.getTransaction();
to Transaction transaction = result.getTarget();
You can see an example of accessing Transaction
objects though Result
objects on this page. If the object is still null afterwards, I'd recommend reaching out to support at support@braintreepayments.com
I am trying out this library (braintree-java, version 2.66), and I have noticed an issues/ problems earlier:
TransactionRequest trRequest = new TransactionRequest().amount(10) .paymentMethodNonce(clientNonce).options().submitForSettlement(true).done(); Result result = gateway.transaction().sale(trRequest);
if(result.isSuccess()){
Transaction transaction = result.getTransaction();
//From here I want to access other things from transaction
//such as transactionId so that I can keep a record of this transaction just in case.
}
I have tested this code and it seems to be working (I can see transactions updated in my sandbox account). However, the problem I am facing is that the transaction object in the if block is null. Am I doing something wrong here? My understanding is that if the result was successful then we would have a way to access the underlying transaction object, and it shouldn't be null.
Thank you.