Versions Compared

Key

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

...

Feature Flag

Description

enable-ticket-restaurant-credit-card-paycomet

This flag will be responsible for activating ticket restaurant payment method using the online payment

enable-ticket-restaurant-voucher-paycomet

This flag will be responsible for activating ticket restaurant payment method using the voucher in person

Code Changes

PaymentMethodBrand

ENUM

VALUE

TICKET_RESTAURANT

TICKET_RESTAURANT

TICKET_RESTAURANT_VOUCHER

TICKET_RESTAURANT_VOUCHER

Frontend

Note

Not all unit tests that will be performed have been added, but it is implicit that it should cover as many tests as possible for this feature

PaymentMethodBrand

The essential part of this feature is the addition of new values ​​for ticket restaurant to the paymentMethodBrand property, which will be responsible for identifying the payment method made and passing it on to all systems listed below, since the system used behind the scenes is payment via credit card.

ENUM

VALUE

TICKET_RESTAURANT

TICKET_RESTAURANT

TICKET_RESTAURANT_VOUCHER

TICKET_RESTAURANT_VOUCHER

Frontend

Development
Expand
titlepayment-method/index.tsx
Code Block
const SelectedTicketRestaurantOptionItem = (
    <PaymentMethodAddNewItemOption
      text={formatMessage({ id: ticketRestaurantLabel(isGuestOrder) })}
      Icon={styledCardIcon(PaymentMethodBrandType.TICKET_RESTAURANT)}
      onClick={getSelectedMethodClickHandler()}
      selected
    />
  );

...

Expand
titlesrc/state/payment/constants.ts

Update all the METHOD_PLACEHOLDER to include ticket_restaurant with null value

Code Block
export const XXXX_METHOD_PLACEHOLDER: IPaymentMethod = {
  ...
  ticketRestaurant: null,
};

Create a new METHOD_PLACEHOLDER for ticket_restaurant and ticket_restaurant_voucher

Code Block
export const TICKET_RESTAURANT_METHOD_PLACEHOLDER: IPaymentMethod = {
  ...
  ticketRestaurant: true,
};

export const TICKET_RESTAURANT_VOUCHER_METHOD_PLACEHOLDER: IPaymentMethod = {
  ...
  ticketRestaurant: true,
  fdAccountId: 'CASH',
  accountIdentifier: 'TICKET_RESTAURANT',
  paymentMethodBrand: 'TICKET_RESTAURANT',
};
Expand
titlestate/payment/types.ts
Code Block
export enum PaymentMethodBrand {
  TICKET_RESTAURANT = 'TICKET_RESTAURANT',
  TICKET_RESTAURANT_VOUCHER = 'TICKET_RESTAURANT_VOUCHER',
}
Code Block
export interface IPaymentMethod {
  ticketRestaurant?: boolean | null;
}
Expand
titlestate/payment/hooks/use-payment.tsx
Code Block
const cashAccount: IPaymentMethod = {
  ticketRestaurant: null,
};

...

Expand
titleutils/payment/voucher.ts
Code Block
export const isVoucher = (method: IPaymentMethod) => {
  return !!method.sodexo || !!method.chequeGourmet || !!method.ticketRestaurant;
};

Graphql

Expand
titlegraphql/schemas/payments.gql

Add the PaymentMethodBrand

Code Block
enum PaymentMethodBrand {
 ...
 TICKET_RESTAURANT
 TICKET_RESTAURANT_VOUCHER
}

https://github.com/rbilabs/intl-whitelabel-graphql/pull/952

Fulfillment

Expand
titlesrc/graphql.ts
Code Block
export enum PaymentMethodBrand {
  ...,
  TICKET_RESTAURANT = "TICKET_RESTAURANT",
  TICKET_RESTAURANT_VOUCHER = "TICKET_RESTAURANT_VOUCHER",
}
Expand
titlelegacy/schemas/payments.graphql
Code Block
enum PaymentMethodBrand {
  ...
  TICKET_RESTAURANT
  TICKET_RESTAURANT_VOUCHER
}

https://github.com/rbilabs/intl-fulfillment-service/pull/813

Packages

Expand
titleorders/src/types/cart.ts
Code Block
export enum PaymentMethodBrand {
  ...,
  TICKET_RESTAURANT = 'TICKET_RESTAURANT',
  TICKET_RESTAURANT_VOUCHER = 'TICKET_RESTAURANT_VOUCHER',
}

https://github.com/rbilabs/intl-packages/pull/1187

DMP

Expand
title@tests/unit/pages/CashFlow/controllers/delegate.spec.ts
Code Block
const expected = [
  'TICKET_RESTAURANT',
  'TICKET_RESTAURANT_VOUCHER',
];
src/constants/paymentMethod
Expand
title
Info

