Skip to content

Commit

Permalink
Merge pull request #5823 from jmacxx/add_ach_domestic_wire
Browse files Browse the repository at this point in the history
Add payment methods ACH Transfer and Domestic Wire Transfer
  • Loading branch information
ripcurlx authored Nov 12, 2021
2 parents 3e6bb3b + bf311e3 commit 17d4d42
Show file tree
Hide file tree
Showing 16 changed files with 791 additions and 3 deletions.
63 changes: 63 additions & 0 deletions core/src/main/java/bisq/core/payment/AchTransferAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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.BankAccountPayload;
import bisq.core.payment.payload.AchTransferAccountPayload;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;

import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
public final class AchTransferAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
public AchTransferAccount() {
super(PaymentMethod.ACH_TRANSFER);
}

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

@Override
public String getBankId() {
return ((BankAccountPayload) paymentAccountPayload).getBankId();
}

@Override
public String getCountryCode() {
return getCountry() != null ? getCountry().code : "";
}

public AchTransferAccountPayload getPayload() {
return (AchTransferAccountPayload) paymentAccountPayload;
}

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

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

public String getMessageForAccountCreation() {
return "payment.achTransfer.info.account";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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.BankAccountPayload;
import bisq.core.payment.payload.DomesticWireTransferAccountPayload;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;

import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
public final class DomesticWireTransferAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
public DomesticWireTransferAccount() {
super(PaymentMethod.DOMESTIC_WIRE_TRANSFER);
}

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

@Override
public String getBankId() {
return ((BankAccountPayload) paymentAccountPayload).getBankId();
}

@Override
public String getCountryCode() {
return getCountry() != null ? getCountry().code : "";
}

public DomesticWireTransferAccountPayload getPayload() {
return (DomesticWireTransferAccountPayload) paymentAccountPayload;
}

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

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

public String getMessageForAccountCreation() {
return "payment.domesticWire.info.account";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) {
return new StrikeAccount();
case PaymentMethod.SWIFT_ID:
return new SwiftAccount();
case PaymentMethod.ACH_TRANSFER_ID:
return new AchTransferAccount();
case PaymentMethod.DOMESTIC_WIRE_TRANSFER_ID:
return new DomesticWireTransferAccount();
case PaymentMethod.BSQ_SWAP_ID:
return new BsqSwapAccount();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* 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.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
@Getter
@Setter
@Slf4j
public final class AchTransferAccountPayload extends BankAccountPayload {
private String holderAddress = "";

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


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

private AchTransferAccountPayload(String paymentMethodName,
String id,
String countryCode,
String holderName,
String bankName,
String branchId,
String accountNr,
String accountType,
String holderAddress,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethodName,
id,
countryCode,
holderName,
bankName,
branchId,
accountNr,
accountType,
null, // holderTaxId not used
null, // bankId not used
null, // nationalAccountId not used
maxTradePeriod,
excludeFromJsonDataMap);

this.holderAddress = holderAddress;
}

@Override
public Message toProtoMessage() {
protobuf.AchTransferAccountPayload.Builder builder = protobuf.AchTransferAccountPayload.newBuilder()
.setHolderAddress(holderAddress);
protobuf.BankAccountPayload.Builder bankAccountPayloadBuilder = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.getBankAccountPayloadBuilder()
.setAchTransferAccountPayload(builder);
protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayloadBuilder = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setBankAccountPayload(bankAccountPayloadBuilder);
return getPaymentAccountPayloadBuilder()
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayloadBuilder)
.build();
}

public static AchTransferAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
protobuf.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload();
protobuf.BankAccountPayload bankAccountPayloadPB = countryBasedPaymentAccountPayload.getBankAccountPayload();
protobuf.AchTransferAccountPayload accountPayloadPB = bankAccountPayloadPB.getAchTransferAccountPayload();
return new AchTransferAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
bankAccountPayloadPB.getHolderName(),
bankAccountPayloadPB.getBankName().isEmpty() ? null : bankAccountPayloadPB.getBankName(),
bankAccountPayloadPB.getBranchId().isEmpty() ? null : bankAccountPayloadPB.getBranchId(),
bankAccountPayloadPB.getAccountNr().isEmpty() ? null : bankAccountPayloadPB.getAccountNr(),
bankAccountPayloadPB.getAccountType().isEmpty() ? null : bankAccountPayloadPB.getAccountType(),
accountPayloadPB.getHolderAddress().isEmpty() ? null : accountPayloadPB.getHolderAddress(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + getPaymentDetailsForTradePopup().replace("\n", ", ");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* 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.BankUtil;
import bisq.core.locale.Res;

import com.google.protobuf.Message;

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
@Getter
@Setter
@Slf4j
public final class DomesticWireTransferAccountPayload extends BankAccountPayload {
private String holderAddress = "";

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


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

private DomesticWireTransferAccountPayload(String paymentMethodName,
String id,
String countryCode,
String holderName,
String bankName,
String branchId,
String accountNr,
String holderAddress,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethodName,
id,
countryCode,
holderName,
bankName,
branchId,
accountNr,
null,
null, // holderTaxId not used
null, // bankId not used
null, // nationalAccountId not used
maxTradePeriod,
excludeFromJsonDataMap);

this.holderAddress = holderAddress;
}

@Override
public Message toProtoMessage() {
protobuf.DomesticWireTransferAccountPayload.Builder builder = protobuf.DomesticWireTransferAccountPayload.newBuilder()
.setHolderAddress(holderAddress);
protobuf.BankAccountPayload.Builder bankAccountPayloadBuilder = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.getBankAccountPayloadBuilder()
.setDomesticWireTransferAccountPayload(builder);
protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayloadBuilder = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setBankAccountPayload(bankAccountPayloadBuilder);
return getPaymentAccountPayloadBuilder()
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayloadBuilder)
.build();
}

public static DomesticWireTransferAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
protobuf.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload();
protobuf.BankAccountPayload bankAccountPayloadPB = countryBasedPaymentAccountPayload.getBankAccountPayload();
protobuf.DomesticWireTransferAccountPayload accountPayloadPB = bankAccountPayloadPB.getDomesticWireTransferAccountPayload();
return new DomesticWireTransferAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
bankAccountPayloadPB.getHolderName(),
bankAccountPayloadPB.getBankName().isEmpty() ? null : bankAccountPayloadPB.getBankName(),
bankAccountPayloadPB.getBranchId().isEmpty() ? null : bankAccountPayloadPB.getBranchId(),
bankAccountPayloadPB.getAccountNr().isEmpty() ? null : bankAccountPayloadPB.getAccountNr(),
accountPayloadPB.getHolderAddress().isEmpty() ? null : accountPayloadPB.getHolderAddress(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

@Override
public String getPaymentDetails() {
String paymentDetails = (Res.get(paymentMethodId) + " - " +
Res.getWithCol("payment.account.owner") + " " + holderName + ", " +
BankUtil.getBankNameLabel(countryCode) + ": " + this.bankName + ", " +
BankUtil.getBranchIdLabel(countryCode) + ": " + this.branchId + ", " +
BankUtil.getAccountNrLabel(countryCode) + ": " + this.accountNr);
return paymentDetails;
}
}
Loading

0 comments on commit 17d4d42

Please sign in to comment.