Skip to content

Commit

Permalink
Specific param for creditcard payment
Browse files Browse the repository at this point in the history
  • Loading branch information
NghiaDTr committed Jul 19, 2024
1 parent f6aa64a commit 6087c2f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions processor/src/utils/map.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ export const createMollieCreatePaymentParams = (payment: Payment): PaymentCreate

const defaultWebhookEndpoint = new URL(process.env.CONNECT_SERVICE_URL ?? '').origin + '/webhook';

let specificParam;
switch (method) {
case PaymentMethod.creditcard:
specificParam = {
cardToken: paymentRequest.cardToken ?? '',
};
break;
default:
break;
}

const molliePaymentParams: PaymentCreateParams = {
description: paymentRequest.description ?? '',
amount: makeMollieAmount(amountPlanned),
Expand All @@ -97,6 +108,7 @@ export const createMollieCreatePaymentParams = (payment: Payment): PaymentCreate
applicationFee: paymentRequest.applicationFee ?? {},
profileId: paymentRequest.profileId ?? null,
testmode: paymentRequest.testmode ?? null,
...specificParam,
};

return molliePaymentParams;
Expand Down
3 changes: 3 additions & 0 deletions processor/tests/utils/map.utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe('createMollieCreatePaymentParams', () => {
restrictPaymentMethodsToCountry: null,
shippingAddress: {},
testmode: null,
cardToken: '',
});
});

Expand All @@ -106,6 +107,7 @@ describe('createMollieCreatePaymentParams', () => {
redirectUrl: 'https://example.com/success',
webhookUrl: 'https://example.com/webhook',
cancelUrl: 'https://example.com/cancel',
cardToken: 'card_token_12345',
};

const CTPayment: Payment = {
Expand Down Expand Up @@ -155,6 +157,7 @@ describe('createMollieCreatePaymentParams', () => {
restrictPaymentMethodsToCountry: null,
shippingAddress: {},
testmode: null,
cardToken: customFieldObject.cardToken,
});
});
});

0 comments on commit 6087c2f

Please sign in to comment.