add payment method CelPay

Signed-off-by: jmacxx <47253594+jmacxx@users.noreply.github.com>
This commit is contained in:
jmacxx 2021-09-23 12:14:26 -05:00
parent 852b9a67fa
commit 9e5a1c2fd4
No known key found for this signature in database
GPG Key ID: 155297BABFE94A1B
12 changed files with 334 additions and 1 deletions

View File

@ -425,6 +425,17 @@ public class CurrencyUtil {
));
}
// 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(

View File

@ -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";
}
}

View File

@ -102,6 +102,8 @@ public class PaymentAccountFactory {
return new InstantCryptoCurrencyAccount();
case PaymentMethod.CAPITUAL_ID:
return new CapitualAccount();
case PaymentMethod.CELPAY_ID:
return new CelPayAccount();
case PaymentMethod.SWIFT_ID:
return new SwiftAccount();

View File

@ -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));
}
}

View File

@ -107,6 +107,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
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
@ -157,6 +158,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
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
@ -217,6 +219,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
UPI = new PaymentMethod(UPI_ID, DAY, Coin.parseCoin("0.05")),
PAYTM = new PaymentMethod(PAYTM_ID, DAY, Coin.parseCoin("0.05")),
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

View File

@ -29,6 +29,7 @@ import bisq.core.payment.payload.CapitualAccountPayload;
import bisq.core.payment.payload.CashAppAccountPayload;
import bisq.core.payment.payload.CashByMailAccountPayload;
import bisq.core.payment.payload.CashDepositAccountPayload;
import bisq.core.payment.payload.CelPayAccountPayload;
import bisq.core.payment.payload.ChaseQuickPayAccountPayload;
import bisq.core.payment.payload.ClearXchangeAccountPayload;
import bisq.core.payment.payload.CryptoCurrencyAccountPayload;
@ -192,6 +193,8 @@ public class CoreProtoResolver implements ProtoResolver {
return InstantCryptoCurrencyPayload.fromProto(proto);
case CAPITUAL_ACCOUNT_PAYLOAD:
return CapitualAccountPayload.fromProto(proto);
case CEL_PAY_ACCOUNT_PAYLOAD:
return CelPayAccountPayload.fromProto(proto);
case SWIFT_ACCOUNT_PAYLOAD:
return SwiftAccountPayload.fromProto(proto);

View File

@ -161,7 +161,8 @@ public final class TradeStatistics3 implements ProcessOncePersistableNetworkPayl
RTGS,
IMPS,
UPI,
PAYTM
PAYTM,
CELPAY
}
@Getter

View File

