Skip to content

Commit

Permalink
Merge branch 'main' into demo-app-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Jun 11, 2024
2 parents 1fb7172 + 7429831 commit 22502ac
Show file tree
Hide file tree
Showing 52 changed files with 249 additions and 168 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# [0.62.0](https://github.com/juspay/hyperswitch-web/compare/v0.61.2...v0.62.0) (2024-06-11)


### Bug Fixes

* two shimmers issue fixed ([#424](https://github.com/juspay/hyperswitch-web/issues/424)) ([78ba856](https://github.com/juspay/hyperswitch-web/commit/78ba8561e85e7dbf9f7257337b155265295d7392))


### Features

* crypto currency network added ([#403](https://github.com/juspay/hyperswitch-web/issues/403)) ([24f7297](https://github.com/juspay/hyperswitch-web/commit/24f72972e7faa45edc77f7e75248ca9c8f3334d8))

## [0.61.2](https://github.com/juspay/hyperswitch-web/compare/v0.61.1...v0.61.2) (2024-06-07)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orca-payment-page",
"version": "0.61.2",
"version": "0.62.0",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/BrowserSpec.res
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ let broswerInfo = () => {
"text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8"->JSON.Encode.string,
),
("language", navigator.language->JSON.Encode.string),
("color_depth", colorDepth->Belt.Int.toFloat->JSON.Encode.float),
("screen_height", screen.height->Belt.Int.toFloat->JSON.Encode.float),
("screen_width", screen.width->Belt.Int.toFloat->JSON.Encode.float),
("color_depth", colorDepth->Int.toFloat->JSON.Encode.float),
("screen_height", screen.height->Int.toFloat->JSON.Encode.float),
("screen_width", screen.width->Int.toFloat->JSON.Encode.float),
("time_zone", date.getTimezoneOffset()->JSON.Encode.float),
("java_enabled", true->JSON.Encode.bool),
("java_script_enabled", true->JSON.Encode.bool),
Expand Down
13 changes: 6 additions & 7 deletions src/CardUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ type options = {timeZone: string}
type dateTimeFormat = {resolvedOptions: unit => options}
@val @scope("Intl") external dateTimeFormat: unit => dateTimeFormat = "DateTimeFormat"

let toInt = val => val->Belt.Int.fromString->Option.getOr(0)
let toString = val => val->Belt.Int.toString
let toInt = val => val->Int.fromString->Option.getOr(0)
let toString = val => val->Int.toString

let getQueryParamsDictforKey = (searchParams, keyName) => {
let dict = Dict.make()
Expand Down Expand Up @@ -206,7 +206,7 @@ let getExpiryDates = val => {
let date = Date.make()->Date.toISOString
let (month, year) = splitExpiryDates(val)
let (_, currentYear) = getCurrentMonthAndYear(date)
let prefix = currentYear->Belt.Int.toString->String.slice(~start=0, ~end=2)
let prefix = currentYear->Int.toString->String.slice(~start=0, ~end=2)
(month, `${prefix}${year}`)
}
let formatExpiryToTwoDigit = expiry => {
Expand Down Expand Up @@ -269,7 +269,7 @@ let getCardBrand = cardNumber => {
isin
->String.replaceRegExp(%re("/[^\d]/g"), "")
->String.substring(~start=0, ~end=6)
->Belt.Int.fromString
->Int.fromString
->Option.getOr(0)

let range = cardRanges->Array.map(cardRange => {
Expand Down Expand Up @@ -317,12 +317,11 @@ let calculateLuhn = value => {
->Array.map(item => {
let val = item->toInt
let double = val * 2
let str = double->Belt.Int.toString
let str = double->Int.toString
let arr = str->String.split("")

switch (arr[0], arr[1]) {
| (Some(first), Some(second)) if double > 9 =>
(first->toInt + second->toInt)->Belt.Int.toString
| (Some(first), Some(second)) if double > 9 => (first->toInt + second->toInt)->Int.toString
| _ => str
}
})
Expand Down
6 changes: 3 additions & 3 deletions src/Components/AccordionContainer.res
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Loader = {
: ""
<div
className={`AccordionItem flex flex-row gap-3 animate-pulse cursor-default place-items-center`}
key={i->Belt.Int.toString}
key={i->Int.toString}
style={
minWidth: "80px",
minHeight: "60px",
Expand Down Expand Up @@ -131,7 +131,7 @@ let make = (~paymentOptions: array<string>, ~checkoutEle: React.element) => {
let isActive = payOption.paymentMethodName == selectedOption
let borderRadiusStyle = getBorderRadiusStyleForCardOptionDetails(i)
<Accordion
key={i->Belt.Int.toString}
key={i->Int.toString}
paymentOption=payOption
isActive
checkoutEle
Expand All @@ -149,7 +149,7 @@ let make = (~paymentOptions: array<string>, ~checkoutEle: React.element) => {
let isActive = payOption.paymentMethodName == selectedOption
let borderRadiusStyle = getBorderRadiusStyleForDropDownOptionDetails(i)
<Accordion
key={i->Belt.Int.toString}
key={i->Int.toString}
paymentOption=payOption
isActive
checkoutEle
Expand Down
41 changes: 41 additions & 0 deletions src/Components/CryptoCurrencyNetworks.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@react.component
let make = () => {
open DropdownField
let currencyVal = Recoil.useRecoilValueFromAtom(RecoilAtoms.userCurrency)
let {config, localeString} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom)
let (cryptoCurrencyNetworks, setCryptoCurrencyNetworks) = Recoil.useRecoilState(
RecoilAtoms.cryptoCurrencyNetworks,
)

let dropdownOptions =
Utils.currencyNetworksDict
->Dict.get(currencyVal)
->Option.getOr([])
->Array.map(item => {
label: Utils.toSpacedUpperCase(~str=item, ~delimiter="_"),
value: item,
})

let initialValue = (
dropdownOptions
->Array.get(0)
->Option.getOr({
label: "",
value: "",
})
).value

React.useEffect(() => {
setCryptoCurrencyNetworks(_ => initialValue)
None
}, [initialValue])

<DropdownField
appearance=config.appearance
fieldName=localeString.currencyNetwork
value=cryptoCurrencyNetworks
setValue=setCryptoCurrencyNetworks
disabled=false
options=dropdownOptions
/>
}
3 changes: 2 additions & 1 deletion src/Components/DynamicFields.res
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ let make = (
key={`outside-billing-${index->Int.toString}`}
className="flex flex-col w-full place-content-between"
style={
marginTop: index !== 0 || paymentMethod === "card" ? themeObj.spacingGridColumn : "",
gridColumnGap: themeObj.spacingGridRow,
}>
{switch item {
Expand Down Expand Up @@ -457,6 +456,7 @@ let make = (
optionalRequiredFields={Some(requiredFields)}
/>
</>
| CryptoCurrencyNetworks => <CryptoCurrencyNetworks />
| Email
| InfoElement
| Country
Expand Down Expand Up @@ -760,6 +760,7 @@ let make = (
| ShippingAddressPincode
| ShippingAddressState
| ShippingAddressCountry(_)
| CryptoCurrencyNetworks
| None => React.null
}}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Loader.res
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ let make = (~showText=true) => {
size=52
style={
animation: "slowShow 1.5s ease-in-out infinite",
animationDelay: {((i + 1) * 180)->Belt.Int.toString ++ "ms"},
animationDelay: {((i + 1) * 180)->Int.toString ++ "ms"},
}
name=item
key={i->Belt.Int.toString}
key={i->Int.toString}
/>
})
->React.array}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/SavedMethods.res
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ let make = (
}
let isActive = paymentTokenVal == obj.paymentToken
<SavedCardItem
key={i->Belt.Int.toString}
key={i->Int.toString}
setPaymentToken
isActive
paymentItem=obj
Expand Down
2 changes: 1 addition & 1 deletion src/Components/SurchargeUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ let useOneClickWalletsMessageGetter = (~paymentMethodListValue) => {
</>
let msgToConcat = if index === 0 {
myMsg
} else if index === oneClickWalletsArr->Belt.Array.length - 1 {
} else if index === oneClickWalletsArr->Array.length - 1 {
<>
{React.string(`${Utils.nbsp}${localeString.\"and"}${Utils.nbsp}`)}
{myMsg}
Expand Down
1 change: 1 addition & 0 deletions src/LocaleStrings/ArabicLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `انتهت صلاحية هذه البطاقة`,
cardHeader: `معلومات البطاقة`,
cardBrandConfiguredErrorText: str => `${str} غير مدعوم في الوقت الحالي.`,
currencyNetwork: `شبكات العملات`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/CatalanLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `Aquesta targeta ha caducat`,
cardHeader: `Informació de la targeta`,
cardBrandConfiguredErrorText: str => `${str} no està suportat en aquest moment.`,
currencyNetwork: `Xarxes de Monedes`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/DeutschLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `Diese Karte ist abgelaufen`,
cardHeader: `Kartendaten`,
cardBrandConfiguredErrorText: str => `${str} wird derzeit nicht unterstützt.`,
currencyNetwork: `Währungsnetzwerke`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/DutchLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `Deze kaart is verlopen`,
cardHeader: `Kaartinformatie`,
cardBrandConfiguredErrorText: str => `${str} wordt op dit moment niet ondersteund.`,
currencyNetwork: `Valutanetwerken`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/EnglishGBLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `This card has expired`,
cardHeader: `Card information`,
cardBrandConfiguredErrorText: str => `${str} is not supported at the moment.`,
currencyNetwork: `Currency Networks`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/EnglishLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `This card has expired`,
cardHeader: `Card information`,
cardBrandConfiguredErrorText: str => `${str} is not supported at the moment.`,
currencyNetwork: `Currency Networks`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/FrenchBelgiumLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `Cette carte a expiré`,
cardHeader: `Informations de carte`,
cardBrandConfiguredErrorText: str => `${str} n'est pas pris en charge pour le moment.`,
currencyNetwork: `Réseaux Monétaires`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/FrenchLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `Cette carte a expiré`,
cardHeader: `Informations de carte`,
cardBrandConfiguredErrorText: str => `${str} n'est pas pris en charge pour le moment.`,
currencyNetwork: `Réseaux Monétaires`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/HebrewLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `הכרטיס הזה פג תוקף`,
cardHeader: `מידע כרטיס`,
cardBrandConfiguredErrorText: str => `${str} לא נתמך כרגע.`,
currencyNetwork: `רשתות מטבעות`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/ItalianLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `Questa carta è scaduta`,
cardHeader: `Informazioni sulla carta`,
cardBrandConfiguredErrorText: str => `${str} non è supportato al momento.`,
currencyNetwork: `Reti Valutarie`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/JapaneseLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `このカードは期限切れです`,
cardHeader: `カード情報`,
cardBrandConfiguredErrorText: str => `${str} は現在サポートされていません。`,
currencyNetwork: `通貨ネットワーク`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/LocaleStringTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ type localeStrings = {
cardExpiredText: string,
cardHeader: string,
cardBrandConfiguredErrorText: string => string,
currencyNetwork: string,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/PolishLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `Ta karta wygasła`,
cardHeader: `Informacje o karcie`,
cardBrandConfiguredErrorText: str => `${str} nie jest obecnie obsługiwany.`,
currencyNetwork: `Sieci Walutowe`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/PortugueseLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `Este cartão expirou`,
cardHeader: `Informações do cartão`,
cardBrandConfiguredErrorText: str => `${str} não é suportado no momento.`,
currencyNetwork: `Redes de Moeda`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/RussianLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardHeader: `Информация о карте`,
cardBrandConfiguredErrorText: str =>
`${str} в данный момент не поддерживается.`,
currencyNetwork: `Валютные сети`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/SpanishLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `Esta tarjeta ha caducado`,
cardHeader: `Información de la tarjeta`,
cardBrandConfiguredErrorText: str => `${str} no está soportado en este momento.`,
currencyNetwork: `Redes de Divisas`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/SwedishLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardExpiredText: `Detta kort har gått ut`,
cardHeader: `Kortinformation`,
cardBrandConfiguredErrorText: str => `${str} stöds inte för tillfället.`,
currencyNetwork: `Valutanätverk`,
}
15 changes: 12 additions & 3 deletions src/PaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let cardsToRender = (width: int) => {
}
@react.component
let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mode) => {
let divRef = React.useRef(Nullable.null)
let sessionsObj = Recoil.useRecoilValueFromAtom(sessions)
let {
showCardFormByDefault,
Expand All @@ -25,7 +26,9 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
let (walletOptions, setWalletOptions) = React.useState(_ => [])
let {sdkHandleConfirmPayment} = Recoil.useRecoilValueFromAtom(optionAtom)

let setPaymentMethodListValue = Recoil.useSetRecoilState(PaymentUtils.paymentMethodListValue)
let (paymentMethodListValue, setPaymentMethodListValue) = Recoil.useRecoilState(
PaymentUtils.paymentMethodListValue,
)
let (cardsContainerWidth, setCardsContainerWidth) = React.useState(_ => 0)
let layoutClass = CardUtils.getLayoutClass(layout)
let (selectedOption, setSelectedOption) = Recoil.useRecoilState(selectedOptionAtom)
Expand Down Expand Up @@ -368,9 +371,15 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
</div>
</RenderIf>
{switch paymentMethodList {
| LoadError(_) => React.null
| LoadError(_) =>
<RenderIf condition={paymentMethodListValue.payment_methods->Array.length === 0}>
<ErrorBoundary.ErrorTextAndImage divRef level={Top} />
</RenderIf>
| _ =>
<RenderIf condition={paymentOptions->Array.length == 0 && walletOptions->Array.length == 0}>
<RenderIf
condition={!displaySavedPaymentMethods &&
paymentOptions->Array.length == 0 &&
walletOptions->Array.length == 0}>
<PaymentElementShimmer />
</RenderIf>
}}
Expand Down
4 changes: 2 additions & 2 deletions src/PaymentOptions.res
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module TabLoader = {
->Array.mapWithIndex((_, i) => {
<div
className={`Tab flex flex-col gap-3 animate-pulse cursor-default`}
key={i->Belt.Int.toString}
key={i->Int.toString}
style={
minWidth: "5rem",
overflowWrap: "hidden",
Expand Down Expand Up @@ -118,7 +118,7 @@ let make = (
{cardOptionDetails
->Array.mapWithIndex((payOption, i) => {
let isActive = payOption.paymentMethodName == selectedOption
<TabCard key={i->Belt.Int.toString} paymentOption=payOption isActive />
<TabCard key={i->Int.toString} paymentOption=payOption isActive />
})
->React.array}
<TabLoader cardShimmerCount />
Expand Down
4 changes: 2 additions & 2 deletions src/Payments/ApplePay.res
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ let make = (~sessionObj: option<JSON.t>) => {

let billingContact =
dict
->getDictfromDict("applePayBillingContact")
->getDictFromDict("applePayBillingContact")
->ApplePayTypes.billingContactItemToObjMapper

let shippingContact =
dict
->getDictfromDict("applePayShippingContact")
->getDictFromDict("applePayShippingContact")
->ApplePayTypes.shippingContactItemToObjMapper

let requiredFieldsBody = DynamicFieldsUtils.getApplePayRequiredFields(
Expand Down
Loading

0 comments on commit 22502ac

Please sign in to comment.