-
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 #5092 from jmacxx/add_cashbymail3
Add payment method "Cash by mail"
- Loading branch information
Showing
20 changed files
with
438 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
58 changes: 58 additions & 0 deletions
58
core/src/main/java/bisq/core/payment/CashByMailAccount.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,58 @@ | ||
/* | ||
* 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.CashByMailAccountPayload; | ||
import bisq.core.payment.payload.PaymentAccountPayload; | ||
import bisq.core.payment.payload.PaymentMethod; | ||
|
||
public final class CashByMailAccount extends PaymentAccount { | ||
|
||
public CashByMailAccount() { | ||
super(PaymentMethod.CASH_BY_MAIL); | ||
} | ||
|
||
@Override | ||
protected PaymentAccountPayload createPayload() { | ||
return new CashByMailAccountPayload(paymentMethod.getId(), id); | ||
} | ||
|
||
public void setPostalAddress(String postalAddress) { | ||
((CashByMailAccountPayload) paymentAccountPayload).setPostalAddress(postalAddress); | ||
} | ||
|
||
public String getPostalAddress() { | ||
return ((CashByMailAccountPayload) paymentAccountPayload).getPostalAddress(); | ||
} | ||
|
||
public void setContact(String contact) { | ||
((CashByMailAccountPayload) paymentAccountPayload).setContact(contact); | ||
} | ||
|
||
public String getContact() { | ||
return ((CashByMailAccountPayload) paymentAccountPayload).getContact(); | ||
} | ||
|
||
public void setExtraInfo(String extraInfo) { | ||
((CashByMailAccountPayload) paymentAccountPayload).setExtraInfo(extraInfo); | ||
} | ||
|
||
public String getExtraInfo() { | ||
return ((CashByMailAccountPayload) paymentAccountPayload).getExtraInfo(); | ||
} | ||
} |
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
124 changes: 124 additions & 0 deletions
124
core/src/main/java/bisq/core/payment/payload/CashByMailAccountPayload.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,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.payload; | ||
|
||
import bisq.core.locale.Res; | ||
|
||
import com.google.protobuf.Message; | ||
|
||
import org.apache.commons.lang3.ArrayUtils; | ||
|
||
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 CashByMailAccountPayload extends PaymentAccountPayload implements PayloadWithHolderName { | ||
private String postalAddress = ""; | ||
private String contact = ""; | ||
private String extraInfo = ""; | ||
|
||
public CashByMailAccountPayload(String paymentMethod, String id) { | ||
super(paymentMethod, id); | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
// PROTO BUFFER | ||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
private CashByMailAccountPayload(String paymentMethod, String id, | ||
String postalAddress, | ||
String contact, | ||
String extraInfo, | ||
long maxTradePeriod, | ||
Map<String, String> excludeFromJsonDataMap) { | ||
super(paymentMethod, | ||
id, | ||
maxTradePeriod, | ||
excludeFromJsonDataMap); | ||
this.postalAddress = postalAddress; | ||
this.contact = contact; | ||
this.extraInfo = extraInfo; | ||
} | ||
|
||
@Override | ||
public Message toProtoMessage() { | ||
return getPaymentAccountPayloadBuilder() | ||
.setCashByMailAccountPayload(protobuf.CashByMailAccountPayload.newBuilder() | ||
.setPostalAddress(postalAddress) | ||
.setContact(contact) | ||
.setExtraInfo(extraInfo)) | ||
.build(); | ||
} | ||
|
||
public static CashByMailAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { | ||
return new CashByMailAccountPayload(proto.getPaymentMethodId(), | ||
proto.getId(), | ||
proto.getCashByMailAccountPayload().getPostalAddress(), | ||
proto.getCashByMailAccountPayload().getContact(), | ||
proto.getCashByMailAccountPayload().getExtraInfo(), | ||
proto.getMaxTradePeriod(), | ||
new HashMap<>(proto.getExcludeFromJsonDataMap())); | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
// API | ||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
@Override | ||
public String getPaymentDetails() { | ||
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.owner") + " " + contact + ", " + | ||
Res.getWithCol("payment.postal.address") + " " + postalAddress + ", " + | ||
Res.getWithCol("payment.shared.extraInfo") + " " + extraInfo; | ||
} | ||
|
||
@Override | ||
public String getPaymentDetailsForTradePopup() { | ||
return Res.getWithCol("payment.account.owner") + " " + contact + "\n" + | ||
Res.getWithCol("payment.postal.address") + " " + postalAddress; | ||
} | ||
|
||
@Override | ||
public byte[] getAgeWitnessInputData() { | ||
// We use here the contact because the address alone seems to be too weak | ||
return super.getAgeWitnessInputData(ArrayUtils.addAll(contact.getBytes(StandardCharsets.UTF_8), | ||
postalAddress.getBytes(StandardCharsets.UTF_8))); | ||
} | ||
|
||
@Override | ||
public String getOwnerId() { | ||
return contact; | ||
} | ||
@Override | ||
public String getHolderName() { | ||
return contact; | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.