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: Japan Bank Transfer #3225

Merged
merged 2 commits into from
Sep 13, 2019
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
11 changes: 11 additions & 0 deletions common/src/main/proto/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ message PaymentAccountPayload {
PromptPayAccountPayload prompt_pay_account_payload = 25;
AdvancedCashAccountPayload advanced_cash_account_payload = 26;
InstantCryptoCurrencyAccountPayload instant_crypto_currency_account_payload = 27;
JapanBankAccountPayload japan_bank_account_payload = 28;
}
map<string, string> exclude_from_json_data = 15;
}
Expand Down Expand Up @@ -862,6 +863,16 @@ message NationalBankAccountPayload {
message SameBankAccountPayload {
}

message JapanBankAccountPayload {
string bank_name = 1;
string bank_code = 2;
string bank_branch_name = 3;
string bank_branch_code = 4;
string bank_account_type = 5;
string bank_account_name = 6;
string bank_account_number = 7;
}

message SpecificBanksAccountPayload {
repeated string accepted_banks = 1;
}
Expand Down
124 changes: 124 additions & 0 deletions core/src/main/java/bisq/core/payment/JapanBankAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* 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.JapanBankAccountPayload;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.payment.payload.JapanBankAccountPayload;

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.JapanBankAccountPayload;

public final class JapanBankAccount extends PaymentAccount
{
public JapanBankAccount()
{
super(PaymentMethod.JAPAN_BANK);
setSingleTradeCurrency(new FiatCurrency("JPY"));
}

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

// bank code
public String getBankCode()
{
return ((JapanBankAccountPayload) paymentAccountPayload).getBankCode();
}
public void setBankCode(String bankCode)
{
if (bankCode == null) bankCode = "";
((JapanBankAccountPayload) paymentAccountPayload).setBankCode(bankCode);
}

// bank name
public String getBankName()
{
return ((JapanBankAccountPayload) paymentAccountPayload).getBankName();
}
public void setBankName(String bankName)
{
if (bankName == null) bankName = "";
((JapanBankAccountPayload) paymentAccountPayload).setBankName(bankName);
}

// branch code
public String getBankBranchCode()
{
return ((JapanBankAccountPayload) paymentAccountPayload).getBankBranchCode();
}
public void setBankBranchCode(String bankBranchCode)
{
if (bankBranchCode == null) bankBranchCode = "";
((JapanBankAccountPayload) paymentAccountPayload).setBankBranchCode(bankBranchCode);
}

// branch name
public String getBankBranchName()
{
return ((JapanBankAccountPayload) paymentAccountPayload).getBankBranchName();
}
public void setBankBranchName(String bankBranchName)
{
if (bankBranchName == null) bankBranchName = "";
((JapanBankAccountPayload) paymentAccountPayload).setBankBranchName(bankBranchName);
}

// account type
public String getBankAccountType()
{
return ((JapanBankAccountPayload) paymentAccountPayload).getBankAccountType();
}
public void setBankAccountType(String bankAccountType)
{
if (bankAccountType == null) bankAccountType = "";
((JapanBankAccountPayload) paymentAccountPayload).setBankAccountType(bankAccountType);
}

// account number
public String getBankAccountNumber()
{
return ((JapanBankAccountPayload) paymentAccountPayload).getBankAccountNumber();
}
public void setBankAccountNumber(String bankAccountNumber)
{
if (bankAccountNumber == null) bankAccountNumber = "";
((JapanBankAccountPayload) paymentAccountPayload).setBankAccountNumber(bankAccountNumber);
}

// account name
public String getBankAccountName()
{
return ((JapanBankAccountPayload) paymentAccountPayload).getBankAccountName();
}
public void setBankAccountName(String bankAccountName)
{
if (bankAccountName == null) bankAccountName = "";
((JapanBankAccountPayload) paymentAccountPayload).setBankAccountName(bankAccountName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) {
return new SameBankAccount();
case PaymentMethod.SPECIFIC_BANKS_ID:
return new SpecificBanksAccount();
case PaymentMethod.JAPAN_BANK_ID:
return new JapanBankAccount();
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,147 @@
/*
* 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 org.springframework.util.CollectionUtils;

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;

// Cannot be deleted as it would break old trade history entries
// Removed due too high chargeback risk
@Deprecated
@EqualsAndHashCode(callSuper = true)
@ToString
@Setter
@Getter
@Slf4j
public final class JapanBankAccountPayload extends PaymentAccountPayload {
// bank
private String bankName = "";
private String bankCode = "";
// branch
private String bankBranchName = "";
private String bankBranchCode = "";
// account
private String bankAccountType = "";
private String bankAccountName = "";
private String bankAccountNumber = "";

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


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

private JapanBankAccountPayload(String paymentMethod,
String id,
String bankName,
String bankCode,
String bankBranchName,
String bankBranchCode,
String bankAccountType,
String bankAccountName,
String bankAccountNumber,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
maxTradePeriod,
excludeFromJsonDataMap);

this.bankName = bankName;
this.bankCode = bankCode;
this.bankBranchName = bankBranchName;
this.bankBranchCode = bankBranchCode;
this.bankAccountType = bankAccountType;
this.bankAccountName = bankAccountName;
this.bankAccountNumber = bankAccountNumber;
}

@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setJapanBankAccountPayload(
protobuf.JapanBankAccountPayload.newBuilder()
.setBankName(bankName)
.setBankCode(bankCode)
.setBankBranchName(bankBranchName)
.setBankBranchCode(bankBranchCode)
.setBankAccountType(bankAccountType)
.setBankAccountName(bankAccountName)
.setBankAccountNumber(bankAccountNumber)
).build();
}

public static JapanBankAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
protobuf.JapanBankAccountPayload japanBankAccountPayload = proto.getJapanBankAccountPayload();
return new JapanBankAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
japanBankAccountPayload.getBankName(),
japanBankAccountPayload.getBankCode(),
japanBankAccountPayload.getBankBranchName(),
japanBankAccountPayload.getBankBranchCode(),
japanBankAccountPayload.getBankAccountType(),
japanBankAccountPayload.getBankAccountName(),
japanBankAccountPayload.getBankAccountNumber(),
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 bankName + "(" + bankCode + ")\n" +
bankBranchName + "(" + bankBranchCode + ")\n" +
bankAccountType + ": " + bankAccountNumber + "\n" +
bankAccountName + "\n";
}


@Override
public byte[] getAgeWitnessInputData() {
String all = this.bankName + this.bankBranchName + this.bankAccountType + this.bankAccountNumber + this.bankAccountName;
return super.getAgeWitnessInputData(all.getBytes(Charset.forName("UTF-8")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable {
public static final String SEPA_INSTANT_ID = "SEPA_INSTANT";
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 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 @@ -108,6 +109,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable {
public static PaymentMethod SEPA_INSTANT;
public static PaymentMethod FASTER_PAYMENTS;
public static PaymentMethod NATIONAL_BANK;
public static PaymentMethod JAPAN_BANK;
public static PaymentMethod SAME_BANK;
public static PaymentMethod SPECIFIC_BANKS;
public static PaymentMethod SWISH;
Expand Down Expand Up @@ -176,6 +178,9 @@ public final class PaymentMethod implements PersistablePayload, Comparable {
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),

// Japan
JAPAN_BANK = new PaymentMethod(JAPAN_BANK_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 @@ -33,6 +33,7 @@
import bisq.core.payment.payload.HalCashAccountPayload;
import bisq.core.payment.payload.InstantCryptoCurrencyPayload;
import bisq.core.payment.payload.InteracETransferAccountPayload;
import bisq.core.payment.payload.JapanBankAccountPayload;;
import bisq.core.payment.payload.MoneyBeamAccountPayload;
import bisq.core.payment.payload.MoneyGramAccountPayload;
import bisq.core.payment.payload.NationalBankAccountPayload;
Expand Down Expand Up @@ -113,6 +114,8 @@ public PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
return FasterPaymentsAccountPayload.fromProto(proto);
case INTERAC_E_TRANSFER_ACCOUNT_PAYLOAD:
return InteracETransferAccountPayload.fromProto(proto);
case JAPAN_BANK_ACCOUNT_PAYLOAD:
return JapanBankAccountPayload.fromProto(proto);
case UPHOLD_ACCOUNT_PAYLOAD:
return UpholdAccountPayload.fromProto(proto);
case MONEY_BEAM_ACCOUNT_PAYLOAD:
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2804,7 +2804,6 @@ payment.f2f.info.openURL=Open web page
payment.f2f.offerbook.tooltip.countryAndCity=Country and city: {0} / {1}
payment.f2f.offerbook.tooltip.extra=Additional information: {0}


# We use constants from the code so we do not use our normal naming convention
# dynamic values are not recognized by IntelliJ

Expand All @@ -2817,6 +2816,7 @@ CASH_DEPOSIT=Cash Deposit
MONEY_GRAM=MoneyGram
WESTERN_UNION=Western Union
F2F=Face to face (in person)
JAPAN_BANK=Japan Zengin Furikomi

# suppress inspection "UnusedProperty"
NATIONAL_BANK_SHORT=National banks
Expand All @@ -2834,6 +2834,8 @@ MONEY_GRAM_SHORT=MoneyGram
WESTERN_UNION_SHORT=Western Union
# suppress inspection "UnusedProperty"
F2F_SHORT=F2F
# suppress inspection "UnusedProperty"
JAPAN_BANK_SHORT=Japan Furikomi

# Do not translate brand names
# suppress inspection "UnusedProperty"
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/i18n/displayStrings_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2317,6 +2317,7 @@ CASH_DEPOSIT=現金入金
MONEY_GRAM=MoneyGram
WESTERN_UNION=Western Union
F2F=対面(直接)
JAPAN_BANK=日本全銀振込

# suppress inspection "UnusedProperty"
NATIONAL_BANK_SHORT=国立銀行
Expand All @@ -2334,6 +2335,8 @@ MONEY_GRAM_SHORT=MoneyGram
WESTERN_UNION_SHORT=Western Union
# suppress inspection "UnusedProperty"
F2F_SHORT=対面
# suppress inspection "UnusedProperty"
JAPAN_BANK_SHORT=日本全銀振込

# Do not translate brand names
# suppress inspection "UnusedProperty"
Expand Down
Loading