Skip to content

Commit

Permalink
Merge pull request #5745 from jmacxx/add_monese_satispay
Browse files Browse the repository at this point in the history
Add payment methods Monese and Satispay
  • Loading branch information
ripcurlx authored Oct 11, 2021
2 parents 2e38c3c + df2d0b3 commit 2d3182c
Show file tree
Hide file tree
Showing 15 changed files with 606 additions and 1 deletion.
9 changes: 9 additions & 0 deletions core/src/main/java/bisq/core/locale/CurrencyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,15 @@ public static List<TradeCurrency> getAllCelPayCurrencies() {
));
}

// https://github.com/bisq-network/growth/issues/227
public static List<TradeCurrency> getAllMoneseCurrencies() {
return new ArrayList<>(Arrays.asList(
new FiatCurrency("EUR"),
new FiatCurrency("GBP"),
new FiatCurrency("RON")
));
}

// https://www.revolut.com/help/getting-started/exchanging-currencies/what-fiat-currencies-are-supported-for-holding-and-exchange
public static List<TradeCurrency> getAllRevolutCurrencies() {
ArrayList<TradeCurrency> currencies = new ArrayList<>(Arrays.asList(
Expand Down
56 changes: 56 additions & 0 deletions core/src/main/java/bisq/core/payment/MoneseAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.payment;

import bisq.core.payment.payload.MoneseAccountPayload;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;

import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
public final class MoneseAccount extends PaymentAccount {
public MoneseAccount() {
super(PaymentMethod.MONESE);
}

@Override
protected PaymentAccountPayload createPayload() {
return new MoneseAccountPayload(paymentMethod.getId(), id);
}

public void setMobileNr(String accountId) {
((MoneseAccountPayload) paymentAccountPayload).setMobileNr(accountId);
}

public String getMobileNr() {
return ((MoneseAccountPayload) paymentAccountPayload).getMobileNr();
}

public String getMessageForBuyer() {
return "payment.monese.info.buyer";
}

public String getMessageForSeller() {
return "payment.monese.info.seller";
}

public String getMessageForAccountCreation() {
return "payment.monese.info.account";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) {
return new CapitualAccount();
case PaymentMethod.CELPAY_ID:
return new CelPayAccount();
case PaymentMethod.MONESE_ID:
return new MoneseAccount();
case PaymentMethod.SATISPAY_ID:
return new SatispayAccount();
case PaymentMethod.SWIFT_ID:
return new SwiftAccount();

Expand Down
56 changes: 56 additions & 0 deletions core/src/main/java/bisq/core/payment/SatispayAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.payment;

import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.payment.payload.SatispayAccountPayload;

import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
public final class SatispayAccount extends CountryBasedPaymentAccount {
public SatispayAccount() {
super(PaymentMethod.SATISPAY);
}

@Override
protected PaymentAccountPayload createPayload() {
return new SatispayAccountPayload(paymentMethod.getId(), id);
}

public void setMobileNr(String accountId) {
((SatispayAccountPayload) paymentAccountPayload).setMobileNr(accountId);
}

public String getMobileNr() {
return ((SatispayAccountPayload) paymentAccountPayload).getMobileNr();
}

public String getMessageForBuyer() {
return "payment.satispay.info.buyer";
}

public String getMessageForSeller() {
return "payment.satispay.info.seller";
}

public String getMessageForAccountCreation() {
return "payment.satispay.info.account";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.payment.payload;

import bisq.core.locale.Res;

import com.google.protobuf.Message;

import java.nio.charset.StandardCharsets;

import java.util.HashMap;
import java.util.Map;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

@EqualsAndHashCode(callSuper = true)
@ToString
@Setter
@Getter
@Slf4j
public final class MoneseAccountPayload extends PaymentAccountPayload {
private String mobileNr = "";

public MoneseAccountPayload(String paymentMethod, String id) {
super(paymentMethod, id);
}

private MoneseAccountPayload(String paymentMethod,
String id,
String mobileNr,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
maxTradePeriod,
excludeFromJsonDataMap);

this.mobileNr = mobileNr;
}

@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setMoneseAccountPayload(protobuf.MoneseAccountPayload.newBuilder().setMobileNr(mobileNr))
.build();
}

public static MoneseAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
return new MoneseAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getMoneseAccountPayload().getMobileNr(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.mobile") + " " + mobileNr;
}

@Override
public String getPaymentDetailsForTradePopup() {
return getPaymentDetails();
}

@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(mobileNr.getBytes(StandardCharsets.UTF_8));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
public static final String CASH_BY_MAIL_ID = "CASH_BY_MAIL";
public static final String CAPITUAL_ID = "CAPITUAL";
public static final String CELPAY_ID = "CELPAY";
public static final String MONESE_ID = "MONESE";
public static final String SATISPAY_ID = "SATISPAY";
public static final String SWIFT_ID = "SWIFT";

// Cannot be deleted as it would break old trade history entries
Expand Down Expand Up @@ -165,6 +167,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
public static PaymentMethod CASH_BY_MAIL;
public static PaymentMethod CAPITUAL;
public static PaymentMethod CELPAY;
public static PaymentMethod MONESE;
public static PaymentMethod SATISPAY;
public static PaymentMethod SWIFT;

// Cannot be deleted as it would break old trade history entries
Expand Down Expand Up @@ -229,6 +233,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
PIX = new PaymentMethod(PIX_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
CAPITUAL = new PaymentMethod(CAPITUAL_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
CELPAY = new PaymentMethod(CELPAY_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
MONESE = new PaymentMethod(MONESE_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
SATISPAY = new PaymentMethod(SATISPAY_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
SWIFT = new PaymentMethod(SWIFT_ID, 7 * DAY, DEFAULT_TRADE_LIMIT_MID_RISK),

// Japan
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.payment.payload;

import bisq.core.locale.Res;

import com.google.protobuf.Message;

import java.nio.charset.StandardCharsets;

import java.util.HashMap;
import java.util.Map;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

@EqualsAndHashCode(callSuper = true)
@ToString
@Setter
@Getter
@Slf4j
public final class SatispayAccountPayload extends CountryBasedPaymentAccountPayload {
private String mobileNr = "";

public SatispayAccountPayload(String paymentMethod, String id) {
super(paymentMethod, id);
}

private SatispayAccountPayload(String paymentMethod,
String id,
String countryCode,
String mobileNr,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
countryCode,
maxTradePeriod,
excludeFromJsonDataMap);

this.mobileNr = mobileNr;
}

@Override
public Message toProtoMessage() {
protobuf.SatispayAccountPayload.Builder builder = protobuf.SatispayAccountPayload.newBuilder()
.setMobileNr(mobileNr);
final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setSatispayAccountPayload(builder);
return getPaymentAccountPayloadBuilder()
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayload)
.build();
}

public static SatispayAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
protobuf.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload();
protobuf.SatispayAccountPayload paytmAccountPayloadPB = countryBasedPaymentAccountPayload.getSatispayAccountPayload();
return new SatispayAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
paytmAccountPayloadPB.getMobileNr(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.mobile") + " " + mobileNr;
}

@Override
public String getPaymentDetailsForTradePopup() {
return getPaymentDetails();
}

@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(mobileNr.getBytes(StandardCharsets.UTF_8));
}
}
6 changes: 6 additions & 0 deletions core/src/main/java/bisq/core/proto/CoreProtoResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import bisq.core.payment.payload.InstantCryptoCurrencyPayload;
import bisq.core.payment.payload.InteracETransferAccountPayload;
import bisq.core.payment.payload.JapanBankAccountPayload;
import bisq.core.payment.payload.MoneseAccountPayload;
import bisq.core.payment.payload.MoneyBeamAccountPayload;
import bisq.core.payment.payload.MoneyGramAccountPayload;
import bisq.core.payment.payload.NationalBankAccountPayload;
Expand All @@ -58,6 +59,7 @@
import bisq.core.payment.payload.RevolutAccountPayload;
import bisq.core.payment.payload.RtgsAccountPayload;
import bisq.core.payment.payload.SameBankAccountPayload;
import bisq.core.payment.payload.SatispayAccountPayload;
import bisq.core.payment.payload.SepaAccountPayload;
import bisq.core.payment.payload.SepaInstantAccountPayload;
import bisq.core.payment.payload.SpecificBanksAccountPayload;
Expand Down Expand Up @@ -137,6 +139,8 @@ public PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
return BizumAccountPayload.fromProto(proto);
case PIX_ACCOUNT_PAYLOAD:
return PixAccountPayload.fromProto(proto);
case SATISPAY_ACCOUNT_PAYLOAD:
return SatispayAccountPayload.fromProto(proto);
case IFSC_BASED_ACCOUNT_PAYLOAD:
final protobuf.IfscBasedAccountPayload.MessageCase messageCaseIfsc = proto.getCountryBasedPaymentAccountPayload().getIfscBasedAccountPayload().getMessageCase();
switch (messageCaseIfsc) {
Expand Down Expand Up @@ -204,6 +208,8 @@ public PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
return CapitualAccountPayload.fromProto(proto);
case CEL_PAY_ACCOUNT_PAYLOAD:
return CelPayAccountPayload.fromProto(proto);
case MONESE_ACCOUNT_PAYLOAD:
return MoneseAccountPayload.fromProto(proto);
case SWIFT_ACCOUNT_PAYLOAD:
return SwiftAccountPayload.fromProto(proto);

Expand Down
Loading

0 comments on commit 2d3182c

Please sign in to comment.