Skip to content

Commit

Permalink
fix: HS-178: Passing payment type in confirm call for all mandates (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArushKapoorJuspay authored Dec 7, 2023
1 parent 111a1c2 commit a97c7a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Utilities/PaymentBody.res
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ let savedCardBody = (~paymentToken, ~customerId, ~cvcNumber) => [
("card_cvc", cvcNumber->Js.Json.string),
]

let mandateBody = () => {
let mandateBody = paymentType => {
[
(
"mandate_data",
Expand All @@ -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}),
]
}

Expand All @@ -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",
[
Expand Down Expand Up @@ -154,7 +154,7 @@ let achBankDebitBody = (
->Js.Dict.fromArray
->Js.Json.object_,
),
]->Js.Array2.concat(mandateBody())
]->Js.Array2.concat(mandateBody(paymentType))

let sepaBankDebitBody = (
~fullName,
Expand Down
9 changes: 6 additions & 3 deletions src/Utilities/PaymentHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,14 @@ let usePaymentIntent = (optLogger: option<OrcaLogger.loggerMake>, 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_
Expand All @@ -573,7 +576,7 @@ let usePaymentIntent = (optLogger: option<OrcaLogger.loggerMake>, paymentType: p
| KlarnaRedirect
| Paypal
| BankDebits =>
intentWithMandate()
intentWithMandate(paymentList.payment_type)
| _ => intentWithoutMandate()
}
| None => intentWithoutMandate()
Expand Down

0 comments on commit a97c7a6

Please sign in to comment.