@ -3580,6 +3580,40 @@ Please note some banks have different limits for their customers.
payment.upi.info.seller=If you intend to receive over Rs. 100,000 per trade you should expect the buyer to have to make multiple transfers. \n\n\
Please note some banks have different limits for their customers.
payment.celpay.info.account=Please make sure to include the email your Celsius account is registered to. \
This will ensure that when you send funds they show from the correct account and when you receive funds they will be credited to your account.\n\n\
CelPay users are limited to sending $2,500 (or other currency/crypto equivalent) in 24 hours.\n\n\
Trades above CelPay account limits will likely have to take place over more than one day, or, be cancelled.\n\n\
CelPay supports multiple stablecoins:\n\n\
USD Stablecoins; DAI, TrueUSD, USDC, ZUSD, BUSD, GUSD, PAX, USDT (ERC20)\n\
CAD Stablecoins; TrueCAD\n\
GBP Stablecoins; TrueGBP\n\
HKD Stablecoins; TrueHKD\n\
AUD Stablecoins; TrueAUD\n\n\
BTC Buyers can send any matching currency stablecoin to the BTC Seller.
payment.celpay.info.buyer=Please send payment only to the email address provided by the BTC Seller by sending a payment link.\n\n\
CelPay is limited to sending $2,500 (or other currency/crypto equivalent) in 24 hours.\n\n\
Trades above CelPay account limits will likely have to take place over more than one day, or, be cancelled.\n\n\
CelPay supports multiple stablecoins:\n\n\
USD Stablecoins; DAI, TrueUSD, USDC, ZUSD, BUSD, GUSD, PAX, USDT (ERC20)\n\
CAD Stablecoins; TrueCAD\n\
GBP Stablecoins; TrueGBP\n\
HKD Stablecoins; TrueHKD\n\
AUD Stablecoins; TrueAUD\n\n\
BTC Buyers can send any matching currency stablecoin to the BTC Seller.
payment.celpay.info.seller=BTC Sellers should expect to receive payment via a secure payment link. \
Please make sure the email payment link contains the email address provided by the BTC Buyer.\n\n\
CelPay users are limited to sending $2,500 (or other currency/crypto equivalent) in 24 hours.\n\n\
Trades above CelPay account limits will likely have to take place over more than one day, or, be cancelled.\n\n\
CelPay supports multiple stablecoins:\n\n\
USD Stablecoins; DAI, TrueUSD, USDC, ZUSD, BUSD, GUSD, PAX, USDT (ERC20)\n\
CAD Stablecoins; TrueCAD\n\
GBP Stablecoins; TrueGBP\n\
HKD Stablecoins; TrueHKD\n\
AUD Stablecoins; TrueAUD\n\n\
BTC Sellers should expect to receive any matching currency stablecoin from the BTC Buyer. It is possible for the BTC Buyer to send any matching currency stablecoin.
payment.celpay.supportedCurrenciesForReceiver=Supported currencies (please note: all the currencies below are supported stable coins within the Celcius app. Trades are for stable coins, not fiat.)
payment.usPostalMoneyOrder.info=Trading using US Postal Money Orders (USPMO) on Bisq requires that you understand the following:\n\
\n\
- BTC buyers must write the BTC Sellers name in both the Payer and the Payees fields & take a high-resolution photo of the USPMO and envelope with proof of tracking before sending.\n\
@ -3763,6 +3797,8 @@ BLOCK_CHAINS_INSTANT=Altcoins Instant
# suppress inspection "UnusedProperty"
CAPITUAL=Capitual
# suppress inspection "UnusedProperty"
CELPAY=CelPay
# suppress inspection "UnusedProperty"
SWIFT=SWIFT International Wire Transfer
# Deprecated: Cannot be deleted as it would break old trade history entries
@ -3833,6 +3869,8 @@ BLOCK_CHAINS_INSTANT_SHORT=Altcoins Instant
# suppress inspection "UnusedProperty"
CAPITUAL_SHORT=Capitual
# suppress inspection "UnusedProperty"
CELPAY_SHORT=CelPay
# suppress inspection "UnusedProperty"
SWIFT_SHORT=SWIFT
# Deprecated: Cannot be deleted as it would break old trade history entries

View File

