From 6fefc9b754ebdd9d03403374bad0e4786c91c3a0 Mon Sep 17 00:00:00 2001 From: Arush Date: Fri, 28 Jun 2024 18:17:05 +0530 Subject: [PATCH] fix: fixed Appearance and Headless PaymentMethodId --- src/Types/PaymentType.res | 4 ++++ src/Utilities/Utils.res | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Types/PaymentType.res b/src/Types/PaymentType.res index 5f91520e3..ecb76617d 100644 --- a/src/Types/PaymentType.res +++ b/src/Types/PaymentType.res @@ -123,6 +123,7 @@ type customerMethods = { paymentToken: string, customerId: string, paymentMethod: string, + paymentMethodId: string, paymentMethodIssuer: option, card: customerCard, paymentMethodType: option, @@ -181,6 +182,7 @@ let defaultCustomerMethods = { paymentToken: "", customerId: "", paymentMethod: "", + paymentMethodId: "", paymentMethodIssuer: None, card: defaultCardDetails, paymentMethodType: None, @@ -870,6 +872,7 @@ let itemToCustomerObjMapper = customerDict => { paymentToken: getString(dict, "payment_token", ""), customerId: getString(dict, "customer_id", ""), paymentMethod: getString(dict, "payment_method", ""), + paymentMethodId: getString(dict, "payment_method_id", ""), paymentMethodIssuer: getOptionString(dict, "payment_method_issuer"), card: getCardDetails(dict, "card"), paymentMethodType: getPaymentMethodType(dict), @@ -904,6 +907,7 @@ let getCustomerMethods = (dict, str) => { paymentToken: getString(json, "payment_token", ""), customerId: getString(json, "customer_id", ""), paymentMethod: getString(json, "payment_method", ""), + paymentMethodId: getString(json, "payment_method_id", ""), paymentMethodIssuer: Some(getString(json, "payment_method_issuer", "")), card: getCardDetails(json, "card"), paymentMethodType: getPaymentMethodType(dict), diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res index 281802612..6631b3d43 100644 --- a/src/Utilities/Utils.res +++ b/src/Utilities/Utils.res @@ -110,12 +110,14 @@ let getDecodedBoolFromJson = (json, callbackFunc, defaultValue) => { let getRequiredString = (dict, key, default, ~logger) => { let optionalStr = getOptionString(dict, key) switch optionalStr { - | None - | Some("") => { + | Some(val) => { + val == "" ? manageErrorWarning(REQUIRED_PARAMETER, ~dynamicStr=key, ~logger, ()) : () + val + } + | None => { manageErrorWarning(REQUIRED_PARAMETER, ~dynamicStr=key, ~logger, ()) optionalStr->Option.getOr(default) } - | Some(val) => val } } @@ -123,11 +125,10 @@ let getWarningString = (dict, key, default, ~logger) => { switch dict->Dict.get(key) { | Some(val) => switch val->JSON.Decode.string { - | None - | Some("") => + | Some(val) => val + | None => manageErrorWarning(TYPE_STRING_ERROR, ~dynamicStr=key, ~logger, ()) default - | Some(val) => val } | None => default }