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: mifinity wallet addition #451

Merged
merged 4 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
226 changes: 186 additions & 40 deletions public/icons/orca.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/Components/DynamicFields.res
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ let make = (
/>
</>
| CryptoCurrencyNetworks => <CryptoCurrencyNetworks />
| DateOfBirth => <DateOfBirth />
| Email
| InfoElement
| Country
Expand Down Expand Up @@ -761,6 +762,7 @@ let make = (
| ShippingAddressState
| ShippingAddressCountry(_)
| CryptoCurrencyNetworks
| DateOfBirth
| None => React.null
}}
</div>
Expand Down
1 change: 1 addition & 0 deletions src/LocaleStrings/ArabicLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} غير مدعوم في الوقت الحالي.`,
currencyNetwork: `شبكات العملات`,
expiryPlaceholder: `MM / YY`,
dateOfBirth: `تاريخ الميلاد`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/CatalanLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} no està suportat en aquest moment.`,
currencyNetwork: `Xarxes de Monedes`,
expiryPlaceholder: `MM / AA`,
dateOfBirth: `Data de naixement`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/DeutschLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} wird derzeit nicht unterstützt.`,
currencyNetwork: `Währungsnetzwerke`,
expiryPlaceholder: `MM / JJ`,
dateOfBirth: `Geburtsdatum`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/DutchLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} wordt op dit moment niet ondersteund.`,
currencyNetwork: `Valutanetwerken`,
expiryPlaceholder: `MM / JJ`,
dateOfBirth: `Geboortedatum`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/EnglishGBLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} is not supported at the moment.`,
currencyNetwork: `Currency Networks`,
expiryPlaceholder: `MM / YY`,
dateOfBirth: `Date of Birth`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/EnglishLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} is not supported at the moment.`,
currencyNetwork: `Currency Networks`,
expiryPlaceholder: `MM / YY`,
dateOfBirth: `Date of Birth`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/FrenchBelgiumLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} n'est pas pris en charge pour le moment.`,
currencyNetwork: `Réseaux Monétaires`,
expiryPlaceholder: `MM / AA`,
dateOfBirth: `Date de naissance`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/FrenchLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} n'est pas pris en charge pour le moment.`,
currencyNetwork: `Réseaux Monétaires`,
expiryPlaceholder: `MM / AA`,
dateOfBirth: `Date de naissance`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/HebrewLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} לא נתמך כרגע.`,
currencyNetwork: `רשתות מטבעות`,
expiryPlaceholder: `MM / YY`,
dateOfBirth: `תאריך לידה`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/ItalianLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} non è supportato al momento.`,
currencyNetwork: `Reti Valutarie`,
expiryPlaceholder: `MM / AA`,
dateOfBirth: `Data di nascita`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/JapaneseLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} は現在サポートされていません。`,
currencyNetwork: `通貨ネットワーク`,
expiryPlaceholder: `MM / YY`,
dateOfBirth: `生年月日`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/LocaleStringTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ type localeStrings = {
cardBrandConfiguredErrorText: string => string,
currencyNetwork: string,
expiryPlaceholder: string,
dateOfBirth: string,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/PolishLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} nie jest obecnie obsługiwany.`,
currencyNetwork: `Sieci Walutowe`,
expiryPlaceholder: `MM / RR`,
dateOfBirth: `Data urodzenia`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/PortugueseLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} não é suportado no momento.`,
currencyNetwork: `Redes de Moeda`,
expiryPlaceholder: `MM / AA`,
dateOfBirth: `Data de nascimento`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/RussianLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
`${str} в данный момент не поддерживается.`,
currencyNetwork: `Валютные сети`,
expiryPlaceholder: `MM / ГГ`,
dateOfBirth: `Дата рождения`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/SpanishLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} no está soportado en este momento.`,
currencyNetwork: `Redes de Divisas`,
expiryPlaceholder: `MM / AA`,
dateOfBirth: `Fecha de nacimiento`,
}
1 change: 1 addition & 0 deletions src/LocaleStrings/SwedishLocale.res
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ let localeStrings: LocaleStringTypes.localeStrings = {
cardBrandConfiguredErrorText: str => `${str} stöds inte för tillfället.`,
currencyNetwork: `Valutanätverk`,
expiryPlaceholder: `MM / ÅÅ`,
dateOfBirth: `Födelsedatum`,
}
79 changes: 79 additions & 0 deletions src/Payments/DateOfBirth.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
%%raw(`import ("react-datepicker/dist/react-datepicker.css")`)