It is necessary to ensure that the bumps were made to the frontend so that it is possible to find the restaurant ticket values.

Unit Tests
Expand
titlestate/payment/__tests__/use-payment.test.tsx
Code Block
jest.mock('state/launchdarkly', () => ({
  useFlag: jest.fn(),
  useGatewayFlags: jest.fn().mockReturnValue(''),
  LaunchDarklyFlag: {
    ENABLE_TICKET_RESTAURANT_VOUCHER_PAYCOMET: 'ticket-restaurant-string',
}));
Expand
titleutils/payment/__tests__/payment-method.test.ts
Code Block
describe('isRemovablePaymentMethod', () => {
  describe.each([
    [{ ticketRestaurant: true }, false],
  ])("on '%s'", (input, expected) => {
    it(`returns '${expected}'`, () => {
      expect(isRemovablePaymentMethod(input as IPaymentMethod)).toEqual(expected);
    });
  });
});
Info

Update other unit tests to cover these changes.

Graphql

Expand
titlegraphql/schemas/payments.gql

Add the PaymentMethodBrand

Code Block
enum PaymentMethodBrand {
 ...
 TICKET_RESTAURANT
 TICKET_RESTAURANT_VOUCHER
}

https://github.com/rbilabs/intl-whitelabel-graphql/pull/952

Fulfillment

Expand
titlesrc/graphql.ts
Code Block
export enum PaymentMethodPaymentMethodBrand {
  ...,
  TICKET_RESTAURANT = '"TICKET_RESTAURANT'",
  TICKET_RESTAURANT_VOUCHER = '"TICKET_RESTAURANT_VOUCHER'",
}

export const paymentMethodTranslation: Record<PaymentMethod, string> = {
Expand
titlelegacy/schemas/payments.graphql
Code Block
enum PaymentMethodBrand {
  ...
  TICKET_RESTAURANT:
'constants.paymentMethod.ticketRestaurant',
  TICKET_RESTAURANT_VOUCHER:
'constants.paymentMethod.ticketRestaurantVoucher',
};

https://github.com/rbilabs/intl-expeditorfulfillment-tabletservice/pull/742813

...

Packages

Expand
titledeliveryorders/settings/last-mile-settings-card/LastMileSettingsCard.tsxsrc/types/cart.ts
Code Block
export constenum paymentMethodTranslation:PaymentMethodBrand Record<PaymentMethod,{
keyof LocalizedDictionary> =...,
{  TICKET_RESTAURANT = 'TICKET_RESTAURANT: `${baseTranslationPath}.ticketRestaurant`',
  TICKET_RESTAURANT_VOUCHER: `${baseTranslationPath}.ticketRestaurantVoucher`,
};

export enum PaymentMethod {
  TICKET_RESTAURANT = = 'TICKET_RESTAURANT_VOUCHER',
}

https://github.com/rbilabs/intl-packages/pull/1187

DMP

Expand
title@tests/unit/pages/CashFlow/controllers/delegate.spec.ts
Code Block
const expected = [
  'TICKET_RESTAURANT',
  'TICKET_RESTAURANT_VOUCHER',
];
Expand
titlesrc/constants/paymentMethod.ts
Code Block
export enum PaymentMethod {
  TICKET_RESTAURANT = 'TICKET_RESTAURANT',
  TICKET_RESTAURANT_VOUCHER = 'TICKET_RESTAURANT_VOUCHER',
}
Expand
titleutils/orders.ts
Code Block


export const paymentMethodTranslation: Record<stringRecord<PaymentMethod, string> = {
  TICKET_RESTAURANT: 'delivery-mgmt.restaurantManagement.changeDriver.paidWith.constants.paymentMethod.ticketRestaurant',
  TICKET_RESTAURANT_VOUCHER: 'delivery-mgmt.restaurantManagement.changeDriver.paidWithconstants.paymentMethod.ticketRestaurantVoucher',
};

https://github.com/rbilabs/ctgintl-fzexpeditor-portaltablet/pull/2799742

...

DOP

Expand
titleorder-details/__tests__/order-details.specdelivery/settings/last-mile-settings-card/LastMileSettingsCard.tsx
Code Block
describe('Payment method', () =>export const paymentMethodTranslation: Record<PaymentMethod, keyof LocalizedDictionary> = {
    it.each`TICKET_RESTAURANT: `${baseTranslationPath}.ticketRestaurant`,
  TICKET_RESTAURANT_VOUCHER: `${baseTranslationPath}.ticketRestaurantVoucher`,
};

caseexport enum PaymentMethod {
  TICKET_RESTAURANT = 'TICKET_RESTAURANT',
   TICKET_RESTAURANT_VOUCHER = 'TICKET_RESTAURANT_VOUCHER',
}
Expand
titleutils/orders.ts
Code Block
export const paymentMethodTranslation: Record<string, string> = {
  TICKET_RESTAURANT: 'delivery-mgmt.restaurantManagement.changeDriver.paidWith.ticketRestaurant',
  TICKET_RESTAURANT_VOUCHER:         | paymentData                'delivery-mgmt.restaurantManagement.changeDriver.paidWith.ticketRestaurantVoucher',
};

https://github.com/rbilabs/ctg-fz-portal/pull/2799

Admin App

Expand
titleorder-details/__tests__/order-details.spec.tsx
Code Block
describe('Payment method', () => {
    it.each`
      case                                     | resultpaymentData       ${'Ticket restaurant'}                   | ${{ cardType: 'VISA', paymentMethodBrand: 'TICKET_RESTAURANT' }}                                   | result
      ${'Ticket Restaurantrestaurant'}       ${'Ticket restaurant voucher'}           | ${{ cardType: 'CASHVISA', paymentMethodBrand: 'TICKET_RESTAURANT_VOUCHER' }}   | $        | ${'Ticket Restaurant Voucher'}
    `('Should display $case payments accordingly', ({ paymentData, result }) => {
    ....
}
Expand
titleutils/utils.ts
Code Block
export function paymentMethodBrandTranslationMap(paymentMethodBrand: string) {
  const translatePaymentMethodBrand = {
    TICKET_RESTAURANT: 'orderDetails.paymentMethodBrand.ticket_restaurant',
    TICKET_RESTAURANT_VOUCHER: 'orderDetails.paymentMethodBrand.ticket_restaurant_voucher',
};

https://github.com/rbilabs/intl-admin-app/pull/403

Driver-app ( Voucher )

Expand
titleenums/index.ts
Code Block
export enum PaymentMethod {  ${'Ticket restaurant voucher'}           | ${{ cardType: 'CASH', paymentMethodBrand: 'TICKET_RESTAURANT_VOUCHER' }}   | ${'Ticket Restaurant Voucher'}
    `('Should display $case payments accordingly', ({ paymentData, result }) => {
    ....
}
Expand
titleutils/utils.ts
Code Block
export function paymentMethodBrandTranslationMap(paymentMethodBrand: string) {
  const translatePaymentMethodBrand = {
    TICKET_RESTAURANT: = 'TICKET_RESTAURANT'orderDetails.paymentMethodBrand.ticket_restaurant',
    TICKET_RESTAURANT_VOUCHER =: 'TICKET_RESTAURANT_VOUCHERorderDetails.paymentMethodBrand.ticket_restaurant_voucher',
};

https://github.com/rbilabs/intl-admin-app/pull/403

Driver-app ( Voucher )

Expand
titleservices/format.ts
Code Block
export const paymentMethodTranslation: Record<PaymentMethod, string> = {
  TICKET_RESTAURANT: `${pathPaymentMethosTranslation}.ticketRestaurant`,
  TICKET_RESTAURANT_VOUCHER: `${pathPaymentMethosTranslation}.ticketRestaurantVoucher`,
};

https://github.com/rbilabs/intl-driver-app/pull/286

Tests

Ticket Restaurant Card

Ticket Restaurant Voucher

...

enums/index.ts
Code Block
export enum PaymentMethod {
  TICKET_RESTAURANT = 'TICKET_RESTAURANT',
  TICKET_RESTAURANT_VOUCHER = 'TICKET_RESTAURANT_VOUCHER',
}
Expand
titleservices/format.ts
Code Block
export const paymentMethodTranslation: Record<PaymentMethod, string> = {
  TICKET_RESTAURANT: `${pathPaymentMethosTranslation}.ticketRestaurant`,
  TICKET_RESTAURANT_VOUCHER: `${pathPaymentMethosTranslation}.ticketRestaurantVoucher`,
};

https://github.com/rbilabs/intl-driver-app/pull/286

Tests

Ticket Restaurant Card

To make payments with the Ticket Restaurant card, we can use the same cards used for credit card payments. This integration with meal voucher cards is activated at restaurant points, together with Paycomet. We just need to validate that the credit card field is displayed to the user and that they can follow the same credit card payment flow and the paymentMethodBrand is filled with “TICKET_RESTAURANT”.

...

Ticket Restaurant Voucher

To make payments with the Ticket Restaurante Voucher, it is necessary to ensure that the process follows the CASH flow and the paymentMethodBrand is filled with “TICKET_RESTAURANT_VOUCHER”, where payment only occurs when the order is delivered to the customer and is made in person.

...

Possible Issues

Ticket Restaurant not accepted in payment request via paycomet

It may occur that a restaurant has payment failure when a payment request is registered via Ticket Restaurant. This problem may be related to the terminal IDs at the restaurant, which must be configured correctly to enable payment via restaurant ticket.