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

Add Account owner full name field to Uphold payment method #5500

Merged
merged 5 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions core/src/main/java/bisq/core/payment/UpholdAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,15 @@ public void setAccountId(String accountId) {
public String getAccountId() {
return ((UpholdAccountPayload) paymentAccountPayload).getAccountId();
}

public String getAccountOwner() {
BtcContributor marked this conversation as resolved.
Show resolved Hide resolved
return ((UpholdAccountPayload) paymentAccountPayload).getAccountOwner();
}

public void setAccountOwner(String accountOwner) {
if (accountOwner == null) {
accountOwner = "";
}
((UpholdAccountPayload) paymentAccountPayload).setAccountOwner(accountOwner);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import bisq.core.locale.Res;

import bisq.common.util.JsonExclude;

import com.google.protobuf.Message;

import java.nio.charset.StandardCharsets;
Expand All @@ -40,6 +42,10 @@
public final class UpholdAccountPayload extends PaymentAccountPayload {
private String accountId = "";

// For backward compatibility we need to exclude the new field from the contract json.
@JsonExclude
private String accountOwner = "";

public UpholdAccountPayload(String paymentMethod, String id) {
super(paymentMethod, id);
}
Expand All @@ -52,6 +58,7 @@ public UpholdAccountPayload(String paymentMethod, String id) {
private UpholdAccountPayload(String paymentMethod,
String id,
String accountId,
String accountOwner,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
Expand All @@ -60,12 +67,14 @@ private UpholdAccountPayload(String paymentMethod,
excludeFromJsonDataMap);

this.accountId = accountId;
this.accountOwner = accountOwner;
}

@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setUpholdAccountPayload(protobuf.UpholdAccountPayload.newBuilder()
.setAccountOwner(accountOwner)
.setAccountId(accountId))
.build();
}
Expand All @@ -74,6 +83,7 @@ public static UpholdAccountPayload fromProto(protobuf.PaymentAccountPayload prot
return new UpholdAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getUpholdAccountPayload().getAccountId(),
proto.getUpholdAccountPayload().getAccountOwner(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
Expand All @@ -85,12 +95,20 @@ public static UpholdAccountPayload fromProto(protobuf.PaymentAccountPayload prot

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

@Override
public String getPaymentDetailsForTradePopup() {
return getPaymentDetails();
if (accountOwner.isEmpty()) {
return
Res.get("payment.account") + ": " + accountId + "\n" +
Res.get("payment.account.owner") + ": N/A";
} else {
return
Res.get("payment.account") + ": " + accountId + "\n" +
Res.get("payment.account.owner") + ": " + accountOwner;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ public class UpholdForm extends PaymentMethodForm {

public static int addFormForBuyer(GridPane gridPane, int gridRow,
PaymentAccountPayload paymentAccountPayload) {
String accountOwner = ((UpholdAccountPayload) paymentAccountPayload).getAccountOwner();
if (accountOwner.isEmpty()) {
accountOwner = Res.get("payment.ask");
}
addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.account.owner"),
accountOwner);

addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.uphold.accountId"),
((UpholdAccountPayload) paymentAccountPayload).getAccountId());

return gridRow;
}

Expand All @@ -64,6 +72,14 @@ public UpholdForm(PaymentAccount paymentAccount, AccountAgeWitnessService accoun
public void addFormForAddAccount() {
gridRowFrom = gridRow + 1;

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

accountIdInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.uphold.accountId"));
accountIdInputTextField.setValidator(upholdValidator);
accountIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
Expand Down Expand Up @@ -102,6 +118,8 @@ public void addFormForDisplayAccount() {
upholdAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"),
Res.get(upholdAccount.getPaymentMethod().getId()));
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"),
Res.get(upholdAccount.getAccountOwner()));
TextField field = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.uphold.accountId"),
upholdAccount.getAccountId()).second;
field.setMouseTransparent(false);
Expand Down
1 change: 1 addition & 0 deletions proto/src/main/proto/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ message OKPayAccountPayload {

message UpholdAccountPayload {
string account_id = 1;
string account_owner = 2;
}

// Deprecated, not used anymore
Expand Down