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: (paymenthelpers, paymentelement) promise being unresolved #297

Merged
merged 2 commits into from
Apr 17, 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
3 changes: 2 additions & 1 deletion src/PaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ let make = (
React.useEffect(() => {
let evalMethodsList = () =>
switch methodslist {
| SemiLoaded | Loaded(_) => handlePostMessage([("ready", true->JSON.Encode.bool)])
| SemiLoaded | LoadError(_) | Loaded(_) =>
handlePostMessage([("ready", true->JSON.Encode.bool)])
| _ => ()
}
if !displaySavedPaymentMethods {
Expand Down
39 changes: 26 additions & 13 deletions src/Utilities/PaymentHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -976,26 +976,39 @@ let usePaymentIntent = (optLogger: option<OrcaLogger.loggerMake>, paymentType: p
}

switch list {
| LoadError(data)
| Loaded(data) =>
let paymentList = data->getDictFromJson->PaymentMethodsRecord.itemToObjMapper
let mandatePaymentType =
paymentList.payment_type->PaymentMethodsRecord.paymentTypeToStringMapper
switch paymentList.mandate_payment {
| Some(_) =>
switch paymentType {
| Card
| Gpay
| Applepay
| KlarnaRedirect
| Paypal
| BankDebits =>
intentWithMandate(mandatePaymentType)
| _ => intentWithoutMandate(mandatePaymentType)
if paymentList.payment_methods->Array.length > 0 {
switch paymentList.mandate_payment {
| Some(_) =>
switch paymentType {
| Card
| Gpay
| Applepay
| KlarnaRedirect
| Paypal
| BankDebits =>
intentWithMandate(mandatePaymentType)
| _ => intentWithoutMandate(mandatePaymentType)
}
| None => intentWithoutMandate(mandatePaymentType)
}
| None => intentWithoutMandate(mandatePaymentType)
} else {
postFailedSubmitResponse(
~errortype="payment_methods_empty",
~message="Payment Failed. Try again!",
)
Console.warn("Please enable atleast one Payment method.")
}
| SemiLoaded => intentWithoutMandate("")
| _ => ()
| _ =>
postFailedSubmitResponse(
~errortype="payment_methods_loading",
~message="Please wait. Try again!",
)
}
| None =>
postFailedSubmitResponse(
Expand Down
Loading