Skip to content

Commit

Permalink
refactor(payments): add card_holder_name to request only if the value…
Browse files Browse the repository at this point in the history
… is present
  • Loading branch information
kashif-m committed Dec 11, 2024
1 parent 098f7ee commit 1081d14
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Payment.res
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
~cardNumber,
~month,
~year,
~cardHolderName="",
~cardHolderName=None,
~cvcNumber,
~cardBrand=cardNetwork,
)
Expand All @@ -250,7 +250,7 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
~cardNumber,
~month,
~year,
~cardHolderName="",
~cardHolderName=None,
~cvcNumber=localCvcNumber,
~cardBrand=cardNetwork,
)
Expand Down
2 changes: 1 addition & 1 deletion src/Payments/CardPayment.res
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ let make = (
~cardNumber,
~month,
~year,
~cardHolderName="",
~cardHolderName=None,
~cvcNumber,
~cardBrand=cardNetwork,
~nickname,
Expand Down
2 changes: 1 addition & 1 deletion src/Types/PaymentType.res
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ let getCardDetails = (dict, str) => {
expiryMonth: getString(json, "expiry_month", ""),
expiryYear: getString(json, "expiry_year", ""),
cardToken: getString(json, "card_token", ""),
cardHolderName: Some(getString(json, "card_holder_name", "")),
cardHolderName: getOptionString(json, "card_holder_name"),
nickname: getString(json, "nick_name", ""),
}
})
Expand Down
7 changes: 5 additions & 2 deletions src/Utilities/PaymentBody.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let cardPaymentBody = (
~cardNumber,
~month,
~year,
~cardHolderName,
~cardHolderName=None,
~cvcNumber,
~cardBrand,
~nickname="",
Expand All @@ -44,11 +44,14 @@ let cardPaymentBody = (
("card_number", cardNumber->CardUtils.clearSpaces->JSON.Encode.string),
("card_exp_month", month->JSON.Encode.string),
("card_exp_year", year->JSON.Encode.string),
("card_holder_name", cardHolderName->JSON.Encode.string),
("card_cvc", cvcNumber->JSON.Encode.string),
("card_issuer", ""->JSON.Encode.string),
]

cardHolderName
->Option.map(name => cardBody->Array.push(("card_holder_name", name->JSON.Encode.string))->ignore)
->ignore

if nickname != "" {
cardBody->Array.push(("nick_name", nickname->JSON.Encode.string))->ignore
}
Expand Down

0 comments on commit 1081d14

Please sign in to comment.