let months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
]

let startYear = 1900
let currentYear = Date.getFullYear(Date.make())
let years = Array.fromInitializer(~length=currentYear - startYear, i => currentYear - i)

@react.component
let make = () => {
let {themeObj, localeString} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom)
let (selectedDate, setSelectedDate) = Recoil.useRecoilState(RecoilAtoms.dateOfBirth)

<div className="flex flex-col gap-1">
<div
className={`Label`}
style={
fontWeight: themeObj.fontWeightNormal,
fontSize: themeObj.fontSizeLg,
opacity: "0.6",
}>
{React.string(localeString.dateOfBirth)}
</div>
<DatePicker
showIcon=true
icon={<Icon name="calander" size=13 className="!px-[6px] !py-[10px]" />}
className="w-full border border-gray-300 rounded p-2"
selected={selectedDate}
onChange={date => setSelectedDate(_ => date)}
dateFormat="dd-MM-yyyy"
wrapperClassName="datepicker"
renderCustomHeader={val => {
<div className="flex gap-4 items-center justify-center m-2">
<select
className="p-1"
value={val.date->Date.getFullYear->Int.toString}
onChange={ev => {
let value = {ev->ReactEvent.Form.target}["value"]
val.changeYear(value)
}}>
{years
->Array.map(option =>
<option key={option->Int.toString} value={option->Int.toString}>
{option->React.int}
</option>
)
->React.array}
</select>
<select
className="p-1"
value={months[val.date->Date.getMonth]->Option.getOr("January")}
onChange={ev => {
let value = {ev->ReactEvent.Form.target}["value"]
val.changeMonth(months->Array.indexOf(value))
}}>
{months
->Array.map(option =>
<option key={option} value={option}> {option->React.string} </option>
)
->React.array}
</select>
</div>
}}
/>
</div>
}
25 changes: 10 additions & 15 deletions src/Payments/PaymentMethodsRecord.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type paymentMethodsFields =
| ShippingAddressState
| ShippingAddressCountry(array<string>)
| CryptoCurrencyNetworks
| DateOfBirth

