diff --git a/core/src/main/java/bisq/core/payment/BizumAccount.java b/core/src/main/java/bisq/core/payment/BizumAccount.java new file mode 100644 index 00000000000..09d43b32acb --- /dev/null +++ b/core/src/main/java/bisq/core/payment/BizumAccount.java @@ -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 . + */ + +package bisq.core.payment; + +import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.payload.PaymentMethod; +import bisq.core.payment.payload.BizumAccountPayload; + +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +public final class BizumAccount extends CountryBasedPaymentAccount { + public BizumAccount() { + super(PaymentMethod.BIZUM); + } + + @Override + protected PaymentAccountPayload createPayload() { + return new BizumAccountPayload(paymentMethod.getId(), id); + } + + public void setMobileNr(String mobileNr) { + ((BizumAccountPayload) paymentAccountPayload).setMobileNr(mobileNr); + } + + public String getMobileNr() { + return ((BizumAccountPayload) paymentAccountPayload).getMobileNr(); + } + + public String getMessageForBuyer() { + return "payment.bizum.info.buyer"; + } + + public String getMessageForSeller() { + return "payment.bizum.info.seller"; + } + + public String getMessageForAccountCreation() { + return "payment.bizum.info.account"; + } +} diff --git a/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java b/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java index e4028727bfb..e594b2acd39 100644 --- a/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java +++ b/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java @@ -98,6 +98,10 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) { return new PaytmAccount(); case PaymentMethod.NEQUI_ID: return new NequiAccount(); + case PaymentMethod.BIZUM_ID: + return new BizumAccount(); + case PaymentMethod.PIX_ID: + return new PixAccount(); case PaymentMethod.AMAZON_GIFT_CARD_ID: return new AmazonGiftCardAccount(); case PaymentMethod.BLOCK_CHAINS_INSTANT_ID: diff --git a/core/src/main/java/bisq/core/payment/PixAccount.java b/core/src/main/java/bisq/core/payment/PixAccount.java new file mode 100644 index 00000000000..9d40cf8a3e9 --- /dev/null +++ b/core/src/main/java/bisq/core/payment/PixAccount.java @@ -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 . + */ + +package bisq.core.payment; + +import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.payload.PaymentMethod; +import bisq.core.payment.payload.PixAccountPayload; + +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +public final class PixAccount extends CountryBasedPaymentAccount { + public PixAccount() { + super(PaymentMethod.PIX); + } + + @Override + protected PaymentAccountPayload createPayload() { + return new PixAccountPayload(paymentMethod.getId(), id); + } + + public void setPixKey(String pixKey) { + ((PixAccountPayload) paymentAccountPayload).setPixKey(pixKey); + } + + public String getPixKey() { + return ((PixAccountPayload) paymentAccountPayload).getPixKey(); + } + + public String getMessageForBuyer() { + return "payment.pix.info.buyer"; + } + + public String getMessageForSeller() { + return "payment.pix.info.seller"; + } + + public String getMessageForAccountCreation() { + return "payment.pix.info.account"; + } +} diff --git a/core/src/main/java/bisq/core/payment/payload/BizumAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/BizumAccountPayload.java new file mode 100644 index 00000000000..d60384d42a1 --- /dev/null +++ b/core/src/main/java/bisq/core/payment/payload/BizumAccountPayload.java @@ -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 . + */ + +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 BizumAccountPayload extends CountryBasedPaymentAccountPayload { + private String mobileNr = ""; + + public BizumAccountPayload(String paymentMethod, String id) { + super(paymentMethod, id); + } + + private BizumAccountPayload(String paymentMethod, + String id, + String countryCode, + String mobileNr, + long maxTradePeriod, + Map excludeFromJsonDataMap) { + super(paymentMethod, + id, + countryCode, + maxTradePeriod, + excludeFromJsonDataMap); + + this.mobileNr = mobileNr; + } + + @Override + public Message toProtoMessage() { + protobuf.BizumAccountPayload.Builder builder = protobuf.BizumAccountPayload.newBuilder() + .setMobileNr(mobileNr); + final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder() + .getCountryBasedPaymentAccountPayloadBuilder() + .setBizumAccountPayload(builder); + return getPaymentAccountPayloadBuilder() + .setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayload) + .build(); + } + + public static BizumAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { + protobuf.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload(); + protobuf.BizumAccountPayload paytmAccountPayloadPB = countryBasedPaymentAccountPayload.getBizumAccountPayload(); + return new BizumAccountPayload(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)); + } +} diff --git a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java index e05a0c2f65f..0d2593350ec 100644 --- a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java +++ b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java @@ -104,6 +104,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable. + */ + +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 PixAccountPayload extends CountryBasedPaymentAccountPayload { + private String pixKey = ""; + + public PixAccountPayload(String paymentMethod, String id) { + super(paymentMethod, id); + } + + private PixAccountPayload(String paymentMethod, + String id, + String countryCode, + String pixKey, + long maxTradePeriod, + Map excludeFromJsonDataMap) { + super(paymentMethod, + id, + countryCode, + maxTradePeriod, + excludeFromJsonDataMap); + + this.pixKey = pixKey; + } + + @Override + public Message toProtoMessage() { + protobuf.PixAccountPayload.Builder builder = protobuf.PixAccountPayload.newBuilder() + .setPixKey(pixKey); + final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder() + .getCountryBasedPaymentAccountPayloadBuilder() + .setPixAccountPayload(builder); + return getPaymentAccountPayloadBuilder() + .setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayload) + .build(); + } + + public static PixAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { + protobuf.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload(); + protobuf.PixAccountPayload paytmAccountPayloadPB = countryBasedPaymentAccountPayload.getPixAccountPayload(); + return new PixAccountPayload(proto.getPaymentMethodId(), + proto.getId(), + countryBasedPaymentAccountPayload.getCountryCode(), + paytmAccountPayloadPB.getPixKey(), + proto.getMaxTradePeriod(), + new HashMap<>(proto.getExcludeFromJsonDataMap())); + } + + @Override + public String getPaymentDetails() { + return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.pix.key") + " " + pixKey; + } + + @Override + public String getPaymentDetailsForTradePopup() { + return getPaymentDetails(); + } + + @Override + public byte[] getAgeWitnessInputData() { + return super.getAgeWitnessInputData(pixKey.getBytes(StandardCharsets.UTF_8)); + } +} diff --git a/core/src/main/java/bisq/core/proto/CoreProtoResolver.java b/core/src/main/java/bisq/core/proto/CoreProtoResolver.java index ca8a5c02ec5..3fc71008c7a 100644 --- a/core/src/main/java/bisq/core/proto/CoreProtoResolver.java +++ b/core/src/main/java/bisq/core/proto/CoreProtoResolver.java @@ -25,6 +25,7 @@ import bisq.core.payment.payload.AliPayAccountPayload; import bisq.core.payment.payload.AmazonGiftCardAccountPayload; import bisq.core.payment.payload.AustraliaPayidPayload; +import bisq.core.payment.payload.BizumAccountPayload; import bisq.core.payment.payload.CapitualAccountPayload; import bisq.core.payment.payload.CashAppAccountPayload; import bisq.core.payment.payload.CashByMailAccountPayload; @@ -51,6 +52,7 @@ import bisq.core.payment.payload.PayseraAccountPayload; import bisq.core.payment.payload.PaytmAccountPayload; import bisq.core.payment.payload.PerfectMoneyAccountPayload; +import bisq.core.payment.payload.PixAccountPayload; import bisq.core.payment.payload.PopmoneyAccountPayload; import bisq.core.payment.payload.PromptPayAccountPayload; import bisq.core.payment.payload.RevolutAccountPayload; @@ -131,6 +133,10 @@ public PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { return PaytmAccountPayload.fromProto(proto); case NEQUI_ACCOUNT_PAYLOAD: return NequiAccountPayload.fromProto(proto); + case BIZUM_ACCOUNT_PAYLOAD: + return BizumAccountPayload.fromProto(proto); + case PIX_ACCOUNT_PAYLOAD: + return PixAccountPayload.fromProto(proto); case IFSC_BASED_ACCOUNT_PAYLOAD: final protobuf.IfscBasedAccountPayload.MessageCase messageCaseIfsc = proto.getCountryBasedPaymentAccountPayload().getIfscBasedAccountPayload().getMessageCase(); switch (messageCaseIfsc) { diff --git a/core/src/main/java/bisq/core/trade/statistics/TradeStatistics3.java b/core/src/main/java/bisq/core/trade/statistics/TradeStatistics3.java index 3f6c5622e88..d4edb0a90e5 100644 --- a/core/src/main/java/bisq/core/trade/statistics/TradeStatistics3.java +++ b/core/src/main/java/bisq/core/trade/statistics/TradeStatistics3.java @@ -163,7 +163,9 @@ private enum PaymentMethodMapper { UPI, PAYTM, CELPAY, - NEQUI + NEQUI, + BIZUM, + PIX } @Getter diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 1cb4ca3aa12..908a3092ef7 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -3630,6 +3630,29 @@ If you intend to trade amount of over 7,000,000 COP per trade you will need to c of around 15,000 COP. After this all transactions will incur a 0.4% of tax. Please ensure you are aware of the latest taxes.\n\n\ Users should also be aware of account limits. Trades above Nequi account limits will likely have to be cancelled. +payment.bizum.info.account=To use Bizum you need a bank account (IBAN) in Spain and to be registered for the service.\n\n\ +Bizum can be used for trades between €0.50 and €1,000.\n\n\ +The maximum amount of transactions you can send/receive using Bizum is €2,000 Euros per day.\n\n\ +Bizum users can have a maximum of 150 operations per month.\n\n\ +Each bank however may establish its own limits, within the above limits, for its clients.\n\n\ +Traders on Bisq should be aware of their limits. If you trade over the above limits your trade might be cancelled and there could be a penalty. +payment.bizum.info.buyer=Please send payment only to the BTC Seller's mobile phone number as provided in Bisq.\n\n\ +The maximum trade size is €1,000 maximum per payment. The maximum amount of transactions you can send using Bizum is €2,000 Euros per day.\n\n\ +If you trade over the above limits your trade might be cancelled and there could be a penalty. +payment.bizum.info.seller=Please make sure your payment is received from the BTC Buyer's mobile phone number as provided in Bisq.\n\n\ +The maximum trade size is €1,000 maximum per payment. The maximum amount of transactions you can receive using Bizum is €2,000 Euros per day.\n\n\ +If you trade over the above limits your trade might be cancelled and there could be a penalty. + +payment.pix.info.account=Please make sure to include your chosen Pix Key. There are four types of keys: \ + CPF (Natural Persons Register) or CNPJ (National Registry of Legal Entities), e-mail address, telephone number or a \ + random key generated by the system called a universally unique identifier (UUID). A different key must be used for \ + each Pix account your have. Individuals can create up to five keys for each account they own.\n\n\ +When trading on Bisq, BTC Buyers should use their Pix Keys as the payment description so that it is easy for the BTC Sellers to identify the payment as coming from themselves. +payment.pix.info.buyer=Please send payment only the Pix Key provided in the BTC Seller's Bisq account.\n\n\ +Please use your Pix Key as the payment reference so that it is easy for the BTC Seller to identify the payment as coming from yourself. +payment.pix.info.seller=Please check that the payment received description matches the Pix Key provided in the BTC Buyer's Bisq account. +payment.pix.key=Pix Key (CPF, CNPJ, Email, Phone number or UUID) + payment.usPostalMoneyOrder.info=Trading using US Postal Money Orders (USPMO) on Bisq requires that you understand the following:\n\ \n\ - BTC buyers must write the BTC Seller’s name in both the Payer and the Payee’s fields & take a high-resolution photo of the USPMO and envelope with proof of tracking before sending.\n\ @@ -3808,6 +3831,10 @@ PAYTM=India/PayTM # suppress inspection "UnusedProperty" NEQUI=Nequi # suppress inspection "UnusedProperty" +BIZUM=Bizum +# suppress inspection "UnusedProperty" +PIX=Pix +# suppress inspection "UnusedProperty" AMAZON_GIFT_CARD=Amazon eGift Card # suppress inspection "UnusedProperty" BLOCK_CHAINS_INSTANT=Altcoins Instant @@ -3882,6 +3909,10 @@ PAYTM_SHORT=PayTM # suppress inspection "UnusedProperty" NEQUI_SHORT=Nequi # suppress inspection "UnusedProperty" +BIZUM_SHORT=Bizum +# suppress inspection "UnusedProperty" +PIX_SHORT=Pix +# suppress inspection "UnusedProperty" AMAZON_GIFT_CARD_SHORT=Amazon eGift Card # suppress inspection "UnusedProperty" BLOCK_CHAINS_INSTANT_SHORT=Altcoins Instant diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/BizumForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/BizumForm.java new file mode 100644 index 00000000000..b7cbd5ffff5 --- /dev/null +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/BizumForm.java @@ -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 . + */ + +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.BizumAccount; +import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.payload.BizumAccountPayload; +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 BizumForm extends PaymentMethodForm { + private final BizumAccount account; + private InputTextField mobileNrInputTextField; + + public static int addFormForBuyer(GridPane gridPane, int gridRow, + PaymentAccountPayload paymentAccountPayload) { + addTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.mobile"), + ((BizumAccountPayload) paymentAccountPayload).getMobileNr(), Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE); + return gridRow; + } + + public BizumForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, + InputValidator inputValidator, GridPane gridPane, + int gridRow, CoinFormatter formatter) { + super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); + this.account = (BizumAccount) paymentAccount; + } + + @Override + public void addFormForAddAccount() { + // this payment method is only for Spain/EUR + account.setSingleTradeCurrency(new FiatCurrency("EUR")); + CountryUtil.findCountryByCode("ES").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); + } +} diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PixForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PixForm.java new file mode 100644 index 00000000000..a1bdd1581d9 --- /dev/null +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PixForm.java @@ -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 . + */ + +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.PixAccount; +import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.payload.PixAccountPayload; +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 PixForm extends PaymentMethodForm { + private final PixAccount account; + private InputTextField pixKeyInputTextField; + + public static int addFormForBuyer(GridPane gridPane, int gridRow, + PaymentAccountPayload paymentAccountPayload) { + addTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.pix.key"), + ((PixAccountPayload) paymentAccountPayload).getPixKey(), Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE); + return gridRow; + } + + public PixForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, + InputValidator inputValidator, GridPane gridPane, + int gridRow, CoinFormatter formatter) { + super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); + this.account = (PixAccount) paymentAccount; + } + + @Override + public void addFormForAddAccount() { + // this payment method is only for Brazil/BRL + account.setSingleTradeCurrency(new FiatCurrency("BRL")); + CountryUtil.findCountryByCode("BR").ifPresent(c -> account.setCountry(c)); + + gridRowFrom = gridRow + 1; + + pixKeyInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.pix.key")); + pixKeyInputTextField.setValidator(inputValidator); + pixKeyInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { + account.setPixKey(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(pixKeyInputTextField.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.pix.key"), + account.getPixKey()).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.getPixKey()).isValid); + } +} diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java index c07f8b1418d..6cb8f84e2f7 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java @@ -23,6 +23,7 @@ import bisq.desktop.components.paymentmethods.AliPayForm; import bisq.desktop.components.paymentmethods.AmazonGiftCardForm; import bisq.desktop.components.paymentmethods.AustraliaPayidForm; +import bisq.desktop.components.paymentmethods.BizumForm; import bisq.desktop.components.paymentmethods.CapitualForm; import bisq.desktop.components.paymentmethods.CashByMailForm; import bisq.desktop.components.paymentmethods.CashDepositForm; @@ -43,6 +44,7 @@ import bisq.desktop.components.paymentmethods.PaymentMethodForm; import bisq.desktop.components.paymentmethods.PaytmForm; import bisq.desktop.components.paymentmethods.PerfectMoneyForm; +import bisq.desktop.components.paymentmethods.PixForm; import bisq.desktop.components.paymentmethods.PopmoneyForm; import bisq.desktop.components.paymentmethods.PromptPayForm; import bisq.desktop.components.paymentmethods.RevolutForm; @@ -565,6 +567,10 @@ private PaymentMethodForm getPaymentMethodForm(PaymentMethod paymentMethod, Paym return new PaytmForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter); case PaymentMethod.NEQUI_ID: return new NequiForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter); + case PaymentMethod.BIZUM_ID: + return new BizumForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter); + case PaymentMethod.PIX_ID: + return new PixForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter); case PaymentMethod.AMAZON_GIFT_CARD_ID: return new AmazonGiftCardForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter); case PaymentMethod.CAPITUAL_ID: diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java index 0aed94c7c3c..45ea40925dd 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java @@ -25,6 +25,7 @@ import bisq.desktop.components.paymentmethods.AliPayForm; import bisq.desktop.components.paymentmethods.AmazonGiftCardForm; import bisq.desktop.components.paymentmethods.AssetsForm; +import bisq.desktop.components.paymentmethods.BizumForm; import bisq.desktop.components.paymentmethods.CapitualForm; import bisq.desktop.components.paymentmethods.CashByMailForm; import bisq.desktop.components.paymentmethods.CashDepositForm; @@ -46,6 +47,7 @@ import bisq.desktop.components.paymentmethods.PayseraForm; import bisq.desktop.components.paymentmethods.PaytmForm; import bisq.desktop.components.paymentmethods.PerfectMoneyForm; +import bisq.desktop.components.paymentmethods.PixForm; import bisq.desktop.components.paymentmethods.PopmoneyForm; import bisq.desktop.components.paymentmethods.PromptPayForm; import bisq.desktop.components.paymentmethods.RevolutForm; @@ -356,6 +358,12 @@ protected void addContent() { case PaymentMethod.NEQUI_ID: gridRow = NequiForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload); break; + case PaymentMethod.BIZUM_ID: + gridRow = BizumForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload); + break; + case PaymentMethod.PIX_ID: + gridRow = PixForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload); + break; case PaymentMethod.AMAZON_GIFT_CARD_ID: gridRow = AmazonGiftCardForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload); break; diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index 9ab43bd25ae..f2ddf37287e 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -1036,6 +1036,8 @@ message CountryBasedPaymentAccountPayload { PaytmAccountPayload paytm_account_payload = 10; IfscBasedAccountPayload ifsc_based_account_payload = 11; NequiAccountPayload nequi_account_payload = 12; + BizumAccountPayload bizum_account_payload = 13; + PixAccountPayload pix_account_payload = 14; } } @@ -1274,6 +1276,14 @@ message NequiAccountPayload { string mobile_nr = 1; } +message BizumAccountPayload { + string mobile_nr = 1; +} + +message PixAccountPayload { + string pix_key = 1; +} + message SwiftAccountPayload { string beneficiary_name = 1; string beneficiary_account_nr = 2;