Versions Compared

Key

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

Document Status

Status
colourBlue
titlein-progress

Document Owner(s)

Capovilla, Evandro

Reviewers

...

  • We are sending the name as the first string until de empty string.

  • We are sending the surname as the rest of the name after the first empty string

  • We are using the same feature flag to send user details to send first name and last name data

  • Mandatory fields are still being sent (email and/or cell phone)

  • The workPhone and homePhone fields are not mandatory due to the rule above

  • The IpAddress field has already been sent - No changes necessary

  • The cardholderName field only requires updates in BE

#1 - Send cardholder name field to paycomet

...

Info

Pre-auth removal refence: https://rbictg.atlassian.net/wiki/spaces/TRX/pages/4312367174/Paycomet+-+Pre-auth+removal#Integration-steps-TO-BE-(Delivery)

Whitelabel App (Already done)

The frontend will be responsible for displaying and retrieving the cardholderName field and sending this information to paycomet. Nowadays this information is already sent via Paycomet forms, but they also need it to be sent via the merchantData field.

...

Expand
titlesrc/modules/legacy/legacy.service.ts

Before

Code Block
paycometSale = {
  ...,
  fullName: paymentUserDetails.name!,
  ...,
};

After

Code Block
paycometSale = {
  ...,
  fullName: payment?.fullName || paymentUserDetails.name!,
  ...,
};

Payment Service (Already done)

Expand
titlesrc/functions/graphql/utils/make-payment.ts
Code Block
private mapPaymentMethod(
    params: IPaycometPaymentSaleEvent,
  ): {
    paymentMethodType: string;
    paymentMethod: string;
  } {
    const isVaultedPayment = !params.storePaymentMethod && params.storedPaymentMethodId;

    if (isVaultedPayment) {
      return {
        paymentMethodType: params.paymentType,
        paymentMethod: JSON.stringify({
          ...,
          cardholderName: params?.fullName,
          ...,
        }),
      };
    }

    return {
      paymentMethodType: params.paymentType,
      paymentMethod: JSON.stringify({
        ...,
        cardholderName: params?.fullName,
        ...,
      }),
    };
  }

...

Expand
titlesrc/paycomet-core/paycomet-helper.ts-helper.ts

The idea here is to update the buildUserDetails function to handle first and last name, since the responsibility of this function is to generate the customer field.

Create two function parseName and parseSurname, to handle the cardholderName to send to paycomet.

Update the buildUserDetails function and tests.

Code Block
public buildUserDetails = (
    region: string,
    cellphone?: string,
    email?: string,
    paymentMethod?: PaymentMethod
  ): TCustomer | undefined => {
    if (!cellphone && !email && !paymentMethod.cardholderName) {
      return undefined;
    }
    return {
      mobilePhone: cellphone ? this.parsePhoneNumber(cellphone, region) : undefined,
      email: email || undefined,
      name: parseName(paymentMethod.cardholderName)
      surname: parseSurname(paymentMethod.cardholderName)
    };
  };

...

Info

Pre-auth reference: /wiki/spaces/TRX/pages/3929702586

Whitelabel App (Already done)

Expand
titlesrc/pages/cart/payment/order-payment/paycomet-hosted-page-payment/paycomet-vaulted-card.tsx
Code Block
generateCreatePreAuthorization({
        variables: {
          input: {
            ...,
            cardHolderName: paymentValues.nameOnCard,
            ...,
          },
        },
      });

GraphQL (Already done)

Expand
titlesrc/functions/graphql/providers/payments.ts
Code Block
public async createPreAuthorizationPaycomet({...}){
  const paycometPreauth =
    await this.paymentsClient.paycometClient.request<ICreatePreAuthorizationResponse>((apis) =>
      apis.paymentsApi.createPreAuthorization({
        iCreatePreAuthorizationRequest: {
          ...,
          cardHolderName,
          ...,
        },
        region: regionCountry,
      }),
    );
}

...

Expand
titlesrc/payment/preauth/preauth.service.ts
Code Block
languagetypescript
public async processPreAuth(...){
  ...
  const customer = this.paycometHelper.buildUserDetails(region, cellphone, email, request);
  ...
}

...

Vaulted

No update required

...

Vaulted - Pre-auth

No update required

...

Update phoneNumber field to use user accounts or delivery data

The idea here is to mainly use the phoneNumber from the cart page and if it doesn't exist, we use the phoneNumber from the user data. If neither of these fields exist, we are sending that data as empty.

Whitelabel App

Expand
titlecart/payment/order-payment/use-order-payment.ts

One-time:

Code Block
const {
  ...,
  orderPhoneNumber,
} = useOrderContext();

const placeOrder = useCallback(async () => {
  ...
  
  const userPaymentDetails = enablePaycometPaymentUserDetails
    ? {
        phoneNumber: orderPhoneNumber ?? auth.user?.details?.phoneNumber,
        email: auth.user?.details?.email,
      }
    : undefined;
    
  ...
  
}

Vaulted:

Code Block
const {
  ...,
  orderPhoneNumber,
} = useOrderContext();

const processOrderWithAccount = useCallback(async () => {
  ...
  
  const userPaymentDetails = enablePaycometPaymentUserDetails
    ? {
        phoneNumber: orderPhoneNumber ?? user?.details.phoneNumber,
        email: user?.details?.email,
      }
    : undefined;
    
  ...
  
}

...