mirror of
https://github.com/retoaccess1/haveno-reto.git
synced 2024-11-10 13:13:36 +01:00
support faster payments
This commit is contained in:
parent
d0c02acba1
commit
6dbd1660e5
@ -73,7 +73,8 @@ public final class PaymentAccountForm implements PersistablePayload {
|
||||
SWIFT,
|
||||
F2F,
|
||||
STRIKE,
|
||||
MONEY_GRAM;
|
||||
MONEY_GRAM,
|
||||
FASTER_PAYMENTS;
|
||||
|
||||
public static PaymentAccountForm.FormId fromProto(protobuf.PaymentAccountForm.FormId formId) {
|
||||
return ProtoUtil.enumFromProto(PaymentAccountForm.FormId.class, formId.name());
|
||||
|
@ -32,6 +32,14 @@ import lombok.NonNull;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class FasterPaymentsAccount extends PaymentAccount {
|
||||
|
||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||
PaymentAccountFormField.FieldId.HOLDER_NAME,
|
||||
PaymentAccountFormField.FieldId.SORT_CODE,
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NR,
|
||||
PaymentAccountFormField.FieldId.SALT
|
||||
);
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("GBP"));
|
||||
|
||||
public FasterPaymentsAccount() {
|
||||
@ -51,7 +59,7 @@ public final class FasterPaymentsAccount extends PaymentAccount {
|
||||
|
||||
@Override
|
||||
public @NonNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
return INPUT_FIELD_IDS;
|
||||
}
|
||||
|
||||
public void setHolderName(String value) {
|
||||
|
@ -27,7 +27,9 @@ import bisq.core.locale.Res;
|
||||
import bisq.core.locale.TradeCurrency;
|
||||
import bisq.core.payment.payload.PaymentAccountPayload;
|
||||
import bisq.core.payment.payload.PaymentMethod;
|
||||
import bisq.core.payment.validation.AccountNrValidator;
|
||||
import bisq.core.payment.validation.BICValidator;
|
||||
import bisq.core.payment.validation.BranchIdValidator;
|
||||
import bisq.core.payment.validation.EmailOrMobileNrValidator;
|
||||
import bisq.core.payment.validation.EmailValidator;
|
||||
import bisq.core.payment.validation.IBANValidator;
|
||||
@ -313,7 +315,8 @@ public abstract class PaymentAccount implements PersistablePayload {
|
||||
processValidationResult(new LengthValidator(2, 100).validate(value));
|
||||
break;
|
||||
case ACCOUNT_NR:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
processValidationResult(new AccountNrValidator("GB").validate(value));
|
||||
break;
|
||||
case ACCOUNT_OWNER:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
case ACCOUNT_TYPE:
|
||||
@ -437,15 +440,13 @@ public abstract class PaymentAccount implements PersistablePayload {
|
||||
if (!value.equals("")) throw new IllegalArgumentException("Salt must be empty");
|
||||
break;
|
||||
case SORT_CODE:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
processValidationResult(new BranchIdValidator("GB").validate(value));
|
||||
break;
|
||||
case SPECIAL_INSTRUCTIONS:
|
||||
break;
|
||||
case STATE:
|
||||
String countryCode = form.getValue(PaymentAccountFormField.FieldId.COUNTRY);
|
||||
System.out.println("BACKEND RECEIVED STATE COUNTRY CODE: " + countryCode);
|
||||
System.out.println("BACKEND RECEIVED STATE: " + value);
|
||||
boolean isStateRequired = BankUtil.isStateRequired(countryCode);
|
||||
System.out.println("IS STATE REQUIRED :" + isStateRequired);
|
||||
if (value == null || value.isEmpty()) {
|
||||
if (isStateRequired) throw new IllegalArgumentException("Must provide state for country " + countryCode);
|
||||
} else {
|
||||
@ -494,7 +495,9 @@ public abstract class PaymentAccount implements PersistablePayload {
|
||||
field.setMaxLength(100);
|
||||
break;
|
||||
case ACCOUNT_NR:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
field.setComponent(PaymentAccountFormField.Component.TEXT);
|
||||
field.setLabel("Account number");
|
||||
break;
|
||||
case ACCOUNT_OWNER:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
case ACCOUNT_TYPE:
|
||||
@ -646,7 +649,9 @@ public abstract class PaymentAccount implements PersistablePayload {
|
||||
field.setLabel("Salt");
|
||||
break;
|
||||
case SORT_CODE:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
field.setComponent(PaymentAccountFormField.Component.TEXT);
|
||||
field.setLabel("UK sort code");
|
||||
break;
|
||||
case SPECIAL_INSTRUCTIONS:
|
||||
field.setComponent(PaymentAccountFormField.Component.TEXT);
|
||||
field.setLabel("Special instructions");
|
||||
|
@ -41,11 +41,12 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Getter
|
||||
@Slf4j
|
||||
public final class FasterPaymentsAccountPayload extends PaymentAccountPayload {
|
||||
@Setter
|
||||
private String holderName = "";
|
||||
@Setter
|
||||
private String sortCode = "";
|
||||
@Setter
|
||||
private String accountNr = "";
|
||||
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
|
||||
|
||||
public FasterPaymentsAccountPayload(String paymentMethod, String id) {
|
||||
super(paymentMethod, id);
|
||||
@ -58,36 +59,36 @@ public final class FasterPaymentsAccountPayload extends PaymentAccountPayload {
|
||||
|
||||
private FasterPaymentsAccountPayload(String paymentMethod,
|
||||
String id,
|
||||
String holderName,
|
||||
String sortCode,
|
||||
String accountNr,
|
||||
String email,
|
||||
long maxTradePeriod,
|
||||
Map<String, String> excludeFromJsonDataMap) {
|
||||
super(paymentMethod,
|
||||
id,
|
||||
maxTradePeriod,
|
||||
excludeFromJsonDataMap);
|
||||
this.holderName = holderName;
|
||||
this.sortCode = sortCode;
|
||||
this.accountNr = accountNr;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message toProtoMessage() {
|
||||
return getPaymentAccountPayloadBuilder()
|
||||
.setFasterPaymentsAccountPayload(protobuf.FasterPaymentsAccountPayload.newBuilder()
|
||||
.setHolderName(holderName)
|
||||
.setSortCode(sortCode)
|
||||
.setAccountNr(accountNr)
|
||||
.setEmail(email))
|
||||
.setAccountNr(accountNr))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static FasterPaymentsAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
|
||||
return new FasterPaymentsAccountPayload(proto.getPaymentMethodId(),
|
||||
proto.getId(),
|
||||
proto.getFasterPaymentsAccountPayload().getHolderName(),
|
||||
proto.getFasterPaymentsAccountPayload().getSortCode(),
|
||||
proto.getFasterPaymentsAccountPayload().getAccountNr(),
|
||||
proto.getFasterPaymentsAccountPayload().getEmail(),
|
||||
proto.getMaxTradePeriod(),
|
||||
new HashMap<>(proto.getExcludeFromJsonDataMap()));
|
||||
}
|
||||
@ -97,14 +98,6 @@ public final class FasterPaymentsAccountPayload extends PaymentAccountPayload {
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getHolderName() {
|
||||
return excludeFromJsonDataMap.getOrDefault(HOLDER_NAME, "");
|
||||
}
|
||||
|
||||
public void setHolderName(String holderName) {
|
||||
excludeFromJsonDataMap.compute(HOLDER_NAME, (k, v) -> Strings.emptyToNull(holderName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPaymentDetails() {
|
||||
return Res.get(paymentMethodId) + " - " + getPaymentDetailsForTradePopup().replace("\n", ", ");
|
||||
|
@ -50,7 +50,6 @@ public abstract class PaymentAccountPayload implements NetworkPayload, UsedForTr
|
||||
|
||||
// Keys for excludeFromJsonDataMap
|
||||
public static final String SALT = "salt";
|
||||
public static final String HOLDER_NAME = "holderName";
|
||||
|
||||
protected final String paymentMethodId;
|
||||
protected final String id;
|
||||
|
@ -336,7 +336,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
|
||||
SWIFT_ID,
|
||||
F2F_ID,
|
||||
STRIKE_ID,
|
||||
MONEY_GRAM_ID);
|
||||
MONEY_GRAM_ID,
|
||||
FASTER_PAYMENTS_ID);
|
||||
return paymentMethods.stream().filter(paymentMethod -> paymentMethodIds.contains(paymentMethod.getId())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -1226,9 +1226,9 @@ message InstantCryptoCurrencyAccountPayload {
|
||||
}
|
||||
|
||||
message FasterPaymentsAccountPayload {
|
||||
string sort_code = 1;
|
||||
string account_nr = 2;
|
||||
string email = 3 [deprecated = true];
|
||||
string holder_name = 1;
|
||||
string sort_code = 2;
|
||||
string account_nr = 3;
|
||||
}
|
||||
|
||||
message InteracETransferAccountPayload {
|
||||
@ -2083,6 +2083,7 @@ message PaymentAccountForm {
|
||||
F2F = 6;
|
||||
STRIKE = 7;
|
||||
MONEY_GRAM = 8;
|
||||
FASTER_PAYMENTS = 9;
|
||||
}
|
||||
FormId id = 1;
|
||||
repeated PaymentAccountFormField fields = 2;
|
||||
|
Loading…
Reference in New Issue
Block a user