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 534a7de1fa..d2e27d780f 100644 --- a/core/src/main/java/haveno/core/api/model/PaymentAccountForm.java +++ b/core/src/main/java/haveno/core/api/model/PaymentAccountForm.java @@ -60,18 +60,19 @@ public final class PaymentAccountForm implements PersistablePayload { public enum FormId { BLOCK_CHAINS, + FASTER_PAYMENTS, + F2F, + MONEY_GRAM, + PAXUM, + PAY_BY_MAIL, REVOLUT, SEPA, SEPA_INSTANT, - TRANSFERWISE, - ZELLE, - SWIFT, - F2F, STRIKE, - MONEY_GRAM, - FASTER_PAYMENTS, + SWIFT, + TRANSFERWISE, UPHOLD, - PAXUM; + ZELLE; 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/payment/PayByMailAccount.java b/core/src/main/java/haveno/core/payment/PayByMailAccount.java index 71e3871c32..ffbb5c8919 100644 --- a/core/src/main/java/haveno/core/payment/PayByMailAccount.java +++ b/core/src/main/java/haveno/core/payment/PayByMailAccount.java @@ -19,6 +19,7 @@ package haveno.core.payment; import haveno.core.api.model.PaymentAccountFormField; import haveno.core.locale.CurrencyUtil; +import haveno.core.locale.Res; import haveno.core.locale.TradeCurrency; import haveno.core.payment.payload.PayByMailAccountPayload; import haveno.core.payment.payload.PaymentAccountPayload; @@ -35,6 +36,15 @@ public final class PayByMailAccount extends PaymentAccount { super(PaymentMethod.PAY_BY_MAIL); } + private static final List INPUT_FIELD_IDS = List.of( + PaymentAccountFormField.FieldId.TRADE_CURRENCIES, + PaymentAccountFormField.FieldId.CONTACT, + PaymentAccountFormField.FieldId.POSTAL_ADDRESS, + PaymentAccountFormField.FieldId.EXTRA_INFO, + PaymentAccountFormField.FieldId.ACCOUNT_NAME, + PaymentAccountFormField.FieldId.SALT + ); + @Override protected PaymentAccountPayload createPayload() { return new PayByMailAccountPayload(paymentMethod.getId(), id); @@ -47,7 +57,7 @@ public final class PayByMailAccount extends PaymentAccount { @Override public @NonNull List getInputFieldIds() { - throw new RuntimeException("Not implemented"); + return INPUT_FIELD_IDS; } public void setPostalAddress(String postalAddress) { @@ -73,4 +83,14 @@ public final class PayByMailAccount extends PaymentAccount { public String getExtraInfo() { return ((PayByMailAccountPayload) paymentAccountPayload).getExtraInfo(); } + + @Override + protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) { + var field = super.getEmptyFormField(fieldId); + if (field.getId() == PaymentAccountFormField.FieldId.TRADE_CURRENCIES) field.setComponent(PaymentAccountFormField.Component.SELECT_ONE); + if (field.getId() == PaymentAccountFormField.FieldId.CONTACT) field.setLabel(Res.get("payment.payByMail.contact.prompt")); + if (field.getId() == PaymentAccountFormField.FieldId.POSTAL_ADDRESS) field.setLabel(Res.get("payment.postal.address")); + if (field.getId() == PaymentAccountFormField.FieldId.EXTRA_INFO) field.setLabel(Res.get("payment.shared.optionalExtra")); + return field; + } } diff --git a/core/src/main/java/haveno/core/payment/PaymentAccount.java b/core/src/main/java/haveno/core/payment/PaymentAccount.java index e113558f43..9eee78b850 100644 --- a/core/src/main/java/haveno/core/payment/PaymentAccount.java +++ b/core/src/main/java/haveno/core/payment/PaymentAccount.java @@ -28,6 +28,7 @@ import haveno.core.locale.BankUtil; import haveno.core.locale.Country; import haveno.core.locale.CountryUtil; import haveno.core.locale.CurrencyUtil; +import haveno.core.locale.Res; import haveno.core.locale.TradeCurrency; import haveno.core.payment.payload.PaymentAccountPayload; import haveno.core.payment.payload.PaymentMethod; @@ -501,7 +502,8 @@ public abstract class PaymentAccount implements PersistablePayload { case PIX_KEY: throw new IllegalArgumentException("Not implemented"); case POSTAL_ADDRESS: - throw new IllegalArgumentException("Not implemented"); + processValidationResult(new InputValidator().validate(value)); + break; case PROMPT_PAY_ID: throw new IllegalArgumentException("Not implemented"); case QUESTION: @@ -709,7 +711,9 @@ public abstract class PaymentAccount implements PersistablePayload { case PIX_KEY: throw new IllegalArgumentException("Not implemented"); case POSTAL_ADDRESS: - throw new IllegalArgumentException("Not implemented"); + field.setComponent(PaymentAccountFormField.Component.TEXTAREA); + field.setLabel(Res.get("payment.postal.address")); + break; case PROMPT_PAY_ID: throw new IllegalArgumentException("Not implemented"); case QUESTION: 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 bf4b484c35..9444576d96 100644 --- a/core/src/main/java/haveno/core/payment/payload/PaymentMethod.java +++ b/core/src/main/java/haveno/core/payment/payload/PaymentMethod.java @@ -345,7 +345,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable paymentMethodIds.contains(paymentMethod.getId())).collect(Collectors.toList()); } diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index 357861840f..d7b1a300bb 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -1840,6 +1840,7 @@ message PaymentAccountForm { FASTER_PAYMENTS = 10; UPHOLD = 11; PAXUM = 12; + PAY_BY_MAIL = 13; } FormId id = 1; repeated PaymentAccountFormField fields = 2;