Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added payment method - bancontact card #70

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android
Submodule android updated 141 files
2 changes: 1 addition & 1 deletion ios
6 changes: 3 additions & 3 deletions src/components/elements/CardFormUi.res
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ let make = (
state={cardNumberIsFocus ? cardNumber : cardNumber->String.sliceToEnd(~start=-4)}
setState={text => onChangeCardNumber(text, expireRef)}
placeholder={cardNumberIsFocus
? "1234 1234 1234 1234"
: "1234 1234 1234 1234"->String.sliceToEnd(~start=-4) ++ "..."}
? Placeholders.cardNumber
: Placeholders.cardNumber->String.sliceToEnd(~start=-4) ++ "..."}
keyboardType=#"number-pad"
enableCrossIcon=false
textColor={isCardNumberValid ? component.color : dangerColor}
Expand Down Expand Up @@ -142,7 +142,7 @@ let make = (
reference={Some(expireRef)}
state=expireDate
setState={text => onChangeCardExpire(text, cvvRef)}
placeholder="MM / YY"
placeholder=Placeholders.cardExpiry
keyboardType=#"number-pad"
enableCrossIcon=false
borderTopWidth=0.
Expand Down
52 changes: 7 additions & 45 deletions src/components/elements/PaymentSheetUi.res
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ let make = (
~onScanCard,
~keyToTrigerButtonClickError,
) => {
let getScanCardComponent = ScanCard.useScanCardComponent()
let (nativeProp, _) = React.useContext(NativePropContext.nativePropContext)
let isCardNumberValid = isCardNumberValid->Option.getOr(true)
let isExpireDateValid = isExpireDataValid->Option.getOr(true)
Expand All @@ -36,7 +37,6 @@ let make = (
}

let {
primaryColor,
component,
dangerColor,
borderRadius,
Expand Down Expand Up @@ -87,49 +87,6 @@ let make = (
None
}, [keyToTrigerButtonClickError])

let getScanCardComponent = (isScanCardAvailable, cardBrand, cardNumber) => {
CustomInput.CustomIcon(
<View style={array([viewStyle(~flexDirection=#row, ~alignItems=#center, ())])}>
<Icon name={cardBrand === "" ? "waitcard" : cardBrand} height=30. width=30. fill="black" />
<UIUtils.RenderIf condition={isScanCardAvailable && cardNumber === ""}>
{<>
<View
style={viewStyle(
~backgroundColor=component.borderColor,
~marginLeft=10.->dp,
~marginRight=10.->dp,
~height=80.->pct,
~width=1.->dp,
(),
)}
/>
<CustomTouchableOpacity
style={viewStyle(
~height=100.->pct,
~width=27.5->dp,
~display=#flex,
~alignItems=#"flex-start",
~justifyContent=#center,
(),
)}
onPress={_pressEvent => {
ScanCardModule.launchScanCard(scanCardCallback)
logger(
~logType=INFO,
~value="Launch",
~category=USER_EVENT,
~eventName=SCAN_CARD,
(),
)
}}>
<Icon name={"CAMERA"} height=25. width=25. fill=primaryColor />
</CustomTouchableOpacity>
</>}
</UIUtils.RenderIf>
</View>,
)
}

<ErrorBoundary level=FallBackScreen.Screen rootTag=nativeProp.rootTag>
<View style={viewStyle(~width=100.->pct, ~borderRadius, ())}>
<View style={viewStyle(~width=100.->pct, ())}>
Expand All @@ -151,7 +108,12 @@ let make = (
borderBottomRightRadius=0.
textColor={isCardNumberValid ? component.color : dangerColor}
enableCrossIcon=false
iconRight={getScanCardComponent(ScanCardModule.isAvailable, cardBrand, cardNumber)}
iconRight={getScanCardComponent(
~isScanCardAvailable=ScanCardModule.isAvailable,
~cardBrand,
~cardNumber,
~onScanCard=scanCardCallback,
)}
onFocus={() => {
setCardNumberIsFocus(_ => true)
onChangeCardNumber(cardNumber, nullRef)
Expand Down
50 changes: 50 additions & 0 deletions src/hooks/ScanCard.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
open ReactNative
open Style

/**
Hook returns an icon (`React.element`) for card brand.

Additonaly, returns the `scan-card` button (if feature is available for the platform).
*/
let useScanCardComponent = () => (~isScanCardAvailable, ~cardBrand, ~cardNumber, ~onScanCard) => {
let {
primaryColor,
component,
} = ThemebasedStyle.useThemeBasedStyle()
let logger = LoggerHook.useLoggerHook()

CustomInput.CustomIcon(
<View style={array([viewStyle(~flexDirection=#row, ~alignItems=#center, ())])}>
<Icon name={cardBrand === "" ? "waitcard" : cardBrand} height=30. width=30. fill="black" />
<UIUtils.RenderIf condition={isScanCardAvailable && cardNumber === ""}>
{<>
<View
style={viewStyle(
~backgroundColor=component.borderColor,
~marginLeft=10.->dp,
~marginRight=10.->dp,
~height=80.->pct,
~width=1.->dp,
(),
)}
/>
<TouchableOpacity
style={viewStyle(
~height=100.->pct,
~width=27.5->dp,
~display=#flex,
~alignItems=#"flex-start",
~justifyContent=#center,
(),
)}
onPress={_pressEvent => {
ScanCardModule.launchScanCard(onScanCard)
logger(~logType=INFO, ~value="Launch", ~category=USER_EVENT, ~eventName=SCAN_CARD, ())
}}>
<Icon name={"CAMERA"} height=25. width=25. fill=primaryColor />
</TouchableOpacity>
</>}
</UIUtils.RenderIf>
</View>,
)
}
Loading