From b3413ac5f06654b2b8dbc19183f17b40e26e9f49 Mon Sep 17 00:00:00 2001 From: Vrishab Srivatsa Date: Wed, 13 Sep 2023 12:59:55 +0530 Subject: [PATCH] Log headers as well --- src/Utilities/PaymentHelpers.res | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index d1d49c442..ff0403d87 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -476,7 +476,7 @@ let usePaymentIntent = (optLogger: option, paymentType: p ]) let uri = `${endpoint}/payments/${paymentIntentID}/confirm` let fetchMethod = Fetch.Post - let loggerPayload = body->Js.Dict.fromArray->Js.Json.object_->Js.Json.stringify + // let loggerPayload = body->Js.Dict.fromArray->Js.Json.object_->Js.Json.stringify let callIntent = body => { let maskedPayload = @@ -485,10 +485,27 @@ let usePaymentIntent = (optLogger: option, paymentType: p ->Belt.Option.getWithDefault(Js.Json.null) ->Utils.getDictFromJson ->maskPayload + let loggerPayload = + [ + ("payload", maskedPayload->Js.Json.string), + ( + "headers", + headers + ->Js.Array2.map(header => { + let (key, value) = header + (key, value->Js.Json.string) + }) + ->Js.Dict.fromArray + ->Js.Json.object_, + ), + ] + ->Js.Dict.fromArray + ->Js.Json.object_ + ->Js.Json.stringify if paymentType == Card { handleLogging( ~optLogger, - ~value=maskedPayload, + ~value=loggerPayload, ~eventName=PAYMENT_ATTEMPT, ~paymentMethod="CARD", ) @@ -497,7 +514,7 @@ let usePaymentIntent = (optLogger: option, paymentType: p if str === "payment_method_type" { handleLogging( ~optLogger, - ~value=maskedPayload, + ~value=loggerPayload, ~eventName=PAYMENT_ATTEMPT, ~paymentMethod=json->Js.Json.decodeString->Belt.Option.getWithDefault(""), )