let getPaymentMethodsFieldsOrder = paymentMethodField => {
switch paymentMethodField {
Expand Down Expand Up @@ -515,6 +516,13 @@ let paymentMethodsFields = [
displayName: "Local Bank Transfer",
miniIcon: None,
},
{
paymentMethodName: "mifinity",
fields: [InfoElement],
icon: Some(icon("mifinity")),
displayName: "Mifinity",
miniIcon: None,
},
]

type required_fields = {
Expand Down Expand Up @@ -549,6 +557,7 @@ let getPaymentMethodsFieldTypeFromString = (str, isBancontact) => {
| ("user_shipping_address_pincode", _) => ShippingAddressPincode
| ("user_shipping_address_state", _) => ShippingAddressState
| ("user_crypto_currency_network", _) => CryptoCurrencyNetworks
| ("user_date_of_birth", _) => DateOfBirth
| _ => None
}
}
Expand Down Expand Up @@ -625,6 +634,7 @@ let dynamicFieldsEnabledPaymentMethods = [
"giropay",
"local_bank_transfer_transfer",
"afterpay_clearpay",
"mifinity",
]

let getIsBillingField = requiredFieldType => {
Expand Down Expand Up @@ -706,8 +716,6 @@ type paymentMethod =
Cards | Wallets | PayLater | BankRedirect | BankTransfer | BankDebit | Crypto | Voucher | NONE

type cardType = Credit | Debit
type paymentMethodType =
Card(cardType) | Klarna | Affirm | AfterPay | Gpay | Paypal | ApplePay | CryptoCurrency | NONE

type paymentExperience = {
payment_experience_type: paymentFlow,
Expand Down Expand Up @@ -802,19 +810,6 @@ let getMethod = str => {
}
}

let getPaymentMethodType = str => {
switch str {
| "afterpay_clearpay" => AfterPay
| "klarna" => Klarna
| "affirm" => Affirm
| "apple_pay" => ApplePay
| "google_pay" => Gpay
| "credit" => Card(Credit)
| "debit" => Card(Debit)
| "crypto_currency" => CryptoCurrency
| _ => NONE
}
}
let getPaymentExperienceType = str => {
switch str {
| "redirect_to_url" => RedirectToURL
Expand Down
13 changes: 11 additions & 2 deletions src/Utilities/DynamicFieldsUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ let useSetInitialRequiredFields = (
let (cryptoCurrencyNetworks, setCryptoCurrencyNetworks) = Recoil.useRecoilState(
cryptoCurrencyNetworks,
)
let (dateOfBirth, setDateOfBirth) = Recoil.useRecoilState(dateOfBirth)

React.useEffect(() => {
let getNameValue = (item: PaymentMethodsRecord.required_fields) => {
Expand Down Expand Up @@ -363,6 +364,10 @@ let useSetInitialRequiredFields = (
if value !== "" && cryptoCurrencyNetworks === "" {
setCryptoCurrencyNetworks(_ => value)
}
| DateOfBirth =>
if value !== "" && dateOfBirth->Date.toDateString === "" {
setDateOfBirth(_ => dateOfBirth)
}
| SpecialField(_)
| InfoElement
| CardNumber
Expand Down Expand Up @@ -410,6 +415,7 @@ let useRequiredFieldsBody = (
let currency = Recoil.useRecoilValueFromAtom(userCurrency)
let {billingAddress} = Recoil.useRecoilValueFromAtom(optionAtom)
let cryptoCurrencyNetworks = Recoil.useRecoilValueFromAtom(cryptoCurrencyNetworks)
let dateOfBirth = Recoil.useRecoilValueFromAtom(dateOfBirth)

let getFieldValueFromFieldType = (fieldType: PaymentMethodsRecord.paymentMethodsFields) => {
switch fieldType {
Expand Down Expand Up @@ -446,6 +452,7 @@ let useRequiredFieldsBody = (
let (_, year) = CardUtils.getExpiryDates(cardExpiry)
year
| CryptoCurrencyNetworks => cryptoCurrencyNetworks
| DateOfBirth => dateOfBirth->Date.toISOString->String.slice(~start=0, ~end=10)
| CardCvc => cvcNumber
| StateAndCity
| CountryAndPincode(_)
Expand Down Expand Up @@ -521,7 +528,7 @@ let useRequiredFieldsBody = (

setRequiredFieldsBody(_ => requiredFieldsBody)
None
}, [
}, (
fullName.value,
email.value,
line1.value,
Expand All @@ -539,7 +546,8 @@ let useRequiredFieldsBody = (
cvcNumber,
selectedBank,
cryptoCurrencyNetworks,
])
dateOfBirth,
))
}

let isFieldTypeToRenderOutsideBilling = (fieldType: PaymentMethodsRecord.paymentMethodsFields) => {
Expand All @@ -552,6 +560,7 @@ let isFieldTypeToRenderOutsideBilling = (fieldType: PaymentMethodsRecord.payment
| CardCvc
| CardExpiryAndCvc
| CryptoCurrencyNetworks
| DateOfBirth
| Currency(_) => true
| _ => false
}
Expand Down
1 change: 1 addition & 0 deletions src/Utilities/PaymentUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ let paymentListLookupNew = (
"momo",
"touch_n_go",
"samsung_pay",
"mifinity",
]
let otherPaymentList = []

Expand Down
1 change: 1 addition & 0 deletions src/Utilities/RecoilAtoms.res
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ let cryptoCurrencyNetworks = Recoil.atom("cryptoCurrencyNetworks", "")
let isShowOrPayUsing = Recoil.atom("isShowOrPayUsing", false)
let areRequiredFieldsValid = Recoil.atom("areRequiredFieldsValid", true)
let areRequiredFieldsEmpty = Recoil.atom("areRequiredFieldsEmpty", false)
let dateOfBirth = Recoil.atom("dateOfBirth", Date.make())
let userBillingName = Recoil.atom("userBillingName", defaultFieldValues)

type areOneClickWalletsRendered = {
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/DatePicker.res
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ external make: (
~renderCustomHeader: customHeaderProps => React.element=?,
~showWeekNumbers: bool=?,
~placeholderText: string=?,
~className: string=?,
~wrapperClassName: string=?,
~closeOnScroll: bool=?,
) => React.element = "default"
Loading