mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-11-16 15:58:08 +00:00
Add an "extra_info" text area for PayPal
This commit is contained in:
parent
31ce183c83
commit
8bf8144709
9 changed files with 79 additions and 6 deletions
|
@ -410,6 +410,8 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
|||
return getExtraDataMap().get(OfferPayload.PAY_BY_MAIL_EXTRA_INFO);
|
||||
else if (getExtraDataMap() != null && getExtraDataMap().containsKey(OfferPayload.AUSTRALIA_PAYID_EXTRA_INFO))
|
||||
return getExtraDataMap().get(OfferPayload.AUSTRALIA_PAYID_EXTRA_INFO);
|
||||
else if (getExtraDataMap() != null && getExtraDataMap().containsKey(OfferPayload.PAYPAL_EXTRA_INFO))
|
||||
return getExtraDataMap().get(OfferPayload.PAYPAL_EXTRA_INFO);
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -100,6 +100,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
|
|||
public static final String F2F_EXTRA_INFO = "f2fExtraInfo";
|
||||
public static final String PAY_BY_MAIL_EXTRA_INFO = "payByMailExtraInfo";
|
||||
public static final String AUSTRALIA_PAYID_EXTRA_INFO = "australiaPayidExtraInfo";
|
||||
public static final String PAYPAL_EXTRA_INFO = "paypalExtraInfo";
|
||||
|
||||
// Comma separated list of ordinal of a haveno.common.app.Capability. E.g. ordinal of
|
||||
// Capability.SIGNED_ACCOUNT_AGE_WITNESS is 11 and Capability.MEDIATION is 12 so if we want to signal that maker
|
||||
|
|
|
@ -40,6 +40,7 @@ import static haveno.core.offer.OfferPayload.CAPABILITIES;
|
|||
import static haveno.core.offer.OfferPayload.F2F_CITY;
|
||||
import static haveno.core.offer.OfferPayload.F2F_EXTRA_INFO;
|
||||
import static haveno.core.offer.OfferPayload.PAY_BY_MAIL_EXTRA_INFO;
|
||||
import static haveno.core.offer.OfferPayload.PAYPAL_EXTRA_INFO;
|
||||
import static haveno.core.offer.OfferPayload.REFERRAL_ID;
|
||||
import static haveno.core.offer.OfferPayload.XMR_AUTO_CONF;
|
||||
import static haveno.core.offer.OfferPayload.XMR_AUTO_CONF_ENABLED_VALUE;
|
||||
|
@ -47,6 +48,7 @@ import static haveno.core.offer.OfferPayload.XMR_AUTO_CONF_ENABLED_VALUE;
|
|||
import haveno.core.payment.AustraliaPayidAccount;
|
||||
import haveno.core.payment.F2FAccount;
|
||||
import haveno.core.payment.PayByMailAccount;
|
||||
import haveno.core.payment.PayPalAccount;
|
||||
import haveno.core.payment.PaymentAccount;
|
||||
import haveno.core.provider.price.MarketPrice;
|
||||
import haveno.core.provider.price.PriceFeedService;
|
||||
|
@ -200,6 +202,10 @@ public class OfferUtil {
|
|||
extraDataMap.put(PAY_BY_MAIL_EXTRA_INFO, ((PayByMailAccount) paymentAccount).getExtraInfo());
|
||||
}
|
||||
|
||||
if (paymentAccount instanceof PayPalAccount) {
|
||||
extraDataMap.put(PAYPAL_EXTRA_INFO, ((PayPalAccount) paymentAccount).getExtraInfo());
|
||||
}
|
||||
|
||||
if (paymentAccount instanceof AustraliaPayidAccount) {
|
||||
extraDataMap.put(AUSTRALIA_PAYID_EXTRA_INFO, ((AustraliaPayidAccount) paymentAccount).getExtraInfo());
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ public final class PayPalAccount extends PaymentAccount {
|
|||
PaymentAccountFormField.FieldId.EMAIL_OR_MOBILE_NR_OR_USERNAME,
|
||||
PaymentAccountFormField.FieldId.TRADE_CURRENCIES,
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||
PaymentAccountFormField.FieldId.EXTRA_INFO,
|
||||
PaymentAccountFormField.FieldId.SALT);
|
||||
|
||||
public PayPalAccount() {
|
||||
|
@ -91,4 +92,12 @@ public final class PayPalAccount extends PaymentAccount {
|
|||
public String getEmailOrMobileNrOrUsername() {
|
||||
return ((PayPalAccountPayload) paymentAccountPayload).getEmailOrMobileNrOrUsername();
|
||||
}
|
||||
|
||||
public void setExtraInfo(String extraInfo) {
|
||||
((PayPalAccountPayload) paymentAccountPayload).setExtraInfo(extraInfo);
|
||||
}
|
||||
|
||||
public String getExtraInfo() {
|
||||
return ((PayPalAccountPayload) paymentAccountPayload).getExtraInfo();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.util.Map;
|
|||
@Slf4j
|
||||
public final class PayPalAccountPayload extends PaymentAccountPayload {
|
||||
private String emailOrMobileNrOrUsername = "";
|
||||
private String extraInfo = "";
|
||||
|
||||
public PayPalAccountPayload(String paymentMethod, String id) {
|
||||
super(paymentMethod, id);
|
||||
|
@ -48,6 +49,7 @@ public final class PayPalAccountPayload extends PaymentAccountPayload {
|
|||
private PayPalAccountPayload(String paymentMethod,
|
||||
String id,
|
||||
String emailOrMobileNrOrUsername,
|
||||
String extraInfo,
|
||||
long maxTradePeriod,
|
||||
Map<String, String> excludeFromJsonDataMap) {
|
||||
super(paymentMethod,
|
||||
|
@ -56,13 +58,15 @@ public final class PayPalAccountPayload extends PaymentAccountPayload {
|
|||
excludeFromJsonDataMap);
|
||||
|
||||
this.emailOrMobileNrOrUsername = emailOrMobileNrOrUsername;
|
||||
this.extraInfo = extraInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message toProtoMessage() {
|
||||
return getPaymentAccountPayloadBuilder()
|
||||
.setPaypalAccountPayload(protobuf.PayPalAccountPayload.newBuilder()
|
||||
.setEmailOrMobileNrOrUsername(emailOrMobileNrOrUsername))
|
||||
.setExtraInfo(extraInfo)
|
||||
.setEmailOrMobileNrOrUsername(emailOrMobileNrOrUsername))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -70,6 +74,7 @@ public final class PayPalAccountPayload extends PaymentAccountPayload {
|
|||
return new PayPalAccountPayload(proto.getPaymentMethodId(),
|
||||
proto.getId(),
|
||||
proto.getPaypalAccountPayload().getEmailOrMobileNrOrUsername(),
|
||||
proto.getPaypalAccountPayload().getExtraInfo(),
|
||||
proto.getMaxTradePeriod(),
|
||||
new HashMap<>(proto.getExcludeFromJsonDataMap()));
|
||||
}
|
||||
|
@ -80,8 +85,8 @@ public final class PayPalAccountPayload extends PaymentAccountPayload {
|
|||
|
||||
@Override
|
||||
public String getPaymentDetails() {
|
||||
return Res.getWithCol("payment.email.mobile.username") + " "
|
||||
+ emailOrMobileNrOrUsername;
|
||||
return Res.getWithCol("payment.email.mobile.username") + " "+ emailOrMobileNrOrUsername + "\n" +
|
||||
Res.getWithCol("payment.shared.extraInfo") + " " + extraInfo+ "\n";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package haveno.desktop.components.paymentmethods;
|
||||
|
||||
import com.jfoenix.controls.JFXTextArea;
|
||||
import haveno.core.account.witness.AccountAgeWitnessService;
|
||||
import haveno.core.locale.Res;
|
||||
import haveno.core.payment.PayPalAccount;
|
||||
|
@ -29,13 +30,16 @@ import haveno.core.util.validation.InputValidator;
|
|||
import haveno.desktop.components.InputTextField;
|
||||
import haveno.desktop.util.FormBuilder;
|
||||
import haveno.desktop.util.Layout;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
|
||||
import static haveno.desktop.util.FormBuilder.addCompactTopLabelTextField;
|
||||
import static haveno.desktop.util.FormBuilder.addCompactTopLabelTextFieldWithCopyIcon;
|
||||
import static haveno.desktop.util.FormBuilder.addCompactTopLabelTextArea;
|
||||
import static haveno.desktop.util.FormBuilder.addTopLabelTextArea;
|
||||
import static haveno.desktop.util.FormBuilder.addTopLabelFlowPane;
|
||||
import static haveno.desktop.util.FormBuilder.addCompactTopLabelTextField;
|
||||
|
||||
public class PayPalForm extends PaymentMethodForm {
|
||||
private final PayPalAccount paypalAccount;
|
||||
|
@ -43,6 +47,13 @@ public class PayPalForm extends PaymentMethodForm {
|
|||
|
||||
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) {
|
||||
addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.email.mobile.username"), ((PayPalAccountPayload) paymentAccountPayload).getEmailOrMobileNrOrUsername());
|
||||
|
||||
PayPalAccountPayload payId = (PayPalAccountPayload) paymentAccountPayload;
|
||||
TextArea textExtraInfo = addCompactTopLabelTextArea(gridPane, gridRow, 1, Res.get("payment.shared.extraInfo"), "").second;
|
||||
textExtraInfo.setMinHeight(70);
|
||||
textExtraInfo.setEditable(false);
|
||||
textExtraInfo.setText(payId.getExtraInfo());
|
||||
|
||||
return gridRow;
|
||||
}
|
||||
|
||||
|
@ -66,6 +77,16 @@ public class PayPalForm extends PaymentMethodForm {
|
|||
paypalAccount.setEmailOrMobileNrOrUsername(newValue.trim());
|
||||
updateFromInputs();
|
||||
});
|
||||
|
||||
TextArea extraTextArea = addTopLabelTextArea(gridPane, ++gridRow,
|
||||
Res.get("payment.shared.optionalExtra"), Res.get("payment.shared.extraInfo.prompt")).second;
|
||||
extraTextArea.setMinHeight(70);
|
||||
((JFXTextArea) extraTextArea).setLabelFloat(false);
|
||||
extraTextArea.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||
paypalAccount.setExtraInfo(newValue);
|
||||
updateFromInputs();
|
||||
});
|
||||
|
||||
addCurrenciesGrid(true);
|
||||
addLimitations(false);
|
||||
addAccountNameTextFieldWithAutoFillToggleButton();
|
||||
|
@ -99,6 +120,12 @@ public class PayPalForm extends PaymentMethodForm {
|
|||
TextField field = addCompactTopLabelTextField(gridPane, ++gridRow,
|
||||
Res.get("payment.email.mobile.username"),
|
||||
paypalAccount.getEmailOrMobileNrOrUsername()).second;
|
||||
|
||||
TextArea textAreaExtra = addCompactTopLabelTextArea(gridPane, ++gridRow, Res.get("payment.shared.extraInfo"), "").second;
|
||||
textAreaExtra.setText(paypalAccount.getExtraInfo());
|
||||
textAreaExtra.setMinHeight(70);
|
||||
textAreaExtra.setEditable(false);
|
||||
|
||||
field.setMouseTransparent(false);
|
||||
addLimitations(true);
|
||||
addCurrenciesGrid(false);
|
||||
|
|
|
@ -158,7 +158,8 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
|
|||
private int gridRow = 0;
|
||||
private final HashMap<String, Boolean> paymentAccountWarningDisplayed = new HashMap<>();
|
||||
private boolean offerDetailsWindowDisplayed, zelleWarningDisplayed, fasterPaymentsWarningDisplayed,
|
||||
takeOfferFromUnsignedAccountWarningDisplayed, payByMailWarningDisplayed, cashAtAtmWarningDisplayed, australiaPayidWarningDisplayed;
|
||||
takeOfferFromUnsignedAccountWarningDisplayed, payByMailWarningDisplayed, cashAtAtmWarningDisplayed,
|
||||
australiaPayidWarningDisplayed, paypalWarningDisplayed;
|
||||
private SimpleBooleanProperty errorPopupDisplayed;
|
||||
private ChangeListener<Boolean> amountFocusedListener, getShowWalletFundedNotificationListener;
|
||||
|
||||
|
@ -268,6 +269,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
|
|||
maybeShowPayByMailWarning(lastPaymentAccount, model.dataModel.getOffer());
|
||||
maybeShowCashAtAtmWarning(lastPaymentAccount, model.dataModel.getOffer());
|
||||
maybeShowAustraliaPayidWarning(lastPaymentAccount, model.dataModel.getOffer());
|
||||
maybeShowPaypalWarning(lastPaymentAccount, model.dataModel.getOffer());
|
||||
|
||||
if (!model.isRange()) {
|
||||
nextButton.setVisible(false);
|
||||
|
@ -1157,6 +1159,23 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
|
|||
}
|
||||
}
|
||||
|
||||
private void maybeShowPaypalWarning(PaymentAccount paymentAccount, Offer offer) {
|
||||
if (paymentAccount.getPaymentMethod().getId().equals(PaymentMethod.PAYPAL_ID) &&
|
||||
!paypalWarningDisplayed && !offer.getExtraInfo().isEmpty()) {
|
||||
paypalWarningDisplayed = true;
|
||||
UserThread.runAfter(() -> {
|
||||
new GenericMessageWindow()
|
||||
.preamble(Res.get("payment.tradingRestrictions"))
|
||||
.instruction(offer.getExtraInfo())
|
||||
.actionButtonText(Res.get("shared.iConfirm"))
|
||||
.closeButtonText(Res.get("shared.close"))
|
||||
.width(Layout.INITIAL_WINDOW_WIDTH)
|
||||
.onClose(() -> close(false))
|
||||
.show();
|
||||
}, 500, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
private Tuple2<Label, VBox> getTradeInputBox(HBox amountValueBox, String promptText) {
|
||||
Label descriptionLabel = new AutoTooltipLabel(promptText);
|
||||
descriptionLabel.setId("input-description-label");
|
||||
|
|
|
@ -174,7 +174,10 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
|
|||
List<String> acceptedCountryCodes = offer.getAcceptedCountryCodes();
|
||||
boolean showAcceptedCountryCodes = acceptedCountryCodes != null && !acceptedCountryCodes.isEmpty();
|
||||
boolean isF2F = offer.getPaymentMethod().equals(PaymentMethod.F2F);
|
||||
boolean showExtraInfo = offer.getPaymentMethod().equals(PaymentMethod.F2F) || offer.getPaymentMethod().equals(PaymentMethod.PAY_BY_MAIL) || offer.getPaymentMethod().equals(PaymentMethod.AUSTRALIA_PAYID);
|
||||
boolean showExtraInfo = offer.getPaymentMethod().equals(PaymentMethod.F2F) ||
|
||||
offer.getPaymentMethod().equals(PaymentMethod.PAY_BY_MAIL) ||
|
||||
offer.getPaymentMethod().equals(PaymentMethod.AUSTRALIA_PAYID)||
|
||||
offer.getPaymentMethod().equals(PaymentMethod.PAYPAL_ID);
|
||||
if (!takeOfferHandlerOptional.isPresent())
|
||||
rows++;
|
||||
if (showAcceptedBanks)
|
||||
|
|
|
@ -1072,6 +1072,7 @@ message VenmoAccountPayload {
|
|||
}
|
||||
message PayPalAccountPayload {
|
||||
string email_or_mobile_nr_or_username = 1;
|
||||
string extra_info = 2;
|
||||
}
|
||||
|
||||
message PopmoneyAccountPayload {
|
||||
|
|
Loading…
Reference in a new issue