Link Search Menu Expand Document

Voucher issued webhook

Triggered as a result of a voucher being issued for user.

An example of a new voucher webhook

{
    "id": "voucher678599",
    "type": "shopper.voucher-issued",
    "chain_id": 1781,
    "created": "2022-05-06T11:50:28Z",
    "data": {
        "voucher_id": 678599,
        "voucher_key": "aba92bee8c89e5467e013697cf0cd9ed6fd82c6b14bb37a6a794838f54ee77cc",
        "voucher_created_datetime": "2022-02-18T14:09:17+00:00",
        "voucher_type": "basket_pct",
        "voucher_status": "claimed",
        "voucher_locked": false,
        "campaign_id": 1751,
        "campaign_type": "loyalty",
        "campaign_title": "ACME Loyalty Campaign",
        "campaign_image_filename": null,
        "campaign_image_url": null,
        "campaign_image_link": null,
        "campaign_image_dimension_x": null,
        "campaign_image_dimension_y": null,
        "voucher_expiry_datetime_utc": "2022-03-20T00:00:00+00:00",
        "voucher_expiry_seconds_remaining": 0,
        "creating_user": {
            "user_id": 21,
            "full_name": "Dave Sevenoaks"
        },
        "voucher_redeemed_datetime": null,
        "generating_return_transaction": [],
        "parent_voucher": null,
        "voucher_title": null,
        "voucher_text": "Happy Birthday",
        "voucher_description": "Enjoy your special day at ACME",
        "voucher_notes": null,
        "voucher_honour_code": null,
        "voucher_image_url": null,
        "voucher_discount_ratio": 0.15,
        "voucher_currency_code": "EUR",
        "voucher_currency_id": 2,
        "voucher_currency_symbol": "€",
        "voucher_amount_original": 4.75,
        "voucher_amount_redeemed": 4.75,
        "voucher_amount": 4.75,
        "redeeming_basket": null,
        "type": "basket_pct",
        "user": {
            "id": 3814225,
            "user_id": 3814225,
            "first_name": "John",
            "last_name": "Smith",
            "address_streetname": "Dawson Street",
            "address_housenumber": "22",
            "address_towncity": "Dublin",
            "address_postalcode": "D02 Y336",
            "country_code": "IE",
            "gender": "F",
            "birthday": "1990-01-06T00:00:00+00:00",
            "signup_channel": "spaaza-mobile-web",
            "username": "john.smith@spaaza.com",
            "authentication_point_identifier": null,
            "auxiliary_identifier": null,
            "authentication_point": null,
            "mailing_list": {
                "mailing_list_sub_offered": false,
                "mailing_list_subscribed": true,
                "printed_mailing_list_subscribed": false
            },
            "opt_in_programme": {
                "programme_opted_in": true,
                "join_date": "2022-02-17T14:21:28+00:00"
            },
            "obfuscated": false,
            "is_influencer": false,
            "address_housenumber_extension": null,
            "address_line_2": null,
            "address_line_3": null,
            "address_regionstate": null,
            "address_latitude": 53.339721,
            "address_longitude": -6.258549,
            "member_number": {
                "type": "custom",
                "code": "2000002"
            },
            "language": null,
            "opt_in_secondary": false,
            "registered": true,
            "is_employee": false,
            "push_notification_subscription": {
                "subscribed": false,
                "subscriptions": []
            },
            "loyalty_status": null,
            "frequency": 5,
            "recency": 5,
            "monetary": 3,
            "overall": 553,
            "stores": "College Green",
            "online_shopper": true,
            "offline_shopper": true,
            "average_basket_value": "69.96",
            "days_since_last_purchase": 1,
            "number_of_purchases": 105,
            "referral_channel": "store",
            "referral_code": "ptola9",
            "referring_user": {
                "authentication_point_identifier": "2152416",
                "campaign_id": 2067,
                "id": 3593704,
                "referral_channel": "webshop",
                "referral_code": "b09zy7"
            }
        }
    }
}

Spaaza can call an external webhook when a customer voucher is created for a customer.

We can configure a webhook URL that you provide. Whenever the voucher-issued event occurs we send a simple POST request to the URL. The body of the POST is JSON that includes details of the event and the voucher that triggered it. So that you can verify that the POST really originates from Spaaza we provide a signature in a request header (X-Spaaza-Hmac-SHA256).

The value of the header is a base 64 encoded HMAC-SHA256 of the whole body of the request with a shared secret that we would provide. Your code to handle the event should recreate the signature using the shared secret and compare it to the value in the header.