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 new payment method: Australian PayID #4742

Closed
wants to merge 3 commits into from
Closed
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
53 changes: 53 additions & 0 deletions core/src/main/java/bisq/core/payment/AustraliaPayid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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.locale.FiatCurrency;
import bisq.core.payment.payload.AustraliaPayidPayload;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;

public final class AustraliaPayid extends PaymentAccount {
public AustraliaPayid() {
super(PaymentMethod.AUSTRALIA_PAYID);
setSingleTradeCurrency(new FiatCurrency("AUD"));
}

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

public String getPayid() {
return ((AustraliaPayidPayload) paymentAccountPayload).getPayid();
}

public void setPayid(String payid) {
if (payid == null) payid = "";
((AustraliaPayidPayload) paymentAccountPayload).setPayid(payid);
}

public String getBankAccountName() {
return ((AustraliaPayidPayload) paymentAccountPayload).getBankAccountName();
}

public void setBankAccountName(String bankAccountName) {
if (bankAccountName == null) bankAccountName = "";
((AustraliaPayidPayload) paymentAccountPayload).setBankAccountName(bankAccountName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) {
return new SpecificBanksAccount();
case PaymentMethod.JAPAN_BANK_ID:
return new JapanBankAccount();
case PaymentMethod.AUSTRALIA_PAYID_ID:
return new AustraliaPayid();
case PaymentMethod.ALI_PAY_ID:
return new AliPayAccount();
case PaymentMethod.WECHAT_PAY_ID:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* 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 bisq.common.util.CollectionUtils;

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 AustraliaPayidPayload extends PaymentAccountPayload {
private String payid = "";
private String bankAccountName = "";

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


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

private AustraliaPayidPayload(String paymentMethod,
String id,
String payid,
String bankAccountName,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
maxTradePeriod,
excludeFromJsonDataMap);

this.payid = payid;
this.bankAccountName = bankAccountName;
}

@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setAustraliaPayidPayload(
protobuf.AustraliaPayidPayload.newBuilder()
.setPayid(payid)
.setBankAccountName(bankAccountName)
).build();
}

public static AustraliaPayidPayload fromProto(protobuf.PaymentAccountPayload proto) {
protobuf.AustraliaPayidPayload AustraliaPayidPayload = proto.getAustraliaPayidPayload();
return new AustraliaPayidPayload(proto.getPaymentMethodId(),
proto.getId(),
AustraliaPayidPayload.getPayid(),
AustraliaPayidPayload.getBankAccountName(),
proto.getMaxTradePeriod(),
CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap()));
}


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

@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + getPaymentDetailsForTradePopup().replace("\n", ", ");
}

@Override
public String getPaymentDetailsForTradePopup() {
return
Res.get("payment.australia.payid") + ": " + payid + "\n" +
Res.get("payment.account.owner") + ": " + bankAccountName;
}


