support extra info for australia payid account #976

This commit is contained in:
woodser 2024-06-04 11:54:08 -04:00
parent f252265ede
commit f6c35ba6f3
12 changed files with 101 additions and 10 deletions

View File

@ -73,7 +73,8 @@ public final class PaymentAccountForm implements PersistablePayload {
SWIFT,
TRANSFERWISE,
UPHOLD,
ZELLE;
ZELLE,
AUSTRALIA_PAYID;
public static PaymentAccountForm.FormId fromProto(protobuf.PaymentAccountForm.FormId formId) {
return ProtoUtil.enumFromProto(PaymentAccountForm.FormId.class, formId.name());

View File

@ -408,6 +408,8 @@ public class Offer implements NetworkPayload, PersistablePayload {
return getExtraDataMap().get(OfferPayload.F2F_EXTRA_INFO);
else if (getExtraDataMap() != null && getExtraDataMap().containsKey(OfferPayload.PAY_BY_MAIL_EXTRA_INFO))
return getExtraDataMap().get(OfferPayload.PAY_BY_MAIL_EXTRA_INFO);
else if (getExtraDataMap() != null && getExtraDataMap().containsKey(OfferPayload.AUSTRALIA_PAYID_EXTRA_INFO))
return getExtraDataMap().get(OfferPayload.AUSTRALIA_PAYID_EXTRA_INFO);
else
return "";
}

View File

@ -99,6 +99,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
public static final String F2F_CITY = "f2fCity";
public static final String F2F_EXTRA_INFO = "f2fExtraInfo";
public static final String PAY_BY_MAIL_EXTRA_INFO = "payByMailExtraInfo";
public static final String AUSTRALIA_PAYID_EXTRA_INFO = "australiaPayidExtraInfo";
// 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

View File

@ -35,6 +35,7 @@ import haveno.core.monetary.Price;
import haveno.core.monetary.TraditionalMoney;
import haveno.core.monetary.Volume;
import static haveno.core.offer.OfferPayload.ACCOUNT_AGE_WITNESS_HASH;
import static haveno.core.offer.OfferPayload.AUSTRALIA_PAYID_EXTRA_INFO;
import static haveno.core.offer.OfferPayload.CAPABILITIES;
import static haveno.core.offer.OfferPayload.F2F_CITY;
import static haveno.core.offer.OfferPayload.F2F_EXTRA_INFO;
@ -42,6 +43,8 @@ import static haveno.core.offer.OfferPayload.PAY_BY_MAIL_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;
import haveno.core.payment.AustraliaPayidAccount;
import haveno.core.payment.F2FAccount;
import haveno.core.payment.PayByMailAccount;
import haveno.core.payment.PaymentAccount;
@ -197,6 +200,10 @@ public class OfferUtil {
extraDataMap.put(PAY_BY_MAIL_EXTRA_INFO, ((PayByMailAccount) paymentAccount).getExtraInfo());
}
if (paymentAccount instanceof AustraliaPayidAccount) {
extraDataMap.put(AUSTRALIA_PAYID_EXTRA_INFO, ((AustraliaPayidAccount) paymentAccount).getExtraInfo());
}
extraDataMap.put(CAPABILITIES, Capabilities.app.toStringList());
if (currencyCode.equals("XMR") && direction == OfferDirection.SELL) {

View File

@ -36,6 +36,14 @@ public final class AustraliaPayidAccount extends PaymentAccount {
setSingleTradeCurrency(SUPPORTED_CURRENCIES.get(0));
}
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
PaymentAccountFormField.FieldId.BANK_ACCOUNT_NAME,
PaymentAccountFormField.FieldId.PAYID,
PaymentAccountFormField.FieldId.EXTRA_INFO,
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
PaymentAccountFormField.FieldId.SALT
);
@Override
protected PaymentAccountPayload createPayload() {
return new AustraliaPayidAccountPayload(paymentMethod.getId(), id);
@ -48,7 +56,7 @@ public final class AustraliaPayidAccount extends PaymentAccount {
@Override
public @NonNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
throw new RuntimeException("Not implemented");
return INPUT_FIELD_IDS;
}
public String getPayid() {
@ -68,4 +76,12 @@ public final class AustraliaPayidAccount extends PaymentAccount {
if (bankAccountName == null) bankAccountName = "";
((AustraliaPayidAccountPayload) paymentAccountPayload).setBankAccountName(bankAccountName);
}
public void setExtraInfo(String extraInfo) {
((AustraliaPayidAccountPayload) paymentAccountPayload).setExtraInfo(extraInfo);
}
public String getExtraInfo() {
return ((AustraliaPayidAccountPayload) paymentAccountPayload).getExtraInfo();
}
}

View File

@ -416,7 +416,8 @@ public abstract class PaymentAccount implements PersistablePayload {
case ANSWER:
throw new IllegalArgumentException("Not implemented");
case BANK_ACCOUNT_NAME:
throw new IllegalArgumentException("Not implemented");
processValidationResult(new LengthValidator(2, 100).validate(value));
break;
case BANK_ACCOUNT_NUMBER:
throw new IllegalArgumentException("Not implemented");
case BANK_ACCOUNT_TYPE:
@ -515,7 +516,8 @@ public abstract class PaymentAccount implements PersistablePayload {
case NATIONAL_ACCOUNT_ID:
throw new IllegalArgumentException("Not implemented");
case PAYID:
throw new IllegalArgumentException("Not implemented");
processValidationResult(new LengthValidator(2, 100).validate(value));
break;
case PIX_KEY:
throw new IllegalArgumentException("Not implemented");
case POSTAL_ADDRESS:
@ -596,7 +598,11 @@ public abstract class PaymentAccount implements PersistablePayload {
case ANSWER:
throw new IllegalArgumentException("Not implemented");
case BANK_ACCOUNT_NAME:
throw new IllegalArgumentException("Not implemented");
field.setComponent(PaymentAccountFormField.Component.TEXT);
field.setLabel(Res.get("payment.account.owner"));
field.setMinLength(2);
field.setMaxLength(100);
break;
case BANK_ACCOUNT_NUMBER:
throw new IllegalArgumentException("Not implemented");
case BANK_ACCOUNT_TYPE:
@ -724,7 +730,9 @@ public abstract class PaymentAccount implements PersistablePayload {
case NATIONAL_ACCOUNT_ID:
throw new IllegalArgumentException("Not implemented");
case PAYID:
throw new IllegalArgumentException("Not implemented");
field.setComponent(PaymentAccountFormField.Component.TEXT);
field.setLabel(Res.get("payment.email.mobile"));
break;
case PIX_KEY:
throw new IllegalArgumentException("Not implemented");
case POSTAL_ADDRESS:

View File

@ -38,6 +38,7 @@ import java.util.Map;
public final class AustraliaPayidAccountPayload extends PaymentAccountPayload {
private String payid = "";
private String bankAccountName = "";
private String extraInfo = "";
public AustraliaPayidAccountPayload(String paymentMethod, String id) {
super(paymentMethod, id);
@ -52,6 +53,7 @@ public final class AustraliaPayidAccountPayload extends PaymentAccountPayload {
String id,
String payid,
String bankAccountName,
String extraInfo,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
@ -61,6 +63,7 @@ public final class AustraliaPayidAccountPayload extends PaymentAccountPayload {
this.payid = payid;
this.bankAccountName = bankAccountName;
this.extraInfo = extraInfo;
}
@Override
@ -70,6 +73,7 @@ public final class AustraliaPayidAccountPayload extends PaymentAccountPayload {
protobuf.AustraliaPayidPayload.newBuilder()
.setPayid(payid)
.setBankAccountName(bankAccountName)
.setExtraInfo(extraInfo)
).build();
}
@ -79,6 +83,7 @@ public final class AustraliaPayidAccountPayload extends PaymentAccountPayload {
proto.getId(),
AustraliaPayidPayload.getPayid(),
AustraliaPayidPayload.getBankAccountName(),
AustraliaPayidPayload.getExtraInfo(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
@ -97,7 +102,8 @@ public final class AustraliaPayidAccountPayload extends PaymentAccountPayload {
public String getPaymentDetailsForTradePopup() {
return
Res.get("payment.australia.payid") + ": " + payid + "\n" +
Res.get("payment.account.owner") + ": " + bankAccountName;
Res.get("payment.account.owner") + ": " + bankAccountName + "\n" +
Res.get("payment.shared.extraInfo") + ": " + extraInfo;
}

View File

@ -363,7 +363,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
SWIFT_ID,
TRANSFERWISE_ID,
UPHOLD_ID,
ZELLE_ID);
ZELLE_ID,
AUSTRALIA_PAYID_ID);
return paymentMethods.stream().filter(paymentMethod -> paymentMethodIds.contains(paymentMethod.getId())).collect(Collectors.toList());
}

View File

@ -29,12 +29,17 @@ import haveno.core.util.coin.CoinFormatter;
import haveno.core.util.validation.InputValidator;
import haveno.desktop.components.InputTextField;
import haveno.desktop.util.FormBuilder;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import static haveno.desktop.util.FormBuilder.addCompactTopLabelTextArea;
import static haveno.desktop.util.FormBuilder.addCompactTopLabelTextField;
import static haveno.desktop.util.FormBuilder.addTopLabelTextArea;
import static haveno.desktop.util.FormBuilder.addTopLabelTextField;
import com.jfoenix.controls.JFXTextArea;
public class AustraliaPayidForm extends PaymentMethodForm {
private final AustraliaPayidAccount australiaPayidAccount;
private final AustraliaPayidValidator australiaPayidValidator;
@ -42,8 +47,15 @@ public class AustraliaPayidForm extends PaymentMethodForm {
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) {
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"),
((AustraliaPayidAccountPayload) paymentAccountPayload).getBankAccountName());
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.payid"),
((AustraliaPayidAccountPayload) paymentAccountPayload).getPayid());
AustraliaPayidAccountPayload payId = (AustraliaPayidAccountPayload) paymentAccountPayload;
TextArea textExtraInfo = addCompactTopLabelTextArea(gridPane, gridRow, 1, Res.get("payment.shared.extraInfo"), "").second;
textExtraInfo.setMinHeight(70);
textExtraInfo.setEditable(false);
textExtraInfo.setText(payId.getExtraInfo());
return gridRow;
}
@ -78,6 +90,15 @@ public class AustraliaPayidForm extends PaymentMethodForm {
updateFromInputs();
});
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) -> {
australiaPayidAccount.setExtraInfo(newValue);
updateFromInputs();
});
TradeCurrency singleTradeCurrency = australiaPayidAccount.getSingleTradeCurrency();
String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "null";
addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);
@ -96,11 +117,19 @@ public class AustraliaPayidForm extends PaymentMethodForm {
addAccountNameTextFieldWithAutoFillToggleButton();
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"),
Res.get(australiaPayidAccount.getPaymentMethod().getId()));
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.payid"),
australiaPayidAccount.getPayid());
TextField field = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"),
australiaPayidAccount.getBankAccountName()).second;
field.setMouseTransparent(false);
TextArea textAreaExtra = addCompactTopLabelTextArea(gridPane, ++gridRow, Res.get("payment.shared.extraInfo"), "").second;
textAreaExtra.setText(australiaPayidAccount.getExtraInfo());
textAreaExtra.setMinHeight(70);
textAreaExtra.setEditable(false);
TradeCurrency singleTradeCurrency = australiaPayidAccount.getSingleTradeCurrency();
String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "null";
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);

View File

@ -158,7 +158,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
private int gridRow = 0;
private final HashMap<String, Boolean> paymentAccountWarningDisplayed = new HashMap<>();
private boolean offerDetailsWindowDisplayed, zelleWarningDisplayed, fasterPaymentsWarningDisplayed,
takeOfferFromUnsignedAccountWarningDisplayed, payByMailWarningDisplayed, cashAtAtmWarningDisplayed;
takeOfferFromUnsignedAccountWarningDisplayed, payByMailWarningDisplayed, cashAtAtmWarningDisplayed, australiaPayidWarningDisplayed;
private SimpleBooleanProperty errorPopupDisplayed;
private ChangeListener<Boolean> amountFocusedListener, getShowWalletFundedNotificationListener;
@ -267,6 +267,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
maybeShowAccountWarning(lastPaymentAccount, model.dataModel.isBuyOffer());
maybeShowPayByMailWarning(lastPaymentAccount, model.dataModel.getOffer());
maybeShowCashAtAtmWarning(lastPaymentAccount, model.dataModel.getOffer());
maybeShowAustraliaPayidWarning(lastPaymentAccount, model.dataModel.getOffer());
if (!model.isRange()) {
nextButton.setVisible(false);
@ -1139,6 +1140,23 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
}
}
private void maybeShowAustraliaPayidWarning(PaymentAccount paymentAccount, Offer offer) {
if (paymentAccount.getPaymentMethod().getId().equals(PaymentMethod.AUSTRALIA_PAYID_ID) &&
!australiaPayidWarningDisplayed && !offer.getExtraInfo().isEmpty()) {
australiaPayidWarningDisplayed = true;
UserThread.runAfter(() -> {
new GenericMessageWindow()
.preamble(Res.get("payment.tradingRestrictions"))
.instruction(offer.getExtraInfo())
.actionButtonText(Res.get("shared.iConfirm"))
.closeButtonText(Res.get("shared.close"))
.width(Layout.INITIAL_WINDOW_WIDTH)
.onClose(() -> close(false))
.show();
}, 500, TimeUnit.MILLISECONDS);
}
}
private Tuple2<Label, VBox> getTradeInputBox(HBox amountValueBox, String promptText) {
Label descriptionLabel = new AutoTooltipLabel(promptText);
descriptionLabel.setId("input-description-label");

View File

@ -174,7 +174,7 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
List<String> acceptedCountryCodes = offer.getAcceptedCountryCodes();
boolean showAcceptedCountryCodes = acceptedCountryCodes != null && !acceptedCountryCodes.isEmpty();
boolean isF2F = offer.getPaymentMethod().equals(PaymentMethod.F2F);
boolean showExtraInfo = offer.getPaymentMethod().equals(PaymentMethod.F2F) || offer.getPaymentMethod().equals(PaymentMethod.PAY_BY_MAIL);
boolean showExtraInfo = offer.getPaymentMethod().equals(PaymentMethod.F2F) || offer.getPaymentMethod().equals(PaymentMethod.PAY_BY_MAIL) || offer.getPaymentMethod().equals(PaymentMethod.AUSTRALIA_PAYID);
if (!takeOfferHandlerOptional.isPresent())
rows++;
if (showAcceptedBanks)

View File

@ -971,6 +971,7 @@ message JapanBankAccountPayload {
message AustraliaPayidPayload {
string bank_account_name = 1;
string payid = 2;
string extra_info = 3;
}
message SpecificBanksAccountPayload {
@ -1870,6 +1871,7 @@ message PaymentAccountForm {
PAXUM = 12;
PAY_BY_MAIL = 13;
CASH_AT_ATM = 14;
AUSTRALIA_PAYID = 15;
}
FormId id = 1;
repeated PaymentAccountFormField fields = 2;