Skip to content

Commit

Permalink
refactor: \Removed Extra code spaced
Browse files Browse the repository at this point in the history
  • Loading branch information
manideepk90 committed Oct 4, 2024
1 parent e0194e4 commit a110012
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 44 deletions.
10 changes: 5 additions & 5 deletions Hyperswitch-React-Demo-App/.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
STATIC_DIR=./dist
HYPERSWITCH_PUBLISHABLE_KEY="pk_snd_a16d9cad85bc4ead9da60fcb225dbcdd"
HYPERSWITCH_SECRET_KEY="snd_YOoGvJy91AuU5X70WkWsrO3liZWCak6KqCNARhsc9ZRCK9sbFPXG1yYf3GC4xH5A"
HYPERSWITCH_SERVER_URL="https://sandbox.hyperswitch.io"
HYPERSWITCH_CLIENT_URL="http://localhost:9050"
HYPERSWITCH_PUBLISHABLE_KEY=
HYPERSWITCH_SECRET_KEY=
HYPERSWITCH_SERVER_URL=
HYPERSWITCH_CLIENT_URL=
SELF_SERVER_URL=
PROFILE_ID=""
PROFILE_ID=
56 changes: 17 additions & 39 deletions src/Utilities/PaymentHelpers.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
open Utils
open Identity
open SharedUtils

@val @scope(("window", "parent", "location")) external href: string = "href"

