Skip to content

Commit

Permalink
Add new payment method: Australian PayID
Browse files Browse the repository at this point in the history
  • Loading branch information
mercurytoxic committed Mar 19, 2020
1 parent 89cfb34 commit faf7f6d
Show file tree
Hide file tree
Showing 11 changed files with 447 additions and 0 deletions.
6 changes: 6 additions & 0 deletions common/src/main/proto/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ message PaymentAccountPayload {
AdvancedCashAccountPayload advanced_cash_account_payload = 26;
InstantCryptoCurrencyAccountPayload instant_crypto_currency_account_payload = 27;
JapanBankAccountPayload japan_bank_account_payload = 28;
AustraliaPayIDPayload australia_payid_payload = 29;
}
map<string, string> exclude_from_json_data = 15;
}
Expand Down Expand Up @@ -968,6 +969,11 @@ message JapanBankAccountPayload {
string bank_account_number = 7;
}

message AustraliaPayIDPayload {
string bank_account_name = 1;
string payid = 2;
}

message SpecificBanksAccountPayload {
repeated string accepted_banks = 1;
}
Expand Down
69 changes: 69 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,69 @@
/*
* 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.AustraliaPayIDPayload;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.payment.payload.AustraliaPayIDPayload;

import org.jetbrains.annotations.NotNull;

import lombok.Getter;
import lombok.Setter;

import bisq.core.locale.Country;
import bisq.core.locale.FiatCurrency;
import bisq.core.payment.payload.AustraliaPayIDPayload;

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

// payid
public String getPayID()
{
return ((AustraliaPayIDPayload) paymentAccountPayload).getPayid();
}
public void setPayID(String payid)
{
if (payid == null) payid = "";
((AustraliaPayIDPayload) paymentAccountPayload).setPayid(payid);
}

// bankAccount name
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,116 @@
/*
* 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.Charset;

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 {
// payid
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(Charset.forName("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 @@ -111,6 +112,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 @@ -182,6 +184,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 @@ -34,6 +34,7 @@
import bisq.core.payment.payload.InstantCryptoCurrencyPayload;
import bisq.core.payment.payload.InteracETransferAccountPayload;
import bisq.core.payment.payload.JapanBankAccountPayload;;
import bisq.core.payment.payload.AustraliaPayIDPayload;;
import bisq.core.payment.payload.MoneyBeamAccountPayload;
import bisq.core.payment.payload.MoneyGramAccountPayload;
import bisq.core.payment.payload.NationalBankAccountPayload;
Expand Down Expand Up @@ -122,6 +123,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 @@ -3100,6 +3100,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 @@ -3114,6 +3119,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 @@ -3133,6 +3139,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
Loading

0 comments on commit faf7f6d

Please sign in to comment.