Versions Compared

Key

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

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

Document Status

...

Status

🛠️ Potential Solutions

...

Table of Contents

🛠️ Potential Solutions

Currently, the restaurant lacks the ability to choose which payment methods to use, particularly offline options like cash, vouchers, or at-home terminals, during the delivery process. RBIIberia aims to provide this flexibility to the restaurant, allowing it to temporarily disable the "at-home terminal" payment method whenever it is not available.

We have two tools that can be used by restaurants to configure payment method availability: Sanity and DOP.

Option 1: Use Sanity for payment methods configurations - Discarded

(plus) Pros

  • This is the standard tool for Fz’s (market) configuration persona

  • Sanity is deployed for every Fz (market) in RBI

...

  • Operations team doesn’t have access to Sanity.

    • Possibilities:

      • New sanity access roles for the operations team

      • Operations team would require Fz’s configurators to update it if necessary

  • For Restaurant configuration level, it should be done one by one (despite that it can be added a new configuration to do for all restaurants at once).

  • It’s not possible to do these configurations for the offline payment methods.

Option 2: Use DOP for payment methods configurations - (Chosen by business)

(plus) Pros

  • This is the tool used by the Operations team. If we use this one, they don’t need to learn and to get access to use another tool.

  • This tool supports the configurations for offline payment methods (mainly for terminal machine at home and cash).

  • Possibility to do these configurations at restaurant level. But it can also be extended to edit for multiple restaurants, just as "Cash Limitation feature".

  • It’s possible to configure payments on DOP and create a “view only” version on Sanity. Then WL can query this information.

...

  • DOP is used only by Iberia and Germany. This solution will only impact these markets.

✅ Proposed Solution

PART I - Add Payment Methods List on DOP

We need to implement a solution that allows users to temporarily disable certain offline payment methods (e.g., vouchers, cash) for specific restaurants in the DOP. When a payment method is disabled, it will not be displayed in the WL-app for that restaurant.

...

After receiving feedback from the Menu team (Rafael Souza, Eduardo Yosida, and Lucas Palencia) and the Transactions team (Felipe Rooke), we have concluded that this solution is the best option at this time.

...

Info

This new screen (sanity document) will only list the available offline payment methods for the market. The restaurant level configuration will be stored in the restaurant documents, and managed via DOP as detailed in below.

...

Info
Note:

The design team has not created these screens yet, this is just a sketch

Field and Details

Screen on Sanity

The new screen in the Restaurant Menu.

In this screen we can add, remove and edit the payment method

image-20241031-140933.png

Screen where we can add new payment

image-20241031-141038.png

Title of Payment (name) - Payment title, we will use this title to save the status within documents restaurant for identification

image-20241016-124738.png

Payment method brand (paymentMethodBrand) - a string key that must match the one in WL_app. We will use this value to ensure consistent validation in the front-end.

Example: “CASH“, “SODEXO_VOUCHER“, “PAYMENT_ON_DELIVERY_CARD”

image-20241016-124752.png

...

Change the source from which the application retrieves payment methods. Currently, this information is fetched from the front-end (Whitelabel). By moving this responsibility to a back-end service, we will be able to access this information from anywhere, ensuring the maintenance of more consolidated payment methods.

Solution Option 2

In this solution, we will add all payment methods to a separate back-end repository, maybe in intl-payment-service or intl-packages. Additionally, we can create a new API to retrieve this information in any other service, such as the DOP.

Once the state of each payment method is selected, this information will be saved in the "Restaurant" document within Sanity.

Basically, we will retrieve the payment file in the front-end (WL-app) and transfer it to the back-end:
workspaces/frontend/src/state/payment/constants.ts

We will need to move all We will need to move all feature flags related to payment methods from the front-end to the back-end.

Info

The Transaction Team is currently working on this, but they will need more time to complete it (approximately 3 to 4 months).

(plus) Pros:

  • All services that need to access payment methods can query the back-end service to obtain this information;

  • A single source for payment methods;

  • More consolidated application.

  • Get Payment Method by brand and market

...

  • Significant change in the payment architecture;

  • Much High effort required;

  • High complexity;

  • The Transactions team is already working in this improvement.

...

Code Block
languagejson
"paymentsMethod": [
  {
    "name": "Cash",
    "keyLokalise": "paymentMethods.cash",
    "paymentMethodBrand": "CASH",
    "onlinePaymentisOnlinePayment": false
  },
  {
    "name": "Sodexo Voucher",
    "keyLokalise": "paymentMethods.sodexoVoucher",
    "paymentMethodBrand": "SODEXO_VOUCHER",
    "onlinePaymentisOnlinePayment": false
  },
  {
    "name": "Ticket Restaurant Voucher",
    "keyLokalise": "paymentMethods.ticketRestaurantVoucher",
    "paymentMethodBrand": "TICKET_RESTAURANT_VOUCHER",
    "onlinePaymentisOnlinePayment": false
  }
];
  • paymentsMethod List:

    • name: a string used for easy identification of the payment method, and we can use this name to show on Sanity.

    • keyLokalise: a string that may contain a key from Lokalise.

    • paymentMethodBrand: a string key that must match the one in WL_app. We will use this value to ensure consistent validation in the front-end.

    • onlinePaymentisOnlinePayment: A boolean value to choose if determine whether the payment method is online or offline. In the first momento we’ll use just Initially, we will only use offline payment.

