Skip to content

Using Discord Webhooks Plus

Working with it as an admin

After setup there is nothing to operate. You change behaviour by editing the settings page:

  • To move an action to another channel, paste a different webhook URL into its Webhook URL field.
  • To silence an action, set its Enabled field to No.
  • To change the wording, edit its Message Template. To go back to the built-in template, empty the field and save.

Changes apply from the next event on. There is no test button. To test an action, trigger it in Paymenter, for example by opening a ticket with a test account.

What the customer sees

Nothing. The extension adds no pages, notices or e-mails for customers. Customers only notice it if you post to a Discord channel they can read.

When messages are sent

The extension listens to Paymenter events while it is enabled. It sends the message at the moment the event happens, inside the same request or command. There is no queue and no cron job of its own.

Action Sent when
Invoice Created Paymenter creates an invoice, from checkout, renewal, the admin area or the API
Invoice Paid An invoice's status changes to paid
Order Created Paymenter creates an order
Service Created Paymenter creates a service
Service Updated A service is saved with changed data. This covers status changes, new expiry dates after renewals and edits in the admin area
Service Cancellation Requested A cancellation is created for a service
Ticket Created A ticket is created
Ticket Message Created A message is added to a ticket, by a customer or by staff. This includes the first message of a new ticket
User Login A user logs in through Paymenter's login form, or completes the two-factor step
User Created A user account is created

Things to know about the timing:

  • Invoice Created and Order Created fire as soon as the record is saved. In Paymenter's checkout, the order and the invoice are saved before their services and invoice items are added. {{order.total}}, {{order.services_count}} and {{invoice.total}} are read at that moment and can therefore be 0 in these two messages. Invoice Paid and the service actions have the full data.
  • {{invoice.number}} can be empty in Invoice Created. If Paymenter is set to assign invoice numbers only when an invoice is paid, the number does not exist yet when the invoice is created. Use {{invoice.id}} in that template instead.
  • A new ticket produces two events. Ticket Created and Ticket Message Created both fire when a customer opens a ticket. Enable only one of them for a channel if you do not want two messages.
  • Service Updated can be frequent. Every saved change to a service triggers it.
  • Admin logins count. User Login fires for any user, staff included.

How a message is built

For each event, the extension goes through these steps:

  1. It reads the action's settings. If the action is not enabled or no webhook URL applies, it stops.
  2. It collects the placeholder values for the action. See Configuration.
  3. It fills the action's template, or the built-in template if the field is empty, and trims surrounding whitespace. If the result is empty, it stops.
  4. It sends one HTTP POST request to the webhook URL with the message text, plus the bot username and avatar URL if they are set.

The message is sent as plain text. The extension does not send embeds, does not shorten long messages and does not retry.

Failures and logging

A failed webhook never blocks the action that caused it. The order, payment, ticket or login goes through regardless.

Situation Log entry in storage/logs/laravel.log
Discord answers with an error status Warning Discord Webhooks Plus: webhook request failed with the action key, the HTTP status and Discord's response body
The request cannot be made or times out Error Discord Webhooks Plus: webhook exception with the action key and the error message. The exception is also reported to Paymenter's error handling

Successful messages and skipped actions are not logged.

Warning

Messages are sent while the customer's request is being processed. If Discord is slow or unreachable, the page that triggered the event waits for up to the Webhook request timeout (seconds) for each message. One checkout can trigger several actions. Keep the timeout low if this matters to you; the minimum is 3 seconds.