mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-23 22:34:23 -04:00
Merge bb1173cc96
into 32148e7440
This commit is contained in:
commit
38614d1470
25 changed files with 238 additions and 50 deletions
|
@ -36,6 +36,8 @@ import haveno.core.payment.InstantCryptoCurrencyAccount;
|
|||
import haveno.core.payment.PaymentAccount;
|
||||
import haveno.core.payment.PaymentAccountFactory;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
import haveno.core.payment.validation.InteracETransferValidator;
|
||||
import haveno.core.trade.HavenoUtils;
|
||||
import haveno.core.user.User;
|
||||
import java.io.File;
|
||||
import static java.lang.String.format;
|
||||
|
@ -48,19 +50,24 @@ import lombok.extern.slf4j.Slf4j;
|
|||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
class CorePaymentAccountsService {
|
||||
public class CorePaymentAccountsService {
|
||||
|
||||
private final CoreAccountService accountService;
|
||||
private final AccountAgeWitnessService accountAgeWitnessService;
|
||||
private final User user;
|
||||
public final InteracETransferValidator interacETransferValidator;
|
||||
|
||||
@Inject
|
||||
public CorePaymentAccountsService(CoreAccountService accountService,
|
||||
AccountAgeWitnessService accountAgeWitnessService,
|
||||
User user) {
|
||||
User user,
|
||||
InteracETransferValidator interacETransferValidator) {
|
||||
this.accountService = accountService;
|
||||
this.accountAgeWitnessService = accountAgeWitnessService;
|
||||
this.user = user;
|
||||
this.interacETransferValidator = interacETransferValidator;
|
||||
|
||||
HavenoUtils.corePaymentAccountService = this;
|
||||
}
|
||||
|
||||
PaymentAccount createPaymentAccount(PaymentAccountForm form) {
|
||||
|
|
|
@ -78,7 +78,15 @@ public final class PaymentAccountForm implements PersistablePayload {
|
|||
CASH_APP,
|
||||
PAYPAL,
|
||||
VENMO,
|
||||
PAYSAFE;
|
||||
PAYSAFE,
|
||||
WECHAT_PAY,
|
||||
ALI_PAY,
|
||||
SWISH,
|
||||
TRANSFERWISE_USD,
|
||||
AMAZON_GIFT_CARD,
|
||||
ACH_TRANSFER,
|
||||
INTERAC_E_TRANSFER,
|
||||
US_POSTAL_MONEY_ORDER;
|
||||
|
||||
public static PaymentAccountForm.FormId fromProto(protobuf.PaymentAccountForm.FormId formId) {
|
||||
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.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.BankUtil;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.AchTransferAccountPayload;
|
||||
import haveno.core.payment.payload.BankAccountPayload;
|
||||
|
@ -34,6 +35,19 @@ public final class AchTransferAccount extends CountryBasedPaymentAccount impleme
|
|||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
|
||||
|
||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||
PaymentAccountFormField.FieldId.HOLDER_NAME,
|
||||
PaymentAccountFormField.FieldId.HOLDER_ADDRESS,
|
||||
PaymentAccountFormField.FieldId.BANK_NAME,
|
||||
PaymentAccountFormField.FieldId.BRANCH_ID,
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NR,
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_TYPE,
|
||||
PaymentAccountFormField.FieldId.COUNTRY,
|
||||
PaymentAccountFormField.FieldId.TRADE_CURRENCIES,
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||
PaymentAccountFormField.FieldId.SALT
|
||||
);
|
||||
|
||||
public AchTransferAccount() {
|
||||
super(PaymentMethod.ACH_TRANSFER);
|
||||
}
|
||||
|
@ -79,6 +93,15 @@ public final class AchTransferAccount extends CountryBasedPaymentAccount impleme
|
|||
|
||||
@Override
|
||||
public @NonNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
return INPUT_FIELD_IDS;
|
||||
}
|
||||
|
||||
@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.BRANCH_ID) field.setLabel(BankUtil.getBranchIdLabel("US"));
|
||||
if (field.getId() == PaymentAccountFormField.FieldId.ACCOUNT_TYPE) field.setLabel(BankUtil.getAccountTypeLabel("US"));
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,13 @@ public final class AliPayAccount extends PaymentAccount {
|
|||
new TraditionalCurrency("ZAR")
|
||||
);
|
||||
|
||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NR,
|
||||
PaymentAccountFormField.FieldId.TRADE_CURRENCIES,
|
||||
PaymentAccountFormField.FieldId.SALT
|
||||
);
|
||||
|
||||
public AliPayAccount() {
|
||||
super(PaymentMethod.ALI_PAY);
|
||||
setSingleTradeCurrency(SUPPORTED_CURRENCIES.get(0));
|
||||
|
@ -77,7 +84,7 @@ public final class AliPayAccount extends PaymentAccount {
|
|||
|
||||
@Override
|
||||
public @NonNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
return INPUT_FIELD_IDS;
|
||||
}
|
||||
|
||||
public void setAccountNr(String accountNr) {
|
||||
|
|
|
@ -46,6 +46,14 @@ public final class AmazonGiftCardAccount extends PaymentAccount {
|
|||
new TraditionalCurrency("USD")
|
||||
);
|
||||
|
||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||
PaymentAccountFormField.FieldId.EMAIL_OR_MOBILE_NR,
|
||||
PaymentAccountFormField.FieldId.COUNTRY,
|
||||
PaymentAccountFormField.FieldId.TRADE_CURRENCIES,
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||
PaymentAccountFormField.FieldId.SALT
|
||||
);
|
||||
|
||||
@Nullable
|
||||
private Country country;
|
||||
|
||||
|
@ -65,7 +73,7 @@ public final class AmazonGiftCardAccount extends PaymentAccount {
|
|||
|
||||
@Override
|
||||
public @NotNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
return INPUT_FIELD_IDS;
|
||||
}
|
||||
|
||||
public String getEmailOrMobileNr() {
|
||||
|
@ -97,4 +105,11 @@ public final class AmazonGiftCardAccount extends PaymentAccount {
|
|||
private AmazonGiftCardAccountPayload getAmazonGiftCardAccountPayload() {
|
||||
return (AmazonGiftCardAccountPayload) paymentAccountPayload;
|
||||
}
|
||||
|
||||
@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);
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,15 @@
|
|||
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountForm;
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.InteracETransferAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
import haveno.core.payment.validation.InteracETransferValidator;
|
||||
import haveno.core.trade.HavenoUtils;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -33,9 +36,22 @@ public final class InteracETransferAccount extends PaymentAccount {
|
|||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("CAD"));
|
||||
|
||||
private final InteracETransferValidator interacETransferValidator;
|
||||
|
||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||
PaymentAccountFormField.FieldId.HOLDER_NAME,
|
||||
PaymentAccountFormField.FieldId.EMAIL_OR_MOBILE_NR,
|
||||
PaymentAccountFormField.FieldId.QUESTION,
|
||||
PaymentAccountFormField.FieldId.ANSWER,
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||
PaymentAccountFormField.FieldId.SALT
|
||||
);
|
||||
|
||||
public InteracETransferAccount() {
|
||||
super(PaymentMethod.INTERAC_E_TRANSFER);
|
||||
setSingleTradeCurrency(SUPPORTED_CURRENCIES.get(0));
|
||||
this.interacETransferValidator = HavenoUtils.corePaymentAccountService.interacETransferValidator;
|
||||
if (interacETransferValidator == null) throw new IllegalArgumentException("InteracETransferValidator cannot be null");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,15 +66,15 @@ public final class InteracETransferAccount extends PaymentAccount {
|
|||
|
||||
@Override
|
||||
public @NotNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
return INPUT_FIELD_IDS;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
((InteracETransferAccountPayload) paymentAccountPayload).setEmail(email);
|
||||
((InteracETransferAccountPayload) paymentAccountPayload).setEmailOrMobileNr(email);
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return ((InteracETransferAccountPayload) paymentAccountPayload).getEmail();
|
||||
return ((InteracETransferAccountPayload) paymentAccountPayload).getEmailOrMobileNr();
|
||||
}
|
||||
|
||||
public void setAnswer(String answer) {
|
||||
|
@ -84,4 +100,18 @@ public final class InteracETransferAccount extends PaymentAccount {
|
|||
public String getHolderName() {
|
||||
return ((InteracETransferAccountPayload) paymentAccountPayload).getHolderName();
|
||||
}
|
||||
|
||||
public void validateFormField(PaymentAccountForm form, PaymentAccountFormField.FieldId fieldId, String value) {
|
||||
switch (fieldId) {
|
||||
case QUESTION:
|
||||
processValidationResult(interacETransferValidator.questionValidator.validate(value));
|
||||
break;
|
||||
case ANSWER:
|
||||
processValidationResult(interacETransferValidator.answerValidator.validate(value));
|
||||
break;
|
||||
default:
|
||||
super.validateFormField(form, fieldId, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -435,7 +435,8 @@ public abstract class PaymentAccount implements PersistablePayload {
|
|||
processValidationResult(new LengthValidator(2, 100).validate(value));
|
||||
break;
|
||||
case ACCOUNT_TYPE:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
processValidationResult(new LengthValidator(2, 100).validate(value));
|
||||
break;
|
||||
case ANSWER:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
case BANK_ACCOUNT_NAME:
|
||||
|
@ -491,7 +492,8 @@ public abstract class PaymentAccount implements PersistablePayload {
|
|||
processValidationResult(new BICValidator().validate(value));
|
||||
break;
|
||||
case BRANCH_ID:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
processValidationResult(new LengthValidator(2, 34).validate(value));
|
||||
break;
|
||||
case CITY:
|
||||
processValidationResult(new LengthValidator(2, 34).validate(value));
|
||||
break;
|
||||
|
@ -518,7 +520,8 @@ public abstract class PaymentAccount implements PersistablePayload {
|
|||
case EXTRA_INFO:
|
||||
break;
|
||||
case HOLDER_ADDRESS:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
processValidationResult(new LengthValidator(0, 100).validate(value));
|
||||
break;
|
||||
case HOLDER_EMAIL:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
case HOLDER_NAME:
|
||||
|
@ -623,9 +626,13 @@ public abstract class PaymentAccount implements PersistablePayload {
|
|||
field.setLabel(Res.get("payment.account.owner"));
|
||||
break;
|
||||
case ACCOUNT_TYPE:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
field.setComponent(PaymentAccountFormField.Component.SELECT_ONE);
|
||||
field.setLabel(Res.get("payment.select.account"));
|
||||
break;
|
||||
case ANSWER:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
field.setComponent(PaymentAccountFormField.Component.TEXT);
|
||||
field.setLabel(Res.get("payment.answer"));
|
||||
break;
|
||||
case BANK_ACCOUNT_NAME:
|
||||
field.setComponent(PaymentAccountFormField.Component.TEXT);
|
||||
field.setLabel(Res.get("payment.account.owner"));
|
||||
|
@ -668,11 +675,11 @@ public abstract class PaymentAccount implements PersistablePayload {
|
|||
break;
|
||||
case BENEFICIARY_ACCOUNT_NR:
|
||||
field.setComponent(PaymentAccountFormField.Component.TEXT);
|
||||
field.setLabel(Res.get("payment.swift.account"));
|
||||
field.setLabel(Res.get("payment.swift.account")); // TODO: this is specific to swift
|
||||
break;
|
||||
case BENEFICIARY_ADDRESS:
|
||||
field.setComponent(PaymentAccountFormField.Component.TEXTAREA);
|
||||
field.setLabel(Res.get("payment.swift.address.beneficiary"));
|
||||
field.setLabel(Res.get("payment.swift.address.beneficiary")); // TODO: this is specific to swift
|
||||
break;
|
||||
case BENEFICIARY_CITY:
|
||||
field.setComponent(PaymentAccountFormField.Component.TEXT);
|
||||
|
@ -691,7 +698,9 @@ public abstract class PaymentAccount implements PersistablePayload {
|
|||
field.setLabel("BIC");
|
||||
break;
|
||||
case BRANCH_ID:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
field.setComponent(PaymentAccountFormField.Component.TEXT);
|
||||
//field.setLabel("Not implemented"); // expected to be overridden by subclasses
|
||||
break;
|
||||
case CITY:
|
||||
field.setComponent(PaymentAccountFormField.Component.TEXT);
|
||||
field.setLabel(Res.get("payment.account.city"));
|
||||
|
@ -717,7 +726,9 @@ public abstract class PaymentAccount implements PersistablePayload {
|
|||
field.setLabel(Res.get("payment.shared.optionalExtra"));
|
||||
break;
|
||||
case HOLDER_ADDRESS:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
field.setComponent(PaymentAccountFormField.Component.TEXTAREA);
|
||||
field.setLabel(Res.get("payment.account.owner.address"));
|
||||
break;
|
||||
case HOLDER_EMAIL:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
case HOLDER_NAME:
|
||||
|
@ -755,7 +766,9 @@ public abstract class PaymentAccount implements PersistablePayload {
|
|||
field.setLabel(Res.get("payment.swift.swiftCode.intermediary"));
|
||||
break;
|
||||
case MOBILE_NR:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
field.setComponent(PaymentAccountFormField.Component.TEXT);
|
||||
field.setLabel(Res.get("payment.mobile"));
|
||||
break;
|
||||
case NATIONAL_ACCOUNT_ID:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
case PAYID:
|
||||
|
@ -771,7 +784,9 @@ public abstract class PaymentAccount implements PersistablePayload {
|
|||
case PROMPT_PAY_ID:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
case QUESTION:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
field.setComponent(PaymentAccountFormField.Component.TEXT);
|
||||
field.setLabel(Res.get("payment.secret"));
|
||||
break;
|
||||
case REQUIREMENTS:
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
case SALT:
|
||||
|
|
|
@ -50,6 +50,7 @@ import static haveno.common.util.Utilities.decodeFromHex;
|
|||
import static haveno.core.locale.CountryUtil.findCountryByCode;
|
||||
import static haveno.core.locale.CurrencyUtil.getTradeCurrenciesInList;
|
||||
import static haveno.core.locale.CurrencyUtil.getTradeCurrency;
|
||||
import static haveno.core.payment.payload.PaymentMethod.AMAZON_GIFT_CARD_ID;
|
||||
import static haveno.core.payment.payload.PaymentMethod.MONEY_GRAM_ID;
|
||||
import static java.lang.String.format;
|
||||
import static java.util.Arrays.stream;
|
||||
|
@ -438,6 +439,8 @@ class PaymentAccountTypeAdapter extends TypeAdapter<PaymentAccount> {
|
|||
// account.setSingleTradeCurrency(fiatCurrency);
|
||||
} else if (account.hasPaymentMethodWithId(MONEY_GRAM_ID)) {
|
||||
((MoneyGramAccount) account).setCountry(country.get());
|
||||
} else if (account.hasPaymentMethodWithId(AMAZON_GIFT_CARD_ID)) {
|
||||
((AmazonGiftCardAccount) account).setCountry(country.get());
|
||||
} else {
|
||||
String errMsg = format("cannot set the country on a %s",
|
||||
paymentAccountType.getSimpleName());
|
||||
|
|
|
@ -17,12 +17,14 @@
|
|||
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountForm;
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
import haveno.core.payment.payload.SwishAccountPayload;
|
||||
import haveno.core.payment.validation.SwishValidator;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
|
||||
|
@ -33,6 +35,13 @@ public final class SwishAccount extends PaymentAccount {
|
|||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("SEK"));
|
||||
|
||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||
PaymentAccountFormField.FieldId.MOBILE_NR,
|
||||
PaymentAccountFormField.FieldId.HOLDER_NAME,
|
||||
PaymentAccountFormField.FieldId.SALT
|
||||
);
|
||||
|
||||
public SwishAccount() {
|
||||
super(PaymentMethod.SWISH);
|
||||
setSingleTradeCurrency(SUPPORTED_CURRENCIES.get(0));
|
||||
|
@ -50,7 +59,7 @@ public final class SwishAccount extends PaymentAccount {
|
|||
|
||||
@Override
|
||||
public @NonNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
return INPUT_FIELD_IDS;
|
||||
}
|
||||
|
||||
public void setMobileNr(String mobileNr) {
|
||||
|
@ -68,4 +77,16 @@ public final class SwishAccount extends PaymentAccount {
|
|||
public String getHolderName() {
|
||||
return ((SwishAccountPayload) paymentAccountPayload).getHolderName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateFormField(PaymentAccountForm form, PaymentAccountFormField.FieldId fieldId, String value) {
|
||||
switch (fieldId) {
|
||||
case MOBILE_NR:
|
||||
processValidationResult(new SwishValidator().validate(value));
|
||||
break;
|
||||
default:
|
||||
super.validateFormField(form, fieldId, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package haveno.core.payment;
|
|||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.Res;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
|
@ -33,6 +34,15 @@ public final class TransferwiseUsdAccount extends CountryBasedPaymentAccount {
|
|||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
|
||||
|
||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||
PaymentAccountFormField.FieldId.EMAIL,
|
||||
PaymentAccountFormField.FieldId.HOLDER_NAME,
|
||||
PaymentAccountFormField.FieldId.HOLDER_ADDRESS,
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||
PaymentAccountFormField.FieldId.COUNTRY,
|
||||
PaymentAccountFormField.FieldId.SALT
|
||||
);
|
||||
|
||||
public TransferwiseUsdAccount() {
|
||||
super(PaymentMethod.TRANSFERWISE_USD);
|
||||
// this payment method is currently restricted to United States/USD
|
||||
|
@ -61,11 +71,11 @@ public final class TransferwiseUsdAccount extends CountryBasedPaymentAccount {
|
|||
}
|
||||
|
||||
public void setBeneficiaryAddress(String address) {
|
||||
((TransferwiseUsdAccountPayload) paymentAccountPayload).setBeneficiaryAddress(address);
|
||||
((TransferwiseUsdAccountPayload) paymentAccountPayload).setHolderAddress(address);
|
||||
}
|
||||
|
||||
public String getBeneficiaryAddress() {
|
||||
return ((TransferwiseUsdAccountPayload) paymentAccountPayload).getBeneficiaryAddress();
|
||||
return ((TransferwiseUsdAccountPayload) paymentAccountPayload).getHolderAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,6 +100,13 @@ public final class TransferwiseUsdAccount extends CountryBasedPaymentAccount {
|
|||
|
||||
@Override
|
||||
public @NotNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
return INPUT_FIELD_IDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) {
|
||||
var field = super.getEmptyFormField(fieldId);
|
||||
if (field.getId() == PaymentAccountFormField.FieldId.HOLDER_ADDRESS) field.setLabel(field.getLabel() + " " + Res.get("payment.transferwiseUsd.address"));
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,13 @@ public final class USPostalMoneyOrderAccount extends PaymentAccount {
|
|||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
|
||||
|
||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||
PaymentAccountFormField.FieldId.HOLDER_NAME,
|
||||
PaymentAccountFormField.FieldId.POSTAL_ADDRESS,
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||
PaymentAccountFormField.FieldId.SALT
|
||||
);
|
||||
|
||||
public USPostalMoneyOrderAccount() {
|
||||
super(PaymentMethod.US_POSTAL_MONEY_ORDER);
|
||||
setSingleTradeCurrency(SUPPORTED_CURRENCIES.get(0));
|
||||
|
@ -50,7 +57,7 @@ public final class USPostalMoneyOrderAccount extends PaymentAccount {
|
|||
|
||||
@Override
|
||||
public @NonNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
return INPUT_FIELD_IDS;
|
||||
}
|
||||
|
||||
public void setPostalAddress(String postalAddress) {
|
||||
|
|
|
@ -38,6 +38,13 @@ public final class WeChatPayAccount extends PaymentAccount {
|
|||
new TraditionalCurrency("GBP")
|
||||
);
|
||||
|
||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NR,
|
||||
PaymentAccountFormField.FieldId.TRADE_CURRENCIES,
|
||||
PaymentAccountFormField.FieldId.SALT
|
||||
);
|
||||
|
||||
public WeChatPayAccount() {
|
||||
super(PaymentMethod.WECHAT_PAY);
|
||||
}
|
||||
|
@ -54,7 +61,7 @@ public final class WeChatPayAccount extends PaymentAccount {
|
|||
|
||||
@Override
|
||||
public @NonNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
return INPUT_FIELD_IDS;
|
||||
}
|
||||
|
||||
public void setAccountNr(String accountNr) {
|
||||
|
|
|
@ -36,7 +36,7 @@ import java.util.Map;
|
|||
@Getter
|
||||
@Slf4j
|
||||
public final class InteracETransferAccountPayload extends PaymentAccountPayload implements PayloadWithHolderName {
|
||||
private String email = "";
|
||||
private String emailOrMobileNr = "";
|
||||
private String holderName = "";
|
||||
private String question = "";
|
||||
private String answer = "";
|
||||
|
@ -52,7 +52,7 @@ public final class InteracETransferAccountPayload extends PaymentAccountPayload
|
|||
|
||||
private InteracETransferAccountPayload(String paymentMethod,
|
||||
String id,
|
||||
String email,
|
||||
String emailOrMobileNr,
|
||||
String holderName,
|
||||
String question,
|
||||
String answer,
|
||||
|
@ -62,7 +62,7 @@ public final class InteracETransferAccountPayload extends PaymentAccountPayload
|
|||
id,
|
||||
maxTradePeriod,
|
||||
excludeFromJsonDataMap);
|
||||
this.email = email;
|
||||
this.emailOrMobileNr = emailOrMobileNr;
|
||||
this.holderName = holderName;
|
||||
this.question = question;
|
||||
this.answer = answer;
|
||||
|
@ -72,7 +72,7 @@ public final class InteracETransferAccountPayload extends PaymentAccountPayload
|
|||
public Message toProtoMessage() {
|
||||
return getPaymentAccountPayloadBuilder()
|
||||
.setInteracETransferAccountPayload(protobuf.InteracETransferAccountPayload.newBuilder()
|
||||
.setEmail(email)
|
||||
.setEmailOrMobileNr(emailOrMobileNr)
|
||||
.setHolderName(holderName)
|
||||
.setQuestion(question)
|
||||
.setAnswer(answer))
|
||||
|
@ -82,7 +82,7 @@ public final class InteracETransferAccountPayload extends PaymentAccountPayload
|
|||
public static InteracETransferAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
|
||||
return new InteracETransferAccountPayload(proto.getPaymentMethodId(),
|
||||
proto.getId(),
|
||||
proto.getInteracETransferAccountPayload().getEmail(),
|
||||
proto.getInteracETransferAccountPayload().getEmailOrMobileNr(),
|
||||
proto.getInteracETransferAccountPayload().getHolderName(),
|
||||
proto.getInteracETransferAccountPayload().getQuestion(),
|
||||
proto.getInteracETransferAccountPayload().getAnswer(),
|
||||
|
@ -98,21 +98,21 @@ public final class InteracETransferAccountPayload extends PaymentAccountPayload
|
|||
@Override
|
||||
public String getPaymentDetails() {
|
||||
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.owner") + " " + holderName + ", " +
|
||||
Res.get("payment.email") + " " + email + ", " + Res.getWithCol("payment.secret") + " " +
|
||||
Res.get("payment.email") + " " + emailOrMobileNr + ", " + Res.getWithCol("payment.secret") + " " +
|
||||
question + ", " + Res.getWithCol("payment.answer") + " " + answer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPaymentDetailsForTradePopup() {
|
||||
return Res.getWithCol("payment.account.owner") + " " + holderName + "\n" +
|
||||
Res.getWithCol("payment.email") + " " + email + "\n" +
|
||||
Res.getWithCol("payment.email") + " " + emailOrMobileNr + "\n" +
|
||||
Res.getWithCol("payment.secret") + " " + question + "\n" +
|
||||
Res.getWithCol("payment.answer") + " " + answer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getAgeWitnessInputData() {
|
||||
return super.getAgeWitnessInputData(ArrayUtils.addAll(email.getBytes(StandardCharsets.UTF_8),
|
||||
return super.getAgeWitnessInputData(ArrayUtils.addAll(emailOrMobileNr.getBytes(StandardCharsets.UTF_8),
|
||||
ArrayUtils.addAll(question.getBytes(StandardCharsets.UTF_8),
|
||||
answer.getBytes(StandardCharsets.UTF_8))));
|
||||
}
|
||||
|
|
|
@ -369,7 +369,15 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
|
|||
CASH_APP_ID,
|
||||
PAYPAL_ID,
|
||||
VENMO_ID,
|
||||
PAYSAFE_ID);
|
||||
PAYSAFE_ID,
|
||||
WECHAT_PAY_ID,
|
||||
ALI_PAY_ID,
|
||||
SWISH_ID,
|
||||
TRANSFERWISE_USD_ID,
|
||||
AMAZON_GIFT_CARD_ID,
|
||||
ACH_TRANSFER_ID,
|
||||
INTERAC_E_TRANSFER_ID,
|
||||
US_POSTAL_MONEY_ORDER_ID);
|
||||
return paymentMethods.stream().filter(paymentMethod -> paymentMethodIds.contains(paymentMethod.getId())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||
public final class TransferwiseUsdAccountPayload extends CountryBasedPaymentAccountPayload {
|
||||
private String email = "";
|
||||
private String holderName = "";
|
||||
private String beneficiaryAddress = "";
|
||||
private String holderAddress = "";
|
||||
|
||||
public TransferwiseUsdAccountPayload(String paymentMethod, String id) {
|
||||
super(paymentMethod, id);
|
||||
|
@ -51,7 +51,7 @@ public final class TransferwiseUsdAccountPayload extends CountryBasedPaymentAcco
|
|||
List<String> acceptedCountryCodes,
|
||||
String email,
|
||||
String holderName,
|
||||
String beneficiaryAddress,
|
||||
String holderAddress,
|
||||
long maxTradePeriod,
|
||||
Map<String, String> excludeFromJsonDataMap) {
|
||||
super(paymentMethod,
|
||||
|
@ -63,7 +63,7 @@ public final class TransferwiseUsdAccountPayload extends CountryBasedPaymentAcco
|
|||
|
||||
this.email = email;
|
||||
this.holderName = holderName;
|
||||
this.beneficiaryAddress = beneficiaryAddress;
|
||||
this.holderAddress = holderAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,7 +71,7 @@ public final class TransferwiseUsdAccountPayload extends CountryBasedPaymentAcco
|
|||
protobuf.TransferwiseUsdAccountPayload.Builder builder = protobuf.TransferwiseUsdAccountPayload.newBuilder()
|
||||
.setEmail(email)
|
||||
.setHolderName(holderName)
|
||||
.setBeneficiaryAddress(beneficiaryAddress);
|
||||
.setHolderAddress(holderAddress);
|
||||
final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder()
|
||||
.getCountryBasedPaymentAccountPayloadBuilder()
|
||||
.setTransferwiseUsdAccountPayload(builder);
|
||||
|
@ -89,7 +89,7 @@ public final class TransferwiseUsdAccountPayload extends CountryBasedPaymentAcco
|
|||
new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()),
|
||||
accountPayloadPB.getEmail(),
|
||||
accountPayloadPB.getHolderName(),
|
||||
accountPayloadPB.getBeneficiaryAddress(),
|
||||
accountPayloadPB.getHolderAddress(),
|
||||
proto.getMaxTradePeriod(),
|
||||
new HashMap<>(proto.getExcludeFromJsonDataMap()));
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import haveno.common.file.FileUtil;
|
|||
import haveno.common.util.Base64;
|
||||
import haveno.common.util.Utilities;
|
||||
import haveno.core.api.CoreNotificationService;
|
||||
import haveno.core.api.CorePaymentAccountsService;
|
||||
import haveno.core.api.XmrConnectionService;
|
||||
import haveno.core.app.HavenoSetup;
|
||||
import haveno.core.offer.OfferPayload;
|
||||
|
@ -132,6 +133,7 @@ public class HavenoUtils {
|
|||
public static XmrConnectionService xmrConnectionService;
|
||||
public static OpenOfferManager openOfferManager;
|
||||
public static CoreNotificationService notificationService;
|
||||
public static CorePaymentAccountsService corePaymentAccountService;
|
||||
public static Preferences preferences;
|
||||
|
||||
public static boolean isSeedNode() {
|
||||
|
|
|
@ -120,7 +120,7 @@ public class AmazonGiftCardForm extends PaymentMethodForm {
|
|||
|
||||
@Override
|
||||
protected void autoFillNameTextField() {
|
||||
setAccountNameWithString(amazonGiftCardAccount.getEmailOrMobileNr());
|
||||
setAccountNameWithString(amazonGiftCardAccount.getEmailOrMobileNr() == null ? "" : amazonGiftCardAccount.getEmailOrMobileNr());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,7 +44,7 @@ public class InteracETransferForm extends PaymentMethodForm {
|
|||
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"),
|
||||
((InteracETransferAccountPayload) paymentAccountPayload).getHolderName());
|
||||
addCompactTopLabelTextField(gridPane, gridRow, 1, Res.get("payment.emailOrMobile"),
|
||||
((InteracETransferAccountPayload) paymentAccountPayload).getEmail());
|
||||
((InteracETransferAccountPayload) paymentAccountPayload).getEmailOrMobileNr());
|
||||
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.secret"),
|
||||
((InteracETransferAccountPayload) paymentAccountPayload).getQuestion());
|
||||
addCompactTopLabelTextField(gridPane, gridRow, 1, Res.get("payment.answer"),
|
||||
|
|
|
@ -57,7 +57,7 @@ public class TransferwiseUsdForm extends PaymentMethodForm {
|
|||
addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, 1, Res.get("payment.email"),
|
||||
((TransferwiseUsdAccountPayload) paymentAccountPayload).getEmail());
|
||||
|
||||
String address = ((TransferwiseUsdAccountPayload) paymentAccountPayload).getBeneficiaryAddress();
|
||||
String address = ((TransferwiseUsdAccountPayload) paymentAccountPayload).getHolderAddress();
|
||||
if (address.length() > 0) {
|
||||
TextArea textAddress = addCompactTopLabelTextArea(gridPane, gridRow, 0, Res.get("payment.account.address"), "").second;
|
||||
textAddress.setMinHeight(70);
|
||||
|
@ -96,7 +96,7 @@ public class TransferwiseUsdForm extends PaymentMethodForm {
|
|||
updateFromInputs();
|
||||
});
|
||||
|
||||
String addressLabel = Res.get("payment.account.owner.address") + Res.get("payment.transferwiseUsd.address");
|
||||
String addressLabel = Res.get("payment.account.owner.address") + " " + Res.get("payment.transferwiseUsd.address");
|
||||
TextArea addressTextArea = addTopLabelTextArea(gridPane, ++gridRow, addressLabel, addressLabel).second;
|
||||
addressTextArea.setMinHeight(70);
|
||||
addressTextArea.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||
|
|
|
@ -165,7 +165,7 @@ public class LockedView extends ActivatableView<VBox, Void> {
|
|||
|
||||
numItems.setText(Res.get("shared.numItemsLabel", sortedList.size()));
|
||||
exportButton.setOnAction(event -> {
|
||||
ObservableList<TableColumn<LockedListItem, ?>> tableColumns = tableView.getColumns();
|
||||
ObservableList<TableColumn<LockedListItem, ?>> tableColumns = GUIUtil.getContentColumns(tableView);
|
||||
int reportColumns = tableColumns.size();
|
||||
CSVEntryConverter<LockedListItem> headerConverter = item -> {
|
||||
String[] columns = new String[reportColumns];
|
||||
|
|
|
@ -165,7 +165,7 @@ public class ReservedView extends ActivatableView<VBox, Void> {
|
|||
|
||||
numItems.setText(Res.get("shared.numItemsLabel", sortedList.size()));
|
||||
exportButton.setOnAction(event -> {
|
||||
ObservableList<TableColumn<ReservedListItem, ?>> tableColumns = tableView.getColumns();
|
||||
ObservableList<TableColumn<ReservedListItem, ?>> tableColumns = GUIUtil.getContentColumns(tableView);
|
||||
int reportColumns = tableColumns.size();
|
||||
CSVEntryConverter<ReservedListItem> headerConverter = item -> {
|
||||
String[] columns = new String[reportColumns];
|
||||
|
|
|
@ -203,7 +203,7 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
|
|||
|
||||
numItems.setText(Res.get("shared.numItemsLabel", sortedDisplayedTransactions.size()));
|
||||
exportButton.setOnAction(event -> {
|
||||
final ObservableList<TableColumn<TransactionsListItem, ?>> tableColumns = tableView.getColumns();
|
||||
final ObservableList<TableColumn<TransactionsListItem, ?>> tableColumns = GUIUtil.getContentColumns(tableView);
|
||||
final int reportColumns = tableColumns.size() - 1; // CSV report excludes the last column (an icon)
|
||||
CSVEntryConverter<TransactionsListItem> headerConverter = item -> {
|
||||
String[] columns = new String[reportColumns];
|
||||
|
|
|
@ -397,7 +397,7 @@ public class TradesChartsView extends ActivatableViewAndModel<VBox, TradesCharts
|
|||
}
|
||||
|
||||
private void exportToCsv() {
|
||||
ObservableList<TableColumn<TradeStatistics3ListItem, ?>> tableColumns = tableView.getColumns();
|
||||
ObservableList<TableColumn<TradeStatistics3ListItem, ?>> tableColumns = GUIUtil.getContentColumns(tableView);
|
||||
int reportColumns = tableColumns.size() + 1;
|
||||
|
||||
boolean showAllTradeCurrencies = model.showAllTradeCurrenciesProperty.get();
|
||||
|
|
|
@ -1281,6 +1281,16 @@ public class GUIUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static <T> ObservableList<TableColumn<T, ?>> getContentColumns(TableView<T> tableView) {
|
||||
ObservableList<TableColumn<T, ?>> contentColumns = FXCollections.observableArrayList();
|
||||
for (TableColumn<T, ?> column : tableView.getColumns()) {
|
||||
if (!column.getStyleClass().contains("first-column") && !column.getStyleClass().contains("last-column")) {
|
||||
contentColumns.add(column);
|
||||
}
|
||||
}
|
||||
return contentColumns;
|
||||
}
|
||||
|
||||
public static ImageView getCurrencyIcon(String currencyCode) {
|
||||
return getCurrencyIcon(currencyCode, 24);
|
||||
}
|
||||
|
|
|
@ -1047,7 +1047,7 @@ message FasterPaymentsAccountPayload {
|
|||
}
|
||||
|
||||
message InteracETransferAccountPayload {
|
||||
string email = 1;
|
||||
string email_or_mobile_nr = 1;
|
||||
string holder_name = 2;
|
||||
string question = 3;
|
||||
string answer = 4;
|
||||
|
@ -1163,7 +1163,7 @@ message TransferwiseAccountPayload {
|
|||
message TransferwiseUsdAccountPayload {
|
||||
string email = 1;
|
||||
string holder_name = 2;
|
||||
string beneficiary_address = 3;
|
||||
string holder_address = 3;
|
||||
}
|
||||
|
||||
message PayseraAccountPayload {
|
||||
|
@ -1903,6 +1903,14 @@ message PaymentAccountForm {
|
|||
PAYPAL = 17;
|
||||
VENMO = 18;
|
||||
PAYSAFE = 19;
|
||||
WECHAT_PAY = 20;
|
||||
ALI_PAY = 21;
|
||||
SWISH = 22;
|
||||
TRANSFERWISE_USD = 23;
|
||||
AMAZON_GIFT_CARD = 24;
|
||||
ACH_TRANSFER = 25;
|
||||
INTERAC_E_TRANSFER = 26;
|
||||
US_POSTAL_MONEY_ORDER = 27;
|
||||
}
|
||||
FormId id = 1;
|
||||
repeated PaymentAccountFormField fields = 2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue