Join our Slack community: News, tips, support, and much more.
Unleash the power of Glassfy webhooks
Glassfy can send you a notification each time a purchase or a subscription event happens in your app. Find out how!
May 31, 2022     |     2 MIN READ

Glassfy can send you a notification each time a purchase or a subscription event happens in your app. It is a very powerful feature that allows you to monitor the status of your subscription, winback users, store subscriber status in your database and more.

**In this article you will learn about:**1. Webhook events.\

  1. Webhook setup.\
  2. Signed Webhook setup.\
  3. Send test events in Webhook and Signed Webhook.\
  4. Retry to send Webhook and Signed Webhook’s failed events.

Webhook events

Webooks events are serialized to a JSON that will be sent to your webhook as a body of a POST

{
 "id": "21e8fe4ea29e4d699a5be432cf79dd9a",
 "event_date": 1644933838,
 "source": "SDK",
 "type": 5008,
 "environment": "S",
 "store": "1",
 "vendorid": "8NOV6FQBHHRJ4F9N2HV0HUXOQ5LL0QA3",
 "appid": "SZ126UWWVGTH82UE9313EQQ5N1YM3QOA",
 "subscriberid": "dfd29763e530470688a5741f419e7c07",
 "productid": "ios_read_article_5",
 "date_ms": 1644933832000,
 "original_purchase_date_ms": 1644933832000,
 "expire_date_ms",16449359832000,
 "duration", 7,
 "auto_renew_status", false,
 "original_transaction_id": "2000000033202384",
 "price": 0.99,
 "price_usd": 1.3381319169279828,
 "currency_code": "GBP",
 "country_code": "GB",
 "sub_platform": "1",
 "system_version": "15.3.1",
 "\*\*device\*\*": "iPhone14,2",
 "sdk_version": "dev",
 "bundle_version": "1",
 "app_version": "1.0",
 "is_trial_period: false,
 "trial_status":0,
 "customid":"custom user id"
 }

Please refer to https://docs.glassfy.io/docs/webhooks for the description of each field

Your server must return a 200 status code and return within 60 seconds. If the server fails Glassfy will retry 4 times (after 5, 15, 30 and 60 minutes). After 4 retries we will stop sending the event.

Webhook setup

In the Glassfy dashboard navigate to Connectors page and Choose “Webhooks” Enter the webhook URL where you want to receive the webhook and optionally set the Authorization Bearer to be set with the POST header

Signed JWS Webhook setup

In the Glassfy dashboard navigate to Connectors page and Choose “JWS Webhook”. Enter the webhook URL where you want to receive the webhook.

The Signed JWS webhook is encapsulating a standard webhook event in the following structure

{
  "event": {
    // see above for a standard event
  },
  "exp": 1644937438,
  "iss": "glassfy"
}

That is then converted to a Signed JSW Token and the POST to your webhook as a body of a POST. 
You can use Glassfy public key [https://dashboard.glassfy.io/.well-known/jwks.json](https://dashboard.glassfy.io/.well-known/jwks.json]%28https://dashboard.glassfy.io/.well-known/jwks.json%29) to verify it.

Here is a sample of a JWS token event:

eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJldmVudCI6eyJzb3J0X2RhdGVfbXMiOjE2NDQ5MzM4MzIwMDAsImlkIjoiMjFlOGZlNGVhMjllNGQ2OTlhNWJlNDMyY2Y3OWRkOWEiLCJldmVudF9kYXRlIjoxNjQ0OTMzODM4LCJzb3VyY2UiOiJTREsiLCJ0eXBlIjo1MDA4LCJlbnZpcm9ubWVudCI6IlMiLCJzdG9yZSI6IjEiLCJ2ZW5kb3JpZCI6IjhOT1Y2RlFCSEhSSjRGOU4ySFYwSFVYT1E1TEwwUUEzIiwiYXBwaWQiOiJTWjEyNlVXV1ZHVEg4MlVFOTMxM0VRUTVOMVlNM1FPQSIsInN1YnNjcmliZXJpZCI6ImRmZDI5NzYzZTUzMDQ3MDY4OGE1NzQxZjQxOWU3YzA3Iiwib3JpZ2luYWxfdHJhbnNhY3Rpb25faWQiOiIxMDAwMDAwOTY5NDMxMTQ2IiwidHJhbnNhY3Rpb25faWQiOiIxMDAwMDAwOTY5NDMxMTQ2IiwicHJvZHVjdGlkIjoiaW9zX3JlYWRfYXJ0aWNsZV81IiwiZGF0ZV9tcyI6MTY0NDkzMzgzMjAwMCwib3JpZ2luYWxfcHVyY2hhc2VfZGF0ZV9tcyI6MTY0NDkzMzgzMjAwMCwicHJpY2UiOjAuOTksInByaWNlX3VzZCI6MS4zMzgxMzE5MTY5Mjc5ODI4LCJjdXJyZW5jeV9jb2RlIjoiR0JQIiwiY291bnRyeV9jb2RlIjoiR0IiLCJxdWFudGl0eSI6MSwid2ViX29yZGVyX2xpbmVfaXRlbV9pZCI6IiIsImRheXMiOjc3MTUsIndlZWtzIjoxMTAyLCJtb250aHMiOjI1MywiYXV0b19yZW5ld19wcm9kdWN0X2lkIjoiIiwiYXV0b19yZW5ld19zdGF0dXMiOmZhbHNlLCJncmFjZV9wZXJpb2RfZXhwaXJlc19kYXRlX21zIjowLCJpc19pbl9iaWxsaW5nX3JldHJ5X3BlcmlvZCI6ZmFsc2UsInByaWNlX2NvbnNlbnRfc3RhdHVzIjoiIiwib2ZmZXJfY29kZV9yZWZfbmFtZSI6IiIsIm9mZmVyaW5naWQiOiJjb25zdW1hYmxlX2FydGljbGVzIiwiZXhwaXJhdGlvbl9pbnRlbnQiOiIiLCJ1c2VydW5rbm93biI6ZmFsc2UsInN1Yl9wbGF0Zm9ybSI6IjEiLCJzeXN0ZW1fdmVyc2lvbiI6IjE1LjMuMSIsImRldmljZSI6ImlQaG9uZTE0LDIiLCJzZGtfdmVyc2lvbiI6ImRldiIsImJ1bmRsZV92ZXJzaW9uIjoiMSIsImFwcF92ZXJzaW9uIjoiMS4wIn0sImV4cCI6MTY0NDkzNzQzOCwiaXNzIjoiZ2xhc3NmeSJ9.mOIfTrxy2LBQTq_TwpTzFnkQQ06KahgMUKsZO7GKJq\_-e1a0nqEDraH_mRmosrxNSQqEnelHne0Jg7_EmkqTOg

Send test events in Webhook and Signed Webhook.

Glassfy allows you to check the connection with your server by clicking “Send Test Event” from the connector dropdown

Retry sending Webhook and Signed Webhook’s failed events.

If the event fails to deliver a yellow alert triangle will appear on your connectors page. By selecting “View Deliveries” you can get more details.

Then the user will be able to retry sending the failed events by clicking on the “Try Again” option in the dropdown on the right.