Reply
Contributor
Posts: 20
Registered: ‎05-25-2016
Accepted Solution

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

[ Edited ]

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

 


Accepted Solutions
Solution
Accepted by topic author kofhearts
‎03-22-2018 10:02 PM
Administrator
Posts: 149
Registered: ‎03-28-2014

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

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


All Replies
Solution
Accepted by topic author kofhearts
‎03-22-2018 10:02 PM
Administrator
Posts: 149
Registered: ‎03-28-2014

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

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...