Skip to content

Commit

Permalink
Add HolderName to Pix account.
Browse files Browse the repository at this point in the history
  • Loading branch information
yonson2023 committed Dec 11, 2023
1 parent 5e0803a commit fcd34ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import com.google.protobuf.Message;

import org.apache.commons.lang3.ArrayUtils;

import java.nio.charset.StandardCharsets;

import java.util.HashMap;
Expand Down Expand Up @@ -84,16 +86,19 @@ public static PixAccountPayload fromProto(protobuf.PaymentAccountPayload proto)

@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.pix.key") + " " + pixKey;
return Res.get(paymentMethodId) + " - " + getPaymentDetailsForTradePopup().replace("\n", ", ");
}

@Override
public String getPaymentDetailsForTradePopup() {
return getPaymentDetails();
return (getHolderName().isEmpty() ? "" : Res.getWithCol("payment.account.owner") + " " + getHolderName() + "\n") +
Res.getWithCol("payment.pix.key") + " " + pixKey;
}

@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(pixKey.getBytes(StandardCharsets.UTF_8));
return super.getAgeWitnessInputData(ArrayUtils.addAll(
pixKey.getBytes(StandardCharsets.UTF_8),
getHolderName().getBytes(StandardCharsets.UTF_8)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public static int addFormForBuyer(GridPane gridPane, int gridRow,
PaymentAccountPayload paymentAccountPayload) {
addTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.pix.key"),
((PixAccountPayload) paymentAccountPayload).getPixKey(), Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"),
paymentAccountPayload.getHolderName());
return gridRow;
}

Expand All @@ -70,6 +72,14 @@ public void addFormForAddAccount() {
updateFromInputs();
});

InputTextField holderNameInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow,
Res.get("payment.account.owner"));
holderNameInputTextField.setValidator(inputValidator);
holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
account.setHolderName(newValue);
updateFromInputs();
});

addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), account.getSingleTradeCurrency().getNameAndCode());
addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.country"), account.getCountry().name);
addLimitations(false);
Expand All @@ -90,6 +100,8 @@ public void addFormForEditAccount() {
TextField field = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.pix.key"),
account.getPixKey()).second;
field.setMouseTransparent(false);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"),
account.getHolderName());
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), account.getSingleTradeCurrency().getNameAndCode());
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.country"), account.getCountry().name);
addLimitations(true);
Expand All @@ -98,6 +110,7 @@ public void addFormForEditAccount() {
@Override
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& inputValidator.validate(account.getHolderName()).isValid
&& inputValidator.validate(account.getPixKey()).isValid);
}
}

0 comments on commit fcd34ea

Please sign in to comment.