I want to set up a webhook to listen to events from the Stripe API. Events have varying definitions depending on their type. For instance, the following is the beginning of an event regarding a checkout.session: { "created": 1326853478, "livemode": false, "id": "evt_00000000000000", "type": "checkout.session.completed", "object": "event", "request": null, "pending_webhooks": 1, "api_version": "2020-08-27", "data": { "object": { "id": "cs_00000000000000", "object": "checkout.session", "after_expiration": null, "allow_promotion_codes": null, "amount_subtotal": null, What’s at the first level is common to all events. But what’s in object is specific of the object.type. I couldn’t find a way to create a single endpoint that would redirect the content of object{} to specific mapping definitions as my endpoint can only use 1 message definition. Is there a way to maybe assign events to a definition that would somehow store the content of object{} for parsing by different import mapping? Or do I have to create an endpoint per object type?
asked
Patrick Prasquier
2 answers
1
If you want to handle it with a single endpoint you could create an import mapping just for the general data of the event. So you can decide based on these attributes (e.g. type) which specific entity you should create with the specific data. You can assign the body to a variable ($httpRequest/Content) and use this one with corresponding import mappings to create the specific entity. Something like:
answered
Thomas Lindenhofer
0
Hi Patrick,
was not able to add a screenshot in a comment, so I add another answer.
This way you can store the json as string into a variable:
And you can use the string as input for an import mapping later: