cancel
Showing results for 
Search instead for 
Did you mean: 

How to set the address parameters for AVS verification

Hi All,

 

I am new to the authorize.net, 

 

Currently am trying to integrate authorize.net with java for credit card processing, In this i want to check the billing address of the customer with Credit card billing address. But am not able to check whether the address is correctly validating or not. am using dummy credit card number.

 

below is the code snippet which am using now.

 

-----------------------------------------------------------------------------------------------------------------------------

URL post_url = new URL("https://test.authorize.net/gateway/transact.dll");
//AuthnetAIM authnet = new AuthnetAIM();
Hashtable post_values = new Hashtable();

// the API Login ID and Transaction Key must be replaced with valid values
post_values.put("x_login", LOGIN_ID);
post_values.put("x_tran_key", TRANSACTION_KEY);

post_values.put("x_version", "3.1");
post_values.put("x_delim_data", "TRUE");
post_values.put("x_delim_char", "|");
post_values.put("x_relay_response", "FALSE");

post_values.put("x_type", "AUTH_CAPTURE");
post_values.put("x_method", "CC");
post_values.put("x_card_num", "4111111111111111");
post_values.put("x_exp_date", "0115");

post_values.put("x_amount", "0.99");
post_values.put("x_description", "Sample Transaction");

post_values.put("x_first_name", "John");
post_values.put("x_last_name", "Doe");
post_values.put("x_address", "1234 Street");
post_values.put("x_state", "Mumbai");
post_values.put("x_zip", "98004asdf");
// Additional fields can be added here as outlined in the AIM integration
// guide at: http://developer.authorize.net

// This section takes the input fields and converts them to the proper format
// for an http post. For example: "x_login=username&x_tran_key=a1B2c3D4"
StringBuffer post_string = new StringBuffer();
Enumeration keys = post_values.keys();
while (keys.hasMoreElements()) {
String key = URLEncoder.encode(keys.nextElement().toString(), "UTF-8");
String value = URLEncoder.encode(post_values.get(key).toString(), "UTF-8");
post_string.append(key + "=" + value + "&");
}

// The following section provides an example of how to add line item details to
// the post string. Because line items may consist of multiple values with the
// same key/name, they cannot be simply added into the above array.
//
// This section is commented out by default.
/*
String[] line_items = {
"item1<|>golf balls<|><|>2<|>18.95<|>Y",
"item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>Y",
"item3<|>book<|>Golf for Dummies<|>1<|>21.99<|>Y"};

for (int i = 0; i < line_items.length; i++) {
String value = line_items[i];
post_string.append("&x_line_item=" + URLEncoder.encode(value));
}
*/

// Open a URLConnection to the specified post url
URLConnection connection = post_url.openConnection();
connection.setDoOutput(true);
connection.setUseCaches(false);

// this line is not necessarily required but fixes a bug with some servers
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

// submit the post_string and close the connection
DataOutputStream requestObject = new DataOutputStream(connection.getOutputStream());
requestObject.write(post_string.toString().getBytes());
requestObject.flush();
requestObject.close();

// process and read the gateway response
BufferedReader rawResponse = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
String responseData = rawResponse.readLine();
rawResponse.close();

----------------------------------------------------------------------------------------------------

 

In the above code, even when am trying to check with state as MUMBAI its working. 
Can any one please help me how exactly i need to set the address.

 

Thanks in Advance.

Harsha. 

12 REPLIES 12

Did you change the setting in the merchant account?

https://test.authorize.net

Account - Settings - Security Settings - Address Verification Service

 

For test account, it will return "P" on avs response. to test the other response

read http://community.developer.authorize.net/t5/Integration-and-Testing/Triggering-Specific-Transaction-...

CC# is 4222222222222 and need to set  x_test_request=TRUE

 

RaynorC1emen7
Expert

 

 

 

 

Hi Raynor,

Thanks for the reply.

 

When am trying to use the below CC#4222222222222 , am getting the transaction is declained,

i again tested with my old CC#4111111111111111, its working fine. i dont know what might be the issue.

 

between what " x_test_request " this will do ?

 

and i enabled the allow radio button for N,A,Z,W,Y in authorize.net setting -> AVS >page

 

Can you please help me 

Thanks,

harsha.

 

 

I guess I not sure what you try to do?

You will need to read http://community.developer.authorize.net/t5/Integration-and-Testing/Triggering-Specific-Transaction-... to use the CC# 4222222222222

 

Test account will return AVS "P" unless you are using the 4222222222222 to get a specific response. That why 4111111111111111 will work.

 

AIM documentation is here.

Ohh!!!..i got you. so even i use the CC#4222222222222,i will get the AVS response as 'P' as am using the test account

 

am i right?

 

Thanks alot for your help.

 

Harsha.

Hi Raynot,

 

Sorry for asking the same questions

 

I tested with the CC# you provided and with the different zip codes and am seeing only P as AVS response.

i made few changes like in settings page Payment form->form feilds -> i enabled required check box for address and zip code columns under customer billing information.

 

Below is the response code :

 

responseData -- > 2|2|29|(TESTMODE) The Paymentech identification numbers are in
correct. Call Merchant Service Provider.|000000|P|0||Sample Transaction|29.00|CC
|auth_capture||John|Doe||1234 Street||WA|46203||||||||||||||||||5C355C1B74459ACB
3ECD7DE803990F4C|||||||||||||XXXX2222|||||||||||||||||

 

Thanks in advance for your help.

 

Thanks,

Harsha.

 

It look like x_test_request need to be "false" not true.

Hi Raynor,

 

i tested by changing it to false

 

2|2|27|The transaction has been declined because of an AVS mismatch. The address provided does not match billing address of cardholder.|P84UAM|E|2173586282||Sample Transaction|1.00|CC|auth_capture||John|Doe||1234 Street||WA|46203||||||||||||||||||3F75447B12295927300E1B7593B59A5A|P|2|||||||||||XXXX2222|Visa||||||||||||||||

 

From the above result what is P84UAMrefers to and now i got AVS COde as E..i think its working now.

 

Actually my requirement is to authorize the credit card credentials wether the customer billing address is same as credit card billing address of card holder or not and the credit card number is valid or not..

 

i dont want the amount to be debited from the credit card.

 

Can you please suggest me what to do in this case.

 

Thanks,

Harsha.

From the above result what is P84UAM refers to

Since it is the fifth field, it is the Authorization Code

http://developer.authorize.net/guides/AIM/Transaction_Response/Fields_in_the_Payment_Gateway_Respons...

 

Actually my requirement is to authorize the credit card credentials wether the customer billing address is same as credit card billing address of card holder or not and the credit card number is valid or not..

Check all the box on the AVS settings. That will reject everything unless AVS is process and match. credit card# is done on the issuer end.

 

 

i dont want the amount to be debited from the credit card.

If the card is decline, no amount will be charge. Or do you mean testing the card? do a auth_only then void for that.