-
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
beaaf59
commit 7654a5d
Showing
11 changed files
with
297 additions
and
0 deletions.
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
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,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.PaymentAccountPayload; | ||
import io.bisq.core.payment.payload.PaymentMethod; | ||
import io.bisq.core.payment.payload.VenmoAccountPayload; | ||
import lombok.EqualsAndHashCode; | ||
|
||
//TODO missing support for selected trade currency | ||
@EqualsAndHashCode(callSuper = true) | ||
public final class VenmoAccount extends PaymentAccount { | ||
public VenmoAccount() { | ||
super(PaymentMethod.VENMO); | ||
setSingleTradeCurrency(new FiatCurrency("USD")); | ||
} | ||
|
||
@Override | ||
protected PaymentAccountPayload createPayload() { | ||
return new VenmoAccountPayload(paymentMethod.getId(), id); | ||
} | ||
|
||
public void setVenmoUserName(String venmoUserName) { | ||
((VenmoAccountPayload) paymentAccountPayload).setVenmoUserName(venmoUserName); | ||
} | ||
|
||
public String getVenmoUserName() { | ||
return ((VenmoAccountPayload) paymentAccountPayload).getVenmoUserName(); | ||
} | ||
} |
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
98 changes: 98 additions & 0 deletions
98
core/src/main/java/io/bisq/core/payment/payload/VenmoAccountPayload.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,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 VenmoAccountPayload extends PaymentAccountPayload { | ||
private String venmoUserName = ""; | ||
|
||
public VenmoAccountPayload(String paymentMethod, String id) { | ||
super(paymentMethod, id); | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
// PROTO BUFFER | ||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
private VenmoAccountPayload(String paymentMethod, | ||
String id, | ||
String venmoUserName, | ||
long maxTradePeriod, | ||
Map<String, String> excludeFromJsonDataMap) { | ||
super(paymentMethod, | ||
id, | ||
maxTradePeriod, | ||
excludeFromJsonDataMap); | ||
|
||
this.venmoUserName = venmoUserName; | ||
} | ||
|
||
@Override | ||
public Message toProtoMessage() { | ||
return getPaymentAccountPayloadBuilder() | ||
.setVenmoAccountPayload(PB.VenmoAccountPayload.newBuilder() | ||
.setVenmoUserName(venmoUserName)) | ||
.build(); | ||
} | ||
|
||
public static VenmoAccountPayload fromProto(PB.PaymentAccountPayload proto) { | ||
return new VenmoAccountPayload(proto.getPaymentMethodId(), | ||
proto.getId(), | ||
proto.getVenmoAccountPayload().getVenmoUserName(), | ||
proto.getMaxTradePeriod(), | ||
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
// API | ||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
@Override | ||
public String getPaymentDetails() { | ||
return "Venmo - Account: " + venmoUserName; | ||
} | ||
|
||
@Override | ||
public String getPaymentDetailsForTradePopup() { | ||
return getPaymentDetails(); | ||
} | ||
|
||
@Override | ||
public byte[] getAgeWitnessInputData() { | ||
return super.getAgeWitnessInputData(venmoUserName.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
101 changes: 101 additions & 0 deletions
101
gui/src/main/java/io/bisq/gui/components/paymentmethods/VenmoForm.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,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.PaymentAccount; | ||
import io.bisq.core.payment.VenmoAccount; | ||
import io.bisq.core.payment.payload.PaymentAccountPayload; | ||
import io.bisq.core.payment.payload.VenmoAccountPayload; | ||
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.VenmoValidator; | ||
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 VenmoForm extends PaymentMethodForm { | ||
private final VenmoAccount account; | ||
private final VenmoValidator validator; | ||
private InputTextField accountIdInputTextField; | ||
|
||
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) { | ||
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.venmo.venmoUserName"), ((VenmoAccountPayload) paymentAccountPayload).getVenmoUserName()); | ||
return gridRow; | ||
} | ||
|
||
public VenmoForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, VenmoValidator aliPayValidator, InputValidator inputValidator, GridPane gridPane, int gridRow, BSFormatter formatter) { | ||
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); | ||
this.account = (VenmoAccount) paymentAccount; | ||
this.validator = aliPayValidator; | ||
} | ||
|
||
@Override | ||
public void addFormForAddAccount() { | ||
gridRowFrom = gridRow + 1; | ||
|
||
accountIdInputTextField = addLabelInputTextField(gridPane, ++gridRow, Res.get("payment.venmo.venmoUserName")).second; | ||
accountIdInputTextField.setValidator(validator); | ||
accountIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { | ||
account.setVenmoUserName(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.venmo.venmoUserName"), account.getVenmoUserName()).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.getVenmoUserName()).isValid | ||
&& account.getTradeCurrencies().size() > 0); | ||
} | ||
} |
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
Oops, something went wrong.