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).
File | Version | Release Date | Description |
---|---|---|---|
usaepayapi-jaxws-1.2.0.zip | 1.2.0 | 8/25/09 | Library .jar and example .java |
usaepay-jaxws-1.2.0.jar.zip | 1.2.0 | 9/5/09 | USAePay-jaxws-1.2.jar only |
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:
import com.usaepay.api.jaxws.*;
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.
// Create security token String SourceKey="_Z0ji6VHHIzMR99PMgaf91FZxwC630mp"; //Test Sandbox source key String Pin ="1234"; //Test Sandbox source key pin String ClientIP="10.10.10.10"; UeSecurityToken token = usaepay.getToken(SourceKey, Pin, ClientIP);
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.