...

(plus) Pros:

  • Fast development;

  • Simple solution;

...

  • we don't have separation by market;

  • All payment method are presented to all markets;

  • When added new market in WL-app, need to add in DOP as well;

...

Option 4 - Payment Methods List in Secrets

In this solution, we would create a Secrets for each market, where each secret would include only the payment methods available for that market. The DOP would use these payment methods as a basis to identify which ones are available and determine which are active or inactive. When saving this information, it would be sent to Sanity, where each payment method would be recorded.

Solution Option 4

In this solution, we intend to implement a secrets, which will include variations tailored for each market.

...

These Secrets will be created in packages/secrets/src/definitions and have the following interface:

Code Block
languagejson
{
  "pk": {
    "S": "rbi/dev/plk/es/payment-method"
  },
  "sk": {
    "S": "current"
  },
  "createdAt": {
    "S": "2024-10-23T12:23:35.389Z"
  },
  "description": {
    "S": "Secrets for the payment method in DOP FZ-Portal."
  },
  "updatedAt": {
    "S": "2024-10-23T12:23:35.389Z"
  },
  "value": {
    "S": "paymentMethods": [
      {
        "name": "Cash",
        "paymentMethodBrand": "CASH",
        "onlinePaymentisOnlinePayment": false
      },
      {
        "name": "Sodexo Voucher",
        "paymentMethodBrand": "SODEXO_VOUCHER",
        "onlinePaymentisOnlinePayment": false
      }
    ]
  }
}
  • Payments Methods List:

    • name: a string used for easy identification of the payment method, and we can use this name to show on Sanity.

    • paymentMethodBrand: a string key that must match the one in WL_app. We will use this value to ensure consistent validation in the front-end.

    • onlinePaymentisOnlinePayment:A boolean value to determine whether the payment method is online or offline. Initially, we will only use offline payment.

...

  • Access restricted to the technical team;

  • With secrets, we can control payment methods by market and brand;No new coding would be required each time

(minus) Cons:

  • When adding a new payment method is added, just include the key in Lokalaise for DOP.

(minus) Cons:

  • When adding a new payment method in the WLapp, in the WLapp, we also need to include it in the Secrets;

  • Need add the secrets for each stage (dev, stg, qa, prod);

  • Need to add this secrets in intl-packages/secrets

  • The Transactions team is currently working on an improvement to get the payment method for a service, so this secrets may be deprecated in the future.

PART II - Store Payment Methods with Their States in Sanity

In this section, we will explain how we will display this information in the DOP and how we will save the state of each payment method. All the solutions outlined above will use this approach to save the payment methods along with their states in Sanity.

...

When the user makes any changes and selects the active and inactive payment methods, the system will save this information in Sanity, into the Restaurant Document like similar to the Cash Limitation feature.

DOP

SANITY

image-20241010-182141.png

image-20241010-182603.png

The data we will save in Sanity in the Restaurant Document will be in have this format:

Code Block
languagejson
{
  "paymentMethods": [
    {
      "name": "Cash",
      "state": true,
      "paymentMethodBrand": "CASH",
      "onlinePaymentisOnlinePayment": false
    },
    {
      "name": "Sodexo Voucher",
      "state": true,
      "paymentMethodBrand": "SODEXO_VOUCHER",
      "onlinePaymentisOnlinePayment": false
    }
  ]
}

Once the configuration is set for the restaurant, every time the DOP opens the payment methods screen, it will perform the two queries again:

...

Now, the Sanity query will provide the status of each payment method, allowing the user to know which are active or inactive and make new modifications.

Info

...

The Sanity

...

Restaurant Document will only display this information for viewing purposes, it will not be possible to change these values or statuses through Sanity, only via the DOP.

Create the fields in Sanity alongside Cash Limitation and present the payment methods and their respective statuses. The file is schemas/menu/documents/restaurant.tsx.

PART III - How will the Whitelabel-app get this Information

intl-packages

We will create a new attribute in IBaseRestaurant in the file packages/sanity/src/restaurant/restaurant.ts.

The name of this attribute can be paymentMethod and it is an object:

Code Block
export interface IPaymentMethod {
  name?: string
  state?: boolean
  paymentMethodBrand?: string
  onlinePaymentisOnlinePayment: boolean
}

