Skip to content

Commit

Permalink
add extra info for zelle, sepa, sepa instant
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed Jan 9, 2025
1 parent 944c189 commit 7e3e1f9
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 14 deletions.
6 changes: 6 additions & 0 deletions core/src/main/java/haveno/core/offer/Offer.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,12 @@ else if (getExtraDataMap() != null && getExtraDataMap().containsKey(OfferPayload
return getExtraDataMap().get(OfferPayload.PAYPAL_EXTRA_INFO);
else if (getExtraDataMap() != null && getExtraDataMap().containsKey(OfferPayload.CASHAPP_EXTRA_INFO))
return getExtraDataMap().get(OfferPayload.CASHAPP_EXTRA_INFO);
else if (getExtraDataMap() != null && getExtraDataMap().containsKey(OfferPayload.ZELLE_EXTRA_INFO))
return getExtraDataMap().get(OfferPayload.ZELLE_EXTRA_INFO);
else if (getExtraDataMap() != null && getExtraDataMap().containsKey(OfferPayload.SEPA_EXTRA_INFO))
return getExtraDataMap().get(OfferPayload.SEPA_EXTRA_INFO);
else if (getExtraDataMap() != null && getExtraDataMap().containsKey(OfferPayload.SEPA_INSTANT_EXTRA_INFO))
return getExtraDataMap().get(OfferPayload.SEPA_INSTANT_EXTRA_INFO);
else
return "";
}
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/haveno/core/offer/OfferPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
public static final String PAY_BY_MAIL_EXTRA_INFO = "payByMailExtraInfo";
public static final String AUSTRALIA_PAYID_EXTRA_INFO = "australiaPayidExtraInfo";
public static final String PAYPAL_EXTRA_INFO = "payPalExtraInfo";
public static final String ZELLE_EXTRA_INFO = "zelleExtraInfo";
public static final String SEPA_EXTRA_INFO = "sepaExtraInfo";
public static final String SEPA_INSTANT_EXTRA_INFO = "sepaInstantExtraInfo";

// Comma separated list of ordinal of a haveno.common.app.Capability. E.g. ordinal of
// Capability.SIGNED_ACCOUNT_AGE_WITNESS is 11 and Capability.MEDIATION is 12 so if we want to signal that maker
Expand Down
18 changes: 18 additions & 0 deletions core/src/main/java/haveno/core/offer/OfferUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
import static haveno.core.offer.OfferPayload.F2F_EXTRA_INFO;
import static haveno.core.offer.OfferPayload.PAY_BY_MAIL_EXTRA_INFO;
import static haveno.core.offer.OfferPayload.PAYPAL_EXTRA_INFO;
import static haveno.core.offer.OfferPayload.SEPA_EXTRA_INFO;
import static haveno.core.offer.OfferPayload.SEPA_INSTANT_EXTRA_INFO;
import static haveno.core.offer.OfferPayload.ZELLE_EXTRA_INFO;
import static haveno.core.offer.OfferPayload.REFERRAL_ID;
import static haveno.core.offer.OfferPayload.XMR_AUTO_CONF;
import static haveno.core.offer.OfferPayload.XMR_AUTO_CONF_ENABLED_VALUE;
Expand All @@ -52,6 +55,9 @@
import haveno.core.payment.PayByMailAccount;
import haveno.core.payment.PayPalAccount;
import haveno.core.payment.PaymentAccount;
import haveno.core.payment.SepaAccount;
import haveno.core.payment.SepaInstantAccount;
import haveno.core.payment.ZelleAccount;
import haveno.core.provider.price.MarketPrice;
import haveno.core.provider.price.PriceFeedService;
import haveno.core.trade.statistics.ReferralIdService;
Expand Down Expand Up @@ -217,6 +223,18 @@ public Map<String, String> getExtraDataMap(PaymentAccount paymentAccount,
extraDataMap.put(AUSTRALIA_PAYID_EXTRA_INFO, ((AustraliaPayidAccount) paymentAccount).getExtraInfo());
}

if (paymentAccount instanceof ZelleAccount) {
extraDataMap.put(ZELLE_EXTRA_INFO, ((ZelleAccount) paymentAccount).getExtraInfo());
}

if (paymentAccount instanceof SepaAccount) {
extraDataMap.put(SEPA_EXTRA_INFO, ((SepaAccount) paymentAccount).getExtraInfo());
}

if (paymentAccount instanceof SepaInstantAccount) {
extraDataMap.put(SEPA_INSTANT_EXTRA_INFO, ((SepaInstantAccount) paymentAccount).getExtraInfo());
}

extraDataMap.put(CAPABILITIES, Capabilities.app.toStringList());

if (currencyCode.equals("XMR") && direction == OfferDirection.SELL) {
Expand Down
9 changes: 9 additions & 0 deletions core/src/main/java/haveno/core/payment/SepaAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public final class SepaAccount extends CountryBasedPaymentAccount implements Ban
PaymentAccountFormField.FieldId.BIC,
PaymentAccountFormField.FieldId.COUNTRY,
PaymentAccountFormField.FieldId.ACCEPTED_COUNTRY_CODES,
PaymentAccountFormField.FieldId.EXTRA_INFO,
PaymentAccountFormField.FieldId.SALT
);

Expand Down Expand Up @@ -104,6 +105,14 @@ public void removeAcceptedCountry(String countryCode) {
((SepaAccountPayload) paymentAccountPayload).removeAcceptedCountry(countryCode);
}

public void setExtraInfo(String extraInfo) {
((SepaAccountPayload) paymentAccountPayload).setExtraInfo(extraInfo);
}

public String getExtraInfo() {
return ((SepaAccountPayload) paymentAccountPayload).getExtraInfo();
}

@Override
public void onPersistChanges() {
super.onPersistChanges();
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/java/haveno/core/payment/SepaInstantAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import haveno.core.locale.TradeCurrency;
import haveno.core.payment.payload.PaymentAccountPayload;
import haveno.core.payment.payload.PaymentMethod;
import haveno.core.payment.payload.SepaAccountPayload;
import haveno.core.payment.payload.SepaInstantAccountPayload;
import haveno.core.payment.validation.SepaIBANValidator;
import lombok.EqualsAndHashCode;
Expand Down Expand Up @@ -90,6 +91,15 @@ public void removeAcceptedCountry(String countryCode) {
((SepaInstantAccountPayload) paymentAccountPayload).removeAcceptedCountry(countryCode);
}


public void setExtraInfo(String extraInfo) {
((SepaAccountPayload) paymentAccountPayload).setExtraInfo(extraInfo);
}

public String getExtraInfo() {
return ((SepaAccountPayload) paymentAccountPayload).getExtraInfo();
}

@Override
public void onPersistChanges() {
super.onPersistChanges();
Expand Down
9 changes: 9 additions & 0 deletions core/src/main/java/haveno/core/payment/ZelleAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public ZelleAccount() {
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
PaymentAccountFormField.FieldId.HOLDER_NAME,
PaymentAccountFormField.FieldId.EMAIL_OR_MOBILE_NR,
PaymentAccountFormField.FieldId.EXTRA_INFO,
PaymentAccountFormField.FieldId.SALT
);

Expand Down Expand Up @@ -75,4 +76,12 @@ public void setHolderName(String holderName) {
public String getHolderName() {
return ((ZelleAccountPayload) paymentAccountPayload).getHolderName();
}

public void setExtraInfo(String extraInfo) {
((ZelleAccountPayload) paymentAccountPayload).setExtraInfo(extraInfo);
}

public String getExtraInfo() {
return ((ZelleAccountPayload) paymentAccountPayload).getExtraInfo();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public final class SepaAccountPayload extends CountryBasedPaymentAccountPayload
@Setter
private String bic = "";
private String email = ""; // not used anymore but need to keep it for backward compatibility, must not be null but empty string, otherwise hash check fails for contract
@Setter
private String extraInfo = "";

// Don't use a set here as we need a deterministic ordering, otherwise the contract hash does not match
private final List<String> persistedAcceptedCountryCodes = new ArrayList<>();
Expand All @@ -73,6 +75,7 @@ private SepaAccountPayload(String paymentMethodName,
String iban,
String bic,
String email,
String extraInfo,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethodName,
Expand All @@ -87,6 +90,7 @@ private SepaAccountPayload(String paymentMethodName,
this.bic = bic;
this.email = email;
this.acceptedCountryCodes = acceptedCountryCodes;
this.extraInfo = extraInfo;
persistedAcceptedCountryCodes.addAll(acceptedCountryCodes);
}

Expand All @@ -97,7 +101,8 @@ public Message toProtoMessage() {
.setHolderName(holderName)
.setIban(iban)
.setBic(bic)
.setEmail(email);
.setEmail(email)
.setExtraInfo(extraInfo);
final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setSepaAccountPayload(builder);
Expand All @@ -117,6 +122,7 @@ public static PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload pro
sepaAccountPayloadPB.getIban(),
sepaAccountPayloadPB.getBic(),
sepaAccountPayloadPB.getEmail(),
sepaAccountPayloadPB.getExtraInfo(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
Expand Down Expand Up @@ -154,15 +160,17 @@ public void revertChanges() {
@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.owner") + " " + holderName + ", IBAN: " +
iban + ", BIC: " + bic + ", " + Res.getWithCol("payment.bank.country") + " " + getCountryCode();
iban + ", BIC: " + bic + ", " + Res.getWithCol("payment.bank.country") + " " + getCountryCode() + ", " +
Res.getWithCol("payment.shared.extraInfo") + " " + extraInfo;
}

@Override
public String getPaymentDetailsForTradePopup() {
return Res.getWithCol("payment.account.owner") + " " + holderName + "\n" +
"IBAN: " + iban + "\n" +
"BIC: " + bic + "\n" +
Res.getWithCol("payment.bank.country") + " " + CountryUtil.getNameByCode(countryCode);
Res.getWithCol("payment.bank.country") + " " + CountryUtil.getNameByCode(countryCode) + "\n" +
Res.getWithCol("payment.shared.extraInfo") + " " + extraInfo;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public final class SepaInstantAccountPayload extends CountryBasedPaymentAccountP
private String iban = "";
@Setter
private String bic = "";
private String extraInfo = "";

// Don't use a set here as we need a deterministic ordering, otherwise the contract hash does not match
private final List<String> persistedAcceptedCountryCodes = new ArrayList<>();
Expand All @@ -71,6 +72,7 @@ private SepaInstantAccountPayload(String paymentMethodName,
String holderName,
String iban,
String bic,
String extraInfo,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethodName,
Expand All @@ -83,6 +85,7 @@ private SepaInstantAccountPayload(String paymentMethodName,
this.holderName = holderName;
this.iban = iban;
this.bic = bic;
this.extraInfo = extraInfo;
persistedAcceptedCountryCodes.addAll(acceptedCountryCodes);
}

Expand All @@ -92,7 +95,8 @@ public Message toProtoMessage() {
protobuf.SepaInstantAccountPayload.newBuilder()
.setHolderName(holderName)
.setIban(iban)
.setBic(bic);
.setBic(bic)
.setExtraInfo(extraInfo);
final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setSepaInstantAccountPayload(builder);
Expand All @@ -111,6 +115,7 @@ public static PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload pro
sepaInstantAccountPayloadPB.getHolderName(),
sepaInstantAccountPayloadPB.getIban(),
sepaInstantAccountPayloadPB.getBic(),
sepaInstantAccountPayloadPB.getExtraInfo(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
Expand Down Expand Up @@ -142,15 +147,17 @@ public void revertChanges() {
@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.owner") + " " + holderName + ", IBAN: " +
iban + ", BIC: " + bic + ", " + Res.getWithCol("payment.bank.country") + " " + getCountryCode();
iban + ", BIC: " + bic + ", " + Res.getWithCol("payment.bank.country") + " " + getCountryCode() + ", " +
Res.getWithCol("payment.shared.extraInfo") + " " + extraInfo;
}

@Override
public String getPaymentDetailsForTradePopup() {
return Res.getWithCol("payment.account.owner") + " " + holderName + "\n" +
"IBAN: " + iban + "\n" +
"BIC: " + bic + "\n" +
Res.getWithCol("payment.bank.country") + " " + CountryUtil.getNameByCode(countryCode);
Res.getWithCol("payment.bank.country") + " " + CountryUtil.getNameByCode(countryCode) + "\n" +
Res.getWithCol("payment.shared.extraInfo") + " " + extraInfo;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
public final class ZelleAccountPayload extends PaymentAccountPayload implements PayloadWithHolderName {
private String emailOrMobileNr = "";
private String holderName = "";
private String extraInfo = "";

public ZelleAccountPayload(String paymentMethod, String id) {
super(paymentMethod, id);
Expand All @@ -51,6 +52,7 @@ private ZelleAccountPayload(String paymentMethod,
String id,
String emailOrMobileNr,
String holderName,
String extraInfo,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
Expand All @@ -60,14 +62,16 @@ private ZelleAccountPayload(String paymentMethod,

this.emailOrMobileNr = emailOrMobileNr;
this.holderName = holderName;
this.extraInfo = extraInfo;
}

@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setZelleAccountPayload(protobuf.ZelleAccountPayload.newBuilder()
.setEmailOrMobileNr(emailOrMobileNr)
.setHolderName(holderName))
.setHolderName(holderName)
.setExtraInfo(extraInfo))
.build();
}

Expand All @@ -76,6 +80,7 @@ public static ZelleAccountPayload fromProto(protobuf.PaymentAccountPayload proto
proto.getId(),
proto.getZelleAccountPayload().getEmailOrMobileNr(),
proto.getZelleAccountPayload().getHolderName(),
proto.getZelleAccountPayload().getExtraInfo(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
Expand All @@ -88,13 +93,15 @@ public static ZelleAccountPayload fromProto(protobuf.PaymentAccountPayload proto
@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.owner") + " " + holderName + ", " +
Res.getWithCol("payment.emailOrMobile") + " " + emailOrMobileNr;
Res.getWithCol("payment.emailOrMobile") + " " + emailOrMobileNr + ", " +
Res.getWithCol("payment.shared.extraInfo") + " " + extraInfo;
}

@Override
public String getPaymentDetailsForTradePopup() {
return Res.getWithCol("payment.account.owner") + " " + holderName + "\n" +
Res.getWithCol("payment.emailOrMobile") + " " + emailOrMobileNr;
Res.getWithCol("payment.emailOrMobile") + " " + emailOrMobileNr + "\n" +
Res.getWithCol("payment.shared.extraInfo") + " " + extraInfo;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@
import haveno.desktop.util.normalization.IBANNormalizer;
import javafx.collections.FXCollections;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextFormatter;
import javafx.scene.layout.GridPane;

import java.util.List;
import java.util.Optional;

import com.jfoenix.controls.JFXTextArea;

import static haveno.desktop.util.FormBuilder.addCompactTopLabelTextArea;
import static haveno.desktop.util.FormBuilder.addCompactTopLabelTextField;
import static haveno.desktop.util.FormBuilder.addCompactTopLabelTextFieldWithCopyIcon;
import static haveno.desktop.util.FormBuilder.addTopLabelTextArea;

public class SepaForm extends GeneralSepaForm {

Expand All @@ -60,6 +65,10 @@ public static int addFormForBuyer(GridPane gridPane, int gridRow,
// IBAN, BIC will not be translated
addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, IBAN, sepaAccountPayload.getIban());
addCompactTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, BIC, sepaAccountPayload.getBic());
TextArea textExtraInfo = addCompactTopLabelTextArea(gridPane, ++gridRow, Res.get("payment.shared.extraInfo"), "").second;
textExtraInfo.setMinHeight(70);
textExtraInfo.setEditable(false);
textExtraInfo.setText(((SepaAccountPayload) paymentAccountPayload).getExtraInfo());
return gridRow;
}

Expand Down Expand Up @@ -141,6 +150,15 @@ public void addFormForAddAccount() {
ibanInputTextField.refreshValidation();
});

TextArea extraTextArea = addTopLabelTextArea(gridPane, ++gridRow,
Res.get("payment.shared.optionalExtra"), Res.get("payment.shared.extraInfo.prompt")).second;
extraTextArea.setMinHeight(70);
((JFXTextArea) extraTextArea).setLabelFloat(false);
extraTextArea.textProperty().addListener((ov, oldValue, newValue) -> {
sepaAccount.setExtraInfo(newValue);
updateFromInputs();
});

updateFromInputs();
}

Expand Down Expand Up @@ -172,6 +190,12 @@ public void addFormForEditAccount() {

addCountriesGrid(Res.get("payment.accept.euro"), CountryUtil.getAllSepaEuroCountries());
addCountriesGrid(Res.get("payment.accept.nonEuro"), CountryUtil.getAllSepaNonEuroCountries());

TextArea textAreaExtra = addCompactTopLabelTextArea(gridPane, ++gridRow, Res.get("payment.shared.extraInfo"), "").second;
textAreaExtra.setText(sepaAccount.getExtraInfo());
textAreaExtra.setMinHeight(70);
textAreaExtra.setEditable(false);

addLimitations(true);
}

Expand Down
Loading

0 comments on commit 7e3e1f9

Please sign in to comment.