Document Status | Status |
---|
colour | BlueGreen |
---|
title | IN REVIEWREVIEWED |
---|
|
|
---|
Document Owner(s) | Capovilla, Evandro |
---|
Reviewers | |
---|
✅ Proposed Solution
...
Info |
---|
Remember that waiting for payment is a feature for all payment methods, but for it to be displayed, two conditions must be met: |
...
Expand |
---|
title | https://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
Payment Service->DB: Update Order \n(PaymentRequestTimeLimit)
Payment Service<-DB: Order Updated
DB<-Payment Service: Create Payment in Payment Table
DB->Payment Service: Payment Created
Graphql/Fulfillment<-Payment Service:Result
Frontend<-Graphql/Fulfillment:Result
loop
group Commit Order
Frontend->DB>Graphql/Fulfillment:Order 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 |
---|
|
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 |
---|
title | src/functions/graphql/generated/graphql.ts |
---|
|
Code Block |
---|
export enum CartPaymentType {
...
MBWay = 'MBWay',
} |
|
Expand |
---|
title | src/functions/graphql/providers/payments.ts |
---|
|
Code Block |
---|
export interface IPaycometPaymentSaleEvent extends IBaseSale {
...
paymentRequestCreatedAtpaymentRequestTimeLimit?: number;
} |
|
Expand |
---|
title | src/functions/graphql/providers/payments.ts |
---|
|
Code Block |
---|
paycometSale = {
...
paymentRequestCreatedAtpaymentRequestTimeLimit: payment?.paymentRequestCreatedAtpaymentRequestTimeLimit,
}; |
|
Expand |
---|
title | src/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 |
---|
title | Initiate 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 |
---|
title | src/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 |
---|
title | src/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 |
---|
title | src/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.
...