From 6087c2f584e6809c7613a9f3eac6b5abcfc9c04f Mon Sep 17 00:00:00 2001 From: Nghia Tran Date: Fri, 19 Jul 2024 13:05:06 +0700 Subject: [PATCH] Specific param for creditcard payment --- processor/src/utils/map.utils.ts | 12 ++++++++++++ processor/tests/utils/map.utils.spec.ts | 3 +++ 2 files changed, 15 insertions(+) diff --git a/processor/src/utils/map.utils.ts b/processor/src/utils/map.utils.ts index 2e48df8..197c3fc 100644 --- a/processor/src/utils/map.utils.ts +++ b/processor/src/utils/map.utils.ts @@ -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), @@ -97,6 +108,7 @@ export const createMollieCreatePaymentParams = (payment: Payment): PaymentCreate applicationFee: paymentRequest.applicationFee ?? {}, profileId: paymentRequest.profileId ?? null, testmode: paymentRequest.testmode ?? null, + ...specificParam, }; return molliePaymentParams; diff --git a/processor/tests/utils/map.utils.spec.ts b/processor/tests/utils/map.utils.spec.ts index 7285a91..e26d4c0 100644 --- a/processor/tests/utils/map.utils.spec.ts +++ b/processor/tests/utils/map.utils.spec.ts @@ -96,6 +96,7 @@ describe('createMollieCreatePaymentParams', () => { restrictPaymentMethodsToCountry: null, shippingAddress: {}, testmode: null, + cardToken: '', }); }); @@ -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 = { @@ -155,6 +157,7 @@ describe('createMollieCreatePaymentParams', () => { restrictPaymentMethodsToCountry: null, shippingAddress: {}, testmode: null, + cardToken: customFieldObject.cardToken, }); }); });