Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

...

...

Table of Contents

Front-end

Say we have the following order:

...

Similar to what we have in the current app (airtouch):

...

  • gastos de envio → delivery fee

  • otros gastos → management fee

...

Mapping of how delivery fee is set:

  • PriceOrder

  • Calls partner service API PriceOrder to get price related info including fees.

  • Persists taxes into the database

FE tech discovery can be found here

Figma: https://www.figma.com/file/RtD0UFtwuwXx14lbLCAPlr/branch/4JKHiBl13JOyOqh88dSPkV/Burger-King?type=design&node-id=20699-1728&mode=design&t=AEfdHRE0DnQ6879D-0

Mapping of how delivery fee is set (BE):

  • PriceOrder

    • Calls partner to get price related info including fees.

    • Persists fees into the database

  • GetOrder

    • Retrieves order related info from the database, including fees

Backend discovery

  • priceOrder

    • intl-whitelabel-app → priceOrder

    • intl-whitelabel-graphql → priceOrder

    • intl-fullfilment-service → priceOrder

      • updateDeliveryEntry

        • intl-delivery-service

        • getFeeAndDiscountByBrand ( using intl-packages delivery lib or intl-delivery-service?)

  • Delivery fees are managed by the fee service ( intl-delivery-service):

    • getFeeAndDiscountByBrand

      • getFeeChargeByTier

        • It get the values from launchdarkly based on the service mode.

          • If catering , it uses tiered-catering-delivery-fees

          • Otherwise, it uses tiered-delivery-fees

        • Searches the tier list from highest to lowest key, stopping when requestedAmountCents exceeds that tier.

        • Said that, we can to analyze the following "return” to propose the management fee. Apart from that, looks like Launchdarkly existing configuration (variations) were thought to enable "free delivery” and we can leverage this approach.

          Code Block
              return {
                baseDeliveryFee: fee, --> LD fee
                deliverySurchargeFee, -->  LD expandedFees (based on delivery quotation value)
                discount, --> LD discount
                fee: fee + geographicalFee + serviceFee + smallCartFee + deliverySurchargeFee,
                geographicalFee, --> LD geographicalFee
                serviceFee, --> Calculated with LD serviceFeePercent of the requested amount
                smallCartFee, --> LD smallCartFee
              };

          We may introduce a new fee named "management fee” to fulfill the current use-case or explore existing fees.

Expandexpand
titlelaunchdark config example (dev)

{
"0": {
"app": {
"discount": 0,
"expandedFees": {
"460": 0,
"560": 0,
"825": 265,
"999": 265,
"default": 0
},
"fee": 399,
"serviceFeePercent": 0,
"smallCartFee": 250
},
"googleFoodOrdering": {
"discount": 0,
"fee": 0,
"serviceFeePercent": 0,
"smallCartFee": 0
},
"kiosk": {
"discount": 0,
"fee": 0,
"serviceFeePercent": 0,
"smallCartFee": 0
},
"web": {
"discount": 0,
"expandedFees": {
"460": 0,
"560": 0,
"825": 265,
"999": 265,
"default": 0
},
"fee": 399,
"serviceFeePercent": 0,
"smallCartFee": 250
}
},
"1000": {
"app": {
"discount": 0,
"expandedFees": {
"460": 0,
"560": 0,
"825": 265,
"999": 265,
"default": 0
},
"fee": 399,
"serviceFeePercent": 0,
"smallCartFee": 0
},
"googleFoodOrdering": {
"discount": 0,
"fee": 0,
"serviceFeePercent": 0,
"smallCartFee": 0
},
"kiosk": {
"discount": 0,
"fee": 0,
"serviceFeePercent": 0,
"smallCartFee": 0
},
"web": {
"discount": 0,
"expandedFees": {
"460": 0,
"560": 0,
"825": 265,
"999": 265,
"default": 0
},
"fee": 399,
"serviceFeePercent": 0,
"smallCartFee": 0
}
},
"2000": {
"app": {
"discount": 0,
"expandedFees": {
"460": 0,
"560": 0,
"825": 265,
"999": 265,
"default": 0
},
"fee": 399,
"serviceFeePercent": 0,
"smallCartFee": 0
},
"googleFoodOrdering": {
"discount": 0,
"fee": 0,
"serviceFeePercent": 0,
"smallCartFee": 0
},
"kiosk": {
"discount": 0,
"fee": 0,
"serviceFeePercent": 0,
"smallCartFee": 0
},
"web": {
"discount": 0,
"expandedFees": {
"460": 0,
"560": 0,
"825": 265,
"999": 265,
"default": 0
},
"fee": 399,
"serviceFeePercent": 0,
"smallCartFee": 0
}
}
}

