-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5823 from jmacxx/add_ach_domestic_wire
Add payment methods ACH Transfer and Domestic Wire Transfer
- Loading branch information
Showing
16 changed files
with
791 additions
and
3 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
core/src/main/java/bisq/core/payment/AchTransferAccount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
core/src/main/java/bisq/core/payment/DomesticWireTransferAccount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
core/src/main/java/bisq/core/payment/payload/AchTransferAccountPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", ", "); | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
core/src/main/java/bisq/core/payment/payload/DomesticWireTransferAccountPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.