Skip to content

Commit

Permalink
fix: HS-148: Added Currency with surcharge amount (#146)
Browse files Browse the repository at this point in the history
Co-authored-by: Praful Koppalkar <[email protected]>
  • Loading branch information
ArushKapoorJuspay and prafulkoppalkar authored Feb 16, 2024
1 parent 615fc1a commit ceadf3e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 41 deletions.
8 changes: 4 additions & 4 deletions src/Components/Surcharge.res
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let make = (
SurchargeUtils.getOneClickWalletsMessage(~list)
} else {
switch paymentMethodTypes.surcharge_details {
| Some(surchargeDetails) => SurchargeUtils.getMessage(~paymentMethod, ~surchargeDetails)
| Some(surchargeDetails) => SurchargeUtils.getMessage(~paymentMethod, ~surchargeDetails, ~list)
| None =>
if paymentMethod === "card" {
let creditPaymentMethodTypes = getPaymentMethodTypes("credit")
Expand All @@ -44,13 +44,13 @@ let make = (
let debitCardSurcharge = debitSurchargeDetails.displayTotalSurchargeAmount

if creditCardSurcharge >= debitCardSurcharge {
SurchargeUtils.getMessage(~paymentMethod, ~surchargeDetails={creditSurchargeDetails})
SurchargeUtils.getMessage(~paymentMethod, ~surchargeDetails={creditSurchargeDetails}, ~list)
} else {
SurchargeUtils.getMessage(~paymentMethod, ~surchargeDetails={debitSurchargeDetails})
SurchargeUtils.getMessage(~paymentMethod, ~surchargeDetails={debitSurchargeDetails}, ~list)
}
| (None, Some(surchargeDetails))
| (Some(surchargeDetails), None) =>
SurchargeUtils.getMessage(~paymentMethod, ~surchargeDetails)
SurchargeUtils.getMessage(~paymentMethod, ~surchargeDetails, ~list)
| (None, None) => None
}
} else {
Expand Down
12 changes: 9 additions & 3 deletions src/Components/SurchargeUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ let getSurchargeDetailsForOneClickWallets = (~list) => {
}, [])
}

let getMessage = (~surchargeDetails: PaymentMethodsRecord.surchargeDetails, ~paymentMethod) => {
let getMessage = (
~surchargeDetails: PaymentMethodsRecord.surchargeDetails,
~paymentMethod,
~list: PaymentMethodsRecord.list,
) => {
let {localeString} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom)
let surchargeValue = surchargeDetails.displayTotalSurchargeAmount->Js.Float.toString

let getLocaleStrForSurcharge = (cardLocale, altPaymentLocale) => {
paymentMethod === "card" ? cardLocale(surchargeValue) : altPaymentLocale(surchargeValue)
paymentMethod === "card"
? cardLocale(list.currency, surchargeValue)
: altPaymentLocale(list.currency, surchargeValue)
}

Some(
Expand All @@ -74,7 +80,7 @@ let getOneClickWalletsMessage = (~list) => {
let amount = wallet.surchargeDetails.displayTotalSurchargeAmount->Js.Float.toString
let myMsg =
<>
<strong> {React.string(amount)} </strong>
<strong> {React.string(`${list.currency} ${amount}`)} </strong>
{React.string(`${Utils.nbsp}${localeString.on} ${wallet.name}`)}
</>
let msgToConcat = if index === 0 {
Expand Down
68 changes: 34 additions & 34 deletions src/LocaleString.res
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ type localeStrings = {
enterFieldsText: string,
enterValidDetailsText: string,
card: string,
surchargeMsgAmount: string => React.element,
surchargeMsgAmountForCard: string => React.element,
surchargeMsgAmount: (string, string) => React.element,
surchargeMsgAmountForCard: (string, string) => React.element,
surchargeMsgAmountForOneClickWallets: string,
billingNameLabel: string,
billingNamePlaceholder: string,
Expand Down Expand Up @@ -99,14 +99,14 @@ let defaultLocale = {
enterFieldsText: "Please enter all fields",
enterValidDetailsText: "Please enter valid details",
card: "Card",
surchargeMsgAmount: str => <>
surchargeMsgAmount: (currency, str) => <>
{React.string(`A surcharge amount of${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string({`${Utils.nbsp}will be applied for this transaction`})}
</>,
surchargeMsgAmountForCard: str => <>
surchargeMsgAmountForCard: (currency, str) => <>
{React.string(`A surcharge amount of upto${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}will be applied for this transaction`)}
</>,
surchargeMsgAmountForOneClickWallets: "Additional fee applicable",
Expand Down Expand Up @@ -166,14 +166,14 @@ let localeStrings = [
enterFieldsText: "Please enter all fields",
enterValidDetailsText: "Please enter valid details",
card: "Card",
surchargeMsgAmount: str => <>
surchargeMsgAmount: (currency, str) => <>
{React.string(`A surcharge amount of${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string({`${Utils.nbsp}will be applied for this transaction`})}
</>,
surchargeMsgAmountForCard: str => <>
surchargeMsgAmountForCard: (currency, str) => <>
{React.string(`A surcharge amount of upto${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}will be applied for this transaction`)}
</>,
surchargeMsgAmountForOneClickWallets: "Additional fee applicable",
Expand Down Expand Up @@ -230,14 +230,14 @@ let localeStrings = [
enterFieldsText: `יש להזין את כל השדות`,
enterValidDetailsText: `יש להזין פרטים תקינים`,
card: `כרטיס`,
surchargeMsgAmount: str => <>
surchargeMsgAmount: (currency, str) => <>
{React.string(`סכום היטל של${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}יוחל עבור עסקה זו`)}
</>,
surchargeMsgAmountForCard: str => <>
surchargeMsgAmountForCard: (currency, str) => <>
{React.string(`סכום היטל של עד${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}יחול עבור עסקה זו`)}
</>,
surchargeMsgAmountForOneClickWallets: `תשלום נוסף חל`,
Expand Down Expand Up @@ -294,14 +294,14 @@ let localeStrings = [
enterFieldsText: `Veuillez saisir tous les champs`,
enterValidDetailsText: `Veuillez saisir des informations valides`,
card: `Carte`,
surchargeMsgAmount: str => <>
surchargeMsgAmount: (currency, str) => <>
{React.string(`Un montant supplémentaire d'${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}sera appliqué pour cette transaction`)}
</>,
surchargeMsgAmountForCard: str => <>
surchargeMsgAmountForCard: (currency, str) => <>
{React.string(`Un montant supplémentaire allant jusqu'à${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}sera appliqué pour cette transaction.`)}
</>,
surchargeMsgAmountForOneClickWallets: `Frais supplémentaires applicables`,
Expand Down Expand Up @@ -358,14 +358,14 @@ let localeStrings = [
enterFieldsText: "Please enter all fields",
enterValidDetailsText: "Please enter valid details",
card: "Card",
surchargeMsgAmount: str => <>
surchargeMsgAmount: (currency, str) => <>
{React.string(`A surcharge amount of${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}will be applied for this transaction`)}
</>,
surchargeMsgAmountForCard: str => <>
surchargeMsgAmountForCard: (currency, str) => <>
{React.string(`A surcharge amount of upto${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}will be applied for this transaction`)}
</>,
surchargeMsgAmountForOneClickWallets: "Additional fee applicable",
Expand Down Expand Up @@ -422,14 +422,14 @@ let localeStrings = [
enterFieldsText: `الرجاء إدخال كافة الحقول`,
enterValidDetailsText: `الرجاء إدخال تفاصيل صالحة`,
card: `بطاقة`,
surchargeMsgAmount: str => <>
surchargeMsgAmount: (currency, str) => <>
{React.string(`سيتم تطبيق مبلغ إضافي من${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}على هذه المعاملة`)}
</>,
surchargeMsgAmountForCard: str => <>
surchargeMsgAmountForCard: (currency, str) => <>
{React.string(`سيتم تطبيق مبلغ إضافي يصل إلى${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}على هذه المعاملة`)}
</>,
surchargeMsgAmountForOneClickWallets: `رسوم إضافية قابلة للتطبيق`,
Expand Down Expand Up @@ -486,14 +486,14 @@ let localeStrings = [
enterFieldsText: `すべてのフィールドに入力してください`,
enterValidDetailsText: `有効な詳細を入力してください`,
card: `カード`,
surchargeMsgAmount: str => <>
surchargeMsgAmount: (currency, str) => <>
{React.string(`この取引には${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}の追加料金が適用されます`)}
</>,
surchargeMsgAmountForCard: str => <>
surchargeMsgAmountForCard: (currency, str) => <>
{React.string(`この取引には${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}までの追加料金が適用されます`)}
</>,
surchargeMsgAmountForOneClickWallets: `追加料金が適用されます`,
Expand Down Expand Up @@ -550,14 +550,14 @@ let localeStrings = [
enterFieldsText: `Bitte füllen Sie alle Felder aus`,
enterValidDetailsText: `Bitte geben Sie gültige Daten ein`,
card: `Karte`,
surchargeMsgAmount: str => <>
surchargeMsgAmount: (currency, str) => <>
{React.string(`Für diese Transaktion wird ein Zuschlag in Höhe von${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}erhoben`)}
</>,
surchargeMsgAmountForCard: str => <>
surchargeMsgAmountForCard: (currency, str) => <>
{React.string(`Für diese Transaktion wird ein Zuschlagsbetrag von bis zu${Utils.nbsp}`)}
<strong> {React.string(str)} </strong>
<strong> {React.string(`${currency} ${str}`)} </strong>
{React.string(`${Utils.nbsp}erhoben`)}
</>,
surchargeMsgAmountForOneClickWallets: `Es fällt eine zusätzliche Gebühr an`,
Expand Down
3 changes: 3 additions & 0 deletions src/Payments/PaymentMethodsRecord.res
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ type mandate = {

type list = {
redirect_url: string,
currency: string,
payment_methods: array<methods>,
mandate_payment: option<mandate>,
payment_type: string,
Expand All @@ -722,6 +723,7 @@ let defaultPaymentMethodType = {

let defaultList = {
redirect_url: "",
currency: "",
payment_methods: [],
mandate_payment: None,
payment_type: "",
Expand Down Expand Up @@ -920,6 +922,7 @@ let getMandate = (dict, str) => {
let itemToObjMapper = dict => {
{
redirect_url: getString(dict, "redirect_url", ""),
currency: getString(dict, "currency", ""),
payment_methods: getMethodsArr(dict, "payment_methods"),
mandate_payment: getMandate(dict, "mandate_payment"),
payment_type: getString(dict, "payment_type", ""),
Expand Down

0 comments on commit ceadf3e

Please sign in to comment.