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 Payment Methods: Paysera and Paxum #5673

Merged
merged 1 commit into from Aug 26, 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
68 changes: 68 additions & 0 deletions core/src/main/java/bisq/core/locale/CurrencyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,74 @@ public static List<TradeCurrency> getAllTransferwiseCurrencies() {
return currencies;
}

// https://github.com/bisq-network/growth/issues/233
public static List<TradeCurrency> getAllPayseraCurrencies() {
ArrayList<TradeCurrency> currencies = new ArrayList<>(Arrays.asList(
new FiatCurrency("AUD"),
new FiatCurrency("BGN"),
new FiatCurrency("BYN"),
new FiatCurrency("CAD"),
new FiatCurrency("CHF"),
new FiatCurrency("CNY"),
new FiatCurrency("CZK"),
new FiatCurrency("DKK"),
new FiatCurrency("EUR"),
new FiatCurrency("GBP"),
new FiatCurrency("GEL"),
new FiatCurrency("HKD"),
new FiatCurrency("HRK"),
new FiatCurrency("HUF"),
new FiatCurrency("ILS"),
new FiatCurrency("INR"),
new FiatCurrency("JPY"),
new FiatCurrency("KZT"),
new FiatCurrency("MXN"),
new FiatCurrency("NOK"),
new FiatCurrency("NZD"),
new FiatCurrency("PHP"),
new FiatCurrency("PLN"),
new FiatCurrency("RON"),
new FiatCurrency("RSD"),
new FiatCurrency("RUB"),
new FiatCurrency("SEK"),
new FiatCurrency("SGD"),
new FiatCurrency("THB"),
new FiatCurrency("TRY"),
new FiatCurrency("USD"),
new FiatCurrency("ZAR")
));

currencies.sort(Comparator.comparing(TradeCurrency::getCode));
return currencies;
}

// https://github.com/bisq-network/growth/issues/235
public static List<TradeCurrency> getAllPaxumCurrencies() {
ArrayList<TradeCurrency> currencies = new ArrayList<>(Arrays.asList(
new FiatCurrency("USD"),
new FiatCurrency("CAD"),
new FiatCurrency("EUR"),
new FiatCurrency("DKK"),
new FiatCurrency("CZK"),
new FiatCurrency("AUD"),
new FiatCurrency("ZAR"),
new FiatCurrency("THB"),
new FiatCurrency("CHF"),
new FiatCurrency("SEK"),
new FiatCurrency("RON"),
new FiatCurrency("PLN"),
new FiatCurrency("NZD"),
new FiatCurrency("NOK"),
new FiatCurrency("INR"),
new FiatCurrency("IDR"),
new FiatCurrency("HUF"),
new FiatCurrency("GBP")
));

currencies.sort(Comparator.comparing(TradeCurrency::getCode));
return currencies;
}

public static List<TradeCurrency> getAllAmazonGiftCardCurrencies() {
List<TradeCurrency> currencies = new ArrayList<>(Arrays.asList(
new FiatCurrency("AUD"),
Expand Down
44 changes: 44 additions & 0 deletions core/src/main/java/bisq/core/payment/PaxumAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.PaxumAccountPayload;

import lombok.EqualsAndHashCode;

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

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

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

public String getEmail() {
return ((PaxumAccountPayload) paymentAccountPayload).getEmail();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) {
return new AdvancedCashAccount();
case PaymentMethod.TRANSFERWISE_ID:
return new TransferwiseAccount();
case PaymentMethod.PAYSERA_ID:
return new PayseraAccount();
case PaymentMethod.PAXUM_ID:
return new PaxumAccount();
case PaymentMethod.AMAZON_GIFT_CARD_ID:
return new AmazonGiftCardAccount();
case PaymentMethod.BLOCK_CHAINS_INSTANT_ID:
Expand Down
44 changes: 44 additions & 0 deletions core/src/main/java/bisq/core/payment/PayseraAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.PayseraAccountPayload;

import lombok.EqualsAndHashCode;

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

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

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

public String getEmail() {
return ((PayseraAccountPayload) paymentAccountPayload).getEmail();
}
}
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 PaxumAccountPayload extends PaymentAccountPayload {
private String email = "";

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


///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////

private PaxumAccountPayload(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()
.setPaxumAccountPayload(protobuf.PaxumAccountPayload.newBuilder().setEmail(email))
.build();
}

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


///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////

@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
Expand Up @@ -96,6 +96,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
public static final String PROMPT_PAY_ID = "PROMPT_PAY";
public static final String ADVANCED_CASH_ID = "ADVANCED_CASH";
public static final String TRANSFERWISE_ID = "TRANSFERWISE";
public static final String PAYSERA_ID = "PAYSERA";
public static final String PAXUM_ID = "PAXUM";
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";
Expand Down Expand Up @@ -138,6 +140,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
public static PaymentMethod PROMPT_PAY;
public static PaymentMethod ADVANCED_CASH;
public static PaymentMethod TRANSFERWISE;
public static PaymentMethod PAYSERA;
public static PaymentMethod PAXUM;
public static PaymentMethod AMAZON_GIFT_CARD;
public static PaymentMethod BLOCK_CHAINS_INSTANT;
public static PaymentMethod CASH_BY_MAIL;
Expand Down Expand Up @@ -193,6 +197,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
PERFECT_MONEY = new PaymentMethod(PERFECT_MONEY_ID, DAY, DEFAULT_TRADE_LIMIT_LOW_RISK),
ADVANCED_CASH = new PaymentMethod(ADVANCED_CASH_ID, DAY, DEFAULT_TRADE_LIMIT_VERY_LOW_RISK),
TRANSFERWISE = new PaymentMethod(TRANSFERWISE_ID, 4 * DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
PAYSERA = new PaymentMethod(PAYSERA_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
PAXUM = new PaymentMethod(PAXUM_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
CAPITUAL = new PaymentMethod(CAPITUAL_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),


Expand Down
Loading