diff --git a/src/Utilities/PaymentBody.res b/src/Utilities/PaymentBody.res index 222edc8e2..a4bec0423 100644 --- a/src/Utilities/PaymentBody.res +++ b/src/Utilities/PaymentBody.res @@ -62,7 +62,7 @@ let savedCardBody = (~paymentToken, ~customerId, ~cvcNumber) => [ ("card_cvc", cvcNumber->Js.Json.string), ] -let mandateBody = () => { +let mandateBody = paymentType => { [ ( "mandate_data", @@ -87,6 +87,7 @@ let mandateBody = () => { ->Js.Json.object_, ), ("setup_future_usage", "off_session"->Js.Json.string), + ("payment_type", {paymentType === "" ? Js.Json.null : paymentType->Js.Json.string}), ] } @@ -106,7 +107,6 @@ let achBankDebitBody = ( ("payment_method", "bank_debit"->Js.Json.string), ("setup_future_usage", "off_session"->Js.Json.string), ("payment_method_type", "ach"->Js.Json.string), - ("payment_type", {paymentType === "" ? Js.Json.null : paymentType->Js.Json.string}), ( "payment_method_data", [ @@ -154,7 +154,7 @@ let achBankDebitBody = ( ->Js.Dict.fromArray ->Js.Json.object_, ), - ]->Js.Array2.concat(mandateBody()) + ]->Js.Array2.concat(mandateBody(paymentType)) let sepaBankDebitBody = ( ~fullName, diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index e5ba00964..db722948c 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -549,11 +549,14 @@ let usePaymentIntent = (optLogger: option, paymentType: p ->Js.Json.stringify callIntent(bodyStr) } - let intentWithMandate = () => { + let intentWithMandate = mandatePaymentType => { let bodyStr = body ->Js.Array2.concat( - bodyArr->Js.Array2.concatMany([PaymentBody.mandateBody(), broswerInfo()]), + bodyArr->Js.Array2.concatMany([ + PaymentBody.mandateBody(mandatePaymentType), + broswerInfo(), + ]), ) ->Js.Dict.fromArray ->Js.Json.object_ @@ -573,7 +576,7 @@ let usePaymentIntent = (optLogger: option, paymentType: p | KlarnaRedirect | Paypal | BankDebits => - intentWithMandate() + intentWithMandate(paymentList.payment_type) | _ => intentWithoutMandate() } | None => intentWithoutMandate()