Redeeming a voucher code

Redeeming a voucher is very simple. Just pass the voucher code, a unique transaction_id that identifies the transaction in your system and the total transaction cost. Vouchery will validate the code as well as all the campaign limitations attached to the voucher and then return with detailed information if redemption was successful.

In this example, we will focus on successful redemption. For information on handling errors please refer to API Reference.

Single-step redemption is suitable for systems where discount verification is not integrated directly into the checkout, like not internet-enabled POS systems or even cash payments. We strongly encourage our customers to use the two-step voucher redemption process, which is covered next.

You can also see below how to pass product items within the voucher redemption.

curl --request POST \
     --url "https://preview.vouchery.io/api/v2.0/vouchers/VOU-S4H9LX/redemptions" \
     --header "Content-Type: application/json" \
     --header "Authorization: Bearer {paste here API key}" \
     --data \
'
{
  "transaction_id": "TRAN-01b7df8b-ae82-4ad2-899e-feddf538eb7e",
  "total_transaction_cost": 100.00,
  "customer_identifier": "293249",
  "confirmed": true,
  "product_items": [
		{
			"product_identifier": "123",
			"sku": "SHIRT-12T943",
			"name": "Nike T-shirt",
			"quantity": 2,
			"price": 250.30,
			"categories": [
				"T-shirts",
				"Sales"
			]
		}
  ]
}
'
{
  "type": "Redemption",
  "id": 4,
  "total_transaction_cost": 100.00,
  "granted_discount": 5.00,
  "transaction_id": "TRAN-01b7df8b-ae82-4ad2-899e-feddf538eb7e",
  "validated_at": "2018-10-14T20:32:58.339Z",
  "confirmed_at": "2018-10-14T20:32:58.339Z",
  "voucher": {
        "code": "giftcard",
        "created_at": "2019-09-06T12:38:19.720Z"
    },
    "created_by": {
        "email": "[email protected]",
        "name": null
    },
    "customer": {
        "id": 2,
        "identifier": "sdfsdf",
        "loyalty_points": 400,
        "categories": [
            {
                "tag": "A",
                "name": "Segment"
            }
        ],
        "created_at": "2019-08-20T07:31:20.159Z",
        "updated_at": "2019-09-04T10:06:49.242Z"
    },
    "campaign": {
        "id": 18,
        "name": "Springs Promo 23 Gift",
        "description": "",
        "customer_information": null,
        "team": null,
        "channel": "",
        "purpose": "",
        "budget_code": null,
        "medium": null,
        "currency": "GBP",
        "currency_symbol": "£"
    },
    "trigger": {
        "id": 173,
        "type": "redemption",
        "data": {
            "voucher": {
                "id": 55,
                "campaign_id": 18,
                "code": "giftcard",
                "created_at": "2019-09-06T12:38:19.720Z",
                "updated_at": "2019-09-06T13:04:41.996Z",
                "customer_id": null,
                "status": "created",
                "source_type": null,
                "source_id": null,
                "value_left": "0.0"
            },
            "total_transaction_cost": "100.0"
        },
        "created_at": "2019-09-10T16:01:32.499Z",
        "all_rules_matched": true,
        "rules_results": [],
        "rewards": [
            {
                "reward_object": {
                    "campaign_id": 18,
                    "data": {
                        "discount_type": "gift_card",
                        "discount_value": "250.0"
                    },
                    "id": 17,
                    "updated_at": "2019-09-06T12:40:05.939Z",
                    "title": "",
                    "description": "",
                    "reward_type": "set_discount"
                },
                "reward_result": {
                    "calculated_discount": 0.0,
                    "reward_formatted": "£0.00 off",
                    "gift_card_value_left": 0.0
                }
            }
        ],
        "customer_id": 2,
        "campaign_id": 18,
        "product_items": [
            {
                "id": 205,
                "product_identifier": "123",
                "product_options": {},
                "categories": [
                    "T-shirts",
                    "Sales"
                ],
                "sku": "SHIRT-12T943",
                "name": "Nike T-shirt",
                "quantity": "2.0",
                "price": "250.3",
                "weight": null,
                "created_at": "2019-09-10T16:01:32.515Z",
                "updated_at": "2019-09-10T16:01:32.515Z",
                "trigger_id": 173
            }
        ]
    }
}