mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
Add Capitual payment method. Waiting for final Info text to add.
This commit is contained in:
parent
1c5b5a8ced
commit
3be547c445
14 changed files with 396 additions and 3 deletions
|
@ -348,6 +348,17 @@ public class CurrencyUtil {
|
|||
return currencies;
|
||||
}
|
||||
|
||||
public static List<TradeCurrency> getAllCapitualCurrencies() {
|
||||
List<TradeCurrency> currencies = new ArrayList<>(Arrays.asList(
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("BRL"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("USD")
|
||||
));
|
||||
currencies.sort(Comparator.comparing(TradeCurrency::getCode));
|
||||
return currencies;
|
||||
}
|
||||
|
||||
// https://www.revolut.com/help/getting-started/exchanging-currencies/what-fiat-currencies-are-supported-for-holding-and-exchange
|
||||
public static List<TradeCurrency> getAllRevolutCurrencies() {
|
||||
ArrayList<TradeCurrency> currencies = new ArrayList<>(Arrays.asList(
|
||||
|
|
46
core/src/main/java/bisq/core/payment/CapitualAccount.java
Normal file
46
core/src/main/java/bisq/core/payment/CapitualAccount.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.core.payment;
|
||||
|
||||
import bisq.core.locale.CurrencyUtil;
|
||||
import bisq.core.payment.payload.CapitualAccountPayload;
|
||||
import bisq.core.payment.payload.PaymentAccountPayload;
|
||||
import bisq.core.payment.payload.PaymentMethod;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class CapitualAccount extends PaymentAccount {
|
||||
public CapitualAccount() {
|
||||
super(PaymentMethod.CAPITUAL);
|
||||
tradeCurrencies.addAll(CurrencyUtil.getAllCapitualCurrencies());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PaymentAccountPayload createPayload() {
|
||||
return new CapitualAccountPayload(paymentMethod.getId(), id);
|
||||
}
|
||||
|
||||
public void setAccountNr(String accountNr) {
|
||||
((CapitualAccountPayload) paymentAccountPayload).setAccountNr(accountNr);
|
||||
}
|
||||
|
||||
public String getAccountNr() {
|
||||
return ((CapitualAccountPayload) paymentAccountPayload).getAccountNr();
|
||||
}
|
||||
}
|
|
@ -86,6 +86,8 @@ public class PaymentAccountFactory {
|
|||
return new AmazonGiftCardAccount();
|
||||
case PaymentMethod.BLOCK_CHAINS_INSTANT_ID:
|
||||
return new InstantCryptoCurrencyAccount();
|
||||
case PaymentMethod.CAPITUAL_ID:
|
||||
return new CapitualAccount();
|
||||
|
||||
// Cannot be deleted as it would break old trade history entries
|
||||
case PaymentMethod.OK_PAY_ID:
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.core.payment.payload;
|
||||
|
||||
import bisq.core.locale.Res;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString
|
||||
@Setter
|
||||
@Getter
|
||||
@Slf4j
|
||||
public final class CapitualAccountPayload extends PaymentAccountPayload {
|
||||
private String accountNr = "";
|
||||
|
||||
public CapitualAccountPayload(String paymentMethod, String id) {
|
||||
super(paymentMethod, id);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PROTO BUFFER
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private CapitualAccountPayload(String paymentMethod,
|
||||
String id,
|
||||
String accountNr,
|
||||
long maxTradePeriod,
|
||||
Map<String, String> excludeFromJsonDataMap) {
|
||||
super(paymentMethod,
|
||||
id,
|
||||
maxTradePeriod,
|
||||
excludeFromJsonDataMap);
|
||||
|
||||
this.accountNr = accountNr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message toProtoMessage() {
|
||||
return getPaymentAccountPayloadBuilder()
|
||||
.setCapitualAccountPayload(protobuf.CapitualAccountPayload.newBuilder()
|
||||
.setAccountNr(accountNr))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CapitualAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
|
||||
return new CapitualAccountPayload(proto.getPaymentMethodId(),
|
||||
proto.getId(),
|
||||
proto.getCapitualAccountPayload().getAccountNr(),
|
||||
proto.getMaxTradePeriod(),
|
||||
new HashMap<>(proto.getExcludeFromJsonDataMap()));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getPaymentDetails() {
|
||||
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.capitual.cap") + " " + accountNr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPaymentDetailsForTradePopup() {
|
||||
return getPaymentDetails();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getAgeWitnessInputData() {
|
||||
return super.getAgeWitnessInputData(accountNr.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
|
@ -99,6 +99,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
|
|||
public static final String AMAZON_GIFT_CARD_ID = "AMAZON_GIFT_CARD";
|
||||
public static final String BLOCK_CHAINS_INSTANT_ID = "BLOCK_CHAINS_INSTANT";
|
||||
public static final String CASH_BY_MAIL_ID = "CASH_BY_MAIL";
|
||||
public static final String CAPITUAL_ID = "CAPITUAL";
|
||||
|
||||
// Cannot be deleted as it would break old trade history entries
|
||||
@Deprecated
|
||||
|
@ -140,6 +141,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
|
|||
public static PaymentMethod AMAZON_GIFT_CARD;
|
||||
public static PaymentMethod BLOCK_CHAINS_INSTANT;
|
||||
public static PaymentMethod CASH_BY_MAIL;
|
||||
public static PaymentMethod CAPITUAL;
|
||||
|
||||
// Cannot be deleted as it would break old trade history entries
|
||||
@Deprecated
|
||||
|
@ -191,6 +193,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
|
|||
PERFECT_MONEY = new PaymentMethod(PERFECT_MONEY_ID, DAY, DEFAULT_TRADE_LIMIT_LOW_RISK),
|
||||
ADVANCED_CASH = new PaymentMethod(ADVANCED_CASH_ID, DAY, DEFAULT_TRADE_LIMIT_VERY_LOW_RISK),
|
||||
TRANSFERWISE = new PaymentMethod(TRANSFERWISE_ID, 4 * DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
|
||||
CAPITUAL = new PaymentMethod(CAPITUAL_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
|
||||
|
||||
|
||||
// Japan
|
||||
JAPAN_BANK = new PaymentMethod(JAPAN_BANK_ID, DAY, DEFAULT_TRADE_LIMIT_LOW_RISK),
|
||||
|
|
|
@ -25,6 +25,7 @@ import bisq.core.payment.payload.AdvancedCashAccountPayload;
|
|||
import bisq.core.payment.payload.AliPayAccountPayload;
|
||||
import bisq.core.payment.payload.AmazonGiftCardAccountPayload;
|
||||
import bisq.core.payment.payload.AustraliaPayidPayload;
|
||||
import bisq.core.payment.payload.CapitualAccountPayload;
|
||||
import bisq.core.payment.payload.CashAppAccountPayload;
|
||||
import bisq.core.payment.payload.CashByMailAccountPayload;
|
||||
import bisq.core.payment.payload.CashDepositAccountPayload;
|
||||
|
@ -159,6 +160,8 @@ public class CoreProtoResolver implements ProtoResolver {
|
|||
return AmazonGiftCardAccountPayload.fromProto(proto);
|
||||
case INSTANT_CRYPTO_CURRENCY_ACCOUNT_PAYLOAD:
|
||||
return InstantCryptoCurrencyPayload.fromProto(proto);
|
||||
case CAPITUAL_ACCOUNT_PAYLOAD:
|
||||
return CapitualAccountPayload.fromProto(proto);
|
||||
|
||||
// Cannot be deleted as it would break old trade history entries
|
||||
case O_K_PAY_ACCOUNT_PAYLOAD:
|
||||
|
|
|
@ -152,7 +152,8 @@ public final class TradeStatistics3 implements ProcessOncePersistableNetworkPayl
|
|||
BLOCK_CHAINS_INSTANT,
|
||||
TRANSFERWISE,
|
||||
AMAZON_GIFT_CARD,
|
||||
CASH_BY_MAIL
|
||||
CASH_BY_MAIL,
|
||||
CAPITUAL
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
|
|
@ -3268,6 +3268,7 @@ payment.select.altcoin=Select or search Altcoin
|
|||
payment.secret=Secret question
|
||||
payment.answer=Answer
|
||||
payment.wallet=Wallet ID
|
||||
payment.capitual.cap=CAP Code
|
||||
payment.amazon.site=Buy giftcard at
|
||||
payment.ask=Ask in Trader Chat
|
||||
payment.uphold.accountId=Username or email or phone no.
|
||||
|
@ -3480,7 +3481,7 @@ payment.amazonGiftCard.info=To pay with Amazon eGift Card, you will need to send
|
|||
- try to use creative, believable text for the gift card''s message (e.g., "Happy birthday Susan!") along with the trade ID (and use trader chat \
|
||||
to tell your trading peer the reference text you picked so they can verify your payment)\n\
|
||||
- Amazon eGift Cards can only be redeemed on the Amazon website they were purchased on (e.g., a gift card purchased on amazon.it can only be redeemed on amazon.it)
|
||||
|
||||
payment.capitual.info=TODO
|
||||
|
||||
# We use constants from the code so we do not use our normal naming convention
|
||||
# dynamic values are not recognized by IntelliJ
|
||||
|
@ -3564,6 +3565,8 @@ TRANSFERWISE=TransferWise
|
|||
AMAZON_GIFT_CARD=Amazon eGift Card
|
||||
# suppress inspection "UnusedProperty"
|
||||
BLOCK_CHAINS_INSTANT=Altcoins Instant
|
||||
# suppress inspection "UnusedProperty"
|
||||
CAPITUAL=Capitual
|
||||
|
||||
# Deprecated: Cannot be deleted as it would break old trade history entries
|
||||
# suppress inspection "UnusedProperty"
|
||||
|
@ -3616,6 +3619,8 @@ TRANSFERWISE_SHORT=TransferWise
|
|||
AMAZON_GIFT_CARD_SHORT=Amazon eGift Card
|
||||
# suppress inspection "UnusedProperty"
|
||||
BLOCK_CHAINS_INSTANT_SHORT=Altcoins Instant
|
||||
# suppress inspection "UnusedProperty"
|
||||
CAPITUAL_SHORT=Capitual
|
||||
|
||||
# Deprecated: Cannot be deleted as it would break old trade history entries
|
||||
# suppress inspection "UnusedProperty"
|
||||
|
@ -3706,3 +3711,4 @@ validation.phone.tooManyDigits=There are too many digits in {0} to be a valid ph
|
|||
validation.phone.invalidDialingCode=Country dialing code for number {0} is invalid for country {1}. \
|
||||
The correct dialing code is {2}.
|
||||
validation.invalidAddressList=Must be comma separated list of valid addresses
|
||||
validation.capitual.invalidFormat=Must be a valid CAP code of format: CAP-XXXXXX (6 alphanumeric characters)
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.components.paymentmethods;
|
||||
|
||||
import bisq.desktop.components.InputTextField;
|
||||
import bisq.desktop.util.FormBuilder;
|
||||
import bisq.desktop.util.Layout;
|
||||
import bisq.desktop.util.validation.CapitualValidator;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
import bisq.core.locale.CurrencyUtil;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.payment.CapitualAccount;
|
||||
import bisq.core.payment.PaymentAccount;
|
||||
import bisq.core.payment.payload.CapitualAccountPayload;
|
||||
import bisq.core.payment.payload.PaymentAccountPayload;
|
||||
import bisq.core.util.coin.CoinFormatter;
|
||||
import bisq.core.util.validation.InputValidator;
|
||||
|
||||
import bisq.common.util.Tuple2;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
|
||||
import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextField;
|
||||
import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextFieldWithCopyIcon;
|
||||
import static bisq.desktop.util.FormBuilder.addTopLabelFlowPane;
|
||||
|
||||
public class CapitualForm extends PaymentMethodForm {
|
||||
private final CapitualAccount capitualAccount;
|
||||
private final CapitualValidator capitualValidator;
|
||||
private InputTextField accountNrInputTextField;
|
||||
|
||||
public static int addFormForBuyer(GridPane gridPane, int gridRow,
|
||||
PaymentAccountPayload paymentAccountPayload) {
|
||||
addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.capitual.cap"),
|
||||
((CapitualAccountPayload) paymentAccountPayload).getAccountNr());
|
||||
return gridRow;
|
||||
}
|
||||
|
||||
public CapitualForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, CapitualValidator capitualValidator,
|
||||
InputValidator inputValidator, GridPane gridPane, int gridRow, CoinFormatter formatter) {
|
||||
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter);
|
||||
this.capitualAccount = (CapitualAccount) paymentAccount;
|
||||
this.capitualValidator = capitualValidator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFormForAddAccount() {
|
||||
gridRowFrom = gridRow + 1;
|
||||
|
||||
accountNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.capitual.cap"));
|
||||
accountNrInputTextField.setValidator(capitualValidator);
|
||||
accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||
capitualAccount.setAccountNr(newValue);
|
||||
updateFromInputs();
|
||||
});
|
||||
|
||||
addCurrenciesGrid(true);
|
||||
addLimitations(false);
|
||||
addAccountNameTextFieldWithAutoFillToggleButton();
|
||||
}
|
||||
|
||||
private void addCurrenciesGrid(boolean isEditable) {
|
||||
final Tuple2<Label, FlowPane> labelFlowPaneTuple2 = addTopLabelFlowPane(gridPane, ++gridRow, Res.get("payment.supportedCurrencies"), 0);
|
||||
|
||||
FlowPane flowPane = labelFlowPaneTuple2.second;
|
||||
|
||||
if (isEditable)
|
||||
flowPane.setId("flow-pane-checkboxes-bg");
|
||||
else
|
||||
flowPane.setId("flow-pane-checkboxes-non-editable-bg");
|
||||
|
||||
CurrencyUtil.getAllCapitualCurrencies().stream().forEach(e ->
|
||||
fillUpFlowPaneWithCurrencies(isEditable, flowPane, e, capitualAccount));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void autoFillNameTextField() {
|
||||
if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.isSelected()) {
|
||||
String accountNr = accountNrInputTextField.getText();
|
||||
accountNr = StringUtils.abbreviate(accountNr, 9);
|
||||
String method = Res.get(paymentAccount.getPaymentMethod().getId());
|
||||
accountNameTextField.setText(method.concat(": ").concat(accountNr));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFormForDisplayAccount() {
|
||||
gridRowFrom = gridRow;
|
||||
addCompactTopLabelTextField(gridPane, gridRow, Res.get("payment.account.name"),
|
||||
capitualAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
|
||||
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"),
|
||||
Res.get(capitualAccount.getPaymentMethod().getId()));
|
||||
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.capitual.cap"),
|
||||
capitualAccount.getAccountNr());
|
||||
addLimitations(true);
|
||||
addCurrenciesGrid(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAllInputsValid() {
|
||||
allInputsValid.set(isAccountNameValid()
|
||||
&& capitualValidator.validate(capitualAccount.getAccountNr()).isValid
|
||||
&& capitualAccount.getTradeCurrencies().size() > 0);
|
||||
}
|
||||
|
||||
}
|
|
@ -23,6 +23,7 @@ import bisq.desktop.components.paymentmethods.AdvancedCashForm;
|
|||
import bisq.desktop.components.paymentmethods.AliPayForm;
|
||||
import bisq.desktop.components.paymentmethods.AmazonGiftCardForm;
|
||||
import bisq.desktop.components.paymentmethods.AustraliaPayidForm;
|
||||
import bisq.desktop.components.paymentmethods.CapitualForm;
|
||||
import bisq.desktop.components.paymentmethods.CashByMailForm;
|
||||
import bisq.desktop.components.paymentmethods.CashDepositForm;
|
||||
import bisq.desktop.components.paymentmethods.ChaseQuickPayForm;
|
||||
|
@ -59,6 +60,7 @@ import bisq.desktop.util.validation.AdvancedCashValidator;
|
|||
import bisq.desktop.util.validation.AliPayValidator;
|
||||
import bisq.desktop.util.validation.AustraliaPayidValidator;
|
||||
import bisq.desktop.util.validation.BICValidator;
|
||||
import bisq.desktop.util.validation.CapitualValidator;
|
||||
import bisq.desktop.util.validation.ChaseQuickPayValidator;
|
||||
import bisq.desktop.util.validation.ClearXchangeValidator;
|
||||
import bisq.desktop.util.validation.F2FValidator;
|
||||
|
@ -83,6 +85,7 @@ import bisq.core.locale.Res;
|
|||
import bisq.core.offer.OfferRestrictions;
|
||||
import bisq.core.payment.AmazonGiftCardAccount;
|
||||
import bisq.core.payment.AustraliaPayid;
|
||||
import bisq.core.payment.CapitualAccount;
|
||||
import bisq.core.payment.CashByMailAccount;
|
||||
import bisq.core.payment.CashDepositAccount;
|
||||
import bisq.core.payment.ClearXchangeAccount;
|
||||
|
@ -135,6 +138,7 @@ public class FiatAccountsView extends PaymentAccountsView<GridPane, FiatAccounts
|
|||
|
||||
private final IBANValidator ibanValidator;
|
||||
private final BICValidator bicValidator;
|
||||
private final CapitualValidator capitualValidator;
|
||||
private final LengthValidator inputValidator;
|
||||
private final UpholdValidator upholdValidator;
|
||||
private final MoneyBeamValidator moneyBeamValidator;
|
||||
|
@ -166,6 +170,7 @@ public class FiatAccountsView extends PaymentAccountsView<GridPane, FiatAccounts
|
|||
public FiatAccountsView(FiatAccountsViewModel model,
|
||||
IBANValidator ibanValidator,
|
||||
BICValidator bicValidator,
|
||||
CapitualValidator capitualValidator,
|
||||
LengthValidator inputValidator,
|
||||
UpholdValidator upholdValidator,
|
||||
MoneyBeamValidator moneyBeamValidator,
|
||||
|
@ -192,6 +197,7 @@ public class FiatAccountsView extends PaymentAccountsView<GridPane, FiatAccounts
|
|||
|
||||
this.ibanValidator = ibanValidator;
|
||||
this.bicValidator = bicValidator;
|
||||
this.capitualValidator = capitualValidator;
|
||||
this.inputValidator = inputValidator;
|
||||
this.inputValidator.setMaxLength(100); // restrict general field entry length
|
||||
this.inputValidator.setMinLength(2);
|
||||
|
@ -339,7 +345,15 @@ public class FiatAccountsView extends PaymentAccountsView<GridPane, FiatAccounts
|
|||
.actionButtonText(Res.get("shared.iUnderstand"))
|
||||
.onAction(() -> doSaveNewAccount(paymentAccount))
|
||||
.show();
|
||||
} else {
|
||||
} else if (paymentAccount instanceof CapitualAccount) {
|
||||
new Popup().information(Res.get("payment.capitual.info", currencyName, currencyName))
|
||||
.width(900)
|
||||
.closeButtonText(Res.get("shared.cancel"))
|
||||
.actionButtonText(Res.get("shared.iUnderstand"))
|
||||
.onAction(() -> doSaveNewAccount(paymentAccount))
|
||||
.show();
|
||||
}
|
||||
else {
|
||||
doSaveNewAccount(paymentAccount);
|
||||
}
|
||||
})
|
||||
|
@ -530,6 +544,8 @@ public class FiatAccountsView extends PaymentAccountsView<GridPane, FiatAccounts
|
|||
return new TransferwiseForm(paymentAccount, accountAgeWitnessService, transferwiseValidator, inputValidator, root, gridRow, formatter);
|
||||
case PaymentMethod.AMAZON_GIFT_CARD_ID:
|
||||
return new AmazonGiftCardForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter);
|
||||
case PaymentMethod.CAPITUAL_ID:
|
||||
return new CapitualForm(paymentAccount, accountAgeWitnessService, capitualValidator, inputValidator, root, gridRow, formatter);
|
||||
default:
|
||||
log.error("Not supported PaymentMethod: " + paymentMethod);
|
||||
return null;
|
||||
|
|
|
@ -25,6 +25,7 @@ import bisq.desktop.components.paymentmethods.AdvancedCashForm;
|
|||
import bisq.desktop.components.paymentmethods.AliPayForm;
|
||||
import bisq.desktop.components.paymentmethods.AmazonGiftCardForm;
|
||||
import bisq.desktop.components.paymentmethods.AssetsForm;
|
||||
import bisq.desktop.components.paymentmethods.CapitualForm;
|
||||
import bisq.desktop.components.paymentmethods.CashByMailForm;
|
||||
import bisq.desktop.components.paymentmethods.CashDepositForm;
|
||||
import bisq.desktop.components.paymentmethods.ChaseQuickPayForm;
|
||||
|
@ -323,6 +324,9 @@ public class BuyerStep2View extends TradeStepView {
|
|||
case PaymentMethod.AMAZON_GIFT_CARD_ID:
|
||||
gridRow = AmazonGiftCardForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
|
||||
break;
|
||||
case PaymentMethod.CAPITUAL_ID:
|
||||
gridRow = CapitualForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
|
||||
break;
|
||||
default:
|
||||
log.error("Not supported PaymentMethod: " + paymentMethodId);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package bisq.desktop.util.validation;
|
||||
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.validation.InputValidator;
|
||||
import bisq.core.util.validation.RegexValidator;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class CapitualValidator extends InputValidator {
|
||||
private RegexValidator regexValidator;
|
||||
|
||||
@Inject
|
||||
public CapitualValidator(RegexValidator regexValidator) {
|
||||
regexValidator.setPattern("CAP-[A-Za-z0-9]{6}");
|
||||
regexValidator.setErrorMessage(Res.get("validation.capitual.invalidFormat"));
|
||||
this.regexValidator = regexValidator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValidationResult validate(String input) {
|
||||
ValidationResult result = regexValidator.validate(input);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package bisq.desktop.util.validation;
|
||||
|
||||
import bisq.core.locale.CurrencyUtil;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.validation.RegexValidator;
|
||||
|
||||
import bisq.common.config.BaseCurrencyNetwork;
|
||||
import bisq.common.config.Config;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class CapitualValidatorTest {
|
||||
@Before
|
||||
public void setup() {
|
||||
final BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork();
|
||||
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();
|
||||
Res.setBaseCurrencyCode(currencyCode);
|
||||
Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName());
|
||||
CurrencyUtil.setBaseCurrencyCode(currencyCode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validate(){
|
||||
CapitualValidator validator = new CapitualValidator(
|
||||
new RegexValidator()
|
||||
);
|
||||
|
||||
assertTrue(validator.validate("CAP-123456").isValid);
|
||||
assertTrue(validator.validate("CAP-XXXXXX").isValid);
|
||||
assertTrue(validator.validate("CAP-123XXX").isValid);
|
||||
|
||||
assertFalse(validator.validate("").isValid);
|
||||
assertFalse(validator.validate(null).isValid);
|
||||
assertFalse(validator.validate("123456").isValid);
|
||||
assertFalse(validator.validate("XXXXXX").isValid);
|
||||
assertFalse(validator.validate("123XXX").isValid);
|
||||
assertFalse(validator.validate("12XXX").isValid);
|
||||
assertFalse(validator.validate("CAP-12XXX").isValid);
|
||||
assertFalse(validator.validate("CA-12XXXx").isValid);
|
||||
}
|
||||
}
|
|
@ -996,6 +996,7 @@ message PaymentAccountPayload {
|
|||
AustraliaPayidPayload australia_payid_payload = 30;
|
||||
AmazonGiftCardAccountPayload amazon_gift_card_account_payload = 31;
|
||||
CashByMailAccountPayload cash_by_mail_account_payload = 32;
|
||||
CapitualAccountPayload capitual_account_payload = 33;
|
||||
}
|
||||
map<string, string> exclude_from_json_data = 15;
|
||||
}
|
||||
|
@ -1217,6 +1218,10 @@ message TransferwiseAccountPayload {
|
|||
string email = 1;
|
||||
}
|
||||
|
||||
message CapitualAccountPayload {
|
||||
string account_nr = 1;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PersistableEnvelope
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Reference in a new issue