-
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
ead3082
commit ad56c26
Showing
11 changed files
with
298 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
46 changes: 46 additions & 0 deletions
46
core/src/main/java/io/bisq/core/payment/CashAppAccount.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,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.CashAppAccountPayload; | ||
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 CashAppAccount extends PaymentAccount { | ||
public CashAppAccount() { | ||
super(PaymentMethod.CASH_APP); | ||
setSingleTradeCurrency(new FiatCurrency("USD")); | ||
} | ||
|
||
@Override | ||
protected PaymentAccountPayload createPayload() { | ||
return new CashAppAccountPayload(paymentMethod.getId(), id); | ||
} | ||
|
||
public void setAccountId(String accountId) { | ||
((CashAppAccountPayload) paymentAccountPayload).setAccountId(accountId); | ||
} | ||
|
||
public String getAccountId() { | ||
return ((CashAppAccountPayload) paymentAccountPayload).getAccountId(); | ||
} | ||
} |
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/CashAppAccountPayload.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 CashAppAccountPayload extends PaymentAccountPayload { | ||
private String accountId = ""; | ||
|
||
public CashAppAccountPayload(String paymentMethod, String id) { | ||
super(paymentMethod, id); | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
// PROTO BUFFER | ||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
private CashAppAccountPayload(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() | ||
.setCashAppAccountPayload(PB.CashAppAccountPayload.newBuilder() | ||
.setAccountId(accountId)) | ||
.build(); | ||
} | ||
|
||
public static CashAppAccountPayload fromProto(PB.PaymentAccountPayload proto) { | ||
return new CashAppAccountPayload(proto.getPaymentMethodId(), | ||
proto.getId(), | ||
proto.getCashAppAccountPayload().getAccountId(), | ||
proto.getMaxTradePeriod(), | ||
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
// API | ||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
@Override | ||
public String getPaymentDetails() { | ||
return "CashApp - Account: " + 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
101 changes: 101 additions & 0 deletions
101
gui/src/main/java/io/bisq/gui/components/paymentmethods/CashAppForm.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.CashAppAccount; | ||
import io.bisq.core.payment.PaymentAccount; | ||
import io.bisq.core.payment.payload.CashAppAccountPayload; | ||
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.CashAppValidator; | ||
import io.bisq.gui.util.validation.InputValidator; | ||
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 CashAppForm extends PaymentMethodForm { | ||
private final CashAppAccount account; | ||
private final CashAppValidator validator; | ||
private InputTextField accountIdInputTextField; | ||
|
||
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) { | ||
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.cashApp.accountId"), ((CashAppAccountPayload) paymentAccountPayload).getAccountId()); | ||
return gridRow; | ||
} | ||
|
||
public CashAppForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, CashAppValidator aliPayValidator, InputValidator inputValidator, GridPane gridPane, int gridRow, BSFormatter formatter) { | ||
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); | ||
this.account = (CashAppAccount) paymentAccount; | ||
this.validator = aliPayValidator; | ||
} | ||
|
||
@Override | ||
public void addFormForAddAccount() { | ||
gridRowFrom = gridRow + 1; | ||
|
||
accountIdInputTextField = addLabelInputTextField(gridPane, ++gridRow, Res.get("payment.cashApp.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.cashApp.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); | ||
} | ||
} |
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.