cancel
Showing results for 
Search instead for 
Did you mean: 

how to set email field when using java authorize.net sdk?

I am using the java sdk. 

 

https://github.com/AuthorizeNet/sdk-java

 

I am using accept.js to send credit card to authorize.net via javascript and then in server side i execute accept payment transaction call as described in the following documentation.  

 

https://developer.authorize.net/api/reference/index.html#payment-transactions-create-an-accept-payme...

 

I have a chunk of code below for populating customer billing information. I set all information such as firstname, lastname, address, email etc. 

 

 

CustomerAddressType customerType = new CustomerAddressType()
customerType.setFirstName(firstName)
customerType.setLastName(lastName)
customerType.setAddress(address)
customerType.setCity(city)
customerType.setState(state)
customerType.setZip(zip)
customerType.setCountry(country)
customerType.setPhoneNumber(phone)
customerType.setEmail(email)

// Create the payment transaction request
TransactionRequestType txnRequest = new TransactionRequestType();
txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value());
txnRequest.setPayment(paymentType);
txnRequest.setBillTo(customerType)

 

txnRequest.setAmount(total.setScale(2, RoundingMode.CEILING));


// Make the API Request
CreateTransactionRequest apiRequest = new CreateTransactionRequest();
apiRequest.setTransactionRequest(txnRequest);
CreateTransactionController controller = new CreateTransactionController(apiRequest);
controller.execute();


CreateTransactionResponse tresponse = controller.getApiResponse();

 

 

 

The problem is that i cannot set the email field. All other fields appear in the transaction but email field is always blank. This hapens both in sandbox as well as production. So i am wondering if i have missed anything that is preventing me to set the email field? I appreciate any help! Thanks!

 

Since i am not being able to paste the image i have uploaded to an external images host. Please see the image in this link

 

 

https://ibb.co/daRQnx

 

kofhearts
Contributor
1 ACCEPTED SOLUTION

Accepted Solutions

You need to set the email address on the transaction. 

 

I've updated the java sample code for Charge A Credit Card, same will work for you, see lines 35,35 & 42 of https://github.com/AuthorizeNet/sample-code-java/blob/master/src/main/java/net/authorize/sample/Paym...

View solution in original post

brianmc
Administrator Administrator
Administrator
1 REPLY 1

You need to set the email address on the transaction. 

 

I've updated the java sample code for Charge A Credit Card, same will work for you, see lines 35,35 & 42 of https://github.com/AuthorizeNet/sample-code-java/blob/master/src/main/java/net/authorize/sample/Paym...

brianmc
Administrator Administrator
Administrator