diff --git a/src/Components/DynamicFields.res b/src/Components/DynamicFields.res index 021695f03..bad778e56 100644 --- a/src/Components/DynamicFields.res +++ b/src/Components/DynamicFields.res @@ -25,7 +25,10 @@ let make = ( PaymentMethodsRecord.getPaymentMethodTypeFromList( ~list, ~paymentMethod, - ~paymentMethodType, + ~paymentMethodType=PaymentUtils.getPaymentMethodName( + ~paymentMethodType=paymentMethod, + ~paymentMethodName=paymentMethodType, + ), )->Belt.Option.getWithDefault(PaymentMethodsRecord.defaultPaymentMethodType) let requiredFieldsWithBillingDetails = if paymentMethod === "card" { diff --git a/src/Components/Surcharge.res b/src/Components/Surcharge.res index 1a88b2712..0ad9e075f 100644 --- a/src/Components/Surcharge.res +++ b/src/Components/Surcharge.res @@ -10,7 +10,10 @@ let make = ( PaymentMethodsRecord.getPaymentMethodTypeFromList( ~list, ~paymentMethod, - ~paymentMethodType, + ~paymentMethodType=PaymentUtils.getPaymentMethodName( + ~paymentMethodType=paymentMethod, + ~paymentMethodName=paymentMethodType, + ), )->Belt.Option.getWithDefault(PaymentMethodsRecord.defaultPaymentMethodType) } diff --git a/src/Payments/PaymentMethodsRecord.res b/src/Payments/PaymentMethodsRecord.res index 72e30ff58..c1a7352d1 100644 --- a/src/Payments/PaymentMethodsRecord.res +++ b/src/Payments/PaymentMethodsRecord.res @@ -478,6 +478,13 @@ let paymentMethodsFields = [ fields: [InfoElement], miniIcon: Some(icon("cashtocode", ~size=19)), }, + { + paymentMethodName: "pix_transfer", + fields: [InfoElement], + icon: Some(icon("pix", ~size=26, ~width=40)), + displayName: "Pix", + miniIcon: None, + }, ] type required_fields = { @@ -560,6 +567,7 @@ let dynamicFieldsEnabledPaymentMethods = [ "eps", "ideal", "sofort", + "pix_transfer", ] let getIsBillingField = requiredFieldType => { diff --git a/src/Payments/PaymentMethodsWrapper.res b/src/Payments/PaymentMethodsWrapper.res index 2deb9ae76..a1e42a527 100644 --- a/src/Payments/PaymentMethodsWrapper.res +++ b/src/Payments/PaymentMethodsWrapper.res @@ -17,7 +17,10 @@ let make = ( let optionPaymentMethodDetails = list ->PaymentMethodsRecord.buildFromPaymentList - ->Js.Array2.find(x => x.paymentMethodName === paymentMethodName) + ->Js.Array2.find(x => + x.paymentMethodName === + PaymentUtils.getPaymentMethodName(~paymentMethodType=x.methodType, ~paymentMethodName) + ) let paymentMethodDetails = optionPaymentMethodDetails->Belt.Option.getWithDefault( PaymentMethodsRecord.defaultPaymentMethodContent, @@ -120,7 +123,7 @@ let make = ( paymentType list paymentMethod=paymentMethodDetails.methodType - paymentMethodType=paymentMethodDetails.paymentMethodName + paymentMethodType=paymentMethodName setRequiredFieldsBody /> diff --git a/src/Payments/QRCodeDisplay.res b/src/Payments/QRCodeDisplay.res index 73aa916e3..7bcdd7160 100644 --- a/src/Payments/QRCodeDisplay.res +++ b/src/Payments/QRCodeDisplay.res @@ -44,7 +44,14 @@ let make = () => { let (x, val) = entries Js.Dict.set(headers, x, val->Js.Json.decodeString->Belt.Option.getWithDefault("")) }) - let _timeExpiry = metaDataDict->getString("expiryTime", "") + let timeExpiry = + metaDataDict + ->getString("expiryTime", "") + ->Belt.Float.fromString + ->Belt.Option.getWithDefault(0.0) + if timeExpiry > 0.0 && timeExpiry < 900000.0 { + setExpiryTime(_ => timeExpiry) + } open Promise setHeaders(_ => headers->Js.Dict.entries) PaymentHelpers.pollRetrievePaymentIntent( diff --git a/src/Types/PaymentConfirmTypes.res b/src/Types/PaymentConfirmTypes.res index ffc56e75e..7e7e9cb0c 100644 --- a/src/Types/PaymentConfirmTypes.res +++ b/src/Types/PaymentConfirmTypes.res @@ -34,6 +34,7 @@ type nextAction = { bank_transfer_steps_and_charges_details: option, session_token: option, image_data_url: option, + display_to_timestamp: option, } type intent = { nextAction: nextAction, @@ -56,6 +57,7 @@ let defaultNextAction = { bank_transfer_steps_and_charges_details: None, session_token: None, image_data_url: None, + display_to_timestamp: None, } let defaultIntent = { nextAction: defaultNextAction, @@ -123,6 +125,7 @@ let getNextAction = (dict, str) => { getJsonObjFromDict(json, "session_token", Js.Dict.empty())->Js.Json.object_, ), image_data_url: Some(json->getString("image_data_url", "")), + display_to_timestamp: Some(json->getString("display_to_timestamp", "")) } }) ->Belt.Option.getWithDefault(defaultNextAction) diff --git a/src/Utilities/PaymentBody.res b/src/Utilities/PaymentBody.res index 69e60785d..1c2cca1ff 100644 --- a/src/Utilities/PaymentBody.res +++ b/src/Utilities/PaymentBody.res @@ -1450,6 +1450,24 @@ let openBankingUKBody = () => { ] } +let pixTransferBody = () => { + [ + ("payment_method", "bank_transfer"->Js.Json.string), + ("payment_method_type", "pix"->Js.Json.string), + ( + "payment_method_data", + [ + ( + "bank_transfer", + [("pix", Js.Dict.empty()->Js.Json.object_)]->Js.Dict.fromArray->Js.Json.object_, + ), + ] + ->Js.Dict.fromArray + ->Js.Json.object_, + ), + ] +} + let getPaymentBody = ( ~paymentMethod, ~fullName, @@ -1513,6 +1531,7 @@ let getPaymentBody = ( | "card_redirect" => cardRedirectBody() | "open_banking_uk" => openBankingUKBody() | "evoucher" => rewardBody(~paymentMethodType=paymentMethod) + | "pix_transfer" => pixTransferBody() | _ => [] } } diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index 04b7fb3e9..d4b016035 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -253,6 +253,7 @@ let intentCall = ( ]) } else if intent.nextAction.type_ === "qr_code_information" { let qrData = intent.nextAction.image_data_url->Belt.Option.getWithDefault("") + let expiryTime = intent.nextAction.display_to_timestamp->Belt.Option.getWithDefault("") let headerObj = Js.Dict.empty() headers->Js.Array2.forEach(entries => { let (x, val) = entries @@ -263,7 +264,7 @@ let intentCall = ( ("qrData", qrData->Js.Json.string), ("paymentIntentId", clientSecret->Js.Json.string), ("headers", headerObj->Js.Json.object_), - ("expiryTime", Js.Json.null), + ("expiryTime", expiryTime->Js.Json.string), ("url", url.href->Js.Json.string), ]->Js.Dict.fromArray handleLogging( diff --git a/src/Utilities/PaymentUtils.res b/src/Utilities/PaymentUtils.res index 456781432..f4ef8f1e1 100644 --- a/src/Utilities/PaymentUtils.res +++ b/src/Utilities/PaymentUtils.res @@ -230,3 +230,13 @@ let getDisplayNameAndIcon = ( | None => (defaultName, defaultIcon) } } + +let getPaymentMethodName = (~paymentMethodType, ~paymentMethodName) => { + if paymentMethodType == "bank_debit" { + paymentMethodName->Js.String2.replace("_debit", "") + } else if paymentMethodType == "bank_transfer" { + paymentMethodName->Js.String2.replace("_transfer", "") + } else { + paymentMethodName + } +}