Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed Appearance and Headless PaymentMethodId #462

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading