Table of Contents |
---|
🛠️ Potential Solutions
...
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
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)
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.
...
Option 1 - Payment Methods List in Sanity - Recommended
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.
...
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.
...
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 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). |
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 | ||
---|---|---|
| ||
"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.
...
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 have the following format:
Need to create this definition on be created in packages/secrets/src/definitions
and have the following interface:
Code Block | ||
---|---|---|
| ||
{ "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 a new payment method is added, just include the key in Lokalaise for DOP.can control payment methods by market and brand;
Cons:
When adding a new payment method 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 |
---|---|
The data we will save in Sanity in the Restaurant Document will be in have this format:
Code Block | ||
---|---|---|
| ||
{ "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.Note: On Sanity the
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 | ||
---|---|---|
| ||
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
componentworkspaces/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 |
PART V - Payment Methods Schedule
In DOP, a possible solution would be to program how long the payment can be disabled.
...