Versions Compared

Key

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

...

Info

Remember that waiting for payment is a feature for all payment methods, but for it to be displayed, two conditions must be met:

  • The order must not be paid yet. (PRICE_SUCESSFUL and PAYMENT_REQUIRED)

  • The request must contain the paymentRequestCreatedAt paymentRequestTimeLimit property in the payment property.

...

Expand
titlehttps://sequencediagram.org/ - Create Payment Request
Code Block
title Create Payment Request

participant Frontend
participant Graphql/Fulfillment
participant DB
participant Payment Service
participant PSP Service
participant Paycomet External

Frontend->Graphql/Fulfillment: Initiate Payment
Graphql/Fulfillment->Payment Service: Initiate Payment
Payment Service->PSP Service:Initiate Payment
PSP Service->Paycomet External:Payments Endpoint
PSP Service<-Paycomet External:Result
Payment Service<-PSP Service:Result
Graphql/Fulfillment<-Payment Service:Result
Frontend<-Graphql/Fulfillment:Result

group Commit Order
Frontend->Graphql/Fulfillment:     Commit Order\n(SaveCommitOnly)
Frontend<-Graphql/Fulfillment: Commit Order Result
end

loop
Frontend->DB:Order Polling
Frontend<-DB:Order Result
end

For this communication, it is necessary to transmit two important pieces of information to the Paycomet service: the amount and the cellphone. The cellphone will be used by Paycomet to create a request in the user's MBWay account. Once the data reaches the Paycomet service, we will create a payload as mentioned below for the /payments endpoint of Paycomet.

...

This task covers the order commit, where we will add a new field called paymentRequestCreatedAt paymentRequestTimeLimit, which will be responsible for recording when the payment request was generated. This field will be used in the future on the "Waiting for Payment" screen. It is important to remember that saveCommitOnly must be enabled for the order commit in the backend to be activated.

Expand
titleCommit Order
Code Block
commitInput = {
  ...commitInput,
  payment: {
    paymentRequestCreatedAtpaymentRequestTimeLimit: 1627383253213, //timestamp
    ...commitInput.paymemt
  }
}

...

This task aims to add mbway to the payment method enums and modify the commit order to accept this new payment method, in addition to including the new field: "paymentRequestCreatedAt" paymentRequestTimeLimit

Expand
titlesrc/functions/graphql/generated/graphql.ts
Code Block
export enum CartPaymentType {
  ...
  MBWay = 'MBWay',
}
Expand
titlesrc/functions/graphql/providers/payments.ts
Code Block
export interface IPaycometPaymentSaleEvent extends IBaseSale {
  ...
  paymentRequestCreatedAtpaymentRequestTimeLimit?: number;
}
Expand
titlesrc/functions/graphql/providers/payments.ts
Code Block
paycometSale = {
  ...
  paymentRequestCreatedAtpaymentRequestTimeLimit: payment?.paymentRequestCreatedAtpaymentRequestTimeLimit,
};
Expand
titlesrc/functions/graphql/utils/make-payment.ts
Code Block
private mapPaymentMethod(
    params: IPaycometPaymentSaleEvent,
  ): {
    paymentMethodType: string;
    paymentMethod: string;
  } {
    ...

    return {
      paymentMethodType: params.paymentRequestCreatedAtpaymentRequestTimeLimit &&
                           params.paymentMethodType ? 'MBWay' : 'scheme',
      paymentMethod: JSON.stringify({
        type: 'scheme',
        subtype: 'onetime',
      }),
    };
  }

...

Expand
titleInitiate Payment Service
Code Block
public async initiatePaymentMBWay(
    region: string,
    request: InitiateRequestDto,
  ): Promise<InitiateResult> {
    try{
      const result = this.createPaymentMBWayRequest(request);
      // Add log about payment initiation attempt
      if(result.errorCode === TransactionStatus.SUCCESSFUL){
        return this.handleSuccesful(region, request, result);
      }
      return this.handleFailure(region, request, result);
    } catch(error){
      return this.handleFailure(region, request, error);
    }
}

Update the makePayment endpoint in Paycomet PSP Service

Expand
titlesrc/payment/payment.service.ts
Code Block
private isOneTimePayment(paymentMethod: PaymentMethod): paymentMethod is OneTimeSchemeDto {
return (
    (paymentMethod.type === PaymentMethodType.Scheme ||
    paymentMethod.type === PaymentMethodType.MBWay) &&
    paymentMethod.subtype === SchemePaymentMethodType.OneTime
  );
}
Expand
titlesrc/paycomet-core/paycomet-helper.ts
Code Block
public getPaymentLinkId(
  ...
): TypePayment | undefined {
  if (!methodId) {
    const paymentLink = transaction?.payment?.history.find(
      (order) =>
        ... ||
        order.methodId === TransactionMethodId.APPLEPAYLINK ||
        order.methodId === TransactionMethodId.MBWAY ||,
    );

    methodId = Number(paymentLink?.methodId);
  }
}
Expand
titlesrc/paycomet-core/commons.types.ts
Code Block
export enum TransactionMethodId {
  APPLEPAYLINK = 1,
  MBWAY = 38
}

Admin App

Adding mbway within the translation enum so that the Admin App knows this new payment method and selects the correct translation.

...