-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
378134c
commit dd86ead
Showing
12 changed files
with
326 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
core/src/main/java/io/bisq/core/payment/PopmoneyAccount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
core/src/main/java/io/bisq/core/payment/payload/PopmoneyAccountPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
gui/src/main/java/io/bisq/gui/components/paymentmethods/PopmoneyForm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.