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
1
{
2
"rule": {
3
"name": "Delivery/large order fee",
4
"enabled": true,
5
"app_id": "9a5d83fd-8570-482e-81ab-cfa88942ee60",
6
"percentage_fee": "5",
7
"condition_type": "CONDITION_TREE",
8
"condition_tree_options": {
9
"operator": "OR",
10
"right_conditions_tree": {
11
"operator": "AND",
12
"right_condition": {
13
"order_field_path": "priceSummary.subtotal",
14
"expected_field_type": "NUMBER",
15
"number": {
16
"value": "200",
17
"operation": "GT"
18
}
19
},
20
"left_condition": {
21
"order_field_path": "shippingInformation.deliveryLogistics.type",
22
"expected_field_type": "STRING",
23
"list": {
24
"values": [
25
"PICKUP"
26
]
27
}
28
}
29
},
30
"left_condition": {
31
"order_field_path": "shippingInformation.deliveryLogistics.type",
32
"expected_field_type": "STRING",
33
"list": {
34
"values": [
35
"DELIVERY"
36
]
37
}
38
}
39
}
40
}
41
}

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.

Was this helpful?
Yes
No