Skip to content

Commit

Permalink
Add popmoney (#1273)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfredKarrer committed Feb 19, 2018
1 parent 378134c commit dd86ead
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 1 deletion.
6 changes: 6 additions & 0 deletions common/src/main/proto/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ message PaymentAccountPayload {
CashAppAccountPayload cash_app_account_payload = 17;
MoneyBeamAccountPayload money_beam_account_payload = 18;
VenmoAccountPayload venmo_account_payload = 19;
PopmoneyAccountPayload popmoney_account_payload = 20;
}
map<string, string> exclude_from_json_data = 15;
}
Expand Down Expand Up @@ -961,6 +962,11 @@ message VenmoAccountPayload {
string holder_name = 2;
}

message PopmoneyAccountPayload {
string account_id = 1;
string holder_name = 2;
}

message PerfectMoneyAccountPayload {
string account_nr = 1;
}
Expand Down
5 changes: 5 additions & 0 deletions common/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,7 @@ payment.uphold.accountId=Username or email or phone no.:
payment.cashApp.cashTag=$Cashtag:
payment.moneyBeam.accountId=Email or phone no.:
payment.venmo.venmoUserName=Venmo username:
payment.popmoney.accountId=Email or phone no.:
payment.supported.okpay=Supported currencies:
payment.supported.uphold=Supported currencies:
payment.limitations=Limitations:
Expand Down Expand Up @@ -1672,6 +1673,7 @@ before starting a trade or creating an offer.\n\n\
\t● FirstBank Person to Person Transfers\n\
\t● Frost Send Money\n\
\t● U.S. Bank Send Money\n\
\t● TD Bank\n\
\t● Wells Fargo SurePay\n\n\
3. You need to be sure to not exceed the daily or monthly Zelle (ClearXchange) transfer limits.\n\n\
Please use Zelle (ClearXchange) only if you fulfill all those requirements, \
Expand Down Expand Up @@ -1714,6 +1716,7 @@ UPHOLD=Uphold
CASH_APP=Cash App
MONEY_BEAM=MoneyBeam
VENMO=Venmo
POPMONEY=Popmoney
PERFECT_MONEY=Perfect Money
ALI_PAY=AliPay
SEPA=SEPA
Expand All @@ -1736,6 +1739,8 @@ MONEY_BEAM_SHORT=MoneyBeam
# suppress inspection "UnusedProperty"
VENMO_SHORT=Venmo
# suppress inspection "UnusedProperty"
POPMONEY_SHORT=Popmoney
# suppress inspection "UnusedProperty"
PERFECT_MONEY_SHORT=Perfect Money
# suppress inspection "UnusedProperty"
ALI_PAY_SHORT=AliPay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) {
return new MoneyBeamAccount();
case PaymentMethod.VENMO_ID:
return new VenmoAccount();
case PaymentMethod.POPMONEY_ID:
return new PopmoneyAccount();
case PaymentMethod.PERFECT_MONEY_ID:
return new PerfectMoneyAccount();
case PaymentMethod.SEPA_ID:
Expand Down
54 changes: 54 additions & 0 deletions core/src/main/java/io/bisq/core/payment/PopmoneyAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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.PaymentAccountPayload;
import io.bisq.core.payment.payload.PaymentMethod;
import io.bisq.core.payment.payload.PopmoneyAccountPayload;
import lombok.EqualsAndHashCode;

//TODO missing support for selected trade currency
@EqualsAndHashCode(callSuper = true)
public final class PopmoneyAccount extends PaymentAccount {
public PopmoneyAccount() {
super(PaymentMethod.POPMONEY);
setSingleTradeCurrency(new FiatCurrency("USD"));
}

@Override
protected PaymentAccountPayload createPayload() {
return new PopmoneyAccountPayload(paymentMethod.getId(), id);
}

public void setAccountId(String accountId) {
((PopmoneyAccountPayload) paymentAccountPayload).setAccountId(accountId);
}

public String getAccountId() {
return ((PopmoneyAccountPayload) paymentAccountPayload).getAccountId();
}

public void setHolderName(String holderName) {
((PopmoneyAccountPayload) paymentAccountPayload).setHolderName(holderName);
}

public String getHolderName() {
return ((PopmoneyAccountPayload) paymentAccountPayload).getHolderName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable {
public static final String CASH_APP_ID = "CASH_APP";
public static final String MONEY_BEAM_ID = "MONEY_BEAM";
public static final String VENMO_ID = "VENMO";
public static final String POPMONEY_ID = "POPMONEY";
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";
Expand All @@ -73,6 +74,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable {
public static PaymentMethod CASH_APP;
public static PaymentMethod MONEY_BEAM;
public static PaymentMethod VENMO;
public static PaymentMethod POPMONEY;
public static PaymentMethod PERFECT_MONEY;
public static PaymentMethod SEPA;
public static PaymentMethod SEPA_INSTANT;
Expand Down Expand Up @@ -179,6 +181,7 @@ public static List<PaymentMethod> getAllValues() {
CLEAR_X_CHANGE = new PaymentMethod(CLEAR_X_CHANGE_ID, 4 * DAY, maxTradeLimitMidRisk),
CASH_APP = new PaymentMethod(CASH_APP_ID, DAY, maxTradeLimitMidRisk),
VENMO = new PaymentMethod(VENMO_ID, DAY, maxTradeLimitMidRisk),
POPMONEY = new PaymentMethod(POPMONEY_ID, DAY, maxTradeLimitMidRisk),
CHASE_QUICK_PAY = new PaymentMethod(CHASE_QUICK_PAY_ID, DAY, maxTradeLimitMidRisk),
US_POSTAL_MONEY_ORDER = new PaymentMethod(US_POSTAL_MONEY_ORDER_ID, 8 * DAY, maxTradeLimitMidRisk),

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* 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 PopmoneyAccountPayload extends PaymentAccountPayload {
private String accountId = "";
private String holderName = "";

public PopmoneyAccountPayload(String paymentMethod, String id) {
super(paymentMethod, id);
}


///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////

private PopmoneyAccountPayload(String paymentMethod,
String id,
String accountId,
String holderName,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
maxTradePeriod,
excludeFromJsonDataMap);

this.accountId = accountId;
this.holderName = holderName;
}

@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setPopmoneyAccountPayload(PB.PopmoneyAccountPayload.newBuilder()
.setAccountId(accountId)
.setHolderName(holderName))
.build();
}

public static PopmoneyAccountPayload fromProto(PB.PaymentAccountPayload proto) {
return new PopmoneyAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getPopmoneyAccountPayload().getAccountId(),
proto.getPopmoneyAccountPayload().getHolderName(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}


///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public String getPaymentDetails() {
return "Popmoney - Holder name: " + holderName + ", email or phone no.: " + accountId;
}

@Override
public String getPaymentDetailsForTradePopup() {
return getPaymentDetails();
}

@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(accountId.getBytes(Charset.forName("UTF-8")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static VenmoAccountPayload fromProto(PB.PaymentAccountPayload proto) {

@Override
public String getPaymentDetails() {
return "Venmo - Account: " + venmoUserName;
return "Venmo - Holder name: " + holderName + ", Venmo username: " + venmoUserName;
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/io/bisq/core/proto/CoreProtoResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public PaymentAccountPayload fromProto(PB.PaymentAccountPayload proto) {
return MoneyBeamAccountPayload.fromProto(proto);
case VENMO_ACCOUNT_PAYLOAD:
return VenmoAccountPayload.fromProto(proto);
case POPMONEY_ACCOUNT_PAYLOAD:
return PopmoneyAccountPayload.fromProto(proto);
case PERFECT_MONEY_ACCOUNT_PAYLOAD:
return PerfectMoneyAccountPayload.fromProto(proto);
case SWISH_ACCOUNT_PAYLOAD:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* 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.PaymentAccount;
import io.bisq.core.payment.PopmoneyAccount;
import io.bisq.core.payment.payload.PaymentAccountPayload;
import io.bisq.core.payment.payload.PopmoneyAccountPayload;
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.PopmoneyValidator;
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 PopmoneyForm extends PaymentMethodForm {
private final PopmoneyAccount account;
private final PopmoneyValidator validator;
private InputTextField accountIdInputTextField;

public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) {
addLabelTextField(gridPane, ++gridRow, Res.getWithCol("payment.account.owner"),
((PopmoneyAccountPayload) paymentAccountPayload).getHolderName());
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.popmoney.accountId"), ((PopmoneyAccountPayload) paymentAccountPayload).getAccountId());
return gridRow;
}

public PopmoneyForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, PopmoneyValidator aliPayValidator, InputValidator inputValidator, GridPane gridPane, int gridRow, BSFormatter formatter) {
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter);
this.account = (PopmoneyAccount) paymentAccount;
this.validator = aliPayValidator;
}

@Override
public void addFormForAddAccount() {
gridRowFrom = gridRow + 1;

InputTextField holderNameInputTextField = addLabelInputTextField(gridPane, ++gridRow,
Res.getWithCol("payment.account.owner")).second;
holderNameInputTextField.setValidator(inputValidator);
holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
account.setHolderName(newValue);
updateFromInputs();
});

accountIdInputTextField = addLabelInputTextField(gridPane, ++gridRow, Res.get("payment.popmoney.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()));
addLabelTextField(gridPane, ++gridRow, Res.getWithCol("payment.account.owner"),
account.getHolderName());
TextField field = addLabelTextField(gridPane, ++gridRow, Res.get("payment.popmoney.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()
&& inputValidator.validate(account.getHolderName()).isValid
&& validator.validate(account.getAccountId()).isValid
&& account.getTradeCurrencies().size() > 0);
}
}
Loading

0 comments on commit dd86ead

Please sign in to comment.