Sample Flows

This article shares an example flow that could support a use case for the Service Fees API.

Create a service fee which applies to large pickup orders and deliveries

A site owner wishes to add a 5% service fee for pickup orders above $200 and all deliveries.

Step 1 | Create your rule

Use Create Rule to establish your rule:

  • Set name as "Delivery/large order fee". This name will be visible to customers.
  • We want this fee to take effect immediately, so set enabled to true.
  • Use your app's ID in appId. For example, Restaurants Online Ordering's app ID is 9a5d83fd-8570-482e-81ab-cfa88942ee60.
  • Set percentageFee to 5. This calculates 5% of the order's subtotal and applies it when the conditions are met.
  • Because there are multiple conditions, set conditionType to "CONDITION_TREE".
  • Set conditionTree to represent the following conditions: Delivery type is "DELIVERY"
    OR
    • The price subtotal is greater than 200
      AND
    • Delivery type is "PICKUP"

Using the values from the list above, create the body for your Create Rule request. The resulting JSON will look something like this:

Copy

Step 2 | Calculate fees for an order

Use Calculate Service Fees to calculate all relevant service fees for a specific order.

When you call Calculate Service Fees:

  • All service fees rules will be evaluated relative to the order passed in API call.
  • For each rule where the conditions are met, it will calculate the fee and tax (if applicable).
  • The response includes all the applicable rules for the order, as well as each rule's corresponding fees and tax.

You can use the response to apply any relevant fees to the customer's price total.

Did this help?