@ -0,0 +1,118 @@
/*
* 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.desktop.components.paymentmethods;
import bisq.desktop.components.InputTextField;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.Layout;
import bisq.desktop.util.validation.EmailValidator;
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.CelPayAccount;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.CelPayAccountPayload;
import bisq.core.util.coin.CoinFormatter;
import bisq.core.util.validation.InputValidator;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextField;
import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextFieldWithCopyIcon;
import static bisq.desktop.util.FormBuilder.addTopLabelTextField;
public class CelPayForm extends PaymentMethodForm {
private final CelPayAccount account;
private InputTextField emailInputTextField;
private EmailValidator validator = new EmailValidator();
public static int addFormForBuyer(GridPane gridPane, int gridRow,
PaymentAccountPayload paymentAccountPayload) {
addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.email"),
((CelPayAccountPayload) paymentAccountPayload).getEmail());
return gridRow;
}
public CelPayForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService,
InputValidator inputValidator, GridPane gridPane,
int gridRow, CoinFormatter formatter) {
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter);
this.account = (CelPayAccount) paymentAccount;
}
@Override
public void addFormForAddAccount() {
gridRowFrom = gridRow + 1;
emailInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.email"));
emailInputTextField.setValidator(validator);
emailInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
account.setEmail(newValue.trim());
updateFromInputs();
});
addCurrenciesGrid(true);
addLimitations(false);
addAccountNameTextFieldWithAutoFillToggleButton();
}
private void addCurrenciesGrid(boolean isEditable) {
FlowPane flowPane = FormBuilder.addTopLabelFlowPane(gridPane, ++gridRow,
Res.get("payment.celpay.supportedCurrenciesForReceiver"), 20, 20).second;
if (isEditable) {
flowPane.setId("flow-pane-checkboxes-bg");
} else {
flowPane.setId("flow-pane-checkboxes-non-editable-bg");
}
CurrencyUtil.getAllCelPayCurrencies().forEach(currency ->
fillUpFlowPaneWithCurrencies(isEditable, flowPane, currency, account));
}
@Override
protected void autoFillNameTextField() {
setAccountNameWithString(emailInputTextField.getText());
}
@Override
public void addFormForDisplayAccount() {
gridRowFrom = gridRow;
addTopLabelTextField(gridPane, gridRow, Res.get("payment.account.name"),
account.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"),
Res.get(account.getPaymentMethod().getId()));
TextField field = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.email"),
account.getEmail()).second;
field.setMouseTransparent(false);
addLimitations(true);
addCurrenciesGrid(false);
}
@Override
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& account.getEmail() != null
&& validator.validate(account.getEmail()).isValid
&& account.getTradeCurrencies().size() > 0);
}
}

View File

@ -26,6 +26,7 @@ import bisq.desktop.components.paymentmethods.AustraliaPayidForm;
import bisq.desktop.components.paymentmethods.CapitualForm;
import bisq.desktop.components.paymentmethods.CashByMailForm;
import bisq.desktop.components.paymentmethods.CashDepositForm;
import bisq.desktop.components.paymentmethods.CelPayForm;
import bisq.desktop.components.paymentmethods.ChaseQuickPayForm;
import bisq.desktop.components.paymentmethods.ClearXchangeForm;
import bisq.desktop.components.paymentmethods.F2FForm;
@ -565,6 +566,8 @@ public class FiatAccountsView extends PaymentAccountsView<GridPane, FiatAccounts
return new AmazonGiftCardForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter);
case PaymentMethod.CAPITUAL_ID:
return new CapitualForm(paymentAccount, accountAgeWitnessService, capitualValidator, inputValidator, root, gridRow, formatter);
case PaymentMethod.CELPAY_ID:
return new CelPayForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter);
case PaymentMethod.SWIFT_ID:
return new SwiftForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter);
default:

View File

@ -28,6 +28,7 @@ import bisq.desktop.components.paymentmethods.AssetsForm;
import bisq.desktop.components.paymentmethods.CapitualForm;
import bisq.desktop.components.paymentmethods.CashByMailForm;
import bisq.desktop.components.paymentmethods.CashDepositForm;
import bisq.desktop.components.paymentmethods.CelPayForm;
import bisq.desktop.components.paymentmethods.ChaseQuickPayForm;
import bisq.desktop.components.paymentmethods.ClearXchangeForm;
import bisq.desktop.components.paymentmethods.F2FForm;
@ -357,6 +358,9 @@ public class BuyerStep2View extends TradeStepView {
case PaymentMethod.CAPITUAL_ID:
gridRow = CapitualForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
break;
case PaymentMethod.CELPAY_ID:
gridRow = CelPayForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
break;
case PaymentMethod.SWIFT_ID:
gridRow = SwiftForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload, trade);
break;

View File

@ -1000,6 +1000,7 @@ message PaymentAccountPayload {
PayseraAccountPayload Paysera_account_payload = 34;
PaxumAccountPayload Paxum_account_payload = 35;
SwiftAccountPayload swift_account_payload = 36;
CelPayAccountPayload cel_pay_account_payload = 37;
}
map<string, string> exclude_from_json_data = 15;
}
@ -1264,6 +1265,10 @@ message CapitualAccountPayload {
string account_nr = 1;
}
message CelPayAccountPayload {
string email = 1;
}
message SwiftAccountPayload {
string beneficiary_name = 1;
string beneficiary_account_nr = 2;