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 Tikkie and TransferWise-USD #5821

Merged
merged 1 commit into from Nov 11, 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
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) {
return new AdvancedCashAccount();
case PaymentMethod.TRANSFERWISE_ID:
return new TransferwiseAccount();
case PaymentMethod.TRANSFERWISE_USD_ID:
return new TransferwiseUsdAccount();
case PaymentMethod.PAYSERA_ID:
return new PayseraAccount();
case PaymentMethod.PAXUM_ID:
Expand Down Expand Up @@ -114,6 +116,8 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) {
return new MoneseAccount();
case PaymentMethod.SATISPAY_ID:
return new SatispayAccount();
case PaymentMethod.TIKKIE_ID:
return new TikkieAccount();
case PaymentMethod.VERSE_ID:
return new VerseAccount();
case PaymentMethod.STRIKE_ID:
Expand Down
56 changes: 56 additions & 0 deletions core/src/main/java/bisq/core/payment/TikkieAccount.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.TikkieAccountPayload;

import lombok.EqualsAndHashCode;

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

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

public void setIban(String iban) {
((TikkieAccountPayload) paymentAccountPayload).setIban(iban);
}

public String getIban() {
return ((TikkieAccountPayload) paymentAccountPayload).getIban();
}

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

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

public String getMessageForAccountCreation() {
return "payment.tikkie.info.account";
}
}
72 changes: 72 additions & 0 deletions core/src/main/java/bisq/core/payment/TransferwiseUsdAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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.TransferwiseUsdAccountPayload;

import lombok.EqualsAndHashCode;

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

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

public void setEmail(String email) {
((TransferwiseUsdAccountPayload) paymentAccountPayload).setEmail(email);
}

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

public void setHolderName(String accountId) {
((TransferwiseUsdAccountPayload) paymentAccountPayload).setHolderName(accountId);
}

public String getHolderName() {
return ((TransferwiseUsdAccountPayload) paymentAccountPayload).getHolderName();
}

public void setBeneficiaryAddress(String address) {
((TransferwiseUsdAccountPayload) paymentAccountPayload).setBeneficiaryAddress(address);
}

public String getBeneficiaryAddress() {
return ((TransferwiseUsdAccountPayload) paymentAccountPayload).getBeneficiaryAddress();
}

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

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

public String getMessageForAccountCreation() {
return "payment.transferwiseUsd.info.account";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ 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 TRANSFERWISE_USD_ID = "TRANSFERWISE_USD";
public static final String PAYSERA_ID = "PAYSERA";
public static final String PAXUM_ID = "PAXUM";
public static final String NEFT_ID = "NEFT";
Expand All @@ -113,6 +114,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
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 TIKKIE_ID = "TIKKIE";
public static final String VERSE_ID = "VERSE";
public static final String STRIKE_ID = "STRIKE";
public static final String SWIFT_ID = "SWIFT";
Expand Down Expand Up @@ -155,6 +157,7 @@ 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 TRANSFERWISE_USD;
public static PaymentMethod PAYSERA;
public static PaymentMethod PAXUM;
public static PaymentMethod NEFT;
Expand All @@ -172,6 +175,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
public static PaymentMethod CELPAY;
public static PaymentMethod MONESE;
public static PaymentMethod SATISPAY;
public static PaymentMethod TIKKIE;
public static PaymentMethod VERSE;
public static PaymentMethod STRIKE;
public static PaymentMethod SWIFT;
Expand Down Expand Up @@ -227,6 +231,7 @@ 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),
TRANSFERWISE_USD = new PaymentMethod(TRANSFERWISE_USD_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),
NEFT = new PaymentMethod(NEFT_ID, DAY, Coin.parseCoin("0.02")),
Expand All @@ -241,6 +246,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
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),
TIKKIE = new PaymentMethod(TIKKIE_ID, DAY, Coin.parseCoin("0.05")),
VERSE = new PaymentMethod(VERSE_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
STRIKE = new PaymentMethod(STRIKE_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
SWIFT = new PaymentMethod(SWIFT_ID, 7 * DAY, DEFAULT_TRADE_LIMIT_MID_RISK),
Expand Down Expand Up @@ -363,7 +369,7 @@ public Coin getMaxTradeLimitAsCoin(String currencyCode) {
if (currencyCode.equals("SF"))
return Coin.parseCoin("4");
// payment methods which define their own trade limits
if (id.equals(NEFT_ID) || id.equals(UPI_ID) || id.equals(PAYTM_ID) || id.equals(BIZUM_ID)) {
if (id.equals(NEFT_ID) || id.equals(UPI_ID) || id.equals(PAYTM_ID) || id.equals(BIZUM_ID) || id.equals(TIKKIE_ID)) {
return Coin.valueOf(maxTradeLimit);
}

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 TikkieAccountPayload extends CountryBasedPaymentAccountPayload {
private String iban = "";

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

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

this.iban = iban;
}

@Override
public Message toProtoMessage() {
protobuf.TikkieAccountPayload.Builder builder = protobuf.TikkieAccountPayload.newBuilder()
.setIban(iban);
final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setTikkieAccountPayload(builder);
return getPaymentAccountPayloadBuilder()
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayload)
.build();
}

public static TikkieAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
protobuf.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload();
protobuf.TikkieAccountPayload accountPayloadPB = countryBasedPaymentAccountPayload.getTikkieAccountPayload();
return new TikkieAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
accountPayloadPB.getIban(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

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

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

@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(iban.getBytes(StandardCharsets.UTF_8));
}
}
Loading