...

*The quotedFee comes from partners. In Iberia, it comes from DMP, aka: intl-partners-delivery. But it depends on the market. DMP also uses launchdarkly to calculate the fee. It doesn’t get the other fees.

Proposal:

...

Once we get these fees (including the zeroed one), intl-delivery-service sends the result to

  • SNS: dev-plk-delivery-on-apply-quote) to not overwrite existing fee values with zeroes.Configure launchdarkly to fit business needs enabling FE to show fees and discounts quote-outcome

    • SQS: aws-rbi-dev-plk-apply-delivery-service-quote

      • Lambda: sls-rbi-dev-plk-orders-delivery-service-apply-quote ( intl-orders-service)

        • Which get the message and updates the current order in the database (dynamodb)

...

BE Proposal

  • Enhance this lambda function (dev-plk-delivery-on-apply-quote) to not overwrite discount and service fees with zeroes. It should keep the value from launchdarkly.

  • Configure launchdarkly to fit business needs enabling FE to show fees and discounts properly.

    • discount <> 0

    • serviceFee <> 0

    • fee <> 0

Configured webhooks*:

...

titleIntegration for store 1111 (zaragoza) - exists dev DELIVERY_QUOTE_CREATE and fallback(DELIVERY_QUOTE)

...

Lucidchart
pageCount1
autoUpdatefalse
alignleft
typerich
autoSize1
macroId676d3a59-c584-4c18-883a-4170ecca3358
instanceId920ae5b1-83d6-3e36-b794-1710780f64f3
pages
width700
documentTokenv2_a14568386f6935b40621989bae5a6103e7e06649d9381712b6ad0cb391a44874-a=133831322&c=920ae5b1-83d6-3e36-b794-1710780f64f3&d=078ef0e7-5034-4e83-a1ff-a31bb14dda99&p=4387570600
documentId078ef0e7-5034-4e83-a1ff-a31bb14dda99
updated1703260480589
height500

...

Note

Note: The calls to the BE in priceOrder is being executed through intl-gateway-service in the envs (enable-fulfillment-service-price-order = true) for Iberia Prod markets. Since in both flows (gateway and graphql) the impact is in intl-delivery-service, no major issues may be found with intl-whitelabel-graphql, but a double check plus tests are needed to ensure no major issues.

Proposal validation with transactions team:

https://rbidigital.slack.com/archives/C04D0V74P0D/p1702672116251489

FE impacts

When discount, fee and service fee come to FE, intl-whitelabel-app can be changed to display FREE fees as according to UX (figma). The design screens should be adapted to consider them accordingly. In such case, depending on the launchdarkly config ( fee tier), we may have a different value for fee, service and discount. In principle, to minimize BE impacts, we may continue using a single field for discount. It’s up to the FE display "FREE” for the related use-cases. E.g:

  • discount == fee + servicefee

    • FREE fee

    • FREE service fee

  • discount == fee, but discount < fee+servicefee

    • FREE fee

    • X.XX service fee

  • discount < fee

    • X.XX fee

    • X.XX service fee

  • Other configurations may not be supported

...

Feature control

