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

refactor(payments): add card_holder_name to request only if the value is present #836

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions src/Payment.res
Original file line number Diff line number Diff line change
@@ -239,7 +239,7 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
~cardNumber,
~month,
~year,
~cardHolderName="",
~cardHolderName=None,
~cvcNumber,
~cardBrand=cardNetwork,
)
@@ -250,7 +250,7 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
~cardNumber,
~month,
~year,
~cardHolderName="",
~cardHolderName=None,
~cvcNumber=localCvcNumber,
~cardBrand=cardNetwork,
)
2 changes: 1 addition & 1 deletion src/Payments/CardPayment.res
Original file line number Diff line number Diff line change
@@ -142,7 +142,7 @@ let make = (
~cardNumber,
~month,
~year,
~cardHolderName="",
~cardHolderName=None,
~cvcNumber,
~cardBrand=cardNetwork,
~nickname=nickname.value,
2 changes: 1 addition & 1 deletion src/Types/PaymentType.res
Original file line number Diff line number Diff line change
@@ -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", ""),
}
})
7 changes: 5 additions & 2 deletions src/Utilities/PaymentBody.res
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ let cardPaymentBody = (
~cardNumber,
~month,
~year,
~cardHolderName,
~cardHolderName=None,
~cvcNumber,
~cardBrand,
~nickname="",
@@ -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
}