Skip to content

Commit

Permalink
fix: modified api endpoint, memoized api data, webpack fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrishab Srivatsa committed Apr 12, 2024
1 parent bffd9df commit 5f2e796
Show file tree
Hide file tree
Showing 12 changed files with 260 additions and 245 deletions.
6 changes: 3 additions & 3 deletions aws/hyperswitch_web_aws_production_deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ echo $( (aws s3api put-bucket-policy --bucket $MY_AWS_S3_BUCKET_NAME --policy "$

echo "Bucket configuration updated"

echo "Enter the backend endpoint your Hyperswitch Client will hit (hosted Hyperswitch Backend, https://beta.hyperswitch.io/api is taken by default):"
echo "Enter the backend endpoint your Hyperswitch Client will hit (hosted Hyperswitch Backend, https://beta.hyperswitch.io/api/payments is taken by default):"
read AWS_BACKEND_URL </dev/tty

if [ -z $AWS_BACKEND_URL ]; then
echo "Setting backend URL value to https://beta.hyperswitch.io/api by default"
AWS_BACKEND_URL="https://beta.hyperswitch.io/api"
echo "Setting backend URL value to https://beta.hyperswitch.io/api/payments by default"
AWS_BACKEND_URL="https://beta.hyperswitch.io/api/payments"

fi

Expand Down
12 changes: 6 additions & 6 deletions aws/hyperswitch_web_aws_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ command_discovery() {
command_discovery curl
command_discovery aws

echo "Please enter the URL where you have hosted Hyperswitch Backend (https://beta.hyperswitch.io/api) "
echo "Please enter the URL where you have hosted Hyperswitch Backend (https://beta.hyperswitch.io/api/payments) "
read HYPERSWITCH_SERVER_URL < /dev/tty

if [ -z "$HYPERSWITCH_SERVER_URL" ]; then
echo "Using default api url: https://beta.hyperswitch.io/api"
HYPERSWITCH_SERVER_URL="https://beta.hyperswitch.io/api"
echo "Using default api url: https://beta.hyperswitch.io/api/payments"
HYPERSWITCH_SERVER_URL="https://beta.hyperswitch.io/api/payments"
fi

# echo "Please enter the api url (https://beta.hyperswitch.io/api) "
# echo "Please enter the api url (https://beta.hyperswitch.io/api/payments) "
# read apiBaseUrl < /dev/tty

# if [ -z "$apiBaseUrl" ]; then
# echo "Using default api url: https://beta.hyperswitch.io/api"
# apiBaseUrl="https://beta.hyperswitch.io/api"
# echo "Using default api url: https://beta.hyperswitch.io/api/payments"
# apiBaseUrl="https://beta.hyperswitch.io/api/payments"
# fi

echo "Please enter the URL where you have hosted Hyperswitch Client SDK (https://beta.hyperswitch.io/v1) "
Expand Down
4 changes: 1 addition & 3 deletions src/App.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ let make = () => {
let clientSecret = CardUtils.getQueryParamsDictforKey(url.search, "clientSecret")
let sessionId = CardUtils.getQueryParamsDictforKey(url.search, "sessionId")
let publishableKey = CardUtils.getQueryParamsDictforKey(url.search, "publishableKey")
let endpoint =
CardUtils.getQueryParamsDictforKey(url.search, "endpoint")->decodeURIComponent
<PreMountLoader publishableKey sessionId clientSecret endpoint />
<PreMountLoader publishableKey sessionId clientSecret />
}
| "achBankTransfer"
| "bacsBankTransfer"
Expand Down
58 changes: 27 additions & 31 deletions src/Payments/PreMountLoader.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@react.component
let make = (~sessionId, ~publishableKey, ~clientSecret, ~endpoint) => {
let make = (~sessionId, ~publishableKey, ~clientSecret) => {
open Utils
let (paymentMethodsResponseSent, setPaymentMethodsResponseSent) = React.useState(_ => false)
let (
Expand All @@ -15,36 +15,32 @@ let make = (~sessionId, ~publishableKey, ~clientSecret, ~endpoint) => {
(),
)

let (
paymentMethodsResponse,
customerPaymentMethodsResponse,
sessionTokensResponse,
) = React.useMemo0(() => {
(
PaymentHelpers.fetchPaymentMethodList(
~clientSecret,
~publishableKey,
~logger,
~switchToCustomPod=false,
~endpoint,
),
PaymentHelpers.fetchCustomerDetails(
~clientSecret,
~publishableKey,
~optLogger=Some(logger),
~switchToCustomPod=false,
~endpoint,
),
PaymentHelpers.fetchSessions(
~clientSecret,
~publishableKey,
~optLogger=Some(logger),
~switchToCustomPod=false,
~endpoint,
(),
),
)
})
let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey, ())

let (paymentMethodsResponse, customerPaymentMethodsResponse, sessionTokensResponse) = (
PaymentHelpers.fetchPaymentMethodList(
~clientSecret,
~publishableKey,
~logger,
~switchToCustomPod=false,
~endpoint,
),
PaymentHelpers.fetchCustomerPaymentMethodList(
~clientSecret,
~publishableKey,
~optLogger=Some(logger),
~switchToCustomPod=false,
~endpoint,
),
PaymentHelpers.fetchSessions(
~clientSecret,
~publishableKey,
~optLogger=Some(logger),
~switchToCustomPod=false,
~endpoint,
(),
),
)

let sendPromiseData = (promise, key) => {
open Promise
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/ApiEndpoint.res
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let getApiEndPoint = (~publishableKey="", ~isConfirmCall=false, ()) => {
| Some(str) => str
| None =>
let backendEndPoint = isConfirmCall ? GlobalVars.confirmEndPoint : GlobalVars.backendEndPoint
GlobalVars.isProd && testMode ? "https://beta.hyperswitch.io/api" : backendEndPoint
GlobalVars.isProd && testMode ? "https://beta.hyperswitch.io/api/payments" : backendEndPoint
}
}

Expand Down
Loading

0 comments on commit 5f2e796

Please sign in to comment.