Menu

Creating a standard order

Creating an Order

Copied!
curl https://api.worldpay.com/v1/orders 
-H "Authorization:your-service-key" 
-H "Content-type: application/json" 
-X POST -d '{
    "token" : "your-token",
    "orderType" : "your-order-type-option",
    "amount" : 500,
    "currencyCode" : "GBP",
    "orderDescription" : "Order description",
    "customerOrderCode":"my-customer-order-code",
    "settlementCurrency":"GBP",
    "name" : "name",
    "billingAddress" : {
        "address1" : "address1",
        "postalCode" : "postCode",
        "city" : "city",
        "countryCode" : "GB"
    },
    "deliveryAddress": {
        "firstName": "John",
        "lastName": "Smith",
        "address1": "address1",
        "address2": "address2",
        "address3": "address3",
        "postalCode": "postCode",
        "city": "city",
        "state": "state",
        "countryCode": "GB",
        "telephoneNumber": "02079460761"
    },
    "shopperEmailAddress": "email address",
    "shopperIpAddress": "195.35.90.111",
    "shopperSessionId" : "123"
}'
$worldpay = new Worldpay('your-service-key');

$response = $worldpay->createOrder(array(
    'token' => 'your-token',
    'amount-in-cents' => 500,
    'currencyCode' => 'GBP',
    'name' => 'test name',
    'billingAddress' => array(
        'address1' => 'address1',
        'postalCode' => 'postCode',
        'city' => 'city',
        'countryCode' => 'GB',
    ),
    'orderDescription' => 'Order description',
    'customerOrderCode' => 'Order code',
    'settlementCurrency'=>:'GBP'));
WorldpayRestClient restClient = new WorldpayRestClient("your-service-key");

OrderRequest orderRequest = new OrderRequest();
orderRequest.setToken("your-token");
orderRequest.setAmount(500);
orderRequest.setCurrencyCode(CurrencyCode.GBP);
orderRequest.setName("test name");
orderRequest.setOrderDescription("Order description");
orderRequest.setCustomerOrderCode("Order code");
orderRequest.setSettlementCurrency(CurrencyCode.GBP);

Address address = new Address();
address.setAddress1("address1");
address.setCity("city");
address.setCountryCode(CountryCode.GB);
address.setPostalCode("postCode");
orderRequest.setBillingAddress(address);

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

response = worldpay.createOrder({
    'token' => 'your-token',
    'amount' => 500,
    'currencyCode' => 'GBP',
    'name' => 'test name',
    'billingAddress' => {
        "address1"=>'address1',
        "postalCode"=> 'postCode',
        "city"=> 'city',
        "countryCode"=> 'GB'
     },
    'orderDescription' => 'Order description',
    'customerOrderCode' => 'Order code',
    'settlementcurrency' => 'GBP'
})
WorldpayRestClient restClient = new WorldpayRestClient("https://api.worldpay.com/v1", "your-service-key");

var orderRequest = new OrderRequest()
{
    token = "your-token",
    amount = 500,
    currencyCode = CurrencyCode.GBP,
    name = "test name",
    orderDescription = "Order description",
    customerOrderCode = "Order code",
    settlementCurrency = CurrencyCode.GBP
};

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

Creating a new order is achieved through a POST on the Order API. A new order can be created using a token, which represents the customer's card details or chosen payment method stored on our servers, added to your checkout form by the WorldPay.js library or obtained via the Token API.

Live orders are created using theLive Service Keyand test orders are created using theTest Service Key. For both Live and Test, WorldPay.js will create the token. When using theLive Client Keyfor test card orders, any card number will be accepted. When using theTest Client Key, only a specific set oftest card numberswill be accepted.

The following fields are recommended to improve risk checking:

  • name
  • billingAddress
  • deliveryAddress
  • shopperEmailAddress
  • shopperIpAddress
  • shopperSessionId

Other optional fields include:

  • customerOrderCode: code under which this order is known in your systems
  • settlementCurrency: the currency you want to be paid in (which has to be enabled in your currency settings