JSON API reference

API Endpoint



Example Request

This is what a typical Worldpay request looks like:

    -H "Authorization:your-test-service-key"
    -H "Content-type: application/json"
    -X POST
    "token": "your-token",
    "orderDescription": "order-description",
    "amount": 500,
    "currencyCode": "GBP"
$worldpay = new Worldpay('your-test-service-key');

$response = $worldpay->createOrder(array(
    'token' => 'your-token',
    'amount-in-cents' => 500,
    'currencyCode' => 'GBP',
    'name' => 'test name',
    'billingAddress' => array(
        'address1'=>'123 House Road',
        'address2' => 'A village',
        'address3'=> '',
        'postalCode' => 'EC1 1AA',
        'city' => 'London',
        'state' => '',
        'countryCode'=> 'GB',
    'orderDescription' => 'Order description',
    'customerOrderCode' => 'Order code'
WorldpayRestClient restClient = new WorldpayRestClient("your-test-service-key");

OrderRequest orderRequest = new OrderRequest();
orderRequest.setName("test name");
orderRequest.setOrderDescription("Order description");
orderRequest.setCustomerOrderCode("Order code");

Address address = new Address();
address.setAddress1("123 House Road");
address.setAddress2("A village");
address.setPostalCode("EC1 1AA");

OrderResponse orderResponse = restClient.getOrderService().create(orderRequest);
worldpay ='your-test-service-key')

response = worldpay.createOrder({
    'token' => 'your-token',
    'amount' => 500,
    'currencyCode' => 'GBP',
    'name' => 'test name',
    'billingAddress' => {
        "address1"=>'123 House Road',
        "address2"=> 'A village',
        "address3"=> '',
        "postalCode"=> 'EC1 1AA',
        "city"=> 'London',
        "state"=> '',
        "countryCode"=> 'GB'
    'orderDescription' => 'Order description',
    'customerOrderCode' => 'Order code'
WorldpayRestClient restClient = new WorldpayRestClient("", "your-test-service-key");

var orderRequest = new OrderRequest()
    token = "your-token",
    amount = 500,
    currencyCode = CurrencyCode.GBP,
    name = "test name",
    orderDescription = "Order description",
    customerOrderCode = "Order code"
var address = new Address(){
    address1 = "123 House Road",
    address2 = "A village",
    city = "London",
    countryCode = CountryCode.GB,
    postalCode = "EC1 1AA"

orderRequest.billingAddress = address;

OrderResponse orderResponse = restClient.GetOrderService().Create(orderRequest);


Our API is based on REST principles which means the following:

All our URLs are resource oriented and we use HTTP verbs such as POST and GET to distinguish between different types of actions.

We use the "Authorization" field in the HTTP header for authorization. You should always use the Service Key for all calls made from your server. For increased security, WorldPay.js uses the Client Key instead of the Service Key. This will allow you to keep your Service Key more secure. The Client Key is not included in the HTTP header because not all browsers support setting of Authorization headers.

We use JSON in the body for all requests and responses.

We use standard HTTP response codes for all requests and responses.

REST and JSON have become the industry standard for APIs so hopefully ours should be easy to learn. Other benefits of REST and JSON is that they are easy to read by human beings and that they can easily be implemented in browsers, from your server and from mobile apps.