diff --git a/core/src/main/java/haveno/core/api/model/PaymentAccountForm.java b/core/src/main/java/haveno/core/api/model/PaymentAccountForm.java index e93c9c83..e890d74f 100644 --- a/core/src/main/java/haveno/core/api/model/PaymentAccountForm.java +++ b/core/src/main/java/haveno/core/api/model/PaymentAccountForm.java @@ -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()); diff --git a/core/src/main/java/haveno/core/offer/Offer.java b/core/src/main/java/haveno/core/offer/Offer.java index 73516a02..5c2f6eb5 100644 --- a/core/src/main/java/haveno/core/offer/Offer.java +++ b/core/src/main/java/haveno/core/offer/Offer.java @@ -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 ""; } diff --git a/core/src/main/java/haveno/core/offer/OfferPayload.java b/core/src/main/java/haveno/core/offer/OfferPayload.java index 2fa0a2a9..1a194a1a 100644 --- a/core/src/main/java/haveno/core/offer/OfferPayload.java +++ b/core/src/main/java/haveno/core/offer/OfferPayload.java @@ -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 diff --git a/core/src/main/java/haveno/core/offer/OfferUtil.java b/core/src/main/java/haveno/core/offer/OfferUtil.java index b6039fd2..6d314fe2 100644 --- a/core/src/main/java/haveno/core/offer/OfferUtil.java +++ b/core/src/main/java/haveno/core/offer/OfferUtil.java @@ -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) { diff --git a/core/src/main/java/haveno/core/payment/AustraliaPayidAccount.java b/core/src/main/java/haveno/core/payment/AustraliaPayidAccount.java index b27834d8..bc1d7b3a 100644 --- a/core/src/main/java/haveno/core/payment/AustraliaPayidAccount.java +++ b/core/src/main/java/haveno/core/payment/AustraliaPayidAccount.java @@ -36,6 +36,14 @@ public final class AustraliaPayidAccount extends PaymentAccount { setSingleTradeCurrency(SUPPORTED_CURRENCIES.get(0)); } + private static final List 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 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(); + } } diff --git a/core/src/main/java/haveno/core/payment/PaymentAccount.java b/core/src/main/java/haveno/core/payment/PaymentAccount.java index aa60e4ee..1d740155 100644 --- a/core/src/main/java/haveno/core/payment/PaymentAccount.java +++ b/core/src/main/java/haveno/core/payment/PaymentAccount.java @@ -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: diff --git a/core/src/main/java/haveno/core/payment/payload/AustraliaPayidAccountPayload.java b/core/src/main/java/haveno/core/payment/payload/AustraliaPayidAccountPayload.java index e50c5d5f..6620e8a2 100644 --- a/core/src/main/java/haveno/core/payment/payload/AustraliaPayidAccountPayload.java +++ b/core/src/main/java/haveno/core/payment/payload/AustraliaPayidAccountPayload.java @@ -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 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; } diff --git a/core/src/main/java/haveno/core/payment/payload/PaymentMethod.java b/core/src/main/java/haveno/core/payment/payload/PaymentMethod.java index 5ea1278a..da8bd94a 100644 --- a/core/src/main/java/haveno/core/payment/payload/PaymentMethod.java +++ b/core/src/main/java/haveno/core/payment/payload/PaymentMethod.java @@ -363,7 +363,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable paymentMethodIds.contains(paymentMethod.getId())).collect(Collectors.toList()); } diff --git a/desktop/src/main/java/haveno/desktop/components/paymentmethods/AustraliaPayidForm.java b/desktop/src/main/java/haveno/desktop/components/paymentmethods/AustraliaPayidForm.java index f9e984d1..c830b889 100644 --- a/desktop/src/main/java/haveno/desktop/components/paymentmethods/AustraliaPayidForm.java +++ b/desktop/src/main/java/haveno/desktop/components/paymentmethods/AustraliaPayidForm.java @@ -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); diff --git a/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java b/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java index a4d65bc7..2b8899c3 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java @@ -158,7 +158,7 @@ public class TakeOfferView extends ActivatableViewAndModel paymentAccountWarningDisplayed = new HashMap<>(); private boolean offerDetailsWindowDisplayed, zelleWarningDisplayed, fasterPaymentsWarningDisplayed, - takeOfferFromUnsignedAccountWarningDisplayed, payByMailWarningDisplayed, cashAtAtmWarningDisplayed; + takeOfferFromUnsignedAccountWarningDisplayed, payByMailWarningDisplayed, cashAtAtmWarningDisplayed, australiaPayidWarningDisplayed; private SimpleBooleanProperty errorPopupDisplayed; private ChangeListener amountFocusedListener, getShowWalletFundedNotificationListener; @@ -267,6 +267,7 @@ public class TakeOfferView extends ActivatableViewAndModel { + 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 getTradeInputBox(HBox amountValueBox, String promptText) { Label descriptionLabel = new AutoTooltipLabel(promptText); descriptionLabel.setId("input-description-label"); diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java index f210a7d5..f7e12cf2 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java @@ -174,7 +174,7 @@ public class OfferDetailsWindow extends Overlay { List 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) diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index e44f843c..1ec7f046 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -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;