Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
NghiaDTr committed Dec 11, 2024
1 parent df4208b commit abe58bd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
30 changes: 11 additions & 19 deletions processor/src/service/payment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,6 @@ export const handleCreatePayment = async (ctPayment: Payment): Promise<Controlle

const paymentParams = createMollieCreatePaymentParams(ctPayment, extensionUrl, surchargeAmountInCent, cart);

if (method && method.toString() === 'googlepay') {
paymentParams.method = PaymentMethod.creditcard;
}

let molliePayment;
if (PaymentMethod[paymentParams.method as PaymentMethod]) {
logger.debug('SCTM - handleCreatePayment - Attempt creating a payment with method defined in Mollie NodeJS Client');
Expand Down Expand Up @@ -531,9 +527,8 @@ export const getCreatePaymentUpdateAction = async (
};

export const handleCreateRefund = async (ctPayment: Payment): Promise<ControllerResponseType> => {
const successChargeTransaction = ctPayment.transactions.find(
(transaction) => transaction.type === CTTransactionType.Charge && transaction.state === CTTransactionState.Success,
);
let successChargeTransaction;
const updateActions = [] as UpdateAction[];

const initialRefundTransaction = ctPayment.transactions.find(
(transaction) => transaction.type === CTTransactionType.Refund && transaction.state === CTTransactionState.Initial,
Expand Down Expand Up @@ -577,12 +572,14 @@ export const handleCreateRefund = async (ctPayment: Payment): Promise<Controller

const refund = await createPaymentRefund(paymentCreateRefundParams);

updateActions.push(
changeTransactionInteractionId(initialRefundTransaction?.id as string, refund.id),
changeTransactionState(initialRefundTransaction?.id as string, CTTransactionState.Pending),
);

return {
statusCode: 201,
actions: [
changeTransactionInteractionId(initialRefundTransaction?.id as string, refund.id),
changeTransactionState(initialRefundTransaction?.id as string, CTTransactionState.Pending),
],
actions: updateActions,
};
};

Expand All @@ -594,13 +591,8 @@ export const handleCreateRefund = async (ctPayment: Payment): Promise<Controller
* @throws {CustomError} If there is an error in the process.
*/
export const handlePaymentCancelRefund = async (ctPayment: Payment): Promise<ControllerResponseType> => {
const successChargeTransaction = ctPayment.transactions.find(
(transaction) => transaction.type === CTTransactionType.Charge && transaction.state === CTTransactionState.Success,
);

const pendingRefundTransaction = ctPayment.transactions.find(
(transaction) => transaction.type === CTTransactionType.Refund && transaction.state === CTTransactionState.Pending,
);
let pendingRefundTransaction: any;
let successChargeTransaction: any;

const initialCancelAuthorization = ctPayment.transactions.find(
(transaction) =>
Expand Down Expand Up @@ -841,4 +833,4 @@ export const handleGetApplePaySession = async (ctPayment: Payment): Promise<Cont
statusCode: 200,
actions: ctActions,
};
};
};

Check failure on line 836 in processor/src/service/payment.service.ts

View workflow job for this annotation

GitHub Actions / build-processor

Insert `⏎`

Check failure on line 836 in processor/src/service/payment.service.ts

View workflow job for this annotation

GitHub Actions / build-processor

Insert `⏎`
3 changes: 2 additions & 1 deletion processor/src/utils/constant.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const CustomFields = {
},
},
transactionSurchargeCost: 'sctm_transaction_surcharge_cost',
transactionRefundForMolliePayment: 'sctm_transaction_refund_for_mollie_payment',
};

export enum ConnectorActions {
Expand Down Expand Up @@ -69,4 +70,4 @@ export const MOLLIE_SURCHARGE_CUSTOM_LINE_ITEM = 'mollie-surcharge-line-item';

export const MOLLIE_SURCHARGE_LINE_DESCRIPTION = 'Total surcharge amount';

export const MOLLIE_SHIPPING_LINE_DESCRIPTION = 'Shipping amount';
export const MOLLIE_SHIPPING_LINE_DESCRIPTION = 'Shipping amount';

Check failure on line 73 in processor/src/utils/constant.utils.ts

View workflow job for this annotation

GitHub Actions / build-processor

Insert `⏎`

Check failure on line 73 in processor/src/utils/constant.utils.ts

View workflow job for this annotation

GitHub Actions / build-processor

Insert `⏎`
13 changes: 6 additions & 7 deletions processor/tests/service/payment.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ describe('Test handleCreatePayment', () => {
],
interfaceInteractions: [],
paymentMethodInfo: {
method: 'googlepay',
method: 'ideal',
},
custom: {
type: {
Expand Down Expand Up @@ -1904,7 +1904,7 @@ describe('Test handleCreatePayment', () => {
});

(createMollieCreatePaymentParams as jest.Mock).mockReturnValueOnce({
method: 'googlepay',
method: 'ideal',
});

(changeTransactionState as jest.Mock).mockReturnValueOnce({
Expand Down Expand Up @@ -1961,7 +1961,7 @@ describe('Test handleCreatePayment', () => {
sctm_id: '5c8b0375-305a-4f19-ae8e-07806b101999',
sctm_action_type: 'createPayment',
sctm_created_at: '2024-03-20T09:13:37+00:00',
sctm_request: '{"transactionId":"5c8b0375-305a-4f19-ae8e-07806b101999","paymentMethod":"googlepay"}',
sctm_request: '{"transactionId":"5c8b0375-305a-4f19-ae8e-07806b101999","paymentMethod":"ideal"}',
sctm_response:
'{"molliePaymentId":"tr_7UhSN1zuXS","checkoutUrl":"https://www.mollie.com/checkout/select-method/7UhSN1zuXS","transactionId":"5c8b0375-305a-4f19-ae8e-07806b101999"}',
},
Expand Down Expand Up @@ -2001,7 +2001,7 @@ describe('Test handleCreatePayment', () => {
});

describe('Test handleCreateRefund', () => {
it('should return status code and array of actions', async () => {
it('should return status code and array of actions (1 success charge transaction)', async () => {
const CTPayment: Payment = {
id: '5c8b0375-305a-4f19-ae8e-07806b101999',
version: 1,
Expand Down Expand Up @@ -2458,7 +2458,6 @@ describe('Test handlePaymentCancelRefund', () => {
{
id: '5c8b0375-305a-4f19-ae8e-07806b102000',
type: 'CancelAuthorization',
interactionId: 're_4qqhO89gsT',
amount: {
type: 'centPrecision',
currencyCode: 'EUR',
Expand Down Expand Up @@ -2533,7 +2532,7 @@ describe('Test handlePaymentCancelRefund', () => {
}
});

it('should return status code and array of actions', async () => {
it('should return status code and array of actions (interactionId is not defined in the Initial CancelAuthorization transaction)', async () => {
const mollieRefund: Refund = {
resource: 'refund',
id: CTPayment.transactions[1].interactionId,
Expand Down Expand Up @@ -3540,4 +3539,4 @@ describe('Test handleGetApplePaySession', () => {
expect(mockMakeCTMoney).toHaveBeenCalledWith({ currency: 'EUR', value: '20.00' });
});
});
});
});

Check failure on line 3542 in processor/tests/service/payment.service.spec.ts

View workflow job for this annotation

GitHub Actions / build-processor

Insert `⏎`

Check failure on line 3542 in processor/tests/service/payment.service.spec.ts

View workflow job for this annotation

GitHub Actions / build-processor

Insert `⏎`

0 comments on commit abe58bd

Please sign in to comment.