How to use Webhooks

Intro

With Webhooks, you can integrate our checkout system to trigger special actions in your other systems, which helps you automate your business even further. In order to use Webhooks, you need to have a basic technical understanding of how software and servers work. If you don't, you are going to need external help, and there are millions of professionals that can help you setup a custom systems integration.

Technical Details

How It Works

When a certain event happens (e.g. new sale), our system sends an HTTP POST to your server endpoint, with detailed information about the respective event, in JSON format.

You can add a new endpoint by clicking the "Add Webhook URL" button in the top right section on the Webhooks page. When you add or update a Webhook URL, its "version" will be set to today's date. This version is used for backwards compatibility, for when we decide to change the structure of the JSON payload.

If your webhook script performs complex logic, or makes network calls, it’s possible that the script would time out before our system sees its complete execution. Ideally, your webhook handler code (acknowledging receipt of an event by returning a 2xx status code) is separate of any other logic you do for that event.

Retry System

Upon sending an HTTP POST to your URL, the Webhooks engine expects to receive HTTP status 200 in order to consider the delivery a success. If your server returns an HTTP error code, our system attempts to deliver your webhooks for up to three days with an exponential back off. In each Webhook URL details sheet, you can view when the next retry will occur.

If you have a Webhooks error and need to learn more information on what data was sent, you can simply click that event in the Webhook URL details sheet and it will reveal the payload that was sent.

Handling webhook events correctly is crucial to making sure your integration’s business logic works as expected.

Payload Examples

Sale payloads:

{
  "id": "evt_0qtzxgt9-7i9gkx",
  "type": "new_simple_sale",
  "api_version": "2020-01-25",
  "account": "acct_-w8mf0k9k4z",
  "data": {
    "order": {
      "id": "PNP0",
"uid": "order_FH2k32s82sG", "amount_subtotal": 323.0, "amount_shipping": 20.0, "amount_discount": 0, "amount_shipping_discount": 0, "amount_tax": 0, "amount_total": 343.0, "currency": "RON", "payment_method": "cash", "date": "2020-01-25 17:32:19 UTC", "referrer": "https://plugnpaid.com/cart/p38ivtr", "status": "pending", "active_instalment": false, "locale": "ro", "products": [ { "id": "prod_g0oYiDWVOGSNGqUax9", "title": "Mistery Box", "amount_cost": 323.0, "amount_tax": 0, "currency": "RON", "quantity": 1 } ], "billing_details": { "name": "Tom Musterman", "email": "tom.musterman@example.com", "phone": "", "state": "", "address": "Musterstreet 1", "city": "Musterville", "postcode": "343244", "country": "Romania", "vat": null, "iso": "RO" }, "shipping_details": { "name": "Tom Musterman", "email": "tom.musterman@example.com", "phone": "", "state": "", "address": "Musterstreet 1", "city": "Musterville", "postcode": "343244", "country": "Romania", "vat": null, "iso": "RO" },
"custom_fields": [
{"Flavor1": "vanilla"},
{"Flavor2": "chocolate"}
], "customer": { "addresses": { "billing": [ { "name": "Tom Musterman", "email": "tom.musterman@example.com", "phone": "", "state": "", "address": "Musterstreet 1", "city": "Musterville", "postcode": "343244", "country": "Romania", "vat": null, "iso": "RO" } ], "shipping": [ { "name": "Tom Musterman", "email": "tom.musterman@example.com", "phone": "+3902392832", "state": "", "address": "Musterstreet 1", "city": "Musterville", "postcode": "343244", "country": "Romania", "vat": null, "iso": "RO" } ] }, "telephone": "+3927764927", "name": "Tom Musterman Sr.", "country": "Romania", "locale": "ro", "vat_number": "", "created_at": "2020-01-25T17:32:19+00:00", "email": "tom.musterman@example.com", "id": "cus_dex4sem-" }, "channel": "Hosted Checkout", "consents": "", "shipping_method_name": "Fan Courier",
"refund": {
"amount": 323.0,
"reason": "requested_by_customer"
} } } }

Subscription payloads:

