Skip to content

Commit

Permalink
Merge pull request #5791 from jmacxx/fix_monese_satispay
Browse files Browse the repository at this point in the history
Include holder name field for Monese & Satispay accounts
  • Loading branch information
ripcurlx authored Nov 4, 2021
2 parents 4cd057e + f5c653b commit 928208c
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 20 deletions.
8 changes: 8 additions & 0 deletions core/src/main/java/bisq/core/payment/MoneseAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ protected PaymentAccountPayload createPayload() {
return new MoneseAccountPayload(paymentMethod.getId(), id);
}

public void setHolderName(String accountId) {
((MoneseAccountPayload) paymentAccountPayload).setHolderName(accountId);
}

public String getHolderName() {
return ((MoneseAccountPayload) paymentAccountPayload).getHolderName();
}

public void setMobileNr(String accountId) {
((MoneseAccountPayload) paymentAccountPayload).setMobileNr(accountId);
}
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/bisq/core/payment/SatispayAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ protected PaymentAccountPayload createPayload() {
return new SatispayAccountPayload(paymentMethod.getId(), id);
}

public void setHolderName(String accountId) {
((SatispayAccountPayload) paymentAccountPayload).setHolderName(accountId);
}

public String getHolderName() {
return ((SatispayAccountPayload) paymentAccountPayload).getHolderName();
}

