Add payment method MoneyBeam (#1349)

This commit is contained in:
Manfred Karrer 2018-02-13 20:00:35 -05:00
parent ad56c26f7f
commit eb0a8b8d49
No known key found for this signature in database
GPG key ID: 401250966A6B2C46
12 changed files with 301 additions and 4 deletions

View file

@ -10,7 +10,7 @@ public class DevEnv {
// peer (click user icon and alt+r), filter/block offers by various data like offer ID (cmd + f).
// The user can set a program argument to ignore all of those privileged network_messages. They are intended for
// emergency cases only (beside update message and arbitrator registration).
public static final boolean USE_DEV_PRIVILEGE_KEYS = false;
public static final boolean USE_DEV_PRIVILEGE_KEYS = true;
public static final String DEV_PRIVILEGE_PUB_KEY = "027a381b5333a56e1cc3d90d3a7d07f26509adf7029ed06fc997c656621f8da1ee";
public static final String DEV_PRIVILEGE_PRIV_KEY = "6ac43ea1df2a290c1c8391736aa42e4339c5cb4f110ff0257a13b63211977b7a";
@ -18,7 +18,7 @@ public class DevEnv {
// If set to true we ignore several UI behavior like confirmation popups as well dummy accounts are created and
// offers are filled with default values. Intended to make dev testing faster.
@SuppressWarnings("PointlessBooleanExpression")
public static final boolean DEV_MODE = STRESS_TEST_MODE || false;
public static final boolean DEV_MODE = STRESS_TEST_MODE || true;
public static final boolean DAO_PHASE2_ACTIVATED = false;
public static final boolean DAO_TRADING_ACTIVATED = false;

View file

@ -832,6 +832,7 @@ message PaymentAccountPayload {
USPostalMoneyOrderAccountPayload u_s_postal_money_order_account_payload = 14;
UpholdAccountPayload uphold_account_payload = 16;
CashAppAccountPayload cash_app_account_payload = 17;
MoneyBeamAccountPayload money_beam_account_payload = 18;
}
map<string, string> exclude_from_json_data = 15;
}
@ -950,6 +951,10 @@ message CashAppAccountPayload {
string account_id = 1;
}
message MoneyBeamAccountPayload {
string account_id = 1;
}
message PerfectMoneyAccountPayload {
string account_nr = 1;
}

View file

@ -1618,8 +1618,9 @@ payment.select.altcoin=Select or search altcoin
payment.secret=Secret question:
payment.answer=Answer:
payment.wallet=Wallet ID:
payment.uphold.accountId=Account ID (username or email or phone. no):
payment.cashApp.accountId=Account ID ($Cashtag or email or phone. no):
payment.uphold.accountId=Username or email or phone no.:
payment.cashApp.accountId=$Cashtag or email or phone no.:
payment.moneyBeam.accountId=Email or phone no.:
payment.supported.okpay=Supported currencies:
payment.supported.uphold=Supported currencies:
payment.limitations=Limitations:
@ -1706,6 +1707,7 @@ WESTERN_UNION_SHORT=Western Union
OK_PAY=OKPay
UPHOLD=Uphold
CASH_APP=Cash App
MONEY_BEAM=MoneyBeam
PERFECT_MONEY=Perfect Money
ALI_PAY=AliPay
SEPA=SEPA
@ -1724,6 +1726,8 @@ UPHOLD_SHORT=Uphold
# suppress inspection "UnusedProperty"
CASH_APP_SHORT=Cash App
# suppress inspection "UnusedProperty"
MONEY_BEAM_SHORT=MoneyBeam
# suppress inspection "UnusedProperty"
PERFECT_MONEY_SHORT=Perfect Money
# suppress inspection "UnusedProperty"
ALI_PAY_SHORT=AliPay

View 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 io.bisq.core.payment;
import io.bisq.common.locale.FiatCurrency;
import io.bisq.core.payment.payload.MoneyBeamAccountPayload;
import io.bisq.core.payment.payload.PaymentAccountPayload;
import io.bisq.core.payment.payload.PaymentMethod;
import lombok.EqualsAndHashCode;
//TODO missing support for selected trade currency
@EqualsAndHashCode(callSuper = true)
public final class MoneyBeamAccount extends PaymentAccount {
public MoneyBeamAccount() {
super(PaymentMethod.MONEY_BEAM);
setSingleTradeCurrency(new FiatCurrency("EUR"));
}
@Override
protected PaymentAccountPayload createPayload() {
return new MoneyBeamAccountPayload(paymentMethod.getId(), id);
}
public void setAccountId(String accountId) {
((MoneyBeamAccountPayload) paymentAccountPayload).setAccountId(accountId);
}
public String getAccountId() {
return ((MoneyBeamAccountPayload) paymentAccountPayload).getAccountId();
}
}

View file

@ -28,6 +28,8 @@ public class PaymentAccountFactory {
return new UpholdAccount();
case PaymentMethod.CASH_APP_ID:
return new CashAppAccount();
case PaymentMethod.MONEY_BEAM_ID:
return new MoneyBeamAccount();
case PaymentMethod.PERFECT_MONEY_ID:
return new PerfectMoneyAccount();
case PaymentMethod.SEPA_ID:

View file

@ -0,0 +1,98 @@
/*
* 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 io.bisq.core.payment.payload;
import com.google.protobuf.Message;
import io.bisq.generated.protobuffer.PB;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
@EqualsAndHashCode(callSuper = true)
@ToString
@Setter
@Getter
@Slf4j
public final class MoneyBeamAccountPayload extends PaymentAccountPayload {
private String accountId = "";
public MoneyBeamAccountPayload(String paymentMethod, String id) {
super(paymentMethod, id);
}
///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////
private MoneyBeamAccountPayload(String paymentMethod,
String id,
String accountId,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
maxTradePeriod,
excludeFromJsonDataMap);
this.accountId = accountId;
}
@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setMoneyBeamAccountPayload(PB.MoneyBeamAccountPayload.newBuilder()
.setAccountId(accountId))
.build();
}
public static MoneyBeamAccountPayload fromProto(PB.PaymentAccountPayload proto) {
return new MoneyBeamAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getMoneyBeamAccountPayload().getAccountId(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public String getPaymentDetails() {
return "MoneyBeam - Account: " + accountId;
}
@Override
public String getPaymentDetailsForTradePopup() {
return getPaymentDetails();
}
@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(accountId.getBytes(Charset.forName("UTF-8")));
}
}

View file

@ -49,6 +49,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable {
public static final String OK_PAY_ID = "OK_PAY";
public static final String UPHOLD_ID = "UPHOLD";
public static final String CASH_APP_ID = "CASH_APP";
public static final String MONEY_BEAM_ID = "MONEY_BEAM";
public static final String PERFECT_MONEY_ID = "PERFECT_MONEY";
public static final String SEPA_ID = "SEPA";
public static final String SEPA_INSTANT_ID = "SEPA_INSTANT";
@ -69,6 +70,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable {
public static PaymentMethod OK_PAY;
public static PaymentMethod UPHOLD;
public static PaymentMethod CASH_APP;
public static PaymentMethod MONEY_BEAM;
public static PaymentMethod PERFECT_MONEY;
public static PaymentMethod SEPA;
public static PaymentMethod SEPA_INSTANT;
@ -163,6 +165,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable {
// EUR
SEPA = new PaymentMethod(SEPA_ID, 6 * DAY, maxTradeLimitMidRisk),
SEPA_INSTANT = new PaymentMethod(SEPA_INSTANT_ID, DAY, maxTradeLimitMidRisk),
MONEY_BEAM = new PaymentMethod(MONEY_BEAM_ID, DAY, maxTradeLimitMidRisk),
// UK
FASTER_PAYMENTS = new PaymentMethod(FASTER_PAYMENTS_ID, DAY, maxTradeLimitMidRisk),

View file

@ -64,6 +64,8 @@ public class CoreProtoResolver implements ProtoResolver {
return UpholdAccountPayload.fromProto(proto);
case CASH_APP_ACCOUNT_PAYLOAD:
return CashAppAccountPayload.fromProto(proto);
case MONEY_BEAM_ACCOUNT_PAYLOAD:
return MoneyBeamAccountPayload.fromProto(proto);
case PERFECT_MONEY_ACCOUNT_PAYLOAD:
return PerfectMoneyAccountPayload.fromProto(proto);
case SWISH_ACCOUNT_PAYLOAD:

View file

@ -0,0 +1,101 @@
/*
* 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 io.bisq.gui.components.paymentmethods;
import io.bisq.common.locale.Res;
import io.bisq.common.locale.TradeCurrency;
import io.bisq.core.payment.AccountAgeWitnessService;
import io.bisq.core.payment.MoneyBeamAccount;
import io.bisq.core.payment.PaymentAccount;
import io.bisq.core.payment.payload.MoneyBeamAccountPayload;
import io.bisq.core.payment.payload.PaymentAccountPayload;
import io.bisq.gui.components.InputTextField;
import io.bisq.gui.util.BSFormatter;
import io.bisq.gui.util.Layout;
import io.bisq.gui.util.validation.InputValidator;
import io.bisq.gui.util.validation.MoneyBeamValidator;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import org.apache.commons.lang3.StringUtils;
import static io.bisq.gui.util.FormBuilder.*;
public class MoneyBeamForm extends PaymentMethodForm {
private final MoneyBeamAccount account;
private final MoneyBeamValidator validator;
private InputTextField accountIdInputTextField;
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) {
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.moneyBeam.accountId"), ((MoneyBeamAccountPayload) paymentAccountPayload).getAccountId());
return gridRow;
}
public MoneyBeamForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, MoneyBeamValidator aliPayValidator, InputValidator inputValidator, GridPane gridPane, int gridRow, BSFormatter formatter) {
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter);
this.account = (MoneyBeamAccount) paymentAccount;
this.validator = aliPayValidator;
}
@Override
public void addFormForAddAccount() {
gridRowFrom = gridRow + 1;
accountIdInputTextField = addLabelInputTextField(gridPane, ++gridRow, Res.get("payment.moneyBeam.accountId")).second;
accountIdInputTextField.setValidator(validator);
accountIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
account.setAccountId(newValue);
updateFromInputs();
});
final TradeCurrency singleTradeCurrency = account.getSingleTradeCurrency();
final String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
addLabelTextField(gridPane, ++gridRow, Res.getWithCol("shared.currency"), nameAndCode);
addLimitations();
addAccountNameTextFieldWithAutoFillCheckBox();
}
@Override
protected void autoFillNameTextField() {
if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
String accountNr = accountIdInputTextField.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;
addLabelTextField(gridPane, gridRow, Res.get("payment.account.name"), account.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addLabelTextField(gridPane, ++gridRow, Res.getWithCol("shared.paymentMethod"), Res.get(account.getPaymentMethod().getId()));
TextField field = addLabelTextField(gridPane, ++gridRow, Res.get("payment.moneyBeam.accountId"), account.getAccountId()).second;
field.setMouseTransparent(false);
final TradeCurrency singleTradeCurrency = account.getSingleTradeCurrency();
final String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
addLabelTextField(gridPane, ++gridRow, Res.getWithCol("shared.currency"), nameAndCode);
addLimitations();
}
@Override
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& validator.validate(account.getAccountId()).isValid
&& account.getTradeCurrencies().size() > 0);
}
}

View file

@ -64,6 +64,7 @@ public class FiatAccountsView extends ActivatableViewAndModel<GridPane, FiatAcco
private final OKPayValidator okPayValidator;
private final UpholdValidator upholdValidator;
private final CashAppValidator cashAppValidator;
private final MoneyBeamValidator moneyBeamValidator;
private final AliPayValidator aliPayValidator;
private final PerfectMoneyValidator perfectMoneyValidator;
private final SwishValidator swishValidator;
@ -89,6 +90,7 @@ public class FiatAccountsView extends ActivatableViewAndModel<GridPane, FiatAcco
OKPayValidator okPayValidator,
UpholdValidator upholdValidator,
CashAppValidator cashAppValidator,
MoneyBeamValidator moneyBeamValidator,
AliPayValidator aliPayValidator,
PerfectMoneyValidator perfectMoneyValidator,
SwishValidator swishValidator,
@ -106,6 +108,7 @@ public class FiatAccountsView extends ActivatableViewAndModel<GridPane, FiatAcco
this.okPayValidator = okPayValidator;
this.upholdValidator = upholdValidator;
this.cashAppValidator = cashAppValidator;
this.moneyBeamValidator = moneyBeamValidator;
this.aliPayValidator = aliPayValidator;
this.perfectMoneyValidator = perfectMoneyValidator;
this.swishValidator = swishValidator;
@ -349,6 +352,8 @@ public class FiatAccountsView extends ActivatableViewAndModel<GridPane, FiatAcco
return new UpholdForm(paymentAccount, accountAgeWitnessService, upholdValidator, inputValidator, root, gridRow, formatter);
case PaymentMethod.CASH_APP_ID:
return new CashAppForm(paymentAccount, accountAgeWitnessService, cashAppValidator, inputValidator, root, gridRow, formatter);
case PaymentMethod.MONEY_BEAM_ID:
return new MoneyBeamForm(paymentAccount, accountAgeWitnessService, moneyBeamValidator, inputValidator, root, gridRow, formatter);
case PaymentMethod.PERFECT_MONEY_ID:
return new PerfectMoneyForm(paymentAccount, accountAgeWitnessService, perfectMoneyValidator, inputValidator, root, gridRow, formatter);
case PaymentMethod.SEPA_ID:

View file

@ -163,6 +163,9 @@ public class BuyerStep2View extends TradeStepView {
case PaymentMethod.CASH_APP_ID:
gridRow = CashAppForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
break;
case PaymentMethod.MONEY_BEAM_ID:
gridRow = MoneyBeamForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
break;
case PaymentMethod.PERFECT_MONEY_ID:
gridRow = PerfectMoneyForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
break;

View file

@ -0,0 +1,28 @@
/*
* 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 io.bisq.gui.util.validation;
public final class MoneyBeamValidator extends InputValidator {
@Override
public ValidationResult validate(String input) {
// TODO
return super.validate(input);
}
}