-
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.
Signed-off-by: jmacxx <[email protected]>
- Loading branch information
jmacxx
committed
Sep 28, 2021
1 parent
9e5a1c2
commit f792db9
Showing
11 changed files
with
303 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* 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 bisq.core.payment; | ||
|
||
import bisq.core.payment.payload.PaymentAccountPayload; | ||
import bisq.core.payment.payload.PaymentMethod; | ||
import bisq.core.payment.payload.NequiAccountPayload; | ||
|
||
import lombok.EqualsAndHashCode; | ||
|
||
@EqualsAndHashCode(callSuper = true) | ||
public final class NequiAccount extends CountryBasedPaymentAccount { | ||
public NequiAccount() { | ||
super(PaymentMethod.NEQUI); | ||
} | ||
|
||
@Override | ||
protected PaymentAccountPayload createPayload() { | ||
return new NequiAccountPayload(paymentMethod.getId(), id); | ||
} | ||
|
||
public void setMobileNr(String mobileNr) { | ||
((NequiAccountPayload) paymentAccountPayload).setMobileNr(mobileNr); | ||
} | ||
|
||
public String getMobileNr() { | ||
return ((NequiAccountPayload) paymentAccountPayload).getMobileNr(); | ||
} | ||
|
||
public String getMessageForBuyer() { | ||
return "payment.nequi.info.buyer"; | ||
} | ||
|
||
public String getMessageForSeller() { | ||
return "payment.nequi.info.seller"; | ||
} | ||
|
||
public String getMessageForAccountCreation() { | ||
return "payment.nequi.info.account"; | ||
} | ||
} |
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
99 changes: 99 additions & 0 deletions
99
core/src/main/java/bisq/core/payment/payload/NequiAccountPayload.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,99 @@ | ||
/* | ||
* 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 bisq.core.payment.payload; | ||
|
||
import bisq.core.locale.Res; | ||
|
||
import com.google.protobuf.Message; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@EqualsAndHashCode(callSuper = true) | ||
@ToString | ||
@Setter | ||
@Getter | ||
@Slf4j | ||
public final class NequiAccountPayload extends CountryBasedPaymentAccountPayload { | ||
private String mobileNr = ""; | ||
|
||
public NequiAccountPayload(String paymentMethod, String id) { | ||
super(paymentMethod, id); | ||
} | ||
|
||
private NequiAccountPayload(String paymentMethod, | ||
String id, | ||
String countryCode, | ||
String mobileNr, | ||
long maxTradePeriod, | ||
Map<String, String> excludeFromJsonDataMap) { | ||
super(paymentMethod, | ||
id, | ||
countryCode, | ||
maxTradePeriod, | ||
excludeFromJsonDataMap); | ||
|
||
this.mobileNr = mobileNr; | ||
} | ||
|
||
@Override | ||
public Message toProtoMessage() { | ||
protobuf.NequiAccountPayload.Builder builder = protobuf.NequiAccountPayload.newBuilder() | ||
.setMobileNr(mobileNr); | ||
final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder() | ||
.getCountryBasedPaymentAccountPayloadBuilder() | ||
.setNequiAccountPayload(builder); | ||
return getPaymentAccountPayloadBuilder() | ||
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayload) | ||
.build(); | ||
} | ||
|
||
public static NequiAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { | ||
protobuf.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload(); | ||
protobuf.NequiAccountPayload paytmAccountPayloadPB = countryBasedPaymentAccountPayload.getNequiAccountPayload(); | ||
return new NequiAccountPayload(proto.getPaymentMethodId(), | ||
proto.getId(), | ||
countryBasedPaymentAccountPayload.getCountryCode(), | ||
paytmAccountPayloadPB.getMobileNr(), | ||
proto.getMaxTradePeriod(), | ||
new HashMap<>(proto.getExcludeFromJsonDataMap())); | ||
} | ||
|
||
@Override | ||
public String getPaymentDetails() { | ||
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.mobile") + " " + mobileNr; | ||
} | ||
|
||
@Override | ||
public String getPaymentDetailsForTradePopup() { | ||
return getPaymentDetails(); | ||
} | ||
|
||
@Override | ||
public byte[] getAgeWitnessInputData() { | ||
return super.getAgeWitnessInputData(mobileNr.getBytes(StandardCharsets.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
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 |
---|---|---|
|
@@ -162,7 +162,8 @@ private enum PaymentMethodMapper { | |
IMPS, | ||
UPI, | ||
PAYTM, | ||
CELPAY | ||
CELPAY, | ||
NEQUI | ||
} | ||
|
||
@Getter | ||
|
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
106 changes: 106 additions & 0 deletions
106
desktop/src/main/java/bisq/desktop/components/paymentmethods/NequiForm.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,106 @@ | ||
/* | ||
* 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 bisq.desktop.components.paymentmethods; | ||
|
||
import bisq.desktop.components.InputTextField; | ||
import bisq.desktop.util.FormBuilder; | ||
import bisq.desktop.util.Layout; | ||
|
||
import bisq.core.account.witness.AccountAgeWitnessService; | ||
import bisq.core.locale.CountryUtil; | ||
import bisq.core.locale.FiatCurrency; | ||
import bisq.core.locale.Res; | ||
import bisq.core.payment.PaymentAccount; | ||
import bisq.core.payment.NequiAccount; | ||
import bisq.core.payment.payload.PaymentAccountPayload; | ||
import bisq.core.payment.payload.NequiAccountPayload; | ||
import bisq.core.util.coin.CoinFormatter; | ||
import bisq.core.util.validation.InputValidator; | ||
|
||
import javafx.scene.control.TextField; | ||
import javafx.scene.layout.GridPane; | ||
|
||
import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextField; | ||
import static bisq.desktop.util.FormBuilder.addTopLabelTextField; | ||
import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon; | ||
|
||
public class NequiForm extends PaymentMethodForm { | ||
private final NequiAccount account; | ||
private InputTextField mobileNrInputTextField; | ||
|
||
public static int addFormForBuyer(GridPane gridPane, int gridRow, | ||
PaymentAccountPayload paymentAccountPayload) { | ||
addTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.mobile"), | ||
((NequiAccountPayload) paymentAccountPayload).getMobileNr(), Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE); | ||
return gridRow; | ||
} | ||
|
||
public NequiForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, | ||
InputValidator inputValidator, GridPane gridPane, | ||
int gridRow, CoinFormatter formatter) { | ||
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); | ||
this.account = (NequiAccount) paymentAccount; | ||
} | ||
|
||
@Override | ||
public void addFormForAddAccount() { | ||
// this payment method is only for Columbia/COP | ||
account.setSingleTradeCurrency(new FiatCurrency("COP")); | ||
CountryUtil.findCountryByCode("CO").ifPresent(c -> account.setCountry(c)); | ||
|
||
gridRowFrom = gridRow + 1; | ||
|
||
mobileNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.mobile")); | ||
mobileNrInputTextField.setValidator(inputValidator); | ||
mobileNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { | ||
account.setMobileNr(newValue.trim()); | ||
updateFromInputs(); | ||
}); | ||
|
||
addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), account.getSingleTradeCurrency().getNameAndCode()); | ||
addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.country"), account.getCountry().name); | ||
addLimitations(false); | ||
addAccountNameTextFieldWithAutoFillToggleButton(); | ||
} | ||
|
||
@Override | ||
protected void autoFillNameTextField() { | ||
setAccountNameWithString(mobileNrInputTextField.getText()); | ||
} | ||
|
||
@Override | ||
public void addFormForDisplayAccount() { | ||
gridRowFrom = gridRow; | ||
addTopLabelTextField(gridPane, gridRow, Res.get("payment.account.name"), | ||
account.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE); | ||
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"), | ||
Res.get(account.getPaymentMethod().getId())); | ||
TextField field = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.mobile"), | ||
account.getMobileNr()).second; | ||
field.setMouseTransparent(false); | ||
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), account.getSingleTradeCurrency().getNameAndCode()); | ||
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.country"), account.getCountry().name); | ||
addLimitations(true); | ||
} | ||
|
||
@Override | ||
public void updateAllInputsValid() { | ||
allInputsValid.set(isAccountNameValid() | ||
&& inputValidator.validate(account.getMobileNr()).isValid); | ||
} | ||
} |
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.