From 9fb0083e0328ba90937f3261ad2c36fdf9eae336 Mon Sep 17 00:00:00 2001 From: Kashif Date: Wed, 11 Dec 2024 14:26:09 +0530 Subject: [PATCH] refactor(payments): add card_holder_name to request only if the value is present (#832) Co-authored-by: Pritish Budhiraja (cherry picked from commit 769f84517e814896e63d18fdd5114c836ecd21fb) --- src/Payment.res | 4 ++-- src/Payments/CardPayment.res | 2 +- src/Types/PaymentType.res | 2 +- src/Utilities/PaymentBody.res | 7 +++++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Payment.res b/src/Payment.res index 250dfe3a..0681c25d 100644 --- a/src/Payment.res +++ b/src/Payment.res @@ -239,7 +239,7 @@ let make = (~paymentMode, ~integrateError, ~logger) => { ~cardNumber, ~month, ~year, - ~cardHolderName="", + ~cardHolderName=None, ~cvcNumber, ~cardBrand=cardNetwork, ) @@ -250,7 +250,7 @@ let make = (~paymentMode, ~integrateError, ~logger) => { ~cardNumber, ~month, ~year, - ~cardHolderName="", + ~cardHolderName=None, ~cvcNumber=localCvcNumber, ~cardBrand=cardNetwork, ) diff --git a/src/Payments/CardPayment.res b/src/Payments/CardPayment.res index 7af2f4b2..27cf1c5d 100644 --- a/src/Payments/CardPayment.res +++ b/src/Payments/CardPayment.res @@ -142,7 +142,7 @@ let make = ( ~cardNumber, ~month, ~year, - ~cardHolderName="", + ~cardHolderName=None, ~cvcNumber, ~cardBrand=cardNetwork, ~nickname=nickname.value, diff --git a/src/Types/PaymentType.res b/src/Types/PaymentType.res index 11d4b36f..d0a2f247 100644 --- a/src/Types/PaymentType.res +++ b/src/Types/PaymentType.res @@ -862,7 +862,7 @@ let getCardDetails = (dict, str) => { expiryMonth: getString(json, "expiry_month", ""), expiryYear: getString(json, "expiry_year", ""), cardToken: getString(json, "card_token", ""), - cardHolderName: Some(getString(json, "card_holder_name", "")), + cardHolderName: getOptionString(json, "card_holder_name"), nickname: getString(json, "nick_name", ""), } }) diff --git a/src/Utilities/PaymentBody.res b/src/Utilities/PaymentBody.res index 3774f02a..09f25ebf 100644 --- a/src/Utilities/PaymentBody.res +++ b/src/Utilities/PaymentBody.res @@ -35,7 +35,7 @@ let cardPaymentBody = ( ~cardNumber, ~month, ~year, - ~cardHolderName, + ~cardHolderName=None, ~cvcNumber, ~cardBrand, ~nickname="", @@ -44,11 +44,14 @@ let cardPaymentBody = ( ("card_number", cardNumber->CardUtils.clearSpaces->JSON.Encode.string), ("card_exp_month", month->JSON.Encode.string), ("card_exp_year", year->JSON.Encode.string), - ("card_holder_name", cardHolderName->JSON.Encode.string), ("card_cvc", cvcNumber->JSON.Encode.string), ("card_issuer", ""->JSON.Encode.string), ] + cardHolderName + ->Option.map(name => cardBody->Array.push(("card_holder_name", name->JSON.Encode.string))->ignore) + ->ignore + if nickname != "" { cardBody->Array.push(("nick_name", nickname->JSON.Encode.string))->ignore }