Start Checkout

Getting Started | Initialise Deko Wallet | Show Finance Info | Start Checkout | Complete Checkout | Confirm Order | Test Data

6. Start Checkout

📘

You can view further details of the API schema in the API Reference

Submit and Verify your Basket

To eliminate the risk of you or your customers being exposed to:

  • a man-in-the-middle attack, or
  • purchasing prohibited items

You need to authorise your basket with a checkout certificate by submitting your merchant ID and basket attributes.

Please note that basket.total property must match the sum of any items and discounts. In future versions, not adhering to this rule will cause the checkout to fail.

In response, you will receive an additional JWT.

curl -X 'POST' \
  'https://dummy-api.staging.host.com/verify-basket' \
  -H 'accept: application/hal+json' \
  -H 'Authorization: Bearer xeyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Imp6SXZmaU1HNkJqVEpUWGxkRlVwZSJ9.eyJpc3MiOiJodHRwczovL2Rla29wYXktbWVyY2hhbnQtZGV2LmV1LmF1dGgwLmNvbS8iLCJzdWIiOiJ2TDBac0VOOWo1TlQ0VlAzY0ZLQnAxakY5NHNtNUM4dkBjbGllbnRzIiwiYXVkIjoiaHR0cDovL2xvY2FsaG9zdDo4MDgxL2FwaS9jaGVja291dCIsImlhdCI6MTYxNjU5MTU4NywiZXhwIjoxNjE2Njc3OTg3LCJhenAiOiJ2TDBac0VOOWo1TlQ0VlAzY0ZLQnAxakY5NHNtNUM4diIsImd0eSI6ImNsaWVudC1jcmVkZW50aWFscyJ9.F-dzPkJVF0ub2kGiWn1As5PSMnIiqAriOhyux47t7lbNk0tD9Wu655JGHmjuAqqQ3uWyqXx9-feuYjv61xufgBfxH17OkIqBB9lVJzEONoVqF5uIzsnaTD2z0FTzcvOuH8RXzA-_q7vFZwvbboE9iZCFd-JN8vI_1jjWDUpdKFWzGk0-AmID9F7qgNnyC2WEb6DK4Ky5VttXPXcGfnIGD2ybOgkg1dOlBhzabJBT9jU_UQuBoKjqQoNqVm1ovhFJzzSWMsHqDIDOb7r-0zXRB33ka4_oKoVnVrvxL2hGblgC-2Jg6gfB7uuVPdbM5FIBFx8Cbt4T83KxXbpJy5hQbg' \
  -H 'Content-Type: application/json' \
  -d '{
  "customer": {
    "billingAddress": {
      "title": "Dr",
      "firstName": "Jane",
      "lastName": "Doe",
      "middleName": "R.",
      "address1": "Deko",
      "address2": "15 Bishopsgate",
      "town": "Cornhill",
      "county": "London",
      "postcode": "EC2N 3AR",
      "country": "GB"
    },
    "shippingAddress": {
      "title": "Dr",
      "firstName": "Jane",
      "lastName": "Doe",
      "middleName": "R.",
      "address1": "Deko",
      "address2": "15 Bishopsgate",
      "town": "Cornhill",
      "county": "London",
      "postcode": "EC2N 3AR",
      "country": "GB"
    },
    "phone": "00447000123456",
    "email": "[email protected]",
    "birthDate": "2021-07-01",
    "fulfilment": "HomeDelivery"
  },
  "basket": {
    "currency": "GBP",
    "total": 134523,
    "items": [
      {
        "description": "A shiny gold watch",
        "quantity": 1,
        "price": 134523,
        "type": "sku",
        "imageUri": "https://www.merchant.website/product/image/uri.jpg",
        "itemUri": "https://www.merchant.website/product1.html"
      }
    ]
  },
  "products": [
    "instalment"
  ],
  "reference": "d290f1ee-6c54-4b01-90e6-d701748f0851",
  "callbackUri": "https://merchant-platform.fake/deko/callback"
}'

📘

Fulfilment

Notice that the customer object includes a field for fulfilment. This can be set to one of three values:

  • HomeDelivery - Delivery to home address, Shipping address should be same as customer address
  • AlternativeAddress - Delivery to an alternate address - shipping address different to customer address
  • CollectInStore - Collection at store

The function you pass to the dekoWallet.checkout method must make a request to your server which in turn should request the checkout token from the Deko Public API. The return type of your function should be a Promise that resolves to the checkout token retrieved by your server. See the init method example above.

const yourCheckoutFunction = () => { 
  return Promise.resolve(myCheckoutToken);
}

// Note using the wallet instance created in the Initialise step above.
wallet.checkout(yourCheckoutFunction);

Please note: You can also manage the display behaviour and visibility of the wallet UI as required.

wallet.hide();
wallet.show();
wallet.close();
wallet.open();