{
  "id": "evt_60c8-4sq15i2g2z",
  "type": "recurring_subscription_sale",
  "api_version": "2020-01-25",
  "account": "acct_-w8mf0k9k4z",
  "data": {
    "order": {
      "id": "PNP3",
      "amount_subtotal": 100.0,
      "amount_shipping": 0,
      "amount_discount": 0,
      "amount_shipping_discount": 0,
      "amount_tax": 0,
      "amount_total": 100.0,
      "currency": "RON",
      "payment_method": "stripe",
      "date": "2020-01-25 17:17:00 UTC",
      "referrer": "https://plugnpaid.com/cart/v1rtvtq",
      "status": "paid",
      "active_instalment": false,
      "locale": "ro",
      "products": [
        {
          "id": "plan_Gc69BoMpSQzlIP",
          "title": "WSJ Subscription",
          "amount_cost": 100.0,
          "amount_tax": 0,
          "currency": "RON",
          "quantity": 1,
          "start_date": 1579972614,
          "end_date": 1582651014,
          "licenses": [
            "mvr6d6qxvzdw9r2"
          ]
        }
      ],
      "billing_details": {
        "phone": "",
        "name": "Tom Musterman",
        "email": "tom.musterman@example.com",
        "address": "Musterstreet 1",
        "city": "Musterville",
        "postcode": "34343",
        "state": "",
        "vat": "",
        "country": "Romania",
        "iso": "RO"
      },
      "shipping_details": {
        "name": "",
        "email": "tom.musterman@example.com",
        "phone": "",
        "state": "",
        "address": "",
        "city": "",
        "postcode": "",
        "country": "Romania",
        "vat": null
      },
      "customer": {
        "addresses": {
          "billing": [
            {
              "phone": "",
              "name": "Tom Musterman",
              "email": "tom.musterman@example.com",
              "address": "Musterstreet 1",
              "city": "Musterville",
              "postcode": "34343",
              "state": "",
              "vat": "",
              "country": "Romania",
              "iso": "RO"
            }
          ],
          "shipping": [
            {
              "name": "",
              "email": "tom.musterman@example.com",
              "phone": "",
              "state": "",
              "address": "",
              "city": "",
              "postcode": "",
              "country": "Romania",
              "vat": null
            }
          ]
        },
        "telephone": "",
        "name": "Tom Musterman Sr.",
        "country": "Romania",
        "locale": "ro",
        "vat_number": "",
        "created_at": "2020-01-25T17:17:00+00:00",
        "email": "tom.musterman@example.com",
        "id": "cus_dex4sem-"
      },
      "channel": "Hosted Checkout",
      "consents": "",
      "is_new_subscription": true
    },
    "subscription": {
      "type": "stripe",
      "gateway_customer_id": "cus_Gc69oyoBOIka6q",
      "gateway_subscription_id": "sub_Gc6S3idfHsELkC",
      "products": [
        {
          "id": "prod_d7r6",
          "name": "WSJ Subscription",
          "price": 100.0,
          "currency": "RON",
          "images": [

          ],
          "stock": 1,
          "unlimited_stock": true,
          "short_description": "description",
          "long_description": null,
          "date_created": "2020-01-25 16:57:43 UTC",
          "date_updated": "2020-01-25 16:57:43 UTC",
          "license_type": "autogenerated",
          "license_list": null,
          "variations": [

          ],
          "billing_cycle": "month",
          "gateway_plan_id": "plan_Gc69BoMpSQzlIP",
          "cycle_interval": 1,
          "trial": 0
        }
      ],
      "status": "active",
      "payments_count": 1,
      "customer": {
        "addresses": {
          "billing": [
            {
              "phone": "",
              "name": "Tom Musterman",
              "email": "tom.musterman@example.com",
              "address": "Musterstreet 1",
              "city": "Musterville",
              "postcode": "34343",
              "state": "",
              "vat": "",
              "country": "Romania",
              "iso": "RO"
            }
          ],
          "shipping": [
            {
              "name": "",
              "email": "tom.musterman@example.com",
              "phone": "",
              "state": "",
              "address": "",
              "city": "",
              "postcode": "",
              "country": "Romania",
              "vat": null
            }
          ]
        },
        "telephone": "",
        "name": "Tom Musterman Sr.",
        "country": "Romania",
        "locale": "ro",
        "vat_number": "",
        "created_at": "2020-01-25T17:17:00+00:00",
        "email": "tom.musterman@example.com",
        "id": "cus_dex4sem-"
      }
    }
  }
}

Customer payloads:

{
  "id": "evt_70uzva73pfk11",
  "type": "new_customer",
  "api_version": "2020-01-25",
  "account": "acct_-w8mf0k9k4z",
  "data": {
    "addresses": {
      "billing": [
        {
          "name": "Tom Musterman",
          "email": "tom.musterman@example.com",
          "phone": "",
          "state": "",
          "address": "Musterstreet 1",
          "city": "Musterville",
          "postcode": "1231231",
          "country": "Romania",
          "vat": null,
          "iso": "RO"
        }
      ],
      "shipping": [
        {
          "name": "Tom Musterman",
          "email": "tom.musterman@example.com",
          "phone": "",
          "state": "",
          "address": "Musterstreet 1",
          "city": "Musterville",
          "postcode": "1231231",
          "country": "Romania",
          "vat": null,
          "iso": "RO"
        }
      ]
    },
    "name": "Tom Musterman",
    "country": "Romania",
    "telephone": "",
    "locale": "ro",
    "vat_number": "",
    "created_at": "2020-01-28T10:34:06+00:00",
    "email": "tom.musterman@example.com",
    "id": "cus_5-ppbp16"
  }
}

Abandoned Cart payload:

{
  "id": "evt_8-tx19qc7mv",
  "type": "cart_abandoned",
  "api_version": "2020-01-25",
  "account": "acct_-w8mf0k9k4z",
  "data": {
    "amount_total": "343.0",
    "currency": "RON",
    "date": "2020-01-29 13:31:34 UTC",
    "referrer": "https://plugnpaid.com/cart/p38ivtr",
    "locale": "en",
    "products": [
      {
        "id": "prod_oPj1uzrVq9SazjFmx9",
        "title": "Mistery Box",
        "amount_cost": 323.0,
        "amount_tax": 0,
        "currency": "RON",
        "quantity": "1"
      }
    ],
    "customer": {
      "name": "Tom Musterman",
      "email": "tom.musterman@example.com",
      "phone": "",
      "timezone": "Asia/Nicosia",
      "currency": "EUR"
    },
    "channel": "Hosted Checkout",
    "consents": null,
    "shipping_method_name": "Fan Courier"
  }
}

Product payloads:

{
  "id": "evt_r1h5zls-nv",
  "type": "updated_product",
  "api_version": "2020-01-29",
  "account": "acct_-w8mf0k9k4z",
  "data": {
    "id": "prod_9zxrh7r2rzm",
    "name": "Intensive Training",
    "price": 1244.0,
    "currency": "RON",
    "images": [

    ],
    "stock": 1,
    "unlimited_stock": true,
    "short_description": "test",
    "long_description": "",
    "date_created": "2020-01-29 10:57:54 UTC",
    "date_updated": "2020-01-29 10:57:54 UTC",
    "license_type": null,
    "license_list": null,
    "variations": [

    ]
  }
}