These docs are for v1.0. Click to read the latest docs for v2.1.

Two-step redemption

Two-step redemption process is the suggested way to build Vouchery integration into your system. In this process Vouchery first verifies and confirms voucher code and transaction validity. This should be done before the customer starts the payment process. For example, in e-commerce context, voucher validation should be performed when customer enters the checkout process. Once the payment is complete, redemption should be confirmed so it is counted against campaign limitations, etc.

In case transaction information changes a redemption should be first deleted and then another one, with updated information, created. This may be a case when voucher code is added to a cart, validated, and then more items are added to the cart before checkout. An existing redemption can't be updated because this may cause it to become invalid (e.g. if minimum transaction value is not met anymore).

Step 1: Validate a voucher

curl --request POST \
     --user "username:password" \
     --url "https://preview.vouchery.io/api/v1.0/vouchers/VOU-S4H9LX/redemptions" \
     --header "Content-Type: application/json" \
     --data \
'
{
  "transaction_id": "TRAN-35f36ebb-f677-4ba0-8ea7-8ae589f51ddc",
  "total_transaction_cost": 150.00
}
'

{
  "type": "Redemption",
  "id": 4,
  "total_transaction_cost": 100.00,
  "granted_discount": 7.50,
  "transaction_id": "TRAN-01b7df8b-ae82-4ad2-899e-feddf538eb7e",
  "validated_at": "2018-10-14T20:32:58.339Z",
  "confirmed_at": null,
  "voucher": {
    "type": "Voucher",
    "id": 199,
    "campaign_id": 9,
    "code": "VOU-S4H9LX",
    "campaign": {
      "type": "Campaign",
      "id": 9,
      "name": "Fall Haul"
    }
  }
}

Step 2: Confirm a redemption

curl --request PATCH \
     --user "[email protected]:123456" \
     --header "Content-Type: application/json" \
     --url "https://preview.vouchery.io/api/v1.0/vouchers/VOU-S4H9LX/redemptions"
     --data \
'
{
	"transaction_id": "TRAN-01b7df8b-ae82-4ad2-899e-feddf538eb7e"
}
'

{
  "type": "Redemption",
  "id": 4,
  "total_transaction_cost": 100.00,
  "granted_discount": 7.50,
  "transaction_id": "TRAN-01b7df8b-ae82-4ad2-899e-feddf538eb7e",
  "validated_at": "2018-10-14T20:32:58.339Z",
  "confirmed_at": "2018-10-14T20:35:23.430Z",
}