mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-23 03:59:36 +00:00
support pay by mail over grpc api
This commit is contained in:
parent
c634d9d0a6
commit
6e768acd1b
5 changed files with 38 additions and 11 deletions
|
@ -60,18 +60,19 @@ public final class PaymentAccountForm implements PersistablePayload {
|
||||||
|
|
||||||
public enum FormId {
|
public enum FormId {
|
||||||
BLOCK_CHAINS,
|
BLOCK_CHAINS,
|
||||||
|
FASTER_PAYMENTS,
|
||||||
|
F2F,
|
||||||
|
MONEY_GRAM,
|
||||||
|
PAXUM,
|
||||||
|
PAY_BY_MAIL,
|
||||||
REVOLUT,
|
REVOLUT,
|
||||||
SEPA,
|
SEPA,
|
||||||
SEPA_INSTANT,
|
SEPA_INSTANT,
|
||||||
TRANSFERWISE,
|
|
||||||
ZELLE,
|
|
||||||
SWIFT,
|
|
||||||
F2F,
|
|
||||||
STRIKE,
|
STRIKE,
|
||||||
MONEY_GRAM,
|
SWIFT,
|
||||||
FASTER_PAYMENTS,
|
TRANSFERWISE,
|
||||||
UPHOLD,
|
UPHOLD,
|
||||||
PAXUM;
|
ZELLE;
|
||||||
|
|
||||||
public static PaymentAccountForm.FormId fromProto(protobuf.PaymentAccountForm.FormId formId) {
|
public static PaymentAccountForm.FormId fromProto(protobuf.PaymentAccountForm.FormId formId) {
|
||||||
return ProtoUtil.enumFromProto(PaymentAccountForm.FormId.class, formId.name());
|
return ProtoUtil.enumFromProto(PaymentAccountForm.FormId.class, formId.name());
|
||||||
|
|
|
@ -19,6 +19,7 @@ package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.CurrencyUtil;
|
import haveno.core.locale.CurrencyUtil;
|
||||||
|
import haveno.core.locale.Res;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PayByMailAccountPayload;
|
import haveno.core.payment.payload.PayByMailAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
|
@ -35,6 +36,15 @@ public final class PayByMailAccount extends PaymentAccount {
|
||||||
super(PaymentMethod.PAY_BY_MAIL);
|
super(PaymentMethod.PAY_BY_MAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final List<PaymentAccountFormField.FieldId> 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
|
@Override
|
||||||
protected PaymentAccountPayload createPayload() {
|
protected PaymentAccountPayload createPayload() {
|
||||||
return new PayByMailAccountPayload(paymentMethod.getId(), id);
|
return new PayByMailAccountPayload(paymentMethod.getId(), id);
|
||||||
|
@ -47,7 +57,7 @@ public final class PayByMailAccount extends PaymentAccount {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
|
public @NonNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
|
||||||
throw new RuntimeException("Not implemented");
|
return INPUT_FIELD_IDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPostalAddress(String postalAddress) {
|
public void setPostalAddress(String postalAddress) {
|
||||||
|
@ -73,4 +83,14 @@ public final class PayByMailAccount extends PaymentAccount {
|
||||||
public String getExtraInfo() {
|
public String getExtraInfo() {
|
||||||
return ((PayByMailAccountPayload) paymentAccountPayload).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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import haveno.core.locale.BankUtil;
|
||||||
import haveno.core.locale.Country;
|
import haveno.core.locale.Country;
|
||||||
import haveno.core.locale.CountryUtil;
|
import haveno.core.locale.CountryUtil;
|
||||||
import haveno.core.locale.CurrencyUtil;
|
import haveno.core.locale.CurrencyUtil;
|
||||||
|
import haveno.core.locale.Res;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
|
@ -501,7 +502,8 @@ public abstract class PaymentAccount implements PersistablePayload {
|
||||||
case PIX_KEY:
|
case PIX_KEY:
|
||||||
throw new IllegalArgumentException("Not implemented");
|
throw new IllegalArgumentException("Not implemented");
|
||||||
case POSTAL_ADDRESS:
|
case POSTAL_ADDRESS:
|
||||||
throw new IllegalArgumentException("Not implemented");
|
processValidationResult(new InputValidator().validate(value));
|
||||||
|
break;
|
||||||
case PROMPT_PAY_ID:
|
case PROMPT_PAY_ID:
|
||||||
throw new IllegalArgumentException("Not implemented");
|
throw new IllegalArgumentException("Not implemented");
|
||||||
case QUESTION:
|
case QUESTION:
|
||||||
|
@ -709,7 +711,9 @@ public abstract class PaymentAccount implements PersistablePayload {
|
||||||
case PIX_KEY:
|
case PIX_KEY:
|
||||||
throw new IllegalArgumentException("Not implemented");
|
throw new IllegalArgumentException("Not implemented");
|
||||||
case POSTAL_ADDRESS:
|
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:
|
case PROMPT_PAY_ID:
|
||||||
throw new IllegalArgumentException("Not implemented");
|
throw new IllegalArgumentException("Not implemented");
|
||||||
case QUESTION:
|
case QUESTION:
|
||||||
|
|
|
@ -345,7 +345,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
|
||||||
MONEY_GRAM_ID,
|
MONEY_GRAM_ID,
|
||||||
FASTER_PAYMENTS_ID,
|
FASTER_PAYMENTS_ID,
|
||||||
UPHOLD_ID,
|
UPHOLD_ID,
|
||||||
PAXUM_ID);
|
PAXUM_ID,
|
||||||
|
PAY_BY_MAIL_ID);
|
||||||
return paymentMethods.stream().filter(paymentMethod -> paymentMethodIds.contains(paymentMethod.getId())).collect(Collectors.toList());
|
return paymentMethods.stream().filter(paymentMethod -> paymentMethodIds.contains(paymentMethod.getId())).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1840,6 +1840,7 @@ message PaymentAccountForm {
|
||||||
FASTER_PAYMENTS = 10;
|
FASTER_PAYMENTS = 10;
|
||||||
UPHOLD = 11;
|
UPHOLD = 11;
|
||||||
PAXUM = 12;
|
PAXUM = 12;
|
||||||
|
PAY_BY_MAIL = 13;
|
||||||
}
|
}
|
||||||
FormId id = 1;
|
FormId id = 1;
|
||||||
repeated PaymentAccountFormField fields = 2;
|
repeated PaymentAccountFormField fields = 2;
|
||||||
|
|
Loading…
Reference in a new issue