public void setMobileNr(String accountId) {
((SatispayAccountPayload) paymentAccountPayload).setMobileNr(accountId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
@Getter
@Slf4j
public final class MoneseAccountPayload extends PaymentAccountPayload {
private String holderName = "";
private String mobileNr = "";

public MoneseAccountPayload(String paymentMethod, String id) {
Expand All @@ -46,6 +47,7 @@ public MoneseAccountPayload(String paymentMethod, String id) {

private MoneseAccountPayload(String paymentMethod,
String id,
String holderName,
String mobileNr,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
Expand All @@ -54,27 +56,31 @@ private MoneseAccountPayload(String paymentMethod,
maxTradePeriod,
excludeFromJsonDataMap);

this.holderName = holderName;
this.mobileNr = mobileNr;
}

@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setMoneseAccountPayload(protobuf.MoneseAccountPayload.newBuilder().setMobileNr(mobileNr))
.setMoneseAccountPayload(protobuf.MoneseAccountPayload.newBuilder()
.setHolderName(holderName)
.setMobileNr(mobileNr))
.build();
}

public static MoneseAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
return new MoneseAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getMoneseAccountPayload().getHolderName(),
proto.getMoneseAccountPayload().getMobileNr(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.mobile") + " " + mobileNr;
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.userName") + " " + holderName;
}

@Override
Expand All @@ -84,6 +90,6 @@ public String getPaymentDetailsForTradePopup() {

@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(mobileNr.getBytes(StandardCharsets.UTF_8));
return super.getAgeWitnessInputData(holderName.getBytes(StandardCharsets.UTF_8));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
@Getter
@Slf4j
public final class SatispayAccountPayload extends CountryBasedPaymentAccountPayload {
private String holderName = "";
private String mobileNr = "";

public SatispayAccountPayload(String paymentMethod, String id) {
Expand All @@ -47,6 +48,7 @@ public SatispayAccountPayload(String paymentMethod, String id) {
private SatispayAccountPayload(String paymentMethod,
String id,
String countryCode,
String holderName,
String mobileNr,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
Expand All @@ -56,12 +58,14 @@ private SatispayAccountPayload(String paymentMethod,
maxTradePeriod,
excludeFromJsonDataMap);

this.holderName = holderName;
this.mobileNr = mobileNr;
}

@Override
public Message toProtoMessage() {
protobuf.SatispayAccountPayload.Builder builder = protobuf.SatispayAccountPayload.newBuilder()
.setHolderName(holderName)
.setMobileNr(mobileNr);
final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
Expand All @@ -73,18 +77,19 @@ public Message toProtoMessage() {

public static SatispayAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
protobuf.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload();
protobuf.SatispayAccountPayload paytmAccountPayloadPB = countryBasedPaymentAccountPayload.getSatispayAccountPayload();
protobuf.SatispayAccountPayload accountPayloadPB = countryBasedPaymentAccountPayload.getSatispayAccountPayload();
return new SatispayAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
paytmAccountPayloadPB.getMobileNr(),
accountPayloadPB.getHolderName(),
accountPayloadPB.getMobileNr(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.mobile") + " " + mobileNr;
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.userName") + " " + holderName;
}

@Override
Expand All @@ -94,6 +99,6 @@ public String getPaymentDetailsForTradePopup() {

@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(mobileNr.getBytes(StandardCharsets.UTF_8));
return super.getAgeWitnessInputData(holderName.getBytes(StandardCharsets.UTF_8));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import bisq.core.util.coin.CoinFormatter;
import bisq.core.util.validation.InputValidator;

import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;

Expand All @@ -41,11 +40,14 @@

public class MoneseForm extends PaymentMethodForm {
private final MoneseAccount account;
private InputTextField holderNameInputTextField;
private InputTextField mobileNrInputTextField;

public static int addFormForBuyer(GridPane gridPane, int gridRow,
PaymentAccountPayload paymentAccountPayload) {
addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.mobile"),
addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, 0, Res.get("payment.account.owner"),
((MoneseAccountPayload) paymentAccountPayload).getHolderName());
addCompactTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.mobile"),
((MoneseAccountPayload) paymentAccountPayload).getMobileNr());
return gridRow;
}
Expand All @@ -61,6 +63,13 @@ public MoneseForm(PaymentAccount paymentAccount, AccountAgeWitnessService accoun
public void addFormForAddAccount() {
gridRowFrom = gridRow + 1;

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

mobileNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.mobile"));
mobileNrInputTextField.setValidator(inputValidator);
mobileNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
Expand Down Expand Up @@ -99,17 +108,18 @@ public void addFormForDisplayAccount() {
account.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"),
Res.get(account.getPaymentMethod().getId()));
TextField field = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.mobile"),
account.getMobileNr()).second;
field.setMouseTransparent(false);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"), account.getHolderName())
.second.setMouseTransparent(false);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.mobile"), account.getMobileNr())
.second.setMouseTransparent(false);
addLimitations(true);
addCurrenciesGrid(false);
}

@Override
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& account.getMobileNr() != null
&& inputValidator.validate(account.getHolderName()).isValid
&& inputValidator.validate(account.getMobileNr()).isValid
&& account.getTradeCurrencies().size() > 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,23 @@
import bisq.core.util.coin.CoinFormatter;
import bisq.core.util.validation.InputValidator;

import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;

import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextField;
import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextFieldWithCopyIcon;
import static bisq.desktop.util.FormBuilder.addTopLabelTextField;
import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon;

public class SatispayForm extends PaymentMethodForm {
private final SatispayAccount account;
private InputTextField holderNameField;
private InputTextField mobileNrInputTextField;

public static int addFormForBuyer(GridPane gridPane, int gridRow,
PaymentAccountPayload paymentAccountPayload) {
addTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.mobile"),
((SatispayAccountPayload) paymentAccountPayload).getMobileNr(), Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE);
addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, 0, Res.get("payment.account.owner"),
((SatispayAccountPayload) paymentAccountPayload).getHolderName());
addCompactTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.mobile"),
((SatispayAccountPayload) paymentAccountPayload).getMobileNr());
return gridRow;
}

Expand All @@ -65,6 +67,13 @@ public void addFormForAddAccount() {

gridRowFrom = gridRow + 1;

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

mobileNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.mobile"));
mobileNrInputTextField.setValidator(inputValidator);
mobileNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
Expand All @@ -90,9 +99,10 @@ public void addFormForDisplayAccount() {
account.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"),
Res.get(account.getPaymentMethod().getId()));
TextField field = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.mobile"),
account.getMobileNr()).second;
field.setMouseTransparent(false);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"), account.getHolderName())
.second.setMouseTransparent(false);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.mobile"), account.getMobileNr())
.second.setMouseTransparent(false);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), account.getSingleTradeCurrency().getNameAndCode());
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.country"), account.getCountry().name);
addLimitations(true);
Expand All @@ -101,6 +111,7 @@ public void addFormForDisplayAccount() {
@Override
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& inputValidator.validate(account.getHolderName()).isValid
&& inputValidator.validate(account.getMobileNr()).isValid);
}
}

0 comments on commit 928208c

Please sign in to comment.