Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
v:2.0:webhooks [2022/05/12 08:05] – [JSON Webhook] foxybrett | v:2.0:webhooks [2023/11/28 17:27] (current) – [Setting up your Webflow collections] marija | ||
---|---|---|---|
Line 3: | Line 3: | ||
===== Overview ===== | ===== Overview ===== | ||
- | Foxy's Webhook functionality allows you to create integrations which subscribe to notifications of new transactions | + | Foxy's Webhook functionality allows you to create integrations which subscribe to notifications of events |
+ | |||
+ | We currently have three different types of Webhook endpoints you can utilise, depending on your needs: | ||
- | We currently have four different types of Webhook endpoints you can utilise, depending on your needs: | ||
* [[# | * [[# | ||
* [[# | * [[# | ||
Line 13: | Line 14: | ||
===== Sending Webhooks & Automatic Retries ===== | ===== Sending Webhooks & Automatic Retries ===== | ||
- | When a new transaction is placed and your webhooks are triggered, Foxy will wait for 1 minute for a response from your webhook endpoint. If a webhook fails to respond successfully (that is, if we don't receive a HTTP response code of '' | + | When webhooks are triggered |
===== Transaction Statuses ===== | ===== Transaction Statuses ===== | ||
- | For working with transactions with the webhook, a '' | + | For working with transactions with the webhook, a '' |
^ Status | ^ Status | ||
Line 36: | Line 37: | ||
Those statuses that are marked as "// | Those statuses that are marked as "// | ||
- | The '' | + | The '' |
Some gateways will trigger multiple web hooks to be sent for a single transaction, | Some gateways will trigger multiple web hooks to be sent for a single transaction, | ||
Line 46: | Line 47: | ||
</ | </ | ||
- | If you use any of the hosted gateways, note that every transaction may generate more than one notification. | + | If you use any of the hosted gateways |
- | Every time our IPN (Instant Payment Notification) server gets a notification from the gateway we also send you a notification. Generally, these notifications should arrive to your webhook endpoint in order, but it's possible that these webhooks are sent to your endpoint within a //very// short window (less than 0.5 seconds), and with possible network delays, your endpoint may receive the notifications out of order. Make sure you account for the '' | + | |
- | The webhook will include | + | Every time our IPN (Instant Payment Notification) server gets a notification |
- | Most hosted gateways usually send 2 notifications: | + | The '' |
+ | |||
+ | Most hosted gateways usually send 2 notifications: | ||
Here is the current list of hosted gateways which take advantage of the status field: | Here is the current list of hosted gateways which take advantage of the status field: | ||
Line 94: | Line 96: | ||
Along with the error log, an email will also be sent to the store' | Along with the error log, an email will also be sent to the store' | ||
- | ==== Did the transaction | + | ==== Did the event complete? ==== |
- | The transaction | + | The event that triggered the webhook still completed successfully. If it was a transaction webhook, the customer was charged and you'll receive payment for the transaction as your chosen payment gateway processes it. |
==== Troubleshooting Webhook Errors ==== | ==== Troubleshooting Webhook Errors ==== | ||
Line 113: | Line 115: | ||
After triggering the transaction to be sent to your webhook again, the system will re-attempt the process again for another hour [[# | After triggering the transaction to be sent to your webhook again, the system will re-attempt the process again for another hour [[# | ||
+ | |||
====== JSON Webhook ====== | ====== JSON Webhook ====== | ||
The JSON webhook is, as you may have guessed, a JSON formatted payload sent to your endpoint. | The JSON webhook is, as you may have guessed, a JSON formatted payload sent to your endpoint. | ||
- | <WRAP tip round> | + | The below documentation is for our latest version of our webhooks functionality (currently labelled as "Webhooks |
- | **Webhooks | + | |
- | Note that we currently have two different versions of webhooks | + | ===== Creating a webhook ===== |
+ | |||
+ | JSON webhooks | ||
+ | |||
+ | Each webhook requires a name, a URL and an encryption key (which will be automatically set with a value). Enter an identifying name and the URL to the endpoint that will be receiving the webhook payload. We'll explain how to create that endpoint | ||
+ | |||
+ | If you'd like to provide your own encryption key for the webhook, click the "Show secret" | ||
+ | |||
+ | ==== Subscribed resources ==== | ||
+ | |||
+ | There are several different resource types that you can subscribe to for the webhooks, one resource per webhook. The following resource types are currently supported: | ||
+ | |||
+ | === Transactions === | ||
+ | |||
+ | Triggered whenever a transaction is completed, it's payment status is updated, or it is captured/ | ||
+ | |||
+ | Events: '' | ||
+ | |||
+ | === Subscriptions === | ||
+ | |||
+ | Triggered whenever a subscription resource is created or updated. Subscriptions are created when first purchased as part of a transaction, | ||
+ | |||
+ | Events: '' | ||
+ | |||
+ | === Customers === | ||
+ | |||
+ | Triggered whenever a customer resource | ||
+ | |||
+ | Events: '' | ||
+ | |||
+ | |||
+ | <WRAP center round info 95%> | ||
+ | Note: Once you have created a webhook, it's not supported to change the subscribed resource type. If you need to change that for a given resource, you can delete the existing webhook and create another. | ||
</ | </ | ||
- | The below documentation is for the " | ||
- | * Configurable payload via API '' | ||
- | * No payload body size. (Orders with dozens of items would fail in our previous webhook system.) | ||
- | * Additional resource types to subscribe to, with more coming (such as errors). | ||
- | * Webhook payloads will always reflect the most current state of resource (whereas the older system would resend an older point-in-time payload of the resource at the earlier time). | ||
- | More documentation | + | ==== API filter query string ==== |
+ | |||
+ | The JSON webhooks uses our API as the source of data, and by default will just return the base resource as the payload (for example, the transaction webhook will just send the [[https:// | ||
+ | |||
+ | The following are examples of query strings that you might want to use: | ||
+ | |||
+ | === Transactions === | ||
+ | |||
+ | * Provide all data related to the transaction (default)\\ < | ||
+ | * Just send the transaction ID and status\\ < | ||
+ | |||
+ | === Subscriptions === | ||
+ | |||
+ | * Provide all data related to the subscription (default)\\ < | ||
+ | |||
+ | === Customers === | ||
+ | |||
+ | * Provide all data related to the customer (default)\\ < | ||
+ | |||
+ | ==== Saving The Webhook ==== | ||
+ | |||
+ | To save changes to the webhook, click the " | ||
+ | |||
+ | Upon saving, a '' | ||
+ | |||
+ | ===== Testing Webhooks: Helpful Tips ===== | ||
+ | |||
+ | It's often helpful to see exactly what the webhook request (sent to your servers) looks like. Though we don't offer this functionality natively, there are a variety | ||
+ | |||
+ | ===== Receiving a webhook ===== | ||
+ | |||
+ | Once you've configured your webhook - whenever actions happen that relate to the events you're subscribed to, a JSON payload containing information about that event will be sent to your endpoint. If your endpoint is secured with HTTPS, then the data is sent unencrypted ready for you to use. If your endpoint is not secured though, the data will be encrypted using '' | ||
+ | |||
+ | ==== Headers ==== | ||
+ | |||
+ | Any requests made to your webhook' | ||
+ | |||
+ | ^ Header ^ Description ^ | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | |||
+ | ==== Example Payload ==== | ||
+ | |||
+ | The JSON payload will follow the same structure as our Hypermedia API. Most of the objects will include the API's '' | ||
+ | |||
+ | The source of the payload data is our Hypermedia API, so you can use [[https:// | ||
+ | |||
+ | <WRAP center round info 95%> | ||
+ | Webhook payloads will always reflect the most current state of the resource at the time it was sent. If a webhook is resent, it will be the current state of the resource, rather than the state of the resource at the time that it was sent. | ||
+ | </ | ||
+ | |||
+ | |||
+ | In the example payloads below - to save space, the '' | ||
+ | |||
+ | === Transaction === | ||
+ | |||
+ | <code javascript> | ||
+ | | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }</ | ||
+ | |||
+ | Within the payload, the following attributes can be helpful for handling the payload: | ||
+ | |||
+ | ; '' | ||
+ | : What type of transaction this was, could be '' | ||
+ | |||
+ | === Subscription === | ||
+ | |||
+ | <code javascript> | ||
+ | " | ||
+ | // Note: These two links are included in order to illustrate where you can obtain subscription-related URLs. There are many other links included in the webhook, and you can explore them in our API documentation at https:// | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }</ | ||
+ | |||
+ | |||
+ | === Customer === | ||
+ | |||
+ | <code javascript> | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }</ | ||
+ | |||
+ | |||
+ | ====== JSON Webhook (Legacy) ====== | ||
+ | |||
+ | The following information is for our legacy webhook functionality. If you're creating a new webhook, you'll use the new version documented above. | ||
===== Creating a webhook ===== | ===== Creating a webhook ===== | ||
Line 968: | Line 1720: | ||
Before connecting Foxy to your Webflow site - you first need to create the necessary product collection within the Webflow CMS. For details on how to create collections - you can [[https:// | Before connecting Foxy to your Webflow site - you first need to create the necessary product collection within the Webflow CMS. For details on how to create collections - you can [[https:// | ||
- | We also have a tutorial | + | We also have tutorials |
If you're creating your own collections, | If you're creating your own collections, |