Skip to content

Commit

Permalink
fix: fixed Appearance and Headless PaymentMethodId
Browse files Browse the repository at this point in the history
  • Loading branch information
ArushKapoorJuspay committed Jun 28, 2024
1 parent 31ad2d3 commit 6fefc9b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/Types/PaymentType.res
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ type customerMethods = {
paymentToken: string,
customerId: string,
paymentMethod: string,
paymentMethodId: string,
paymentMethodIssuer: option<string>,
card: customerCard,
paymentMethodType: option<string>,
Expand Down Expand Up @@ -181,6 +182,7 @@ let defaultCustomerMethods = {
paymentToken: "",
customerId: "",
paymentMethod: "",
paymentMethodId: "",
paymentMethodIssuer: None,
card: defaultCardDetails,
paymentMethodType: None,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
13 changes: 7 additions & 6 deletions src/Utilities/Utils.res
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,25 @@ 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
}
}

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
}
Expand Down

0 comments on commit 6fefc9b

Please sign in to comment.