export interface IBaseRestaurant {
  ...
  paymentMethod?: IPaymentMethod[];
  ...
}

...

And now the function listBySearchParams get this information on Sanity.

Create the paymentMethod field on GraphQL Flow

intl-whitelabel-graphql

Create a new attribute in RestaurantNode in the file src/functions/graphql/schemas/restaurant.gql

Code Block
languagejson
type PaymentMethod {
  name: string
  state: boolean
  paymentMethodBrand: string
  onlinePaymentisOnlinePayment: boolean
}

type RestaurantNode implements Node {
...
  paymentMethod: [PaymentMethod]
...
}

...

Code Block
type PaymentMethod {
  name: string
  state: boolean
  paymentMethodBrand: string
  onlinePaymentisOnlinePayment: boolean
}

type RestaurantNode implements Node {
...
  paymentMethod: [PaymentMethod]
...
}

...

Create a new hook to payments methods and call this hook on workspaces/frontend/src/pages/cart/payment/order-payment/paycomet-hosted-page-payment/paycomet-hosted-page-payment.tsx.

This file contains the list of payment methods, and we can use this list to compare it with the new payment list of restaurants.

Sanity and DOP Payments

Whitelabel Payments

Payments avaliable to user on payment screen

cash: true

Sodexo Voucher: false

Ticket Restaurant: false

Payment delivery card: true

Credit Card

Paypal

cash

Sodexo Voucher

Ticket Restaurant

Payment delivery card

Credit Card

Paypal

cash

Payment delivery card

To compare these payment methods, we will use the field paymentMethodBrand and onlinePayment in the first moment we’ll use only onlinePayment: false therefore only to offline payment.Note:

Info

The source of truth will always be the Whitelabel. If a payment method exists only in Sanity, the Whitelabel will not display it, as the payment method must be registered in the Whitelabel.

PART IV - Change Checkbox Components

Before:

...

After:

...

We can use the EditorAvailability component
workspaces/frontend/src/pages/editor/editor-grid/EditorAvailability.tsx

An exampleExample:

...

And the setState we need to change as well, like this:

...

This way allow we can change to 3 statusstatuses, true, false and neutral:

False

True

Neutral

Remove the value or change to 0 the value of cash limitation

Allow we can put a value for cash limitation

Ignore the field, nothing will be changed, this behavior only happens when we choose more than one restaurant

image-20241008-114922.pngimage-20241008-114940.pngimage-20241008-114958.png


PART V - Payment Methods Schedule

In DOP, a possible solution would be to program how long the payment can be disabled.

...

Note

Tip: Document here any improvement or discussion regarding the feature

Which screen will the user be able to make these changes?

...

When updating multiple restaurants and wanting to change only one payment method, the others should not be altered. However, this information is organized in a list within Sanity. During the update, it is possible to remove the other payment methods, as the front-end in the DOP will ignore them to prevent incorrect status changes. Therefore, when saving this information, the DOP needs to check each restaurant and update only the payment method that was modified. This may take significantly more time if there is a large number of restaurants, and it might be necessary to use a batch process.

⁉️ FAQ

Info

Doubts and questions

Which screen will the user be able to make these changes?

Users can make changes on the "Edit Payment Methods" screen located in the Restaurants tab. This screen is the same one used for Cash Limitation, so users with access to Cash Limitation will also be able to access the to access the offline payment methods list.

If we add a new payment method only in the DOP, will it appear in the WL-app?

No, the new payment method will not appear. This request is solely for controlling the display of already existing offline payment methods list.

If we add a new payment method only in the DOP, will it appear in the WL-app?

No, the new payment method will not appear. This request is solely for controlling the display of already existing offline payment methods.

If we configure the DOP to allow the SODEXO payment method, but we disable the flag for that payment in the WL-app, will it be displayed?

No, it will not be displayed, as the Whitelabel has greater control in this case.

Can I make changes directly in Sanity for the saved payment methods in the Restaurant Document?

No, editing must be done exclusively through the DOP.

Why will we save the payment status in Sanity?

...

configure the DOP to allow the SODEXO payment method, but we disable the flag for that payment in the WL-app, will it be displayed?

No, it will not be displayed, as the Whitelabel has greater control in this case.

Can I make changes directly in Sanity for the saved payment methods in the Restaurant Document?

No, editing must be done exclusively through the DOP.

Why will we save the payment status in Sanity?

Because Sanity is the true source of restaurant information. All details about the restaurant are stored in this document, so we will maintain this standard.

If a payment method is removed and there is already a state defined for this method in one of more restaurants, will the restaurant document also be updated?

This will only be updated when the DOP saves the payment methods again, because if you remove it from this list in Sanity it will not appear in the DOP and when the DOP saves the payment method again it will be removed from the restaurant in Sanity.