Skip to main content

Setting up a webhook in Plug&Pay

Create a webhook in Plug&Pay

Written by Bryan Schoenmaker

In Plug&Pay, you have the option to set up a webhook. Setting up a webhook ensures that a particular action is carried out in another system or tool after an order has been placed, after a subscription has expired or after an affiliate has been accepted.

In this article, you'll learn how to create and set up a webhook in Plug&Pay.


What are webhooks?

Webhooks can be seen as automatic messages that Plug&Pay sends to another system as soon as something happens. The other system can then do something, such as sign up a customer, send an email or create an invoice.

Webhooks make sure that Plug&Pay passes on events immediately to other systems, so everything keeps running automatically without you having to do anything yourself.

Example: Setting up a webhook means that after an order has been placed, your customer automatically receives login details for an environment.


Which triggers can I use?

webhook plug&pay

With Plug&Pay, you can set up the following starting moments for a webhook:

  • Affiliate accepted

  • Affiliate denied

  • Affiliate quit

  • Invoice created

  • Order paid

  • Subscription ended


Which data is sent via webhooks?

❗️ This information only applies to Webhooks V2.

Webhooks in Plug&Pay only send an event payload. This includes, among other things:

  • trigger_type

    e.g. order_created

  • triggerable_id

    e.g. order_ID

  • triggerable_type

    e.g. orders

  • sent_at

  • tenant_id

  • rule_id

You have to retrieve the actual data yourself with the API. You do this through a URL. The structure of this URL differs depending on the data you retrieve. Here are a few examples πŸ‘‡

If triggerable_type is order

πŸ”— Documentation

If triggerable_type is subscription

πŸ”— Documentation

The advantage of this is that you always have the most up-to-date data to hand. Because you only retrieve the data when you process the webhook, you can check whether the information is still correct (with sent_at, for example) or retrieve data later if your webhook arrives with a delay.

This also gives you more flexibility in retrieving different types of data.


Adding a webhook

Within Plug&Pay, you have the option to set up a webhook for a specific product/checkout, or a universal webhook for all products and all checkouts.

Setting up a universal webhook

A universal webhook is called every time the chosen trigger occurs. For example, on every order or every accepted affiliate.

set up webhook plug&Pay

Go to Settings > Rules to get started. Click Add rule, give your rule a name, choose a trigger and select the Webhook V2 option under 'Action'.

create webhook plug&Pay

Enter the webhook URL of the system you'd like to connect with. Click 'Create rule' to save your new webhook.


Setting up a webhook per product

If you want to set up a webhook that isn't called for every order, but only for a specific product, follow the steps below.

Navigate to Products and open the product you want. Go to the Rules tab and add a new integration.

webhook product plug&pay

Give your rule a name, choose the trigger, select Webhook V2 and enter the webhook URL. Save your rule by clicking 'Create rule'.

create webhook plug&Pay

Setting up a webhook per checkout

If you want to set up a webhook that isn't called for every order, but only for a specific checkout, follow the steps below.

Navigate to Pages > Checkouts and open the page you want. Go to the Integrations tab and add a new integration.

webhook checkout plug&pay

Give your rule a name, choose the trigger, select Webhook V2 and enter the webhook URL. Save your rule by clicking 'Create rule'.

create webhook plug&Pay

Webhook key πŸ”‘

You can also verify your webhooks with a webhook key. This verification is optional, and you use it to verify that the data being sent comes from your Plug&Pay environment.

You'll find the webhook key under Settings > Developers.​


Good to know

  • We use JSON format in all Webhooks V2 payloads.​

  • If you've created a universal integration with the trigger Invoice created, a webhook is also called after a successful transaction via the one-click upsell.​

  • Do you want to call a webhook for a specific upsell? You can do this via the upsell's settings under the Advanced tab by filling in the webhook field with the desired webhook URL.​
    ​

  • Connecting with Huddle? Then read this article πŸ“–β€‹

  • Connecting with ActiveCampaign? Then read this article πŸ“–

Did this answer your question?