As usual the activation of this feature should be done using LD feature flag in both FE and BE. Later it can leverage a new sanity config (toogle) under guest checkout.

Enhancements

  • Since, in the future, we may have partners who calculates delivery fees not only based on LD, we can have an additional config for FREE delivery fee / FREE delivery service fee, where BE (intl-delivery-service) would override LD values - meaning that discount can be set with the same amount of the fee or fee + service fee.

...

Architecture

...

In partners service, create quote flow calls both in delivery : quote_create and quote_apply

Configured webhooks*:

Expand
titleIntegration for store 1111 (zaragoza) - exists dev DELIVERY_QUOTE_CREATE and fallback(DELIVERY_QUOTE)
Code Block
{
  "integrationId": "a6e48415-ff02-44e9-bba3-ae9918e0cac1",
  "partnerId": "2acdd610-fad8-4acc-a030-eee340041a8c",
  "secret": "$3cr3t",
  "stores": [
    {
      "country": "ES",
      "storeId": "13769005484"
    },
    {
      "country": "ES",
      "storeId": "22221111"
    },
    {
      "country": "ES",
      "storeId": "6000013769"
    }
  ],
  "webhooks": [
    {
      "typecountry": "DELIVERY_CREATEES",
      "urlstoreId": "https://euw3-dev-plk-partners-delivery.rbictg.com/api/v1/ES/PLK/orders"2222"
    },
    {
      "typecountry": "DELIVERY_QUOTE_APPLYES",
      "urlstoreId": "https://euw3-dev-plk-partners-delivery.rbictg.com/api/v1/ES/PLK/quotes/apply60000"
    }
  ],
  "webhooks": [
    {
      "type": "DELIVERY_QUOTE_CREATE",
      "url": "https://euw3-dev-plk-partners-delivery.rbictg.com/api/v1/ES/PLK/quotesorders"
    },
    {
      "type": "MENU_PRICESDELIVERY_AVAILABILITYQUOTE_UPDATEAPPLY",
      "url": "https://euw3-dev-plk-mock-partners-integrationsdelivery.rbictg.com/menu/menu/version?mock_secret=$3cr3t/api/v1/ES/PLK/quotes/apply"
    },
    {
      "type": "ORDERDELIVERY_QUOTE_COMMITCREATE",
      "url": "https://euw3-dev-plk-mock-partners-integrationsdelivery.rbictg.com/orders/commit?mock_secret=$3cr3t/api/v1/ES/PLK/quotes"
    },
    {
      "type": "ORDER_FIREMENU_PRICES_AVAILABILITY_UPDATE",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.comcom/menu/ordersmenu/fireversion?mock_secret=$3cr3t"
    },
    {
      "type": "ORDER_PRICECOMMIT",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/orders/pricecommit?mock_secret=$3cr3t"
    },
    {
      "type": "STORE_SUPPORT_TICKET_EVENTORDER_FIRE",
      "url": "https://euw3-dev-plk-mock-partners-deliveryintegrations.rbictg.com/api/v1/ES/PLK/complaints"
    }
  ]
}
Expand
titleIntegration for store 3385 (fuenlenbrada) - exists mocked DELIVERY_QUOTE - returning hard coded fee value
Code Block
{
  "integrationId": "e5ef1f71-caa0-4ba8-888f-4d937b64f50f",
  "partnerId": "7425a4c0-f5bb-4f10-9bf0-6918b319525a",
  "secret": "4b26e43f0d7c7a51fbc6581d33549921",
  "stores": [orders/fire?mock_secret=$3cr3t"
    },
    {
      "type": "ORDER_PRICE",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/orders/price?mock_secret=$3cr3t"
    },
    {
      "countrytype": "ESSTORE_SUPPORT_TICKET_EVENT",
         "storeId": "3385"url": "https://euw3-dev-plk-partners-delivery.rbictg.com/api/v1/ES/PLK/complaints"
    }
  ],
  "webhooks": [
    {
   
}
Expand
titleIntegration for store 3385 (fuenlenbrada) - exists mocked DELIVERY_QUOTE - returning hard coded fee value
Code Block
{
  "typeintegrationId": "DELIVERY_CREATE",
   e5ef1f71-caa0-4ba8-888f-4d937b64f50f",
  "urlpartnerId": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/delivery/create?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
    },7425a4c0-f5bb-4f10-9bf0-6918b319525a",
  "secret": "4b26e43f0d7c7a51fbc6581d33549921",
  "stores": [
    {
      "typecountry": "DELIVERY_EVENTES",
      "urlstoreId": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/delivery/events?mock_secret=4b26e43f0d7c7a51fbc6581d335499213385"
    }
  ],
  "webhooks": [
    {
      "type": "DELIVERY_QUOTECREATE",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/delivery/quotecreate?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
    },
    {
      "type": "GENERAL_SUPPORT_TICKETDELIVERY_EVENT",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/ticketsdelivery/events?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
    },
    {
      "type": "MENUDELIVERY_EVENTQUOTE",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/menudelivery/eventsquote?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
    },
    {
      "type": "MENUGENERAL_PRICESSUPPORT_AVAILABILITYTICKET_UPDATEEVENT",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/menutickets/updatedevents?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
    },
    {
      "type": "MENU_UPDATEDEVENT",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/menu/updatedevents?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
    },
    {
      "type": "ORDER_COMMITMENU_PRICES_AVAILABILITY_UPDATE",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/ordersmenu/commitupdated?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
    },
    {
      "type": "ORDERMENU_EVENTUPDATED",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/ordersmenu/eventsupdated?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
    },
    {
      "type": "ORDER_FIRECOMMIT",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/orders/firecommit?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
    },
    {
      "type": "ORDER_PRICEEVENT",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/orders/priceevents?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
    },
    {
      "type": "STOREORDER_HEARTBEATFIRE",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/storesorders/statusfire?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
    },
    {
      "type": "STORE_SUPPORT_TICKET_EVENTORDER_PRICE",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/ticketsorders/eventsprice?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
    },
    {
      "type": "TICKETSTORE_EVENTHEARTBEAT",
      "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/ticketsstores/eventsstatus?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
    },
    {
     ]
}

In partners service, create quote flow calls both in delivery : quote_create and quote_apply

Note

The following flows are triggered whenever an order is updated in the database, so that the fee amounts are properly read by the API services and returned to the caller.

  • intl-data-service: Dynamodb order mutated (updated to createDelivery) from queue ORDER_UPDATED_TOPIC_ARN

  • processMessage

  • intl-orders-service

  • processMessage

  • requestTransportation

  • createDelivery / Quote flows

    swagger:
     "type": "STORE_SUPPORT_TICKET_EVENT",
          "url": "https://euw3-dev-plk-mock-partners-integrations.rbictg.com/tickets/events?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
        },
        {
          "type": "TICKET_EVENT",
          "url": "https://euw3-dev-plk-mock-partners-
    delivery
    integrations.rbictg.com/
    docs#/
  • Image Removed
  • Image Removed
  • Image Removed
  • Architecture

    ...

    Problems detected in DEV:

    • Added 9 sauces of 2.00 in the cart

    • After resulting in 18, it multiplied by 9 again:

    Image Removed

    Button + reached limit of 5, and kept varying between 4 and 5 in upsell cart modal

    ...

    tickets/events?mock_secret=4b26e43f0d7c7a51fbc6581d33549921"
        }
      ]
    }

    ...

    Possible existing bugs

    During this discovery, strange behaviors were detected. They are detailed here

    Hints:

    How to run local lambdas:

    • Example:

      • yarn start:function on-apply-quote

    A suggestion from trx team is to use partners-service repo as reference, where it shows also how to mock local events simulating (local queues). It ensures that you will be able that your lambda “consumer” will really read the event (and not the lambda that is AWS).