Js.Array2.length > 0 && !isBancontact}>
,
+ nickname: string,
}
type customerMethods = {
paymentToken: string,
@@ -164,6 +165,7 @@ let defaultCardDetails = {
expiryYear: "",
cardToken: "",
cardHolderName: None,
+ nickname: "",
}
let defaultCustomerMethods = {
paymentToken: "",
@@ -781,6 +783,7 @@ let getCardDetails = (dict, str) => {
expiryYear: getString(json, "expiry_year", ""),
cardToken: getString(json, "card_token", ""),
cardHolderName: Some(getString(json, "card_holder_name", "")),
+ nickname: getString(json, "nick_name", ""),
}
})
->Belt.Option.getWithDefault(defaultCardDetails)
diff --git a/src/Utilities/PaymentBody.res b/src/Utilities/PaymentBody.res
index c2ec6a5ef..790939f71 100644
--- a/src/Utilities/PaymentBody.res
+++ b/src/Utilities/PaymentBody.res
@@ -1,29 +1,38 @@
@val @scope("window")
external btoa: string => string = "btoa"
-let cardPaymentBody = (~cardNumber, ~month, ~year, ~cardHolderName, ~cvcNumber, ~cardBrand) => [
- ("payment_method", "card"->Js.Json.string),
- (
- "payment_method_data",
- [
- (
- "card",
- [
- ("card_number", cardNumber->CardUtils.clearSpaces->Js.Json.string),
- ("card_exp_month", month->Js.Json.string),
- ("card_exp_year", year->Js.Json.string),
- ("card_holder_name", cardHolderName->Js.Json.string),
- ("card_cvc", cvcNumber->Js.Json.string),
- ("card_issuer", ""->Js.Json.string),
- ]
- ->Js.Array2.concat(cardBrand)
- ->Js.Dict.fromArray
- ->Js.Json.object_,
- ),
- ]
- ->Js.Dict.fromArray
- ->Js.Json.object_,
- ),
-]
+let cardPaymentBody = (
+ ~cardNumber,
+ ~month,
+ ~year,
+ ~cardHolderName,
+ ~cvcNumber,
+ ~cardBrand,
+ ~nickname="",
+ (),
+) => {
+ let cardBody = [
+ ("card_number", cardNumber->CardUtils.clearSpaces->Js.Json.string),
+ ("card_exp_month", month->Js.Json.string),
+ ("card_exp_year", year->Js.Json.string),
+ ("card_holder_name", cardHolderName->Js.Json.string),
+ ("card_cvc", cvcNumber->Js.Json.string),
+ ("card_issuer", ""->Js.Json.string),
+ ]
+
+ if nickname != "" {
+ cardBody->Js.Array2.push(("nickname", nickname->Js.Json.string))->ignore
+ }
+
+ [
+ ("payment_method", "card"->Js.Json.string),
+ (
+ "payment_method_data",
+ [("card", cardBody->Js.Array2.concat(cardBrand)->Js.Dict.fromArray->Js.Json.object_)]
+ ->Js.Dict.fromArray
+ ->Js.Json.object_,
+ ),
+ ]
+}
let bancontactBody = () => [
("payment_method", "bank_redirect"->Js.Json.string),