You can sign up for a Xfers account at https://xfers.com.
Java 1.6 and later.
Add this dependency to your project's POM:
<dependency>
<groupId>com.xfers</groupId>
<artifactId>xfers-java</artifactId>
<version>1.19.0</version>
</dependency>
You'll need to manually install the following JARs:
- The Xfers JAR from https://github.com/Xfers/xfers-java/releases/latest.
- Google Gson from http://google-gson.googlecode.com/.
- Google Guava from https://github.com/google/guava.
- Unirest for Java from http://unirest.io/java.html.
- JUnit from http://junit.org/junit4/.
Please see the API docs for the most up-to-date documentation.
XfersExample.java
import com.xfers.Xfers;
import com.xfers.model.Charge;
import com.xfers.model.Item;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class XfersExample {
public static void main(String[] args) {
Xfers.apiKey = "pXcfdAKNorDe_o1eou1NSp4mwssiEzem_6sg8fwnZWs";
Xfers.setSGSandbox();
try {
System.out.println("Listing charges without filter");
List<Charge> charges = Charge.listAll();
for (Charge charge : charges) {
System.out.println(charge.toString());
List<Item> items = charge.getItems();
for (Item item : items) {
System.out.println(item.toString());
}
}
System.out.println("Listing charges with filter");
Map<String, Object> params = new HashMap<String, Object>();
params.put("limit", "1");
charges = Charge.listAll(params);
for (Charge charge : charges) {
System.out.println(charge.toString());
}
} catch (Exception e) {
e.printStackTrace();
}
}
AuthenticationException -> given 401 by Xfers. These are usually xfers_api_token related bug.
InvalidRequestException, -> given 400 error by Xfers. Most Expected Error will belong in this categort
APIException -> status non 400, 401, 200. (usually indicates 500 error/ unexpected error, please escalate to Xfers when this happens)
APIConnectionException -> Happens if the HTTP method used is not in (POST, GET, PUT, PATCH). Should not happen in your client app.
UnirestException -> Happens if xfers URL given is unreachable (wrong URL). Should not happen in your client app.