Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Worldpay/worldpay-lib-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Worldpay REST API Java SDK

Java SDK for interacting with the Worldpay Developer REST API.

Issues

Please see our support contact information to raise an issue.

Download

Please download lastest released jar from release section. This jar does not require any other dependency.

Documentation

https://online.worldpay.com/docs

API Reference

https://online.worldpay.com/api-reference

Usage

Initialize the REST client with the default URL and the specified service key and then use the required service:

WorldpayRestClient restClient = new WorldpayRestClient("YOUR_SERVICE_KEY");

OrderRequest orderRequest = new OrderRequest();
orderRequest.setToken("valid-token");
orderRequest.setAmount(1999);
orderRequest.setCurrencyCode(CurrencyCode.GBP);
orderRequest.setName("test name");
orderRequest.setOrderDescription("test description");

try {
    OrderResponse orderResponse = restClient.getOrderService().create(orderRequest);
    System.out.println("Order code: " + orderResponse.getOrderCode());
} catch (WorldpayException e) {
    System.out.println("Error code: " + e.getApiError().getCustomCode());
    System.out.println("Error description: " + e.getApiError().getDescription());
    System.out.println("Error message: " + e.getApiError().getMessage());
}

Alternatively, the client can also be initialized with the REST service URL as well as the service key e.g.

WorldpayRestClient restClient = new WorldpayRestClient("https://api.worldpay.com/v1", "YOUR_SERVICE_KEY");

Use following API to get the Current SDK Library Version (available in v1.8 onwards only) in use:

WorldpayRestClient restClient = new WorldpayRestClient("YOUR_SERVICE_KEY");
String worldpaySdkVersion = restClient.getVersion();