diff --git a/src/Payments/PaymentMethodsRecord.res b/src/Payments/PaymentMethodsRecord.res
index 8b69abc58..d5197e904 100644
--- a/src/Payments/PaymentMethodsRecord.res
+++ b/src/Payments/PaymentMethodsRecord.res
@@ -34,6 +34,7 @@ type paymentMethodsFields =
| ShippingAddressPincode
| ShippingAddressState
| ShippingAddressCountry(array)
+ | CryptoCurrencyNetworks
let getPaymentMethodsFieldsOrder = paymentMethodField => {
switch paymentMethodField {
@@ -47,10 +48,11 @@ let getPaymentMethodsFieldsOrder = paymentMethodField => {
| AddressLine2 => 5
| AddressCity => 6
| AddressState => 7
- | AddressCountry(_) => 8
- | AddressPincode => 9
| StateAndCity => 7
+ | AddressCountry(_) => 8
| CountryAndPincode(_) => 8
+ | AddressPincode => 9
+ | CryptoCurrencyNetworks => 10
| InfoElement => 99
| _ => 3
}
@@ -546,6 +548,7 @@ let getPaymentMethodsFieldTypeFromString = (str, isBancontact) => {
| ("user_shipping_address_city", _) => ShippingAddressCity
| ("user_shipping_address_pincode", _) => ShippingAddressPincode
| ("user_shipping_address_state", _) => ShippingAddressState
+ | ("user_crypto_currency_network", _) => CryptoCurrencyNetworks
| _ => None
}
}
@@ -1061,40 +1064,3 @@ let getCardNetwork = (~paymentMethodType, ~cardBrand) => {
->Array.get(0)
->Option.getOr(defaultCardNetworks)
}
-
-let paymentMethodFieldToStrMapper = (field: paymentMethodsFields) => {
- switch field {
- | Email => "Email"
- | FullName => "FullName"
- | InfoElement => "InfoElement"
- | Country => "Country"
- | Bank => "Bank"
- | SpecialField(_) => "SpecialField"
- | None => "None"
- | BillingName => "BillingName"
- | PhoneNumber => "PhoneNumber"
- | AddressLine1 => "AddressLine1"
- | AddressLine2 => "AddressLine2"
- | AddressCity => "AddressCity"
- | StateAndCity => "StateAndCity"
- | CountryAndPincode(_) => "CountryAndPincode"
- | AddressPincode => "AddressPincode"
- | AddressState => "AddressState"
- | AddressCountry(_) => "AddressCountry"
- | BlikCode => "BlikCode"
- | Currency(_) => "Currency"
- | CardNumber => "CardNumber"
- | CardExpiryMonth => "CardExpiryMonth"
- | CardExpiryYear => "CardExpiryYear"
- | CardExpiryMonthAndYear => "CardExpiryMonthAndYear"
- | CardCvc => "CardCvc"
- | CardExpiryAndCvc => "CardExpiryAndCvc"
- | ShippingName => "ShippingName"
- | ShippingAddressLine1 => "ShippingAddressLine1"
- | ShippingAddressLine2 => "ShippingAddressLine2"
- | ShippingAddressCity => "ShippingAddressCity"
- | ShippingAddressPincode => "ShippingAddressPincode"
- | ShippingAddressState => "ShippingAddressState"
- | ShippingAddressCountry(_) => "ShippingAddressCountry"
- }
-}
diff --git a/src/Payments/PaymentMethodsWrapper.res b/src/Payments/PaymentMethodsWrapper.res
index 38b3bff28..f0377ad50 100644
--- a/src/Payments/PaymentMethodsWrapper.res
+++ b/src/Payments/PaymentMethodsWrapper.res
@@ -83,7 +83,6 @@ let make = (~paymentType: CardThemeType.mode, ~paymentMethodName: string) => {
phoneNumber.countryCode->Option.getOr("") ++ phoneNumber.value,
),
~paymentExperience=paymentFlow,
- ~currency,
)
->Dict.fromArray
->JSON.Encode.object
diff --git a/src/Utilities/DynamicFieldsUtils.res b/src/Utilities/DynamicFieldsUtils.res
index 1a0e770fe..13b62e520 100644
--- a/src/Utilities/DynamicFieldsUtils.res
+++ b/src/Utilities/DynamicFieldsUtils.res
@@ -125,6 +125,7 @@ let useRequiredFieldsEmptyAndValid = (
let setAreRequiredFieldsValid = Recoil.useSetRecoilState(areRequiredFieldsValid)
let setAreRequiredFieldsEmpty = Recoil.useSetRecoilState(areRequiredFieldsEmpty)
let {billingAddress} = Recoil.useRecoilValueFromAtom(optionAtom)
+ let cryptoCurrencyNetworks = Recoil.useRecoilValueFromAtom(cryptoCurrencyNetworks)
let fieldsArrWithBillingAddress = fieldsArr->addBillingAddressIfUseBillingAddress(billingAddress)
@@ -149,6 +150,7 @@ let useRequiredFieldsEmptyAndValid = (
| AddressPincode => postalCode.value !== ""
| AddressState => state.value !== ""
| BlikCode => blikCode.value !== ""
+ | CryptoCurrencyNetworks => cryptoCurrencyNetworks !== ""
| Currency(currencyArr) => currency !== "" || currencyArr->Array.length === 0
| CardNumber => isCardValid->Option.getOr(false)
| CardExpiryMonth
@@ -185,6 +187,7 @@ let useRequiredFieldsEmptyAndValid = (
| AddressPincode => postalCode.value === ""
| AddressState => state.value === ""
| BlikCode => blikCode.value === ""
+ | CryptoCurrencyNetworks => cryptoCurrencyNetworks === ""
| Currency(currencyArr) => currency === "" && currencyArr->Array.length > 0
| CardNumber => cardNumber === ""
| CardExpiryMonth =>
@@ -261,6 +264,9 @@ let useSetInitialRequiredFields = (
logger,
)
let (currency, setCurrency) = Recoil.useLoggedRecoilState(userCurrency, "currency", logger)
+ let (cryptoCurrencyNetworks, setCryptoCurrencyNetworks) = Recoil.useRecoilState(
+ cryptoCurrencyNetworks,
+ )
React.useEffect(() => {
let getNameValue = (item: PaymentMethodsRecord.required_fields) => {
@@ -353,6 +359,10 @@ let useSetInitialRequiredFields = (
if value !== "" && selectedBank === "" {
setSelectedBank(_ => value)
}
+ | CryptoCurrencyNetworks =>
+ if value !== "" && cryptoCurrencyNetworks === "" {
+ setCryptoCurrencyNetworks(_ => value)
+ }
| SpecialField(_)
| InfoElement
| CardNumber
@@ -399,6 +409,7 @@ let useRequiredFieldsBody = (
let selectedBank = Recoil.useRecoilValueFromAtom(userBank)
let currency = Recoil.useRecoilValueFromAtom(userCurrency)
let {billingAddress} = Recoil.useRecoilValueFromAtom(optionAtom)
+ let cryptoCurrencyNetworks = Recoil.useRecoilValueFromAtom(cryptoCurrencyNetworks)
let getFieldValueFromFieldType = (fieldType: PaymentMethodsRecord.paymentMethodsFields) => {
switch fieldType {
@@ -434,6 +445,7 @@ let useRequiredFieldsBody = (
| CardExpiryYear =>
let (_, year) = CardUtils.getExpiryDates(cardExpiry)
year
+ | CryptoCurrencyNetworks => cryptoCurrencyNetworks
| CardCvc => cvcNumber
| StateAndCity
| CountryAndPincode(_)
@@ -526,6 +538,7 @@ let useRequiredFieldsBody = (
cardExpiry,
cvcNumber,
selectedBank,
+ cryptoCurrencyNetworks,
])
}
@@ -538,6 +551,7 @@ let isFieldTypeToRenderOutsideBilling = (fieldType: PaymentMethodsRecord.payment
| CardExpiryMonthAndYear
| CardCvc
| CardExpiryAndCvc
+ | CryptoCurrencyNetworks
| Currency(_) => true
| _ => false
}
diff --git a/src/Utilities/PaymentBody.res b/src/Utilities/PaymentBody.res
index dc6b4c4d3..9e3d6fad3 100644
--- a/src/Utilities/PaymentBody.res
+++ b/src/Utilities/PaymentBody.res
@@ -547,16 +547,11 @@ let applePayThirdPartySdkBody = (~connectors) => [
),
]
-let cryptoBody = (~currency) => [
+let cryptoBody = [
("payment_method", "crypto"->JSON.Encode.string),
("payment_method_type", "crypto_currency"->JSON.Encode.string),
("payment_experience", "redirect_to_url"->JSON.Encode.string),
- (
- "payment_method_data",
- [
- ("crypto", [("pay_currency", currency->JSON.Encode.string)]->Utils.getJsonFromArrayOfJson),
- ]->Utils.getJsonFromArrayOfJson,
- ),
+ ("payment_method_data", []->Utils.getJsonFromArrayOfJson),
]
let afterpayRedirectionBody = () => [
@@ -1055,11 +1050,10 @@ let getPaymentBody = (
~blikCode,
~paymentExperience: PaymentMethodsRecord.paymentFlow=RedirectToURL,
~phoneNumber,
- ~currency,
) =>
switch paymentMethodType {
| "afterpay_clearpay" => afterpayRedirectionBody()
- | "crypto_currency" => cryptoBody(~currency)
+ | "crypto_currency" => cryptoBody
| "sofort" => sofortBody(~country, ~name=fullName, ~email)
| "ideal" => iDealBody(~name=fullName, ~bankName=bank)
| "eps" => epsBody(~name=fullName, ~bankName=bank)
diff --git a/src/Utilities/RecoilAtoms.res b/src/Utilities/RecoilAtoms.res
index 40beb7a88..ace9a1639 100644
--- a/src/Utilities/RecoilAtoms.res
+++ b/src/Utilities/RecoilAtoms.res
@@ -53,6 +53,7 @@ let userBlikCode = Recoil.atom("userBlikCode", defaultFieldValues)
let fieldsComplete = Recoil.atom("fieldsComplete", false)
let isManualRetryEnabled = Recoil.atom("isManualRetryEnabled", false)
let userCurrency = Recoil.atom("userCurrency", "")
+let cryptoCurrencyNetworks = Recoil.atom("cryptoCurrencyNetworks", "")
let isShowOrPayUsing = Recoil.atom("isShowOrPayUsing", false)
let areRequiredFieldsValid = Recoil.atom("areRequiredFieldsValid", true)
let areRequiredFieldsEmpty = Recoil.atom("areRequiredFieldsEmpty", false)
diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res
index b7714e427..b1f9af103 100644
--- a/src/Utilities/Utils.res
+++ b/src/Utilities/Utils.res
@@ -1282,3 +1282,28 @@ let getStateNameFromStateCodeAndCountry = (list: JSON.t, stateCode: string, coun
}
let removeHyphen = str => str->String.replaceRegExp(%re("/-/g"), "")
+
+let currencyNetworksDict =
+ [
+ ("BTC", ["bitcoin", "bnb_smart_chain"]),
+ ("LTC", ["litecoin", "bnb_smart_chain"]),
+ ("ETH", ["ethereum", "bnb_smart_chain"]),
+ ("XRP", ["ripple", "bnb_smart_chain"]),
+ ("XLM", ["stellar", "bnb_smart_chain"]),
+ ("BCH", ["bitcoin_cash", "bnb_smart_chain"]),
+ ("ADA", ["cardano", "bnb_smart_chain"]),
+ ("SOL", ["solana", "bnb_smart_chain"]),
+ ("SHIB", ["ethereum", "bnb_smart_chain"]),
+ ("TRX", ["tron", "bnb_smart_chain"]),
+ ("DOGE", ["dogecoin", "bnb_smart_chain"]),
+ ("BNB", ["bnb_smart_chain"]),
+ ("USDT", ["ethereum", "tron", "bnb_smart_chain"]),
+ ("USDC", ["ethereum", "tron", "bnb_smart_chain"]),
+ ("DAI", ["ethereum", "bnb_smart_chain"]),
+ ]->Dict.fromArray
+
+let toSpacedUpperCase = (~str, ~delimiter) =>
+ str
+ ->String.toUpperCase
+ ->String.split(delimiter)
+ ->Array.joinWith(" ")