support sepa instant

This commit is contained in:
woodser 2022-06-22 11:10:22 -04:00
parent c40938f438
commit d0c02acba1
5 changed files with 48 additions and 12 deletions

View File

@ -67,6 +67,7 @@ public final class PaymentAccountForm implements PersistablePayload {
public enum FormId { public enum FormId {
REVOLUT, REVOLUT,
SEPA, SEPA,
SEPA_INSTANT,
TRANSFERWISE, TRANSFERWISE,
CLEAR_X_CHANGE, CLEAR_X_CHANGE,
SWIFT, SWIFT,

View File

@ -36,7 +36,7 @@ import org.jetbrains.annotations.NotNull;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public final class SepaAccount extends CountryBasedPaymentAccount implements BankAccount { public final class SepaAccount extends CountryBasedPaymentAccount implements BankAccount {
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of( protected static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
PaymentAccountFormField.FieldId.ACCOUNT_NAME, PaymentAccountFormField.FieldId.ACCOUNT_NAME,
PaymentAccountFormField.FieldId.HOLDER_NAME, PaymentAccountFormField.FieldId.HOLDER_NAME,
PaymentAccountFormField.FieldId.IBAN, PaymentAccountFormField.FieldId.IBAN,
@ -142,7 +142,7 @@ public final class SepaAccount extends CountryBasedPaymentAccount implements Ban
super.validateFormField(form, fieldId, value); super.validateFormField(form, fieldId, value);
} }
} }
@Override @Override
protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) { protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) {
var field = super.getEmptyFormField(fieldId); var field = super.getEmptyFormField(fieldId);

View File

@ -17,16 +17,18 @@
package bisq.core.payment; package bisq.core.payment;
import bisq.core.api.model.PaymentAccountForm;
import bisq.core.api.model.PaymentAccountFormField; import bisq.core.api.model.PaymentAccountFormField;
import bisq.core.locale.Country;
import bisq.core.locale.CountryUtil; import bisq.core.locale.CountryUtil;
import bisq.core.locale.FiatCurrency; import bisq.core.locale.FiatCurrency;
import bisq.core.locale.TradeCurrency; import bisq.core.locale.TradeCurrency;
import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod; import bisq.core.payment.payload.PaymentMethod;
import bisq.core.payment.payload.SepaInstantAccountPayload; import bisq.core.payment.payload.SepaInstantAccountPayload;
import bisq.core.payment.validation.SepaIBANValidator;
import java.util.List; import java.util.List;
import javax.annotation.Nullable;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -100,13 +102,44 @@ public final class SepaInstantAccount extends CountryBasedPaymentAccount impleme
((SepaInstantAccountPayload) paymentAccountPayload).revertChanges(); ((SepaInstantAccountPayload) paymentAccountPayload).revertChanges();
} }
@Override
public @NotNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
return SepaAccount.INPUT_FIELD_IDS;
}
@Override @Override
public @NotNull List<TradeCurrency> getSupportedCurrencies() { public @NotNull List<TradeCurrency> getSupportedCurrencies() {
return SUPPORTED_CURRENCIES; return SUPPORTED_CURRENCIES;
} }
@Override @Override
public @NotNull List<PaymentAccountFormField.FieldId> getInputFieldIds() { @Nullable
throw new RuntimeException("Not implemented"); public List<Country> getSupportedCountries() {
return CountryUtil.getAllSepaCountries();
}
@Override
public void validateFormField(PaymentAccountForm form, PaymentAccountFormField.FieldId fieldId, String value) {
switch (fieldId) {
case IBAN:
processValidationResult(new SepaIBANValidator().validate(value));
break;
default:
super.validateFormField(form, fieldId, value);
}
}
@Override
protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) {
var field = super.getEmptyFormField(fieldId);
switch (fieldId) {
case ACCEPTED_COUNTRY_CODES:
field.setSupportedSepaEuroCountries(CountryUtil.getAllSepaEuroCountries());
field.setSupportedSepaNonEuroCountries(CountryUtil.getAllSepaNonEuroCountries());
break;
default:
// no action
}
return field;
} }
} }

View File

@ -330,6 +330,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
List<String> paymentMethodIds = List.of( List<String> paymentMethodIds = List.of(
REVOLUT_ID, REVOLUT_ID,
SEPA_ID, SEPA_ID,
SEPA_INSTANT_ID,
TRANSFERWISE_ID, TRANSFERWISE_ID,
CLEAR_X_CHANGE_ID, CLEAR_X_CHANGE_ID,
SWIFT_ID, SWIFT_ID,

View File

@ -2076,12 +2076,13 @@ message PaymentAccountForm {
enum FormId { enum FormId {
REVOLUT = 0; REVOLUT = 0;
SEPA = 1; SEPA = 1;
TRANSFERWISE = 2; SEPA_INSTANT = 2;
CLEAR_X_CHANGE = 3; TRANSFERWISE = 3;
SWIFT = 4; CLEAR_X_CHANGE = 4;
F2F = 5; SWIFT = 5;
STRIKE = 6; F2F = 6;
MONEY_GRAM = 7; STRIKE = 7;
MONEY_GRAM = 8;
} }
FormId id = 1; FormId id = 1;
repeated PaymentAccountFormField fields = 2; repeated PaymentAccountFormField fields = 2;