Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Nequi payment method #5724

Merged
merged 2 commits into from Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/src/main/java/bisq/core/locale/CurrencyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,17 @@ public static List<TradeCurrency> getAllCapitualCurrencies() {
));
}

// https://github.com/bisq-network/growth/issues/231
public static List<TradeCurrency> getAllCelPayCurrencies() {
return new ArrayList<>(Arrays.asList(
new FiatCurrency("AUD"),
new FiatCurrency("CAD"),
new FiatCurrency("GBP"),
new FiatCurrency("HKD"),
new FiatCurrency("USD")
));
}

// 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/CelPayAccount.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.CelPayAccountPayload;

import lombok.EqualsAndHashCode;

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

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

public void setEmail(String accountId) {
((CelPayAccountPayload) paymentAccountPayload).setEmail(accountId);
}

public String getEmail() {
return ((CelPayAccountPayload) paymentAccountPayload).getEmail();
}

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

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

public String getMessageForAccountCreation() {
return "payment.celpay.info.account";
}
}
56 changes: 56 additions & 0 deletions core/src/main/java/bisq/core/payment/NequiAccount.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.NequiAccountPayload;

import lombok.EqualsAndHashCode;

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

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

public void setMobileNr(String mobileNr) {
((NequiAccountPayload) paymentAccountPayload).setMobileNr(mobileNr);
}

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

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

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

public String getMessageForAccountCreation() {
return "payment.nequi.info.account";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,16 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) {
return new UpiAccount();
case PaymentMethod.PAYTM_ID:
return new PaytmAccount();
case PaymentMethod.NEQUI_ID:
return new NequiAccount();
case PaymentMethod.AMAZON_GIFT_CARD_ID:
return new AmazonGiftCardAccount();
case PaymentMethod.BLOCK_CHAINS_INSTANT_ID:
return new InstantCryptoCurrencyAccount();
case PaymentMethod.CAPITUAL_ID:
return new CapitualAccount();
case PaymentMethod.CELPAY_ID:
return new CelPayAccount();
case PaymentMethod.SWIFT_ID:
return new SwiftAccount();

Expand Down
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 CelPayAccountPayload extends PaymentAccountPayload {
private String email = "";

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

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

this.email = email;
}

@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setCelPayAccountPayload(protobuf.CelPayAccountPayload.newBuilder().setEmail(email))
.build();
}

public static CelPayAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
return new CelPayAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getCelPayAccountPayload().getEmail(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

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

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

@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(email.getBytes(StandardCharsets.UTF_8));
}
}
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 NequiAccountPayload extends CountryBasedPaymentAccountPayload {
private String mobileNr = "";

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

private NequiAccountPayload(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.NequiAccountPayload.Builder builder = protobuf.NequiAccountPayload.newBuilder()
.setMobileNr(mobileNr);
final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setNequiAccountPayload(builder);
return getPaymentAccountPayloadBuilder()
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayload)
.build();
}

public static NequiAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
protobuf.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload();
protobuf.NequiAccountPayload paytmAccountPayloadPB = countryBasedPaymentAccountPayload.getNequiAccountPayload();
return new NequiAccountPayload(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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
public static final String IMPS_ID = "IMPS";
public static final String UPI_ID = "UPI";
public static final String PAYTM_ID = "PAYTM";
public static final String NEQUI_ID = "NEQUI";
public static final String AMAZON_GIFT_CARD_ID = "AMAZON_GIFT_CARD";
public static final String BLOCK_CHAINS_INSTANT_ID = "BLOCK_CHAINS_INSTANT";
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 SWIFT_ID = "SWIFT";

// Cannot be deleted as it would break old trade history entries
Expand Down Expand Up @@ -153,10 +155,12 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
public static PaymentMethod IMPS;
public static PaymentMethod UPI;
public static PaymentMethod PAYTM;
public static PaymentMethod NEQUI;
public static PaymentMethod AMAZON_GIFT_CARD;
public static PaymentMethod BLOCK_CHAINS_INSTANT;
public static PaymentMethod CASH_BY_MAIL;
public static PaymentMethod CAPITUAL;
public static PaymentMethod CELPAY;
public static PaymentMethod SWIFT;

// Cannot be deleted as it would break old trade history entries
Expand Down Expand Up @@ -216,7 +220,9 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
IMPS = new PaymentMethod(IMPS_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
UPI = new PaymentMethod(UPI_ID, DAY, Coin.parseCoin("0.05")),
PAYTM = new PaymentMethod(PAYTM_ID, DAY, Coin.parseCoin("0.05")),
NEQUI = new PaymentMethod(NEQUI_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),
SWIFT = new PaymentMethod(SWIFT_ID, 7 * DAY, DEFAULT_TRADE_LIMIT_MID_RISK),

// Japan
Expand Down
Loading