@Override
public byte[] getAgeWitnessInputData() {
String all = this.payid + this.bankAccountName;
return super.getAgeWitnessInputData(all.getBytes(StandardCharsets.UTF_8));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
public static final String FASTER_PAYMENTS_ID = "FASTER_PAYMENTS";
public static final String NATIONAL_BANK_ID = "NATIONAL_BANK";
public static final String JAPAN_BANK_ID = "JAPAN_BANK";
public static final String AUSTRALIA_PAYID_ID = "AUSTRALIA_PAYID";
public static final String SAME_BANK_ID = "SAME_BANK";
public static final String SPECIFIC_BANKS_ID = "SPECIFIC_BANKS";
public static final String SWISH_ID = "SWISH";
Expand Down Expand Up @@ -112,6 +113,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
public static PaymentMethod FASTER_PAYMENTS;
public static PaymentMethod NATIONAL_BANK;
public static PaymentMethod JAPAN_BANK;
public static PaymentMethod AUSTRALIA_PAYID;
public static PaymentMethod SAME_BANK;
public static PaymentMethod SPECIFIC_BANKS;
public static PaymentMethod SWISH;
Expand Down Expand Up @@ -185,6 +187,9 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
// Japan
JAPAN_BANK = new PaymentMethod(JAPAN_BANK_ID, DAY, DEFAULT_TRADE_LIMIT_LOW_RISK),

// Australia
AUSTRALIA_PAYID = new PaymentMethod(AUSTRALIA_PAYID_ID, DAY, DEFAULT_TRADE_LIMIT_LOW_RISK),

// China
ALI_PAY = new PaymentMethod(ALI_PAY_ID, DAY, DEFAULT_TRADE_LIMIT_LOW_RISK),
WECHAT_PAY = new PaymentMethod(WECHAT_PAY_ID, DAY, DEFAULT_TRADE_LIMIT_LOW_RISK),
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/bisq/core/proto/CoreProtoResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import bisq.core.dao.governance.proposal.storage.appendonly.ProposalPayload;
import bisq.core.payment.payload.AdvancedCashAccountPayload;
import bisq.core.payment.payload.AliPayAccountPayload;
import bisq.core.payment.payload.AustraliaPayidPayload;
import bisq.core.payment.payload.CashAppAccountPayload;
import bisq.core.payment.payload.CashDepositAccountPayload;
import bisq.core.payment.payload.ChaseQuickPayAccountPayload;
Expand Down Expand Up @@ -124,6 +125,8 @@ public PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
return InteracETransferAccountPayload.fromProto(proto);
case JAPAN_BANK_ACCOUNT_PAYLOAD:
return JapanBankAccountPayload.fromProto(proto);
case AUSTRALIA_PAYID_PAYLOAD:
return AustraliaPayidPayload.fromProto(proto);
case UPHOLD_ACCOUNT_PAYLOAD:
return UpholdAccountPayload.fromProto(proto);
case MONEY_BEAM_ACCOUNT_PAYLOAD:
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3331,6 +3331,11 @@ payment.japan.bank=Bank
payment.japan.branch=Branch
payment.japan.account=Account
payment.japan.recipient=Name
payment.australia.payid=PayID
payment.payid=PayID linked to financial institution. Like email address or mobile phone.
payment.payid.info=A PayID like a phone number, email address or an Australian Business Number (ABN), that you can securely link to your \
bank, credit union or building society account. You need to have already created a PayID with your Australian financial institution. \
Both sending and receiving financial institutions must support PayID. For more information please check https://payid.com.au/faqs/

# We use constants from the code so we do not use our normal naming convention
# dynamic values are not recognized by IntelliJ
Expand All @@ -3345,6 +3350,7 @@ MONEY_GRAM=MoneyGram
WESTERN_UNION=Western Union
F2F=Face to face (in person)
JAPAN_BANK=Japan Bank Furikomi
AUSTRALIA_PAYID=Australian PayID

# suppress inspection "UnusedProperty"
NATIONAL_BANK_SHORT=National banks
Expand All @@ -3364,6 +3370,8 @@ WESTERN_UNION_SHORT=Western Union
F2F_SHORT=F2F
# suppress inspection "UnusedProperty"
JAPAN_BANK_SHORT=Japan Furikomi
# suppress inspection "UnusedProperty"
AUSTRALIA_PAYID_SHORT=PayID

# Do not translate brand names
# suppress inspection "UnusedProperty"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* 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.AustraliaPayidValidator;

import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.payment.AustraliaPayid;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.AustraliaPayidPayload;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.util.coin.CoinFormatter;
import bisq.core.util.validation.InputValidator;

import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;

import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextField;
import static bisq.desktop.util.FormBuilder.addTopLabelTextField;

public class AustraliaPayidForm extends PaymentMethodForm {
private final AustraliaPayid australiaPayid;
private final AustraliaPayidValidator australiaPayidValidator;
private InputTextField mobileNrInputTextField;

public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) {
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"),
((AustraliaPayidPayload) paymentAccountPayload).getBankAccountName());
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.payid"),
((AustraliaPayidPayload) paymentAccountPayload).getPayid());
return gridRow;
}

public AustraliaPayidForm(PaymentAccount paymentAccount,
AccountAgeWitnessService accountAgeWitnessService,
AustraliaPayidValidator australiaPayidValidator,
InputValidator inputValidator,
GridPane gridPane,
int gridRow,
CoinFormatter formatter) {
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter);
this.australiaPayid = (AustraliaPayid) paymentAccount;
this.australiaPayidValidator = australiaPayidValidator;
}

@Override
public void addFormForAddAccount() {
gridRowFrom = gridRow + 1;

InputTextField holderNameInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow,
Res.get("payment.account.owner"));
holderNameInputTextField.setValidator(inputValidator);
holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
australiaPayid.setBankAccountName(newValue);
updateFromInputs();
});

mobileNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.payid"));
mobileNrInputTextField.setValidator(australiaPayidValidator);
mobileNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
australiaPayid.setPayid(newValue);
updateFromInputs();
});

TradeCurrency singleTradeCurrency = australiaPayid.getSingleTradeCurrency();
String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "null";
addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);
addLimitations(false);
addAccountNameTextFieldWithAutoFillToggleButton();
}

@Override
protected void autoFillNameTextField() {
setAccountNameWithString(mobileNrInputTextField.getText());
}

@Override
public void addFormForDisplayAccount() {
gridRowFrom = gridRow;
addTopLabelTextField(gridPane, gridRow, Res.get("payment.account.name"),
australiaPayid.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"),
Res.get(australiaPayid.getPaymentMethod().getId()));
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.payid"),
australiaPayid.getPayid());
TextField field = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"),
australiaPayid.getBankAccountName()).second;
field.setMouseTransparent(false);
TradeCurrency singleTradeCurrency = australiaPayid.getSingleTradeCurrency();
String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "null";
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);
addLimitations(true);
}

@Override
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& australiaPayidValidator.validate(australiaPayid.getPayid()).isValid
&& inputValidator.validate(australiaPayid.getBankAccountName()).isValid
&& australiaPayid.getTradeCurrencies().size() > 0);
}
}
Loading