Make your first order

Paying for your order

All orders made by API will be charged to your saved card. You have the option to specify which card we should use at time of order. We generate a receipt for every transaction you make with us.

To make an order, you need at a minimum:

  • idempotency_key - A unique value which the server uses to prevent duplicate purchases.
  • items - An array of items to include in the order you are about to make. Each item contains the following fields:
    • country - The ISO code for the country, for example US or GB, in which the recipient will redeem this item. All items in an order must have the same country code. See the Supported countries page for a listing of countries we currently support.
    • face_value - The face value of the item you wish to order. This will be in the currency of the country provided in the country field of the item.
  • card_id - The card ID of the saved card you want to use to pay for the order. You may retrieve existing card IDs or add a new one on at https://app.wegift.io/payment-methods
  • Optional: products - An array of products the recipients can choose from when they redeem the order items. When this is not included, all products you're eligible for will be available to the recipient. For the basic example outlined in this guide, we will not specify a list of products.

๐Ÿ“˜

Note on idempotencyKey:

If the server receives a request with the same idempotency_key as an existing order, no new order will be created and the details of the original will be returned instead. This is important to prevent duplicate orders being created if the HTTP request has to be retried.

Here's an example of a basic request body:

{
  "items": [{"country": "GB", "face_value": 10}],
  "idempotency_key": "985b8147-4120-4a05-ae9e-5b7477a6928d",
  "card_id": "wg123abc"
}

For more details, or to quickly try out the endpoint, navigate to the API reference for the Create Order endpoint. Simply paste in the API key you generated in the Getting started guide into the Header, fill in the idempotency_key and items fields, and click the "Try it!" button, as pictured below:

1552

Here's an example of a successful response:

{
  "description": null,
  "customer_id": "C-ABC123",
  "id": "O-ABC123",
  "user_id": null,
  "created_at": "2022-09-13T11:54:27.383022+00:00",
  "is_complete": false,
  "card_payment_id": "CP-ABC123",
  "currency": "GBP",
  "countries": [
    "GB"
  ],
  "initial_values": {
    "link_count": 1,
    "total_price": 1,
    "total_value": 1
  },
  "final_values": null,
  "product_count": 1,
  "customer_name": "Company Name",
  "customisation": null,
  "items": [
    {
      "id": "E-ABC123",
      "order_id": "O-ABC123",
      "country": "GB",
      "currency": "GBP",
      "face_value": 1,
      "price": 1,
      "delivery_email": "[email protected]",
      "current_token": null,
      "tokens": []
    }
  ],
  "card_payment_details": null
}

Retrieving your reward links

Now that you've made an order, you can retrieve the reward links for the items in your order using the Get Order Links endpoint. These are URLs to a reward page where the gift card details and instructions to use will be displayed.

You will need the order ID from the response you got after calling the Create Order endpoint. In our example response above, that would be O-ABC123. Use this as a query parameter in https://api.wegift.io/v2/order/{id}/links to retrieve links for items in the order.

Try out the endpoint: open the Get Order Links page and add your order ID into the id path parameter.

2344

The response from a successful request will include token_url. This is the link you can use to redeem the item. Here's an example of a successful response:

[
  {
    "id": "E-123ABCD",
    "order_item_token_id": "OIT-ABC1234",
    "order_id": "O-123ABCD",
    "currency": "GBP",
    "face_value": 10,
    "price": 10,
    "token_created_at": "2022-09-13T12:57:21.352Z",
    "first_clicked_at": "2022-09-13T12:57:21.352Z",
    "last_clicked_at": "2022-09-13T12:57:21.352Z",
    "token_url": "https://the-link-to-redeem-this-order-item",
    "select_link_id": "the-link-id",
    "select_link": {
      "id": "SL-ABCD123",
      "currency": "GBP",
      "initial_balance": 10,
      "unspent_balance": 10
    },
    "delivery_email": "string",
    "deliveries": [
      {
        "id": 0,
        "order_item_id": "string",
        "email_address": "string",
        "queued_at": "2022-09-13T12:57:21.352Z"
      }
    ]
  }
]

Whatโ€™s Next

Now that you've made a basic order let's customise the redemption experience by curating a list of products the recipient can redeem against.