Dynamic webhooks

Add and use new webhooks to DEUNA for any other functionality needed during the checkout.

The implementation of dynamic webhooks supports new webhooks and avoids generating programming workload for each new webhook added.

📘

Configure and execute each webhook.

Dynamic webhook implementation

Arquitectura de la nueva implementacion de Webhooks Dinamicos

Example implementation for adding tips

Webhook configuration

Configure a new webhook following these steps:

  1. Create a new webhook for a process
  2. Consume an endpoint that receives the information from the new webhook.

Example

POST api/v1/merchants/{merchant_id}/webhooks
Header: {merchant_token}
Body:
{
	"event_name": string,
	"url": string,
	"fields_update" :  {
		"fields": string[],
		"custom_fields": string[]
	},
	"response_body" : {
		"fields": string[],
		"custom_fields": string[]
	},
	"response_template": string 
	"response_data" : string
}

Payload details

Note the details of the payload:

  • event_name: Name of the webhook.
  • url: URL to which the request will be executed.
  • fields_update: Container for the order fields to be updated.
    • fields: List of order fields that are modified when the webhook is executed.
    • custom_fields: List of custom fields in the order that are modified when the webhook is executed. These are the fields required for your business.
  • response_body: Container for the order fields that are returned to the front end when the webhook is executed.
    • fields: List of order fields that are modified when the webhook is executed.
    • custom_fields: List of custom fields of the order that are modified when the webhook is executed.
  • response_template: Response template to transform the merchant order into a DEUNA order during webhook execution.

Order structure

Note that each merchant has a different order structure:

  • The `response_template field implements Go Templates to transform an order from your store into a DEUNA order.
  • Order transformation is performed after obtaining the response from the request.
  • Use the field error_response_template to transform the merchant's error during webhook execution.
  • Use the field response_data to understand what DEUNA expects when executing a request to your store.
    • This field always has to be included with the field response_template.
    • This field validates that response_template is functional.

Define the structure

To define the structure of the template you need to:

  • Know the merchant's webhook response structure.
  • Have the order structure in JSON.
  • Be clear about which order fields are going to be modified.

📘

To edit fields, refer to Go Templates.

Template example

{
  "order": {
    "order_id": "{{ .result.uuid }}",
    "custom_fields": { "business_id": "{{ .result.business_id }}" }
  }
}

📘

For more examples, refer to our GitHub.

Webhook execution

Use the webhook to notify your system of an event from the EMA API.

📘

EMA API has an endpoint that triggers the execution of a specific webhook.

Execution to set tip webhook from EMA API

Ejecucion para establecer propina

📘

The response is signed by DEUNA in accordance with security standards. You can validate the signature

Practical examples

Learn about practical examples in the DEUNA ecosystem.

Add tips

You can add a tip field without affecting other merchants.

This feature customizes the way the price is displayed.

Currently, you can create the tip module/pattern, but each merchant must:

  • Tokenize the order with the tip change.
  • Add the tip to the total of the order.

Add tax to a cash order

Add a field for a 3% tax on the total order when the payment method is cash.

Execute payments with points and coupons

Implement dynamic webhooks to execute payment tasks with points, donations, and coupons.