The following guide demonstrates how to use the USAePay-jaxws.jar package with either Sun's Jax-WS 2.1 or Apache Foundation's CXF libary. This package contains a helper class for easily generating security tokens, classes for all USAePay soap objects and a client service class for calling soap methods. The package requires Jax-WS (see Dependencies).
In classes that are going to use the USAePay soap methods or object, you need to import the appropriate classes from com.usaepay.api.jaxws package. The following will import all usaepay objects at once:
All calls to the USAePay soap servers are handled by a “client” object of type “UeSoapServerPortType”. There are two ways to instantiate the client object. To instantiate a client for use with the main production servers:
// Instantiate client for production UeSoapServerPortType client = usaepay.getClient();
Alternately, you can specify a server hostname, which will allow you to setup a connection to the sandbox server for testing or a backup datacenter (see the high availability programming guide).
// Instantiate client for sandbox UeSoapServerPortType client = usaepay.getClient("sandbox.usaepay.com");
A “token” object (of type UeSecurityToken) is required by all soap methods in the USAePay API. It is used to identify the merchant.
Soap methods are called using the client object. Below is an example for calling the runSale method. For further examples see the soap api documentation.
TransactionRequestObject request = new TransactionRequestObject(); request.setAccountHolder("Tester John"); TransactionDetail details = new TransactionDetail(); details.setAmount(12.30); details.setDescription("Example Sale"); request.setDetails(details); CreditCardData ccdata = new CreditCardData(); ccdata.setAvsStreet("1234 Main"); ccdata.setAvsZip("12345"); ccdata.setCardNumber("4000100011112224"); ccdata.setCardExpiration("0919"); request.setCreditCardData(ccdata); TransactionResponse response; response = client.runSale(token, request); System.out.println("Response: " + response.getResult() + " RefNum: " + response.getRefNum());
For addition documentation on which methods are available and example usage, please see the main Soap API Documenation. The soap documentation includes a description of all methods and their parameters as well as examples for the java library.
If you run into any trouble please contact our integration support department.