Symptoms

As the Provider, I want to configure OA Billing to send different notifications depending on the type of service a customer purchased:

  • Different notifications for domain registration and domain transfer
  • Special notifications for orders on specific Service Plans
  • Special notifications for orders containing a specific resource

Resolution

Billing uses system events to send notifications to customers. The procedure described below uses the Order Placed event as an example. If required, a similar process can be followed for Renewal Order Placed or Cancellation Order Placed event types.

By default, Order Placed notifications are sent for all new orders placed. It is determined by the default event handler "MESSAGE::OrderNotification":

System > Settings > Events > "Order Placed" > Event Handlers tab:

The default settings are shown at the screenshot below:

MESSAGE::OrderNotification default settings

This means that the "Order Placed" notification is sent for all orders by default. It uses the Order Placed notification template (defined in the Signature setting). If you need to keep sending it for new orders and want to make an exception (send a different notification) for some specific cases, follow the steps outlined below.

  1. Create a new notification template, "NEW TEMPLATE", in the Billing Provider/Reseller Control Panel:

    System > Settings > Notifications > Notification Templates

    The notification should be of the "Order Notification" type, set as active, and visible to resellers if applicable (note that reseller's plans IDs are changed when delegated).

  2. Create a new event handler with the same parameters as in the default one and assign the created Notification Template name to the "TemplateName" parameter:

    System > Settings > Events > "Order Placed" > Event Handlers

    Add a new event handler to the Order Placed event type and specify the name of the created notification template in the Signature parameter:

    Event Type   - Order Placed
    Object - MESSAGE
    Method - OrderNotification
    Signature - integer OrderID, string TemplateName=NEW TEMPLATE
    Max attempts - 1
    Synchronous - No
  3. Set a proper condition for the notification template created in step one (above):

    System > Settings > Notifications > Notification Templates > "NEW TEMPLATE"

    The condition is based on POSIX basic regular expressions where available Billing placeholders can be used. Examples of the conditions can be found in the usage scenarios below.

Important! Input a contradictory condition (containing "!") to the default Order Placed notification template. This allows you to send the custom notification if the condition is satisfied and the default notification if the condition is not satisfied. Otherwise, Billing will not be able to understand which notification should be sent if the placed order does not satisfy the defined condition.

Conditions

General information about the conditions structure can be found in the documentation.

Below are some commonly used scenarios.

Scenario #1. Send specific notifications for orders on specific Service Plans.

Condition for notifications to be sent for the orders placed on Service Plans 2, 17, and 96 (put the condition into the custom notification template you created):

"##DetailList#_@@Detail_PlanID@_##/DetailList#"~="(_2_)|(_17_)|(_96_)"

Condition for notifications to be sent for all Service Plans except 2, 17, and 96:

"##DetailList#_@@Detail_PlanID@_##/DetailList#"!~"(_2_)|(_17_)|(_96_)"

Note: "2", "17", and "96" are just examples. There can be any number of plan IDs divided by a "|" sign.

Important: Remember to put the contradictory condition into the default notification template. For example, if you create a condition to send notifications for Service Plans 2, 17, and 96 in the custom notification template, then put a condition to send a notification for all Service Plans except 2, 17, and 96 into the default notification template.

Note: If the price for the subscription period/resource is "0" for any reason (e.g., a promotion was applied or the price is set to "0") and the option Show Zero Prices is set to No in the service plan/promotion properties, then the order details will not be generated and, as a result, the condition will not work. Consider enabling the option Show Zero Prices to make the conditions work in the event of zero prices as well.

Scenario #2. Send specific notifications for orders containing a specific resource.

Condition for notifications to be sent for orders containing a specific resource "RESOURCE NAME":

"##DetailList#@@Detail_Comment@##/DetailList#"~="RESOURCE NAME"

Replace "RESOURCE NAME" with the certain resource name that is supposed to be ordered by a customer.

Note: If the price for the subscription period/resource is "0" for any reason (e.g., a promotion was applied or the price is set to "0") and the option Show Zero Prices is set to No in the service plan/promotion properties, then the order details will not be generated and, as a result, the condition will not work. Consider enabling the option Show Zero Prices to make the conditions work in the event of zero prices as well.

Scenario #3. Send different notifications for orders for a domain registration or transfer.

Distinguish domain registrations from a domain transfer operation by adding corresponding words to the descriptions of the subscription periods in the Service Plans. For example, "Domain Registration Fee" or "Domain Transfer Fee."

The condition for the domain registration orders is as follows:

"##DetailList#@@Detail_Comment@##/DetailList#"~="(Registration)"

The condition above will be true if the word "Registration" is found in the order details.

"##DetailList#@@Detail_Comment@##/DetailList#"~="(Transfer)"

The condition above will be true if the word "Transfer" is found in the order details.

Scenario #4 Do not send the notification if the order total is zero.

Notifications will not be sent if an order total balance is 0:

"@@Total@"!="0.00"

You can put multiple conditions in the notification template using the logical operators "AND" and "OR":

  • Logical AND: condition1 && condition2, e.g

    "@@Total@"!="0.00" && "##DetailList#@@DetailPlanID@##/DetailList#"!~"^(10)$"

    A notification having this condition configured will be sent for non zero orders placed for a service plan with ID other than 10 (show zero price should be enabled for recurring fee on service plan 10 for the condition to work properly).

  • Logical OR: condition1 || condition2

Scenario #5 Send notifications for orders placed only by Provider's resellers.

Notifications will be sent only for those orders placed by the Provider's resellers (L1 resellers):

@@Cust_Account_Type@=="Reseller" && @@Vend_Account_ID@~="1"

Important: Placeholder "@@Cust_Account_Type@" returns localized value in case if recipient account has other than the English locale. For example, for the Spanish locale the condition should be reworked like:

@@Cust_Account_Type@=="Revendedor" && @@Vend_Account_ID@~="1"

Additional information

You may also find the recommendations from the PBA documentation useful.

Please note that is not possible to add a Gate-based placeholder.

Internal content