Add maxTradePeriod to PaymentAccountPayload again as it would break trade contract otherwise

This commit is contained in:
Manfred Karrer 2017-11-09 14:34:37 -05:00
parent 44c7c712a3
commit 6e19c69a47
No known key found for this signature in database
GPG Key ID: 401250966A6B2C46
22 changed files with 376 additions and 287 deletions

View File

@ -4,13 +4,14 @@ import java.util.ArrayList;
import java.util.Arrays;
public class Capabilities {
// We can define here special features the client is supporting.
// Useful for updates to new versions where a new data type would break backwards compatibility or to
// We can define here special features the client is supporting.
// Useful for updates to new versions where a new data type would break backwards compatibility or to
// limit a node to certain behaviour and roles like the seed nodes.
// We don't use the Enum in any serialized data, as changes in the enum would break backwards compatibility. We use the ordinal integer instead.
// Sequence in the enum must not be changed (append only).
public enum Capability {
TRADE_STATISTICS
TRADE_STATISTICS,
ACCOUNT_AGE_WITNESS
}
public static void setCapabilities(ArrayList<Integer> capabilities) {
@ -19,7 +20,8 @@ public class Capabilities {
@SuppressWarnings("ArraysAsListWithZeroOrOneArgument")
private static ArrayList<Integer> capabilities = new ArrayList<>(Arrays.asList(
Capability.TRADE_STATISTICS.ordinal()
Capability.TRADE_STATISTICS.ordinal(),
Capability.ACCOUNT_AGE_WITNESS.ordinal()
));
/**

View File

@ -17,7 +17,6 @@
package io.bisq.core.offer.messages;
import io.bisq.common.app.Capabilities;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.PubKeyRing;
import io.bisq.generated.protobuffer.PB;
@ -25,7 +24,9 @@ import io.bisq.network.p2p.SupportedCapabilitiesMessage;
import lombok.EqualsAndHashCode;
import lombok.Value;
import java.util.ArrayList;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Optional;
// We add here the SupportedCapabilitiesMessage interface as that message always predates a direct connection
// to the trading peer
@ -34,12 +35,13 @@ import java.util.ArrayList;
public final class OfferAvailabilityRequest extends OfferMessage implements SupportedCapabilitiesMessage {
private final PubKeyRing pubKeyRing;
private final long takersTradePrice;
private final ArrayList<Integer> supportedCapabilities = Capabilities.getCapabilities();
@Nullable
private final List<Integer> supportedCapabilities;
public OfferAvailabilityRequest(String offerId,
PubKeyRing pubKeyRing,
long takersTradePrice) {
this(offerId, pubKeyRing, takersTradePrice, Version.getP2PMessageVersion());
this(offerId, pubKeyRing, takersTradePrice, null, Version.getP2PMessageVersion());
}
@ -50,20 +52,25 @@ public final class OfferAvailabilityRequest extends OfferMessage implements Supp
private OfferAvailabilityRequest(String offerId,
PubKeyRing pubKeyRing,
long takersTradePrice,
@Nullable List<Integer> supportedCapabilities,
int messageVersion) {
super(messageVersion, offerId);
this.pubKeyRing = pubKeyRing;
this.takersTradePrice = takersTradePrice;
this.supportedCapabilities = supportedCapabilities;
}
@Override
public PB.NetworkEnvelope toProtoNetworkEnvelope() {
final PB.OfferAvailabilityRequest.Builder builder = PB.OfferAvailabilityRequest.newBuilder()
.setOfferId(offerId)
.setPubKeyRing(pubKeyRing.toProtoMessage())
.setTakersTradePrice(takersTradePrice);
Optional.ofNullable(supportedCapabilities).ifPresent(e -> builder.addAllSupportedCapabilities(supportedCapabilities));
return getNetworkEnvelopeBuilder()
.setOfferAvailabilityRequest(PB.OfferAvailabilityRequest.newBuilder()
.setOfferId(offerId)
.setPubKeyRing(pubKeyRing.toProtoMessage())
.setTakersTradePrice(takersTradePrice)
.addAllSupportedCapabilities(supportedCapabilities))
.setOfferAvailabilityRequest(builder)
.build();
}
@ -71,6 +78,7 @@ public final class OfferAvailabilityRequest extends OfferMessage implements Supp
return new OfferAvailabilityRequest(proto.getOfferId(),
PubKeyRing.fromProto(proto.getPubKeyRing()),
proto.getTakersTradePrice(),
proto.getSupportedCapabilitiesList().isEmpty() ? null : proto.getSupportedCapabilitiesList(),
messageVersion);
}
}

View File

@ -18,7 +18,6 @@
package io.bisq.core.offer.messages;
import io.bisq.common.app.Capabilities;
import io.bisq.common.app.Version;
import io.bisq.common.proto.ProtoUtil;
import io.bisq.core.offer.AvailabilityResult;
@ -27,7 +26,9 @@ import io.bisq.network.p2p.SupportedCapabilitiesMessage;
import lombok.EqualsAndHashCode;
import lombok.Value;
import java.util.ArrayList;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Optional;
// We add here the SupportedCapabilitiesMessage interface as that message always predates a direct connection
// to the trading peer
@ -35,10 +36,11 @@ import java.util.ArrayList;
@Value
public final class OfferAvailabilityResponse extends OfferMessage implements SupportedCapabilitiesMessage {
private final AvailabilityResult availabilityResult;
private final ArrayList<Integer> supportedCapabilities = Capabilities.getCapabilities();
@Nullable
private final List<Integer> supportedCapabilities;
public OfferAvailabilityResponse(String offerId, AvailabilityResult availabilityResult) {
this(offerId, availabilityResult, Version.getP2PMessageVersion());
this(offerId, availabilityResult, null, Version.getP2PMessageVersion());
}
@ -46,24 +48,32 @@ public final class OfferAvailabilityResponse extends OfferMessage implements Sup
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////
private OfferAvailabilityResponse(String offerId, AvailabilityResult availabilityResult, int messageVersion) {
private OfferAvailabilityResponse(String offerId,
AvailabilityResult availabilityResult,
@Nullable List<Integer> supportedCapabilities,
int messageVersion) {
super(messageVersion, offerId);
this.availabilityResult = availabilityResult;
this.supportedCapabilities = supportedCapabilities;
}
@Override
public PB.NetworkEnvelope toProtoNetworkEnvelope() {
final PB.OfferAvailabilityResponse.Builder builder = PB.OfferAvailabilityResponse.newBuilder()
.setOfferId(offerId)
.setAvailabilityResult(PB.AvailabilityResult.valueOf(availabilityResult.name()));
Optional.ofNullable(supportedCapabilities).ifPresent(e -> builder.addAllSupportedCapabilities(supportedCapabilities));
return getNetworkEnvelopeBuilder()
.setOfferAvailabilityResponse(PB.OfferAvailabilityResponse.newBuilder()
.setOfferId(offerId)
.setAvailabilityResult(PB.AvailabilityResult.valueOf(availabilityResult.name()))
.addAllSupportedCapabilities(supportedCapabilities))
.setOfferAvailabilityResponse(builder)
.build();
}
public static OfferAvailabilityResponse fromProto(PB.OfferAvailabilityResponse proto, int messageVersion) {
return new OfferAvailabilityResponse(proto.getOfferId(),
ProtoUtil.enumFromProto(AvailabilityResult.class, proto.getAvailabilityResult().name()),
proto.getSupportedCapabilitiesList().isEmpty() ? null : proto.getSupportedCapabilitiesList(),
messageVersion);
}
}

View File

@ -18,17 +18,19 @@
package io.bisq.core.payment;
import com.google.protobuf.ByteString;
import io.bisq.common.app.Capabilities;
import io.bisq.common.proto.persistable.PersistableEnvelope;
import io.bisq.common.util.Utilities;
import io.bisq.generated.protobuffer.PB;
import io.bisq.network.p2p.storage.P2PDataStorage;
import io.bisq.network.p2p.storage.payload.CapabilityRequiringPayload;
import io.bisq.network.p2p.storage.payload.LazyProcessedPayload;
import io.bisq.network.p2p.storage.payload.PersistableNetworkPayload;
import io.bisq.network.p2p.storage.payload.DateTolerantPayload;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;
import java.util.*;
import java.util.concurrent.TimeUnit;
// Object has 28 raw bytes (33 bytes is size of ProtoBuffer object in storage list, 5 byte extra for list -> totalBytes = 5 + n*33)
@ -36,7 +38,7 @@ import java.util.concurrent.TimeUnit;
// so only the newly added objects since the last release will be retrieved over the P2P network.
@Slf4j
@Value
public class AccountAgeWitness implements LazyProcessedPayload, PersistableNetworkPayload, PersistableEnvelope, DateTolerantPayload {
public class AccountAgeWitness implements LazyProcessedPayload, PersistableNetworkPayload, PersistableEnvelope, DateTolerantPayload, CapabilityRequiringPayload {
private static final long TOLERANCE = TimeUnit.DAYS.toMillis(1);
private final byte[] hash; // Ripemd160(Sha256(concatenated accountHash, signature and sigPubKey)); 20 bytes
@ -94,6 +96,14 @@ public class AccountAgeWitness implements LazyProcessedPayload, PersistableNetwo
return hash.length == 20;
}
// Pre 0.6 version don't know the new message type and throw an error which leads to disconnecting the peer.
@Override
public List<Integer> getRequiredCapabilities() {
return new ArrayList<>(Collections.singletonList(
Capabilities.Capability.ACCOUNT_AGE_WITNESS.ordinal()
));
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters

View File

@ -49,26 +49,29 @@ public final class AliPayAccountPayload extends PaymentAccountPayload {
private AliPayAccountPayload(String paymentMethod,
String id,
String accountNr,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
excludeFromJsonDataMap);
id,
maxTradePeriod,
excludeFromJsonDataMap);
this.accountNr = accountNr;
}
@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setAliPayAccountPayload(PB.AliPayAccountPayload.newBuilder()
.setAccountNr(accountNr))
.build();
.setAliPayAccountPayload(PB.AliPayAccountPayload.newBuilder()
.setAccountNr(accountNr))
.build();
}
public static AliPayAccountPayload fromProto(PB.PaymentAccountPayload proto) {
return new AliPayAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getAliPayAccountPayload().getAccountNr(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
proto.getAliPayAccountPayload().getAccountNr(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

View File

@ -73,11 +73,13 @@ public abstract class BankAccountPayload extends CountryBasedPaymentAccountPaylo
String holderTaxId,
String bankId,
String email,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethodName,
id,
countryCode,
excludeFromJsonDataMap);
id,
countryCode,
maxTradePeriod,
excludeFromJsonDataMap);
this.holderName = holderName;
this.bankName = bankName;
@ -92,8 +94,8 @@ public abstract class BankAccountPayload extends CountryBasedPaymentAccountPaylo
@Override
public PB.PaymentAccountPayload.Builder getPaymentAccountPayloadBuilder() {
PB.BankAccountPayload.Builder builder =
PB.BankAccountPayload.newBuilder()
.setHolderName(holderName);
PB.BankAccountPayload.newBuilder()
.setHolderName(holderName);
Optional.ofNullable(holderTaxId).ifPresent(builder::setHolderTaxId);
Optional.ofNullable(bankName).ifPresent(builder::setBankName);
Optional.ofNullable(branchId).ifPresent(builder::setBranchId);
@ -102,10 +104,10 @@ public abstract class BankAccountPayload extends CountryBasedPaymentAccountPaylo
Optional.ofNullable(bankId).ifPresent(builder::setBankId);
Optional.ofNullable(email).ifPresent(builder::setEmail);
final PB.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayloadBuilder = super.getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setBankAccountPayload(builder);
.getCountryBasedPaymentAccountPayloadBuilder()
.setBankAccountPayload(builder);
return super.getPaymentAccountPayloadBuilder()
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayloadBuilder);
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayloadBuilder);
}
@ -117,26 +119,26 @@ public abstract class BankAccountPayload extends CountryBasedPaymentAccountPaylo
@Override
public String getPaymentDetailsForTradePopup() {
String bankName = BankUtil.isBankNameRequired(countryCode) ?
BankUtil.getBankNameLabel(countryCode) + " " + this.bankName + "\n" : "";
BankUtil.getBankNameLabel(countryCode) + " " + this.bankName + "\n" : "";
String bankId = BankUtil.isBankIdRequired(countryCode) ?
BankUtil.getBankIdLabel(countryCode) + " " + this.bankId + "\n" : "";
BankUtil.getBankIdLabel(countryCode) + " " + this.bankId + "\n" : "";
String branchId = BankUtil.isBranchIdRequired(countryCode) ?
BankUtil.getBranchIdLabel(countryCode) + " " + this.branchId + "\n" : "";
BankUtil.getBranchIdLabel(countryCode) + " " + this.branchId + "\n" : "";
String accountNr = BankUtil.isAccountNrRequired(countryCode) ?
BankUtil.getAccountNrLabel(countryCode) + " " + this.accountNr + "\n" : "";
BankUtil.getAccountNrLabel(countryCode) + " " + this.accountNr + "\n" : "";
String accountType = BankUtil.isAccountTypeRequired(countryCode) ?
BankUtil.getAccountTypeLabel(countryCode) + " " + this.accountType + "\n" : "";
BankUtil.getAccountTypeLabel(countryCode) + " " + this.accountType + "\n" : "";
String holderTaxIdString = BankUtil.isHolderIdRequired(countryCode) ?
(BankUtil.getHolderIdLabel(countryCode) + " " + holderTaxId + "\n") : "";
(BankUtil.getHolderIdLabel(countryCode) + " " + holderTaxId + "\n") : "";
return "Holder name: " + holderName + "\n" +
bankName +
bankId +
branchId +
accountNr +
accountType +
holderTaxIdString +
"Country of bank: " + CountryUtil.getNameByCode(countryCode);
bankName +
bankId +
branchId +
accountNr +
accountType +
holderTaxIdString +
"Country of bank: " + CountryUtil.getNameByCode(countryCode);
}
protected String getHolderIdLabel() {
@ -156,17 +158,17 @@ public abstract class BankAccountPayload extends CountryBasedPaymentAccountPaylo
String accountNr = BankUtil.isAccountNrRequired(countryCode) ? this.accountNr : "";
String accountType = BankUtil.isAccountTypeRequired(countryCode) ? this.accountType : "";
String holderTaxIdString = BankUtil.isHolderIdRequired(countryCode) ?
(BankUtil.getHolderIdLabel(countryCode) + " " + holderTaxId + "\n") : "";
(BankUtil.getHolderIdLabel(countryCode) + " " + holderTaxId + "\n") : "";
// We don't add holderName because we don't want to break age validation if the user recreates an account with
// slight changes in holder name (e.g. add or remove middle name)
String all = bankName +
bankId +
branchId +
accountNr +
accountType +
holderTaxIdString;
bankId +
branchId +
accountNr +
accountType +
holderTaxIdString;
return super.getAgeWitnessInputData(all.getBytes(Charset.forName("UTF-8")));
}

View File

@ -80,9 +80,12 @@ public class CashDepositAccountPayload extends CountryBasedPaymentAccountPayload
@Nullable String requirements,
@Nullable String holderTaxId,
@Nullable String bankId,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethodName, id,
super(paymentMethodName,
id,
countryCode,
maxTradePeriod,
excludeFromJsonDataMap);
this.holderName = holderName;
this.holderEmail = holderEmail;
@ -132,6 +135,7 @@ public class CashDepositAccountPayload extends CountryBasedPaymentAccountPayload
cashDepositAccountPayload.getRequirements().isEmpty() ? null : cashDepositAccountPayload.getRequirements(),
cashDepositAccountPayload.getHolderTaxId().isEmpty() ? null : cashDepositAccountPayload.getHolderTaxId(),
cashDepositAccountPayload.getBankId().isEmpty() ? null : cashDepositAccountPayload.getBankId(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

View File

@ -49,13 +49,16 @@ public final class ChaseQuickPayAccountPayload extends PaymentAccountPayload {
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////
private ChaseQuickPayAccountPayload(String paymentMethod, String id,
private ChaseQuickPayAccountPayload(String paymentMethod,
String id,
String email,
String holderName,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
excludeFromJsonDataMap);
id,
maxTradePeriod,
excludeFromJsonDataMap);
this.email = email;
this.holderName = holderName;
@ -64,18 +67,19 @@ public final class ChaseQuickPayAccountPayload extends PaymentAccountPayload {
@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setChaseQuickPayAccountPayload(PB.ChaseQuickPayAccountPayload.newBuilder()
.setEmail(email)
.setHolderName(holderName))
.build();
.setChaseQuickPayAccountPayload(PB.ChaseQuickPayAccountPayload.newBuilder()
.setEmail(email)
.setHolderName(holderName))
.build();
}
public static ChaseQuickPayAccountPayload fromProto(PB.PaymentAccountPayload proto) {
return new ChaseQuickPayAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getChaseQuickPayAccountPayload().getEmail(),
proto.getChaseQuickPayAccountPayload().getHolderName(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
proto.getChaseQuickPayAccountPayload().getEmail(),
proto.getChaseQuickPayAccountPayload().getHolderName(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
@ -91,7 +95,7 @@ public final class ChaseQuickPayAccountPayload extends PaymentAccountPayload {
@Override
public String getPaymentDetailsForTradePopup() {
return "Holder name: " + holderName + "\n" +
"Email: " + email;
"Email: " + email;
}
@Override

View File

@ -53,10 +53,12 @@ public final class ClearXchangeAccountPayload extends PaymentAccountPayload {
String id,
String emailOrMobileNr,
String holderName,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
excludeFromJsonDataMap);
id,
maxTradePeriod,
excludeFromJsonDataMap);
this.emailOrMobileNr = emailOrMobileNr;
this.holderName = holderName;
@ -65,18 +67,19 @@ public final class ClearXchangeAccountPayload extends PaymentAccountPayload {
@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setClearXchangeAccountPayload(PB.ClearXchangeAccountPayload.newBuilder()
.setEmailOrMobileNr(emailOrMobileNr)
.setHolderName(holderName))
.build();
.setClearXchangeAccountPayload(PB.ClearXchangeAccountPayload.newBuilder()
.setEmailOrMobileNr(emailOrMobileNr)
.setHolderName(holderName))
.build();
}
public static ClearXchangeAccountPayload fromProto(PB.PaymentAccountPayload proto) {
return new ClearXchangeAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getClearXchangeAccountPayload().getEmailOrMobileNr(),
proto.getClearXchangeAccountPayload().getHolderName(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
proto.getClearXchangeAccountPayload().getEmailOrMobileNr(),
proto.getClearXchangeAccountPayload().getHolderName(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
@ -92,7 +95,7 @@ public final class ClearXchangeAccountPayload extends PaymentAccountPayload {
@Override
public String getPaymentDetailsForTradePopup() {
return "Holder name: " + holderName + "\n" +
"Email or mobile no.: " + emailOrMobileNr;
"Email or mobile no.: " + emailOrMobileNr;
}
@Override

View File

@ -44,10 +44,12 @@ public abstract class CountryBasedPaymentAccountPayload extends PaymentAccountPa
protected CountryBasedPaymentAccountPayload(String paymentMethodName,
String id,
String countryCode,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethodName,
id,
excludeFromJsonDataMap);
id,
maxTradePeriod,
excludeFromJsonDataMap);
this.countryCode = countryCode;
}
@ -55,9 +57,9 @@ public abstract class CountryBasedPaymentAccountPayload extends PaymentAccountPa
@Override
protected PB.PaymentAccountPayload.Builder getPaymentAccountPayloadBuilder() {
PB.CountryBasedPaymentAccountPayload.Builder builder = PB.CountryBasedPaymentAccountPayload.newBuilder()
.setCountryCode(countryCode);
.setCountryCode(countryCode);
return super.getPaymentAccountPayloadBuilder()
.setCountryBasedPaymentAccountPayload(builder);
.setCountryBasedPaymentAccountPayload(builder);
}
abstract public String getPaymentDetails();

View File

@ -51,26 +51,29 @@ public final class CryptoCurrencyAccountPayload extends PaymentAccountPayload {
private CryptoCurrencyAccountPayload(String paymentMethod,
String id,
String address,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
excludeFromJsonDataMap);
id,
maxTradePeriod,
excludeFromJsonDataMap);
this.address = address;
}
@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setCryptoCurrencyAccountPayload(PB.CryptoCurrencyAccountPayload.newBuilder()
.setAddress(address))
.build();
.setCryptoCurrencyAccountPayload(PB.CryptoCurrencyAccountPayload.newBuilder()
.setAddress(address))
.build();
}
public static CryptoCurrencyAccountPayload fromProto(PB.PaymentAccountPayload proto) {
return new CryptoCurrencyAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getCryptoCurrencyAccountPayload().getAddress(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
proto.getCryptoCurrencyAccountPayload().getAddress(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

View File

@ -57,10 +57,12 @@ public final class FasterPaymentsAccountPayload extends PaymentAccountPayload {
String sortCode,
String accountNr,
String email,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
excludeFromJsonDataMap);
id,
maxTradePeriod,
excludeFromJsonDataMap);
this.sortCode = sortCode;
this.accountNr = accountNr;
this.email = email;
@ -69,20 +71,21 @@ public final class FasterPaymentsAccountPayload extends PaymentAccountPayload {
@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setFasterPaymentsAccountPayload(PB.FasterPaymentsAccountPayload.newBuilder()
.setSortCode(sortCode)
.setAccountNr(accountNr)
.setEmail(email))
.build();
.setFasterPaymentsAccountPayload(PB.FasterPaymentsAccountPayload.newBuilder()
.setSortCode(sortCode)
.setAccountNr(accountNr)
.setEmail(email))
.build();
}
public static FasterPaymentsAccountPayload fromProto(PB.PaymentAccountPayload proto) {
return new FasterPaymentsAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getFasterPaymentsAccountPayload().getSortCode(),
proto.getFasterPaymentsAccountPayload().getAccountNr(),
proto.getFasterPaymentsAccountPayload().getEmail(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
proto.getFasterPaymentsAccountPayload().getSortCode(),
proto.getFasterPaymentsAccountPayload().getAccountNr(),
proto.getFasterPaymentsAccountPayload().getEmail(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
@ -98,12 +101,12 @@ public final class FasterPaymentsAccountPayload extends PaymentAccountPayload {
@Override
public String getPaymentDetailsForTradePopup() {
return "UK Sort code: " + sortCode + "\n" +
"Account number: " + accountNr;
"Account number: " + accountNr;
}
@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(ArrayUtils.addAll(sortCode.getBytes(Charset.forName("UTF-8")),
accountNr.getBytes(Charset.forName("UTF-8"))));
accountNr.getBytes(Charset.forName("UTF-8"))));
}
}

View File

@ -58,10 +58,12 @@ public final class InteracETransferAccountPayload extends PaymentAccountPayload
String holderName,
String question,
String answer,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
excludeFromJsonDataMap);
id,
maxTradePeriod,
excludeFromJsonDataMap);
this.email = email;
this.holderName = holderName;
this.question = question;
@ -71,22 +73,23 @@ public final class InteracETransferAccountPayload extends PaymentAccountPayload
@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setInteracETransferAccountPayload(PB.InteracETransferAccountPayload.newBuilder()
.setEmail(email)
.setHolderName(holderName)
.setQuestion(question)
.setAnswer(answer))
.build();
.setInteracETransferAccountPayload(PB.InteracETransferAccountPayload.newBuilder()
.setEmail(email)
.setHolderName(holderName)
.setQuestion(question)
.setAnswer(answer))
.build();
}
public static InteracETransferAccountPayload fromProto(PB.PaymentAccountPayload proto) {
return new InteracETransferAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getInteracETransferAccountPayload().getEmail(),
proto.getInteracETransferAccountPayload().getHolderName(),
proto.getInteracETransferAccountPayload().getQuestion(),
proto.getInteracETransferAccountPayload().getAnswer(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
proto.getInteracETransferAccountPayload().getEmail(),
proto.getInteracETransferAccountPayload().getHolderName(),
proto.getInteracETransferAccountPayload().getQuestion(),
proto.getInteracETransferAccountPayload().getAnswer(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
@ -102,15 +105,15 @@ public final class InteracETransferAccountPayload extends PaymentAccountPayload
@Override
public String getPaymentDetailsForTradePopup() {
return "Holder name: " + holderName + "\n" +
"Email: " + email + "\n" +
"Secret question: " + question + "\n" +
"Answer: " + answer;
"Email: " + email + "\n" +
"Secret question: " + question + "\n" +
"Answer: " + answer;
}
@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(ArrayUtils.addAll(email.getBytes(Charset.forName("UTF-8")),
ArrayUtils.addAll(question.getBytes(Charset.forName("UTF-8")),
answer.getBytes(Charset.forName("UTF-8")))));
ArrayUtils.addAll(question.getBytes(Charset.forName("UTF-8")),
answer.getBytes(Charset.forName("UTF-8")))));
}
}

View File

@ -54,52 +54,55 @@ public final class NationalBankAccountPayload extends BankAccountPayload {
String holderTaxId,
String bankId,
String email,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethodName,
id,
countryCode,
holderName,
bankName,
branchId,
accountNr,
accountType,
holderTaxId,
bankId,
email,
excludeFromJsonDataMap);
id,
countryCode,
holderName,
bankName,
branchId,
accountNr,
accountType,
holderTaxId,
bankId,
email,
maxTradePeriod,
excludeFromJsonDataMap);
}
@Override
public Message toProtoMessage() {
PB.BankAccountPayload.Builder bankAccountPayloadBuilder = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.getBankAccountPayloadBuilder()
.setNationalBankAccountPayload(PB.NationalBankAccountPayload.newBuilder());
.getCountryBasedPaymentAccountPayloadBuilder()
.getBankAccountPayloadBuilder()
.setNationalBankAccountPayload(PB.NationalBankAccountPayload.newBuilder());
PB.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayloadBuilder = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setBankAccountPayload(bankAccountPayloadBuilder);
.getCountryBasedPaymentAccountPayloadBuilder()
.setBankAccountPayload(bankAccountPayloadBuilder);
return getPaymentAccountPayloadBuilder()
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayloadBuilder)
.build();
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayloadBuilder)
.build();
}
public static NationalBankAccountPayload fromProto(PB.PaymentAccountPayload proto) {
PB.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload();
PB.BankAccountPayload bankAccountPayloadPB = countryBasedPaymentAccountPayload.getBankAccountPayload();
return new NationalBankAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
bankAccountPayloadPB.getHolderName(),
bankAccountPayloadPB.getBankName().isEmpty() ? null : bankAccountPayloadPB.getBankName(),
bankAccountPayloadPB.getBranchId().isEmpty() ? null : bankAccountPayloadPB.getBranchId(),
bankAccountPayloadPB.getAccountNr().isEmpty() ? null : bankAccountPayloadPB.getAccountNr(),
bankAccountPayloadPB.getAccountType().isEmpty() ? null : bankAccountPayloadPB.getAccountType(),
bankAccountPayloadPB.getHolderTaxId().isEmpty() ? null : bankAccountPayloadPB.getHolderTaxId(),
bankAccountPayloadPB.getBankId().isEmpty() ? null : bankAccountPayloadPB.getBankId(),
bankAccountPayloadPB.getEmail().isEmpty() ? null : bankAccountPayloadPB.getEmail(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
bankAccountPayloadPB.getHolderName(),
bankAccountPayloadPB.getBankName().isEmpty() ? null : bankAccountPayloadPB.getBankName(),
bankAccountPayloadPB.getBranchId().isEmpty() ? null : bankAccountPayloadPB.getBranchId(),
bankAccountPayloadPB.getAccountNr().isEmpty() ? null : bankAccountPayloadPB.getAccountNr(),
bankAccountPayloadPB.getAccountType().isEmpty() ? null : bankAccountPayloadPB.getAccountType(),
bankAccountPayloadPB.getHolderTaxId().isEmpty() ? null : bankAccountPayloadPB.getHolderTaxId(),
bankAccountPayloadPB.getBankId().isEmpty() ? null : bankAccountPayloadPB.getBankId(),
bankAccountPayloadPB.getEmail().isEmpty() ? null : bankAccountPayloadPB.getEmail(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
@Override

View File

@ -50,10 +50,12 @@ public final class OKPayAccountPayload extends PaymentAccountPayload {
private OKPayAccountPayload(String paymentMethod,
String id,
String accountNr,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
excludeFromJsonDataMap);
id,
maxTradePeriod,
excludeFromJsonDataMap);
this.accountNr = accountNr;
}
@ -61,16 +63,17 @@ public final class OKPayAccountPayload extends PaymentAccountPayload {
@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setOKPayAccountPayload(PB.OKPayAccountPayload.newBuilder()
.setAccountNr(accountNr))
.build();
.setOKPayAccountPayload(PB.OKPayAccountPayload.newBuilder()
.setAccountNr(accountNr))
.build();
}
public static OKPayAccountPayload fromProto(PB.PaymentAccountPayload proto) {
return new OKPayAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getOKPayAccountPayload().getAccountNr(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
proto.getOKPayAccountPayload().getAccountNr(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

View File

@ -54,6 +54,9 @@ public abstract class PaymentAccountPayload implements NetworkPayload, Restricte
protected final String paymentMethodId;
protected final String id;
// Is just kept for not breaking backward compatibility. Set to -1 to indicate it is no used anymore.
protected final long maxTradePeriod;
// In v0.6 we removed maxTradePeriod but we need to keep it in the PB file for backward compatibility
// protected final long maxTradePeriod;
@ -71,8 +74,9 @@ public abstract class PaymentAccountPayload implements NetworkPayload, Restricte
PaymentAccountPayload(String paymentMethodId, String id) {
this(paymentMethodId,
id,
null);
id,
-1,
null);
}
///////////////////////////////////////////////////////////////////////////////////////////
@ -81,9 +85,11 @@ public abstract class PaymentAccountPayload implements NetworkPayload, Restricte
protected PaymentAccountPayload(String paymentMethodId,
String id,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMapParam) {
this.paymentMethodId = paymentMethodId;
this.id = id;
this.maxTradePeriod = maxTradePeriod;
this.excludeFromJsonDataMap = excludeFromJsonDataMapParam == null ? new HashMap<>() : excludeFromJsonDataMapParam;
// If not set (old versions) we set by default a random 256 bit salt.
@ -95,8 +101,9 @@ public abstract class PaymentAccountPayload implements NetworkPayload, Restricte
protected PB.PaymentAccountPayload.Builder getPaymentAccountPayloadBuilder() {
final PB.PaymentAccountPayload.Builder builder = PB.PaymentAccountPayload.newBuilder()
.setPaymentMethodId(paymentMethodId)
.setId(id);
.setPaymentMethodId(paymentMethodId)
.setMaxTradePeriod(maxTradePeriod)
.setId(id);
Optional.ofNullable(excludeFromJsonDataMap).ifPresent(builder::putAllExcludeFromJsonData);

View File

@ -48,12 +48,15 @@ public final class PerfectMoneyAccountPayload extends PaymentAccountPayload {
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////
private PerfectMoneyAccountPayload(String paymentMethod, String id,
private PerfectMoneyAccountPayload(String paymentMethod,
String id,
String accountNr,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
excludeFromJsonDataMap);
id,
maxTradePeriod,
excludeFromJsonDataMap);
this.accountNr = accountNr;
}
@ -61,16 +64,17 @@ public final class PerfectMoneyAccountPayload extends PaymentAccountPayload {
@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setPerfectMoneyAccountPayload(PB.PerfectMoneyAccountPayload.newBuilder()
.setAccountNr(accountNr))
.build();
.setPerfectMoneyAccountPayload(PB.PerfectMoneyAccountPayload.newBuilder()
.setAccountNr(accountNr))
.build();
}
public static PerfectMoneyAccountPayload fromProto(PB.PaymentAccountPayload proto) {
return new PerfectMoneyAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getPerfectMoneyAccountPayload().getAccountNr(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
proto.getPerfectMoneyAccountPayload().getAccountNr(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

View File

@ -54,53 +54,56 @@ public final class SameBankAccountPayload extends BankAccountPayload {
String holderTaxId,
String bankId,
String email,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethodName,
id,
countryCode,
holderName,
bankName,
branchId,
accountNr,
accountType,
holderTaxId,
bankId,
email,
excludeFromJsonDataMap);
id,
countryCode,
holderName,
bankName,
branchId,
accountNr,
accountType,
holderTaxId,
bankId,
email,
maxTradePeriod,
excludeFromJsonDataMap);
}
@Override
public Message toProtoMessage() {
PB.BankAccountPayload.Builder bankAccountPayloadBuilder = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.getBankAccountPayloadBuilder()
.setSameBankAccontPayload(PB.SameBankAccountPayload.newBuilder());
.getCountryBasedPaymentAccountPayloadBuilder()
.getBankAccountPayloadBuilder()
.setSameBankAccontPayload(PB.SameBankAccountPayload.newBuilder());
PB.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayloadBuilder = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setBankAccountPayload(bankAccountPayloadBuilder);
.getCountryBasedPaymentAccountPayloadBuilder()
.setBankAccountPayload(bankAccountPayloadBuilder);
return getPaymentAccountPayloadBuilder()
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayloadBuilder)
.build();
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayloadBuilder)
.build();
}
public static SameBankAccountPayload fromProto(PB.PaymentAccountPayload proto) {
PB.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload();
PB.BankAccountPayload bankAccountPayload = countryBasedPaymentAccountPayload.getBankAccountPayload();
return new SameBankAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
bankAccountPayload.getHolderName(),
bankAccountPayload.getBankName().isEmpty() ? null : bankAccountPayload.getBankName(),
bankAccountPayload.getBranchId().isEmpty() ? null : bankAccountPayload.getBranchId(),
bankAccountPayload.getAccountNr().isEmpty() ? null : bankAccountPayload.getAccountNr(),
bankAccountPayload.getAccountType().isEmpty() ? null : bankAccountPayload.getAccountType(),
bankAccountPayload.getHolderTaxId().isEmpty() ? null : bankAccountPayload.getHolderTaxId(),
bankAccountPayload.getBankId().isEmpty() ? null : bankAccountPayload.getBankId(),
bankAccountPayload.getEmail().isEmpty() ? null : bankAccountPayload.getEmail(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
bankAccountPayload.getHolderName(),
bankAccountPayload.getBankName().isEmpty() ? null : bankAccountPayload.getBankName(),
bankAccountPayload.getBranchId().isEmpty() ? null : bankAccountPayload.getBranchId(),
bankAccountPayload.getAccountNr().isEmpty() ? null : bankAccountPayload.getAccountNr(),
bankAccountPayload.getAccountType().isEmpty() ? null : bankAccountPayload.getAccountType(),
bankAccountPayload.getHolderTaxId().isEmpty() ? null : bankAccountPayload.getHolderTaxId(),
bankAccountPayload.getBankId().isEmpty() ? null : bankAccountPayload.getBankId(),
bankAccountPayload.getEmail().isEmpty() ? null : bankAccountPayload.getEmail(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
///////////////////////////////////////////////////////////////////////////////////////////

View File

@ -53,7 +53,7 @@ public final class SepaAccountPayload extends CountryBasedPaymentAccountPayload
public SepaAccountPayload(String paymentMethod, String id, List<Country> acceptedCountries) {
super(paymentMethod, id);
Set<String> acceptedCountryCodesAsSet = acceptedCountries.stream()
.map(e -> e.code).collect(Collectors.toSet());
.map(e -> e.code).collect(Collectors.toSet());
acceptedCountryCodes = new ArrayList<>(acceptedCountryCodesAsSet);
acceptedCountryCodes.sort(String::compareTo);
}
@ -71,11 +71,13 @@ public final class SepaAccountPayload extends CountryBasedPaymentAccountPayload
String bic,
String email,
List<String> acceptedCountryCodes,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethodName,
id,
countryCode,
excludeFromJsonDataMap);
id,
countryCode,
maxTradePeriod,
excludeFromJsonDataMap);
this.holderName = holderName;
this.iban = iban;
@ -87,32 +89,33 @@ public final class SepaAccountPayload extends CountryBasedPaymentAccountPayload
@Override
public Message toProtoMessage() {
PB.SepaAccountPayload.Builder builder =
PB.SepaAccountPayload.newBuilder()
.setHolderName(holderName)
.setIban(iban)
.setBic(bic)
.setEmail(email)
.addAllAcceptedCountryCodes(acceptedCountryCodes);
PB.SepaAccountPayload.newBuilder()
.setHolderName(holderName)
.setIban(iban)
.setBic(bic)
.setEmail(email)
.addAllAcceptedCountryCodes(acceptedCountryCodes);
final PB.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setSepaAccountPayload(builder);
.getCountryBasedPaymentAccountPayloadBuilder()
.setSepaAccountPayload(builder);
return getPaymentAccountPayloadBuilder()
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayload)
.build();
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayload)
.build();
}
public static PaymentAccountPayload fromProto(PB.PaymentAccountPayload proto) {
PB.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload();
PB.SepaAccountPayload sepaAccountPayloadPB = countryBasedPaymentAccountPayload.getSepaAccountPayload();
return new SepaAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
sepaAccountPayloadPB.getHolderName(),
sepaAccountPayloadPB.getIban(),
sepaAccountPayloadPB.getBic(),
sepaAccountPayloadPB.getEmail(),
new ArrayList<>(sepaAccountPayloadPB.getAcceptedCountryCodesList()),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
sepaAccountPayloadPB.getHolderName(),
sepaAccountPayloadPB.getIban(),
sepaAccountPayloadPB.getBic(),
sepaAccountPayloadPB.getEmail(),
new ArrayList<>(sepaAccountPayloadPB.getAcceptedCountryCodesList()),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
@ -138,9 +141,9 @@ public final class SepaAccountPayload extends CountryBasedPaymentAccountPayload
@Override
public String getPaymentDetailsForTradePopup() {
return "Holder name: " + holderName + "\n" +
"IBAN: " + iban + "\n" +
"BIC: " + bic + "\n" +
"Country of bank: " + CountryUtil.getNameByCode(countryCode);
"IBAN: " + iban + "\n" +
"BIC: " + bic + "\n" +
"Country of bank: " + CountryUtil.getNameByCode(countryCode);
}
@Override

View File

@ -61,19 +61,21 @@ public final class SpecificBanksAccountPayload extends BankAccountPayload {
String bankId,
String email,
ArrayList<String> acceptedBanks,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethodName,
id,
countryCode,
holderName,
bankName,
branchId,
accountNr,
accountType,
holderTaxId,
bankId,
email,
excludeFromJsonDataMap);
id,
countryCode,
holderName,
bankName,
branchId,
accountNr,
accountType,
holderTaxId,
bankId,
email,
maxTradePeriod,
excludeFromJsonDataMap);
this.acceptedBanks = acceptedBanks;
}
@ -81,20 +83,20 @@ public final class SpecificBanksAccountPayload extends BankAccountPayload {
@Override
public Message toProtoMessage() {
final PB.SpecificBanksAccountPayload.Builder builder = PB.SpecificBanksAccountPayload.newBuilder()
.addAllAcceptedBanks(acceptedBanks);
.addAllAcceptedBanks(acceptedBanks);
PB.BankAccountPayload.Builder bankAccountPayloadBuilder = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.getBankAccountPayloadBuilder()
.setSpecificBanksAccountPayload(builder);
.getCountryBasedPaymentAccountPayloadBuilder()
.getBankAccountPayloadBuilder()
.setSpecificBanksAccountPayload(builder);
PB.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayloadBuilder = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setBankAccountPayload(bankAccountPayloadBuilder);
.getCountryBasedPaymentAccountPayloadBuilder()
.setBankAccountPayload(bankAccountPayloadBuilder);
return getPaymentAccountPayloadBuilder()
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayloadBuilder)
.build();
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayloadBuilder)
.build();
}
public static SpecificBanksAccountPayload fromProto(PB.PaymentAccountPayload proto) {
@ -102,18 +104,19 @@ public final class SpecificBanksAccountPayload extends BankAccountPayload {
PB.BankAccountPayload bankAccountPayload = countryBasedPaymentAccountPayload.getBankAccountPayload();
PB.SpecificBanksAccountPayload specificBanksAccountPayload = bankAccountPayload.getSpecificBanksAccountPayload();
return new SpecificBanksAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
bankAccountPayload.getHolderName(),
bankAccountPayload.getBankName().isEmpty() ? null : bankAccountPayload.getBankName(),
bankAccountPayload.getBranchId().isEmpty() ? null : bankAccountPayload.getBranchId(),
bankAccountPayload.getAccountNr().isEmpty() ? null : bankAccountPayload.getAccountNr(),
bankAccountPayload.getAccountType().isEmpty() ? null : bankAccountPayload.getAccountType(),
bankAccountPayload.getHolderTaxId().isEmpty() ? null : bankAccountPayload.getHolderTaxId(),
bankAccountPayload.getBankId().isEmpty() ? null : bankAccountPayload.getBankId(),
bankAccountPayload.getEmail().isEmpty() ? null : bankAccountPayload.getEmail(),
new ArrayList<>(specificBanksAccountPayload.getAcceptedBanksList()),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
bankAccountPayload.getHolderName(),
bankAccountPayload.getBankName().isEmpty() ? null : bankAccountPayload.getBankName(),
bankAccountPayload.getBranchId().isEmpty() ? null : bankAccountPayload.getBranchId(),
bankAccountPayload.getAccountNr().isEmpty() ? null : bankAccountPayload.getAccountNr(),
bankAccountPayload.getAccountType().isEmpty() ? null : bankAccountPayload.getAccountType(),
bankAccountPayload.getHolderTaxId().isEmpty() ? null : bankAccountPayload.getHolderTaxId(),
bankAccountPayload.getBankId().isEmpty() ? null : bankAccountPayload.getBankId(),
bankAccountPayload.getEmail().isEmpty() ? null : bankAccountPayload.getEmail(),
new ArrayList<>(specificBanksAccountPayload.getAcceptedBanksList()),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
@ -138,6 +141,6 @@ public final class SpecificBanksAccountPayload extends BankAccountPayload {
@Override
public String getPaymentDetailsForTradePopup() {
return super.getPaymentDetailsForTradePopup() + "\n" +
"Accepted banks: " + Joiner.on(", ").join(acceptedBanks);
"Accepted banks: " + Joiner.on(", ").join(acceptedBanks);
}
}

View File

@ -52,10 +52,12 @@ public final class SwishAccountPayload extends PaymentAccountPayload {
private SwishAccountPayload(String paymentMethod, String id,
String mobileNr,
String holderName,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
excludeFromJsonDataMap);
id,
maxTradePeriod,
excludeFromJsonDataMap);
this.mobileNr = mobileNr;
this.holderName = holderName;
}
@ -63,18 +65,19 @@ public final class SwishAccountPayload extends PaymentAccountPayload {
@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setSwishAccountPayload(PB.SwishAccountPayload.newBuilder()
.setMobileNr(mobileNr)
.setHolderName(holderName))
.build();
.setSwishAccountPayload(PB.SwishAccountPayload.newBuilder()
.setMobileNr(mobileNr)
.setHolderName(holderName))
.build();
}
public static SwishAccountPayload fromProto(PB.PaymentAccountPayload proto) {
return new SwishAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getSwishAccountPayload().getMobileNr(),
proto.getSwishAccountPayload().getHolderName(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
proto.getSwishAccountPayload().getMobileNr(),
proto.getSwishAccountPayload().getHolderName(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
@ -90,7 +93,7 @@ public final class SwishAccountPayload extends PaymentAccountPayload {
@Override
public String getPaymentDetailsForTradePopup() {
return "Holder name: " + holderName + "\n" +
"Mobile no.: " + mobileNr;
"Mobile no.: " + mobileNr;
}
@Override

View File

@ -53,10 +53,12 @@ public final class USPostalMoneyOrderAccountPayload extends PaymentAccountPayloa
private USPostalMoneyOrderAccountPayload(String paymentMethod, String id,
String postalAddress,
String holderName,
long maxTradePeriod,
@Nullable Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
excludeFromJsonDataMap);
id,
maxTradePeriod,
excludeFromJsonDataMap);
this.postalAddress = postalAddress;
this.holderName = holderName;
}
@ -64,18 +66,19 @@ public final class USPostalMoneyOrderAccountPayload extends PaymentAccountPayloa
@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setUSPostalMoneyOrderAccountPayload(PB.USPostalMoneyOrderAccountPayload.newBuilder()
.setPostalAddress(postalAddress)
.setHolderName(holderName))
.build();
.setUSPostalMoneyOrderAccountPayload(PB.USPostalMoneyOrderAccountPayload.newBuilder()
.setPostalAddress(postalAddress)
.setHolderName(holderName))
.build();
}
public static USPostalMoneyOrderAccountPayload fromProto(PB.PaymentAccountPayload proto) {
return new USPostalMoneyOrderAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getUSPostalMoneyOrderAccountPayload().getPostalAddress(),
proto.getUSPostalMoneyOrderAccountPayload().getHolderName(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
proto.getId(),
proto.getUSPostalMoneyOrderAccountPayload().getPostalAddress(),
proto.getUSPostalMoneyOrderAccountPayload().getHolderName(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}
@ -92,13 +95,13 @@ public final class USPostalMoneyOrderAccountPayload extends PaymentAccountPayloa
@Override
public String getPaymentDetailsForTradePopup() {
return "Holder name: " + holderName + "\n" +
"Postal address: " + postalAddress;
"Postal address: " + postalAddress;
}
@Override
public byte[] getAgeWitnessInputData() {
// We use here the holderName because the address alone seems to be too weak
return super.getAgeWitnessInputData(ArrayUtils.addAll(holderName.getBytes(Charset.forName("UTF-8")),
postalAddress.getBytes(Charset.forName("UTF-8"))));
postalAddress.getBytes(Charset.forName("UTF-8"))));
}
}