mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Merge pull request #5117 from jmacxx/add_country_amazon_account
Specify Amazon eGift Card country
This commit is contained in:
commit
31b7292d56
11 changed files with 316 additions and 21 deletions
|
@ -33,6 +33,7 @@ import bisq.core.dao.governance.voteresult.VoteResultException;
|
||||||
import bisq.core.dao.state.unconfirmed.UnconfirmedBsqChangeOutputListService;
|
import bisq.core.dao.state.unconfirmed.UnconfirmedBsqChangeOutputListService;
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
import bisq.core.offer.OpenOfferManager;
|
import bisq.core.offer.OpenOfferManager;
|
||||||
|
import bisq.core.payment.AmazonGiftCardAccount;
|
||||||
import bisq.core.payment.PaymentAccount;
|
import bisq.core.payment.PaymentAccount;
|
||||||
import bisq.core.payment.RevolutAccount;
|
import bisq.core.payment.RevolutAccount;
|
||||||
import bisq.core.payment.payload.PaymentMethod;
|
import bisq.core.payment.payload.PaymentMethod;
|
||||||
|
@ -179,6 +180,9 @@ public class BisqSetup {
|
||||||
private Consumer<List<RevolutAccount>> revolutAccountsUpdateHandler;
|
private Consumer<List<RevolutAccount>> revolutAccountsUpdateHandler;
|
||||||
@Setter
|
@Setter
|
||||||
@Nullable
|
@Nullable
|
||||||
|
private Consumer<List<AmazonGiftCardAccount>> amazonGiftCardAccountsUpdateHandler;
|
||||||
|
@Setter
|
||||||
|
@Nullable
|
||||||
private Runnable osxKeyLoggerWarningHandler;
|
private Runnable osxKeyLoggerWarningHandler;
|
||||||
@Setter
|
@Setter
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -456,6 +460,7 @@ public class BisqSetup {
|
||||||
filterWarningHandler,
|
filterWarningHandler,
|
||||||
voteResultExceptionHandler,
|
voteResultExceptionHandler,
|
||||||
revolutAccountsUpdateHandler,
|
revolutAccountsUpdateHandler,
|
||||||
|
amazonGiftCardAccountsUpdateHandler,
|
||||||
daoRequiresRestartHandler);
|
daoRequiresRestartHandler);
|
||||||
|
|
||||||
if (walletsSetup.downloadPercentageProperty().get() == 1) {
|
if (walletsSetup.downloadPercentageProperty().get() == 1) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ import bisq.core.notifications.alerts.market.MarketAlerts;
|
||||||
import bisq.core.notifications.alerts.price.PriceAlert;
|
import bisq.core.notifications.alerts.price.PriceAlert;
|
||||||
import bisq.core.offer.OpenOfferManager;
|
import bisq.core.offer.OpenOfferManager;
|
||||||
import bisq.core.offer.TriggerPriceService;
|
import bisq.core.offer.TriggerPriceService;
|
||||||
|
import bisq.core.payment.AmazonGiftCardAccount;
|
||||||
import bisq.core.payment.RevolutAccount;
|
import bisq.core.payment.RevolutAccount;
|
||||||
import bisq.core.payment.TradeLimits;
|
import bisq.core.payment.TradeLimits;
|
||||||
import bisq.core.provider.fee.FeeService;
|
import bisq.core.provider.fee.FeeService;
|
||||||
|
@ -189,6 +190,7 @@ public class DomainInitialisation {
|
||||||
Consumer<String> filterWarningHandler,
|
Consumer<String> filterWarningHandler,
|
||||||
Consumer<VoteResultException> voteResultExceptionHandler,
|
Consumer<VoteResultException> voteResultExceptionHandler,
|
||||||
Consumer<List<RevolutAccount>> revolutAccountsUpdateHandler,
|
Consumer<List<RevolutAccount>> revolutAccountsUpdateHandler,
|
||||||
|
Consumer<List<AmazonGiftCardAccount>> amazonGiftCardAccountsUpdateHandler,
|
||||||
Runnable daoRequiresRestartHandler) {
|
Runnable daoRequiresRestartHandler) {
|
||||||
clockWatcher.start();
|
clockWatcher.start();
|
||||||
|
|
||||||
|
@ -267,5 +269,12 @@ public class DomainInitialisation {
|
||||||
.filter(RevolutAccount::userNameNotSet)
|
.filter(RevolutAccount::userNameNotSet)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
if (amazonGiftCardAccountsUpdateHandler != null) {
|
||||||
|
amazonGiftCardAccountsUpdateHandler.accept(user.getPaymentAccountsAsObservable().stream()
|
||||||
|
.filter(paymentAccount -> paymentAccount instanceof AmazonGiftCardAccount)
|
||||||
|
.map(paymentAccount -> (AmazonGiftCardAccount) paymentAccount)
|
||||||
|
.filter(AmazonGiftCardAccount::countryNotSet)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,16 @@ public class CountryUtil {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Country> getAllAmazonGiftCardCountries() {
|
||||||
|
List<Country> list = new ArrayList<>();
|
||||||
|
String[] codes = {"AU", "CA", "FR", "DE", "IT", "NL", "ES", "GB", "IN", "JP",
|
||||||
|
"SA", "SE", "SG", "TR", "US"};
|
||||||
|
populateCountryListByCodes(list, codes);
|
||||||
|
list.sort((a, b) -> a.name.compareTo(b.name));
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<Country> getAllSepaInstantEuroCountries() {
|
public static List<Country> getAllSepaInstantEuroCountries() {
|
||||||
return getAllSepaEuroCountries();
|
return getAllSepaEuroCountries();
|
||||||
}
|
}
|
||||||
|
@ -133,6 +143,8 @@ public class CountryUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getNameAndCode(String countryCode) {
|
public static String getNameAndCode(String countryCode) {
|
||||||
|
if (countryCode.isEmpty())
|
||||||
|
return "";
|
||||||
return getNameByCode(countryCode) + " (" + countryCode + ")";
|
return getNameByCode(countryCode) + " (" + countryCode + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,21 @@
|
||||||
|
|
||||||
package bisq.core.payment;
|
package bisq.core.payment;
|
||||||
|
|
||||||
|
import bisq.core.locale.Country;
|
||||||
|
import bisq.core.locale.CountryUtil;
|
||||||
import bisq.core.payment.payload.AmazonGiftCardAccountPayload;
|
import bisq.core.payment.payload.AmazonGiftCardAccountPayload;
|
||||||
import bisq.core.payment.payload.PaymentAccountPayload;
|
import bisq.core.payment.payload.PaymentAccountPayload;
|
||||||
import bisq.core.payment.payload.PaymentMethod;
|
import bisq.core.payment.payload.PaymentMethod;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public final class AmazonGiftCardAccount extends PaymentAccount {
|
public final class AmazonGiftCardAccount extends PaymentAccount {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private Country country;
|
||||||
|
|
||||||
public AmazonGiftCardAccount() {
|
public AmazonGiftCardAccount() {
|
||||||
super(PaymentMethod.AMAZON_GIFT_CARD);
|
super(PaymentMethod.AMAZON_GIFT_CARD);
|
||||||
}
|
}
|
||||||
|
@ -40,6 +49,24 @@ public final class AmazonGiftCardAccount extends PaymentAccount {
|
||||||
getAmazonGiftCardAccountPayload().setEmailOrMobileNr(emailOrMobileNr);
|
getAmazonGiftCardAccountPayload().setEmailOrMobileNr(emailOrMobileNr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean countryNotSet() {
|
||||||
|
return (getAmazonGiftCardAccountPayload()).countryNotSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Country getCountry() {
|
||||||
|
if (country == null) {
|
||||||
|
final String countryCode = getAmazonGiftCardAccountPayload().getCountryCode();
|
||||||
|
CountryUtil.findCountryByCode(countryCode).ifPresent(c -> this.country = c);
|
||||||
|
}
|
||||||
|
return country;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCountry(@NotNull Country country) {
|
||||||
|
this.country = country;
|
||||||
|
getAmazonGiftCardAccountPayload().setCountryCode(country.code);
|
||||||
|
}
|
||||||
|
|
||||||
private AmazonGiftCardAccountPayload getAmazonGiftCardAccountPayload() {
|
private AmazonGiftCardAccountPayload getAmazonGiftCardAccountPayload() {
|
||||||
return (AmazonGiftCardAccountPayload) paymentAccountPayload;
|
return (AmazonGiftCardAccountPayload) paymentAccountPayload;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package bisq.core.payment.payload;
|
package bisq.core.payment.payload;
|
||||||
|
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
|
import bisq.common.util.JsonExclude;
|
||||||
|
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
|
|
||||||
|
@ -39,6 +40,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AmazonGiftCardAccountPayload extends PaymentAccountPayload {
|
public class AmazonGiftCardAccountPayload extends PaymentAccountPayload {
|
||||||
private String emailOrMobileNr;
|
private String emailOrMobileNr;
|
||||||
|
// For backward compatibility we need to exclude the new field for the contract json.
|
||||||
|
// We can remove that after a while when risk that users with pre 1.5.5 version is very low.
|
||||||
|
@JsonExclude
|
||||||
|
private String countryCode = "";
|
||||||
|
|
||||||
public AmazonGiftCardAccountPayload(String paymentMethod, String id) {
|
public AmazonGiftCardAccountPayload(String paymentMethod, String id) {
|
||||||
super(paymentMethod, id);
|
super(paymentMethod, id);
|
||||||
|
@ -52,6 +57,7 @@ public class AmazonGiftCardAccountPayload extends PaymentAccountPayload {
|
||||||
private AmazonGiftCardAccountPayload(String paymentMethodName,
|
private AmazonGiftCardAccountPayload(String paymentMethodName,
|
||||||
String id,
|
String id,
|
||||||
String emailOrMobileNr,
|
String emailOrMobileNr,
|
||||||
|
String countryCode,
|
||||||
long maxTradePeriod,
|
long maxTradePeriod,
|
||||||
Map<String, String> excludeFromJsonDataMap) {
|
Map<String, String> excludeFromJsonDataMap) {
|
||||||
super(paymentMethodName,
|
super(paymentMethodName,
|
||||||
|
@ -59,12 +65,14 @@ public class AmazonGiftCardAccountPayload extends PaymentAccountPayload {
|
||||||
maxTradePeriod,
|
maxTradePeriod,
|
||||||
excludeFromJsonDataMap);
|
excludeFromJsonDataMap);
|
||||||
this.emailOrMobileNr = emailOrMobileNr;
|
this.emailOrMobileNr = emailOrMobileNr;
|
||||||
|
this.countryCode = countryCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Message toProtoMessage() {
|
public Message toProtoMessage() {
|
||||||
protobuf.AmazonGiftCardAccountPayload.Builder builder =
|
protobuf.AmazonGiftCardAccountPayload.Builder builder =
|
||||||
protobuf.AmazonGiftCardAccountPayload.newBuilder()
|
protobuf.AmazonGiftCardAccountPayload.newBuilder()
|
||||||
|
.setCountryCode(countryCode)
|
||||||
.setEmailOrMobileNr(emailOrMobileNr);
|
.setEmailOrMobileNr(emailOrMobileNr);
|
||||||
return getPaymentAccountPayloadBuilder()
|
return getPaymentAccountPayloadBuilder()
|
||||||
.setAmazonGiftCardAccountPayload(builder)
|
.setAmazonGiftCardAccountPayload(builder)
|
||||||
|
@ -76,6 +84,7 @@ public class AmazonGiftCardAccountPayload extends PaymentAccountPayload {
|
||||||
return new AmazonGiftCardAccountPayload(proto.getPaymentMethodId(),
|
return new AmazonGiftCardAccountPayload(proto.getPaymentMethodId(),
|
||||||
proto.getId(),
|
proto.getId(),
|
||||||
amazonGiftCardAccountPayload.getEmailOrMobileNr(),
|
amazonGiftCardAccountPayload.getEmailOrMobileNr(),
|
||||||
|
amazonGiftCardAccountPayload.getCountryCode(),
|
||||||
proto.getMaxTradePeriod(),
|
proto.getMaxTradePeriod(),
|
||||||
new HashMap<>(proto.getExcludeFromJsonDataMap()));
|
new HashMap<>(proto.getExcludeFromJsonDataMap()));
|
||||||
}
|
}
|
||||||
|
@ -100,4 +109,8 @@ public class AmazonGiftCardAccountPayload extends PaymentAccountPayload {
|
||||||
String data = "AmazonGiftCard" + emailOrMobileNr;
|
String data = "AmazonGiftCard" + emailOrMobileNr;
|
||||||
return super.getAgeWitnessInputData(data.getBytes(StandardCharsets.UTF_8));
|
return super.getAgeWitnessInputData(data.getBytes(StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean countryNotSet() {
|
||||||
|
return countryCode.isEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -653,10 +653,6 @@ portfolio.pending.step2_buyer.moneyGram.extra=IMPORTANT REQUIREMENT:\nAfter you
|
||||||
portfolio.pending.step2_buyer.westernUnion=Please pay {0} to the BTC seller by using Western Union.\n\n
|
portfolio.pending.step2_buyer.westernUnion=Please pay {0} to the BTC seller by using Western Union.\n\n
|
||||||
portfolio.pending.step2_buyer.westernUnion.extra=IMPORTANT REQUIREMENT:\nAfter you have done the payment send the MTCN (tracking number) and a photo of the receipt by email to the BTC seller.\n\
|
portfolio.pending.step2_buyer.westernUnion.extra=IMPORTANT REQUIREMENT:\nAfter you have done the payment send the MTCN (tracking number) and a photo of the receipt by email to the BTC seller.\n\
|
||||||
The receipt must clearly show the seller''s full name, city, country and the amount. The seller''s email is: {0}.
|
The receipt must clearly show the seller''s full name, city, country and the amount. The seller''s email is: {0}.
|
||||||
# suppress inspection "TrailingSpacesInProperty"
|
|
||||||
portfolio.pending.step2_buyer.amazonGiftCard=Please purchase an Amazon eGift Card for {0} at your Amazon account and \
|
|
||||||
use the BTC seller''s email or mobile number as receiver. \
|
|
||||||
In case the trade amount exceeds the permitted amount send multiple cards.\n\n
|
|
||||||
|
|
||||||
# suppress inspection "TrailingSpacesInProperty"
|
# suppress inspection "TrailingSpacesInProperty"
|
||||||
portfolio.pending.step2_buyer.postal=Please send {0} by \"US Postal Money Order\" to the BTC seller.\n\n
|
portfolio.pending.step2_buyer.postal=Please send {0} by \"US Postal Money Order\" to the BTC seller.\n\n
|
||||||
|
@ -3203,6 +3199,8 @@ payment.select.altcoin=Select or search Altcoin
|
||||||
payment.secret=Secret question
|
payment.secret=Secret question
|
||||||
payment.answer=Answer
|
payment.answer=Answer
|
||||||
payment.wallet=Wallet ID
|
payment.wallet=Wallet ID
|
||||||
|
payment.amazon.site=Buy giftcard at
|
||||||
|
payment.ask=Ask in Trader Chat
|
||||||
payment.uphold.accountId=Username or email or phone no.
|
payment.uphold.accountId=Username or email or phone no.
|
||||||
payment.moneyBeam.accountId=Email or phone no.
|
payment.moneyBeam.accountId=Email or phone no.
|
||||||
payment.venmo.venmoUserName=Venmo username
|
payment.venmo.venmoUserName=Venmo username
|
||||||
|
@ -3313,6 +3311,13 @@ payment.account.revolut.addUserNameInfo={0}\n\
|
||||||
This will not affect your account age signing status.
|
This will not affect your account age signing status.
|
||||||
payment.revolut.addUserNameInfo.headLine=Update Revolut account
|
payment.revolut.addUserNameInfo.headLine=Update Revolut account
|
||||||
|
|
||||||
|
payment.amazonGiftCard.upgrade=Amazon gift cards payment method requires the country to be specified.
|
||||||
|
payment.account.amazonGiftCard.addCountryInfo={0}\n\
|
||||||
|
Your existing Amazon Gift Card account ({1}) does not have a Country specified.\n\
|
||||||
|
Please enter your Amazon Gift Card Country to update your account data.\n\
|
||||||
|
This will not affect your account age status.
|
||||||
|
payment.amazonGiftCard.upgrade.headLine=Update Amazon Gift Card account
|
||||||
|
|
||||||
payment.usPostalMoneyOrder.info=Trading using US Postal Money Orders (USPMO) on Bisq requires that you understand the following:\n\
|
payment.usPostalMoneyOrder.info=Trading using US Postal Money Orders (USPMO) on Bisq requires that you understand the following:\n\
|
||||||
\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\
|
- 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\
|
||||||
|
|
|
@ -18,10 +18,11 @@
|
||||||
package bisq.desktop.components.paymentmethods;
|
package bisq.desktop.components.paymentmethods;
|
||||||
|
|
||||||
import bisq.desktop.components.InputTextField;
|
import bisq.desktop.components.InputTextField;
|
||||||
import bisq.desktop.util.FormBuilder;
|
|
||||||
import bisq.desktop.util.Layout;
|
import bisq.desktop.util.Layout;
|
||||||
|
|
||||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
|
import bisq.core.locale.Country;
|
||||||
|
import bisq.core.locale.CountryUtil;
|
||||||
import bisq.core.locale.CurrencyUtil;
|
import bisq.core.locale.CurrencyUtil;
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
import bisq.core.locale.TradeCurrency;
|
import bisq.core.locale.TradeCurrency;
|
||||||
|
@ -33,25 +34,41 @@ import bisq.core.payment.payload.PaymentMethod;
|
||||||
import bisq.core.util.coin.CoinFormatter;
|
import bisq.core.util.coin.CoinFormatter;
|
||||||
import bisq.core.util.validation.InputValidator;
|
import bisq.core.util.validation.InputValidator;
|
||||||
|
|
||||||
|
import javafx.scene.control.ComboBox;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
|
||||||
|
import javafx.util.StringConverter;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextField;
|
import static bisq.desktop.util.FormBuilder.*;
|
||||||
import static bisq.desktop.util.FormBuilder.addInputTextField;
|
|
||||||
import static bisq.desktop.util.FormBuilder.addTopLabelTextField;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AmazonGiftCardForm extends PaymentMethodForm {
|
public class AmazonGiftCardForm extends PaymentMethodForm {
|
||||||
private InputTextField accountNrInputTextField;
|
private InputTextField accountNrInputTextField;
|
||||||
|
ComboBox<Country> countryCombo;
|
||||||
private final AmazonGiftCardAccount amazonGiftCardAccount;
|
private final AmazonGiftCardAccount amazonGiftCardAccount;
|
||||||
|
|
||||||
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) {
|
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) {
|
||||||
FormBuilder.addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.email.mobile"),
|
AmazonGiftCardAccountPayload amazonGiftCardAccountPayload = (AmazonGiftCardAccountPayload) paymentAccountPayload;
|
||||||
((AmazonGiftCardAccountPayload) paymentAccountPayload).getEmailOrMobileNr());
|
|
||||||
|
addTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.amazon.site"),
|
||||||
|
countryToAmazonSite(amazonGiftCardAccountPayload.getCountryCode()),
|
||||||
|
Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE);
|
||||||
|
addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.email.mobile"),
|
||||||
|
amazonGiftCardAccountPayload.getEmailOrMobileNr());
|
||||||
|
String countryText = CountryUtil.getNameAndCode(amazonGiftCardAccountPayload.getCountryCode());
|
||||||
|
if (countryText.isEmpty()) {
|
||||||
|
countryText = Res.get("payment.ask");
|
||||||
|
}
|
||||||
|
addCompactTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1,
|
||||||
|
Res.get("shared.country"),
|
||||||
|
countryText);
|
||||||
return gridRow;
|
return gridRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,11 +83,6 @@ public class AmazonGiftCardForm extends PaymentMethodForm {
|
||||||
this.amazonGiftCardAccount = (AmazonGiftCardAccount) paymentAccount;
|
this.amazonGiftCardAccount = (AmazonGiftCardAccount) paymentAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTradeCurrency() {
|
|
||||||
addTradeCurrencyComboBox();
|
|
||||||
currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getAllAmazonGiftCardCurrencies()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFormForAddAccount() {
|
public void addFormForAddAccount() {
|
||||||
gridRowFrom = gridRow + 1;
|
gridRowFrom = gridRow + 1;
|
||||||
|
@ -82,13 +94,33 @@ public class AmazonGiftCardForm extends PaymentMethodForm {
|
||||||
updateFromInputs();
|
updateFromInputs();
|
||||||
});
|
});
|
||||||
|
|
||||||
addTradeCurrency();
|
countryCombo = addComboBox(gridPane, ++gridRow, Res.get("shared.country"));
|
||||||
|
countryCombo.setPromptText(Res.get("payment.select.country"));
|
||||||
|
countryCombo.setItems(FXCollections.observableArrayList(CountryUtil.getAllAmazonGiftCardCountries()));
|
||||||
|
TextField ccyField = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), "").second;
|
||||||
|
countryCombo.setConverter(new StringConverter<>() {
|
||||||
|
@Override
|
||||||
|
public String toString(Country country) {
|
||||||
|
return country.name + " (" + country.code + ")";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Country fromString(String s) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
countryCombo.setOnAction(e -> {
|
||||||
|
Country countryCode = countryCombo.getValue();
|
||||||
|
amazonGiftCardAccount.setCountry(countryCode);
|
||||||
|
TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(countryCode.code);
|
||||||
|
paymentAccount.setSingleTradeCurrency(currency);
|
||||||
|
ccyField.setText(currency.getNameAndCode());
|
||||||
|
updateFromInputs();
|
||||||
|
});
|
||||||
|
|
||||||
addLimitations(false);
|
addLimitations(false);
|
||||||
addAccountNameTextFieldWithAutoFillToggleButton();
|
addAccountNameTextFieldWithAutoFillToggleButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void autoFillNameTextField() {
|
protected void autoFillNameTextField() {
|
||||||
setAccountNameWithString(accountNrInputTextField.getText());
|
setAccountNameWithString(accountNrInputTextField.getText());
|
||||||
|
@ -121,9 +153,33 @@ public class AmazonGiftCardForm extends PaymentMethodForm {
|
||||||
Res.get("payment.email.mobile"), accountNr).second;
|
Res.get("payment.email.mobile"), accountNr).second;
|
||||||
field.setMouseTransparent(false);
|
field.setMouseTransparent(false);
|
||||||
|
|
||||||
|
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.country"),
|
||||||
|
amazonGiftCardAccount.getCountry() != null ? amazonGiftCardAccount.getCountry().name : "");
|
||||||
String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
|
String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
|
||||||
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);
|
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);
|
||||||
|
|
||||||
addLimitations(true);
|
addLimitations(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String countryToAmazonSite(String countryCode) {
|
||||||
|
HashMap<String, String> mapCountryToSite = new HashMap<>() {{
|
||||||
|
put("AU", "https://www.amazon.au");
|
||||||
|
put("CA", "https://www.amazon.ca");
|
||||||
|
put("FR", "https://www.amazon.fr");
|
||||||
|
put("DE", "https://www.amazon.de");
|
||||||
|
put("IT", "https://www.amazon.it");
|
||||||
|
put("NL", "https://www.amazon.nl");
|
||||||
|
put("ES", "https://www.amazon.es");
|
||||||
|
put("UK", "https://www.amazon.co.uk");
|
||||||
|
put("IN", "https://www.amazon.in");
|
||||||
|
put("JP", "https://www.amazon.co.jp");
|
||||||
|
put("SA", "https://www.amazon.sa");
|
||||||
|
put("SE", "https://www.amazon.se");
|
||||||
|
put("SG", "https://www.amazon.sg");
|
||||||
|
put("TR", "https://www.amazon.tr");
|
||||||
|
put("US", "https://www.amazon.com");
|
||||||
|
put("", Res.get("payment.ask"));
|
||||||
|
}};
|
||||||
|
return mapCountryToSite.get(countryCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import bisq.desktop.main.overlays.popups.Popup;
|
||||||
import bisq.desktop.main.overlays.windows.DisplayAlertMessageWindow;
|
import bisq.desktop.main.overlays.windows.DisplayAlertMessageWindow;
|
||||||
import bisq.desktop.main.overlays.windows.TacWindow;
|
import bisq.desktop.main.overlays.windows.TacWindow;
|
||||||
import bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow;
|
import bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow;
|
||||||
|
import bisq.desktop.main.overlays.windows.UpdateAmazonGiftCardAccountWindow;
|
||||||
import bisq.desktop.main.overlays.windows.UpdateRevolutAccountWindow;
|
import bisq.desktop.main.overlays.windows.UpdateRevolutAccountWindow;
|
||||||
import bisq.desktop.main.overlays.windows.WalletPasswordWindow;
|
import bisq.desktop.main.overlays.windows.WalletPasswordWindow;
|
||||||
import bisq.desktop.main.overlays.windows.downloadupdate.DisplayUpdateDownloadWindow;
|
import bisq.desktop.main.overlays.windows.downloadupdate.DisplayUpdateDownloadWindow;
|
||||||
|
@ -50,6 +51,7 @@ import bisq.core.locale.Res;
|
||||||
import bisq.core.offer.OpenOffer;
|
import bisq.core.offer.OpenOffer;
|
||||||
import bisq.core.offer.OpenOfferManager;
|
import bisq.core.offer.OpenOfferManager;
|
||||||
import bisq.core.payment.AliPayAccount;
|
import bisq.core.payment.AliPayAccount;
|
||||||
|
import bisq.core.payment.AmazonGiftCardAccount;
|
||||||
import bisq.core.payment.CryptoCurrencyAccount;
|
import bisq.core.payment.CryptoCurrencyAccount;
|
||||||
import bisq.core.payment.RevolutAccount;
|
import bisq.core.payment.RevolutAccount;
|
||||||
import bisq.core.payment.payload.AssetsAccountPayload;
|
import bisq.core.payment.payload.AssetsAccountPayload;
|
||||||
|
@ -408,6 +410,10 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener {
|
||||||
// We copy the array as we will mutate it later
|
// We copy the array as we will mutate it later
|
||||||
showRevolutAccountUpdateWindow(new ArrayList<>(revolutAccountList));
|
showRevolutAccountUpdateWindow(new ArrayList<>(revolutAccountList));
|
||||||
});
|
});
|
||||||
|
bisqSetup.setAmazonGiftCardAccountsUpdateHandler(amazonGiftCardAccountList -> {
|
||||||
|
// We copy the array as we will mutate it later
|
||||||
|
showAmazonGiftCardAccountUpdateWindow(new ArrayList<>(amazonGiftCardAccountList));
|
||||||
|
});
|
||||||
bisqSetup.setOsxKeyLoggerWarningHandler(() -> {
|
bisqSetup.setOsxKeyLoggerWarningHandler(() -> {
|
||||||
String key = "osxKeyLoggerWarning";
|
String key = "osxKeyLoggerWarning";
|
||||||
if (preferences.showAgain(key)) {
|
if (preferences.showAgain(key)) {
|
||||||
|
@ -485,6 +491,17 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showAmazonGiftCardAccountUpdateWindow(List<AmazonGiftCardAccount> amazonGiftCardAccountList) {
|
||||||
|
if (!amazonGiftCardAccountList.isEmpty()) {
|
||||||
|
AmazonGiftCardAccount amazonGiftCardAccount = amazonGiftCardAccountList.get(0);
|
||||||
|
amazonGiftCardAccountList.remove(0);
|
||||||
|
new UpdateAmazonGiftCardAccountWindow(amazonGiftCardAccount, user).onClose(() -> {
|
||||||
|
// We delay a bit in case we have multiple account for better UX
|
||||||
|
UserThread.runAfter(() -> showAmazonGiftCardAccountUpdateWindow(amazonGiftCardAccountList), 300, TimeUnit.MILLISECONDS);
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setupP2PNumPeersWatcher() {
|
private void setupP2PNumPeersWatcher() {
|
||||||
p2PService.getNumConnectedPeers().addListener((observable, oldValue, newValue) -> {
|
p2PService.getNumConnectedPeers().addListener((observable, oldValue, newValue) -> {
|
||||||
int numPeers = (int) newValue;
|
int numPeers = (int) newValue;
|
||||||
|
|
|
@ -0,0 +1,154 @@
|
||||||
|
/*
|
||||||
|
* 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.main.overlays.windows;
|
||||||
|
|
||||||
|
import bisq.desktop.main.overlays.Overlay;
|
||||||
|
|
||||||
|
import bisq.core.locale.Res;
|
||||||
|
import bisq.core.locale.Country;
|
||||||
|
import bisq.core.payment.AmazonGiftCardAccount;
|
||||||
|
import bisq.core.user.User;
|
||||||
|
|
||||||
|
import bisq.common.UserThread;
|
||||||
|
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.ComboBox;
|
||||||
|
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
|
||||||
|
import javafx.util.StringConverter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static bisq.core.locale.CountryUtil.findCountryByCode;
|
||||||
|
import static bisq.core.locale.CountryUtil.getAllAmazonGiftCardCountries;
|
||||||
|
import static bisq.desktop.util.FormBuilder.addComboBox;
|
||||||
|
import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextField;
|
||||||
|
import static bisq.desktop.util.FormBuilder.addLabel;
|
||||||
|
|
||||||
|
public class UpdateAmazonGiftCardAccountWindow extends Overlay<UpdateAmazonGiftCardAccountWindow> {
|
||||||
|
private final AmazonGiftCardAccount amazonGiftCardAccount;
|
||||||
|
private final User user;
|
||||||
|
private ComboBox<Country> countryCombo;
|
||||||
|
|
||||||
|
public UpdateAmazonGiftCardAccountWindow(AmazonGiftCardAccount amazonGiftCardAccount, User user) {
|
||||||
|
super();
|
||||||
|
this.amazonGiftCardAccount = amazonGiftCardAccount;
|
||||||
|
this.user = user;
|
||||||
|
type = Type.Attention;
|
||||||
|
hideCloseButton = true;
|
||||||
|
actionButtonText = Res.get("shared.save");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setupKeyHandler(Scene scene) {
|
||||||
|
// We do not support enter or escape here
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
if (headLine == null)
|
||||||
|
headLine = Res.get("payment.amazonGiftCard.upgrade.headLine");
|
||||||
|
|
||||||
|
width = 868;
|
||||||
|
createGridPane();
|
||||||
|
addHeadLine();
|
||||||
|
addContent();
|
||||||
|
addButtons();
|
||||||
|
applyStyles();
|
||||||
|
display();
|
||||||
|
// when there is only one possible country to choose from just go ahead and choose it. e.g. UK, US, JP etc.
|
||||||
|
if (countryCombo.getItems().size() == 1) {
|
||||||
|
countryCombo.setValue(countryCombo.getItems().get(0));
|
||||||
|
UserThread.runAfter(() -> actionButton.fire(), 300, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addContent() {
|
||||||
|
addLabel(gridPane, ++rowIndex, Res.get("payment.account.amazonGiftCard.addCountryInfo", Res.get("payment.amazonGiftCard.upgrade"), amazonGiftCardAccount.getAccountName()));
|
||||||
|
addCompactTopLabelTextField(gridPane, ++rowIndex, Res.get("shared.currency"), amazonGiftCardAccount.getSingleTradeCurrency().getNameAndCode());
|
||||||
|
countryCombo = addComboBox(gridPane, ++rowIndex, Res.get("shared.country"));
|
||||||
|
countryCombo.setPromptText(Res.get("payment.select.country"));
|
||||||
|
countryCombo.setItems(FXCollections.observableArrayList(getAppropriateCountries(amazonGiftCardAccount.getSingleTradeCurrency().getCode())));
|
||||||
|
countryCombo.setConverter(new StringConverter<>() {
|
||||||
|
@Override
|
||||||
|
public String toString(Country country) {
|
||||||
|
return country.name + " (" + country.code + ")";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Country fromString(String s) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
countryCombo.setOnAction(e -> {
|
||||||
|
Country countryCode = countryCombo.getValue();
|
||||||
|
actionButton.setDisable(countryCode == null || countryCode.code == null || countryCode.code.length() < 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addButtons() {
|
||||||
|
super.addButtons();
|
||||||
|
Country countryCode = countryCombo.getValue();
|
||||||
|
if (countryCode == null || countryCode.code == null || countryCode.code.isEmpty())
|
||||||
|
actionButton.setDisable(true);
|
||||||
|
// We do not allow close in case the field is not correctly added
|
||||||
|
actionButton.setOnAction(event -> {
|
||||||
|
Country chosenCountryCode = countryCombo.getValue();
|
||||||
|
if (chosenCountryCode != null && chosenCountryCode.code != null && !chosenCountryCode.code.isEmpty()) {
|
||||||
|
amazonGiftCardAccount.setCountry(chosenCountryCode);
|
||||||
|
user.requestPersistence();
|
||||||
|
closeHandlerOptional.ifPresent(Runnable::run);
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Country> getAppropriateCountries(String currency) {
|
||||||
|
List<Country> list = new ArrayList<>();
|
||||||
|
if (currency.equalsIgnoreCase("EUR")) {
|
||||||
|
// Eurozone countries using EUR
|
||||||
|
list = getAllAmazonGiftCardCountries();
|
||||||
|
list = list.stream().filter(e -> e.code.matches("FR|DE|IT|NL|ES")).collect(Collectors.toList());
|
||||||
|
} else {
|
||||||
|
// non-Eurozone with own ccy
|
||||||
|
HashMap<String, String> mapCcyToCountry = new HashMap<>(Map.of(
|
||||||
|
"AUD", "AU",
|
||||||
|
"CAD", "CA",
|
||||||
|
"GBP", "GB",
|
||||||
|
"INR", "IN",
|
||||||
|
"JPY", "JP",
|
||||||
|
"SAR", "SA",
|
||||||
|
"SEK", "SE",
|
||||||
|
"SGD", "SG",
|
||||||
|
"TRY", "TR",
|
||||||
|
"USD", "US"
|
||||||
|
));
|
||||||
|
Optional<Country> found = findCountryByCode(mapCcyToCountry.get(currency));
|
||||||
|
if (found.isPresent())
|
||||||
|
list.add(found.get());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
|
@ -63,7 +63,6 @@ import bisq.core.network.MessageState;
|
||||||
import bisq.core.offer.Offer;
|
import bisq.core.offer.Offer;
|
||||||
import bisq.core.payment.PaymentAccount;
|
import bisq.core.payment.PaymentAccount;
|
||||||
import bisq.core.payment.PaymentAccountUtil;
|
import bisq.core.payment.PaymentAccountUtil;
|
||||||
import bisq.core.payment.payload.AmazonGiftCardAccountPayload;
|
|
||||||
import bisq.core.payment.payload.AssetsAccountPayload;
|
import bisq.core.payment.payload.AssetsAccountPayload;
|
||||||
import bisq.core.payment.payload.CashByMailAccountPayload;
|
import bisq.core.payment.payload.CashByMailAccountPayload;
|
||||||
import bisq.core.payment.payload.CashDepositAccountPayload;
|
import bisq.core.payment.payload.CashDepositAccountPayload;
|
||||||
|
@ -569,9 +568,6 @@ public class BuyerStep2View extends TradeStepView {
|
||||||
Res.get("portfolio.pending.step2_buyer.fasterPaymentsHolderNameInfo") + "\n\n" +
|
Res.get("portfolio.pending.step2_buyer.fasterPaymentsHolderNameInfo") + "\n\n" +
|
||||||
refTextWarn + "\n\n" +
|
refTextWarn + "\n\n" +
|
||||||
fees;
|
fees;
|
||||||
} else if (paymentAccountPayload instanceof AmazonGiftCardAccountPayload) {
|
|
||||||
message += Res.get("portfolio.pending.step2_buyer.amazonGiftCard", amount) +
|
|
||||||
refTextWarn;
|
|
||||||
} else if (paymentAccountPayload instanceof CashByMailAccountPayload ||
|
} else if (paymentAccountPayload instanceof CashByMailAccountPayload ||
|
||||||
paymentAccountPayload instanceof HalCashAccountPayload) {
|
paymentAccountPayload instanceof HalCashAccountPayload) {
|
||||||
message += Res.get("portfolio.pending.step2_buyer.pay", amount);
|
message += Res.get("portfolio.pending.step2_buyer.pay", amount);
|
||||||
|
|
|
@ -1075,6 +1075,7 @@ message WesternUnionAccountPayload {
|
||||||
|
|
||||||
message AmazonGiftCardAccountPayload {
|
message AmazonGiftCardAccountPayload {
|
||||||
string email_or_mobile_nr = 1;
|
string email_or_mobile_nr = 1;
|
||||||
|
string country_code = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SepaAccountPayload {
|
message SepaAccountPayload {
|
||||||
|
|
Loading…
Add table
Reference in a new issue