KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Sample2


1 import com.jcommercesql.gateway.authorizenet.AuthorizeNetCC;
2
3
4 public class Sample2 {
5
6   public static void main(String JavaDoc[] args) {
7
8   try {
9
10     AuthorizeNetCC anetcc = new AuthorizeNetCC("config.prop");
11     anetcc.addOptionalField("x_Address","123 Main St."); // if needed for AVS
12
anetcc.addOptionalField("x_Zip","10101"); // if needed for AVS
13
anetcc.setTransaction("1234123412341234","11/09","100.00","AUTH_CAPTURE");
14     anetcc.addMerchantDefinedField("m_Comment", "Basic Example 2");
15     anetcc.submit();
16
17     if (anetcc.getResponseCode().equals("1")) {
18     System.out.println("Your transaction was approved!");
19     } else {
20     System.out.println("Your transaction was declined! " + anetcc.getResponseReasonText());
21     }
22   } catch(Exception JavaDoc e) {
23       System.out.println("System Error! " + e);
24   }
25  
26   } // end main
27
} // end class
28
Popular Tags