Making a purchase of an item

Making the purchase orf a gift certificate involves the following steps.

Please make sure you read the Conventions before continuing with this guide.

Prerequisites

You will need an X-API-KEY and a Basic Access Authentication token generated from your username and password.

Steps to complete a purchase

1) Select a product

Get the list of configured products, select one where "family": 'paid in'. You will need the values of the following properties _id and accountId (from now on providerId).

1) Get the paid in items information

This will return an array of items.

Select the one you want to purchase. You will need the _id to add it to the cart.

Notice that the Items have a fields property. Inside the fields property each field is represented as a property of the field object. Notice there is a required property and a display for each field, this is for the UI.

If display is true, is expected we show that field in the UI. If required is true you should make sure the user enters a value.

There are other rules in the item itself.

identicalNotesAndDescription if this is true, you will need to validate that the values entered in the notes and description fields are the same. amountEditable If this is true, you can show a field to the user to enter the price they will paid for the item.

-danger We recommend never to show to end users items where the amountEditable field is true since the API can't validate they are entering a valid amount for the item.

2) Authenticate

You are almost ready to add the trip into the shopping cart. First, you must authenticate.

Store the shortToken from the authentication response, so that you can use it in subsequent API calls.

3) Add the item to the cart

The sourceItemId is the _id of the Item definition selected in step (1).

Remember the cartId and the total from the response. You will need this information to complete the order.

4) Select a payment type

To complete the order, first retrieve the available payment types and select one. Remember the method field.

5) Select country and province info for the customer

Get our list of country and province information, and remember the result.

You will need a valid ISO code of a country and a province (if it applies) to complete the customer information when paying for the order, in the next step.

6) Create the order

Create an order (pay for the items in the cart) using the information from the previous steps.

Once the payment is accepted, the booking is complete. Take note of the transactionIds if you need to perform further actions, like downloading the certificates.

11) (Optional) Download paid in

Follow the same instructions as in download tickets for the booking. The items are downloaded as PDF files (this will only work on items with the printable property set to true).