type searchParams = {set: (string, string) => unit}
Expand Down Expand Up @@ -896,9 +897,7 @@ let usePaymentSync = (optLogger: option<OrcaLogger.loggerMake>, paymentType: pay
switch keys.clientSecret {
| Some(clientSecret) =>
let paymentIntentID = clientSecret->getPaymentId
let headers = getHeader(
~apiKey=confirmParam.publishableKey,
)
let headers = getHeader(~apiKey=confirmParam.publishableKey)
let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey=confirmParam.publishableKey)
let uri = `${endpoint}/payments/${paymentIntentID}?force_sync=true&client_secret=${clientSecret}`

Expand Down Expand Up @@ -981,9 +980,9 @@ let usePaymentIntent = (optLogger, paymentType) => {
let paymentIntentID = clientSecret->getPaymentId
let headers = getHeader(
~apiKey=confirmParam.publishableKey,
~clientSource=paymentTypeFromUrl->CardThemeType.getPaymentModeToStrMapper
~clientSource=paymentTypeFromUrl->CardThemeType.getPaymentModeToStrMapper,
)

let returnUrlArr = [("return_url", confirmParam.return_url->JSON.Encode.string)]
let manual_retry = manualRetry ? [("retry_action", "manual_retry"->JSON.Encode.string)] : []
let body =
Expand Down Expand Up @@ -1153,9 +1152,9 @@ let useCompleteAuthorize = (optLogger: option<OrcaLogger.loggerMake>, paymentTyp
switch keys.clientSecret {
| Some(clientSecret) =>
let paymentIntentID = clientSecret->getPaymentId
let headers = getHeader(
let headers = getHeader(
~apiKey=confirmParam.publishableKey,
~clientSource=paymentTypeFromUrl->CardThemeType.getPaymentModeToStrMapper
~clientSource=paymentTypeFromUrl->CardThemeType.getPaymentModeToStrMapper,
)
let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey=confirmParam.publishableKey)
let uri = `${endpoint}/payments/${paymentIntentID}/complete_authorize`
Expand Down Expand Up @@ -1212,10 +1211,7 @@ let fetchSessions = (
) => {
open Promise
let uri = `${endpoint}/payments/session_tokens`
let headers = getHeader(
~apiKey=publishableKey,
~merchantHostname=merchantHostname,
)
let headers = getHeader(~apiKey=publishableKey, ~merchantHostname)
let paymentIntentID = clientSecret->getPaymentId
let body =
[
Expand Down Expand Up @@ -1290,9 +1286,7 @@ let fetchSessions = (

let confirmPayout = (~clientSecret, ~publishableKey, ~logger, ~customPodUri, ~uri, ~body) => {
open Promise
let headers = getHeader(
~apiKey=publishableKey,
)
let headers = getHeader(~apiKey=publishableKey)
logApi(
~optLogger=Some(logger),
~url=uri,
Expand Down Expand Up @@ -1367,9 +1361,7 @@ let createPaymentMethod = (
~body,
) => {
open Promise
let headers = getHeader(
~apiKey=publishableKey,
)
let headers = getHeader(~apiKey=publishableKey)
let uri = `${endpoint}/payment_methods`
logApi(
~optLogger=Some(logger),
Expand Down Expand Up @@ -1444,9 +1436,7 @@ let fetchPaymentMethodList = (
~endpoint,
) => {
open Promise
let headers = getHeader(
~apiKey=publishableKey,
)
let headers = getHeader(~apiKey=publishableKey)
let uri = `${endpoint}/account/payment_methods?client_secret=${clientSecret}`
logApi(
~optLogger=Some(logger),
Expand Down Expand Up @@ -1512,9 +1502,7 @@ let fetchCustomerPaymentMethodList = (
~isPaymentSession=false,
) => {
open Promise
let headers = getHeader(
~apiKey=publishableKey,
)
let headers = getHeader(~apiKey=publishableKey)
let uri = `${endpoint}/customers/payment_methods?client_secret=${clientSecret}`
logApi(
~optLogger,
Expand Down Expand Up @@ -1606,9 +1594,7 @@ let paymentIntentForPaymentSession = (
~isConfirmCall=true,
)
let uri = `${endpoint}/payments/${paymentIntentID}/confirm`
let headers = getHeader(
~apiKey=confirmParam.publishableKey,
)
let headers = getHeader(~apiKey=confirmParam.publishableKey)
let broswerInfo = BrowserSpec.broswerInfo()
let returnUrlArr = [("return_url", confirmParam.return_url->JSON.Encode.string)]

Expand Down Expand Up @@ -1653,9 +1639,7 @@ let callAuthLink = (
open Promise
let endpoint = ApiEndpoint.getApiEndPoint()
let uri = `${endpoint}/payment_methods/auth/link`
let headers = getHeader(
~apiKey=publishableKey,
)->Dict.fromArray
let headers = getHeader(~apiKey=publishableKey)->Dict.fromArray
logApi(
~optLogger,
~url=uri,
Expand Down Expand Up @@ -1763,9 +1747,7 @@ let callAuthExchange = (
("payment_method_type", paymentMethodType->JSON.Encode.string),
("public_token", publicToken->JSON.Encode.string),
]
let headers = getHeader(
~apiKey=publishableKey,
)->Dict.fromArray
let headers = getHeader(~apiKey=publishableKey)->Dict.fromArray
logApi(
~optLogger,
~url=uri,
Expand Down Expand Up @@ -1861,9 +1843,7 @@ let fetchSavedPaymentMethodList = (
~isPaymentSession=false,
) => {
open Promise
let headers = getHeader(
~apiKey=ephemeralKey,
)
let headers = getHeader(~apiKey=ephemeralKey)
let uri = `${endpoint}/customers/payment_methods`
logApi(
~optLogger,
Expand Down Expand Up @@ -1927,9 +1907,7 @@ let fetchSavedPaymentMethodList = (
let deletePaymentMethod = (~ephemeralKey, ~paymentMethodId, ~logger, ~customPodUri) => {
open Promise
let endpoint = ApiEndpoint.getApiEndPoint()
let headers = getHeader(
~apiKey=ephemeralKey,
)
let headers = getHeader(~apiKey=ephemeralKey)
let uri = `${endpoint}/payment_methods/${paymentMethodId}`
logApi(
~optLogger=Some(logger),
Expand Down Expand Up @@ -1997,7 +1975,7 @@ let calculateTax = (
) => {
open Promise
let endpoint = ApiEndpoint.getApiEndPoint()
let headers = getHeader(~apiKey=apiKey,)
let headers = getHeader(~apiKey)
let uri = `${endpoint}/payments/${paymentId}/calculate_tax`
let body = [
("client_secret", clientSecret),
Expand Down

0 comments on commit a110012

Please sign in to comment.