forked from haveno-dex/haveno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
409 additions
and
4 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
113 changes: 113 additions & 0 deletions
113
core/src/main/java/haveno/core/payment/PaysafeAccount.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,113 @@ | ||
/* | ||
* This file is part of Haveno. | ||
* | ||
* Haveno 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. | ||
* | ||
* Haveno 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 Haveno. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package haveno.core.payment; | ||
|
||
import haveno.core.api.model.PaymentAccountFormField; | ||
import haveno.core.locale.TraditionalCurrency; | ||
import haveno.core.locale.TradeCurrency; | ||
import haveno.core.payment.payload.PaymentAccountPayload; | ||
import haveno.core.payment.payload.PaymentMethod; | ||
import haveno.core.payment.payload.PaysafeAccountPayload; | ||
import lombok.EqualsAndHashCode; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
@EqualsAndHashCode(callSuper = true) | ||
public final class PaysafeAccount extends PaymentAccount { | ||
|
||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of( | ||
PaymentAccountFormField.FieldId.ACCOUNT_NAME, | ||
PaymentAccountFormField.FieldId.EMAIL, | ||
PaymentAccountFormField.FieldId.TRADE_CURRENCIES, | ||
PaymentAccountFormField.FieldId.SALT | ||
); | ||
|
||
// https://developer.paysafe.com/en/support/reference-information/codes/ | ||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of( | ||
new TraditionalCurrency("AED"), | ||
new TraditionalCurrency("ARS"), | ||
new TraditionalCurrency("AUD"), | ||
new TraditionalCurrency("BGN"), | ||
new TraditionalCurrency("BRL"), | ||
new TraditionalCurrency("CAD"), | ||
new TraditionalCurrency("CHF"), | ||
new TraditionalCurrency("CZK"), | ||
new TraditionalCurrency("DKK"), | ||
new TraditionalCurrency("EGP"), | ||
new TraditionalCurrency("EUR"), | ||
new TraditionalCurrency("GBP"), | ||
new TraditionalCurrency("GEL"), | ||
new TraditionalCurrency("HRK"), | ||
new TraditionalCurrency("HUF"), | ||
new TraditionalCurrency("ILS"), | ||
new TraditionalCurrency("INR"), | ||
new TraditionalCurrency("JPY"), | ||
new TraditionalCurrency("ISK"), | ||
new TraditionalCurrency("KWD"), | ||
new TraditionalCurrency("KRW"), | ||
new TraditionalCurrency("MXN"), | ||
new TraditionalCurrency("NOK"), | ||
new TraditionalCurrency("NZD"), | ||
new TraditionalCurrency("PEN"), | ||
new TraditionalCurrency("PHP"), | ||
new TraditionalCurrency("PLN"), | ||
new TraditionalCurrency("RON"), | ||
new TraditionalCurrency("RSD"), | ||
new TraditionalCurrency("RUB"), | ||
new TraditionalCurrency("SAR"), | ||
new TraditionalCurrency("SEK"), | ||
new TraditionalCurrency("TRY"), | ||
new TraditionalCurrency("USD"), | ||
new TraditionalCurrency("UYU") | ||
); | ||
|
||
public PaysafeAccount() { | ||
super(PaymentMethod.PAYSAFE); | ||
} | ||
|
||
@Override | ||
protected PaymentAccountPayload createPayload() { | ||
return new PaysafeAccountPayload(paymentMethod.getId(), id); | ||
} | ||
|
||
@Override | ||
public @NotNull List<TradeCurrency> getSupportedCurrencies() { | ||
return SUPPORTED_CURRENCIES; | ||
} | ||
|
||
@Override | ||
public @NotNull List<PaymentAccountFormField.FieldId> getInputFieldIds() { | ||
return INPUT_FIELD_IDS; | ||
} | ||
|
||
public void setEmail(String accountId) { | ||
((PaysafeAccountPayload) paymentAccountPayload).setEmail(accountId); | ||
} | ||
|
||
public String getEmail() { | ||
return ((PaysafeAccountPayload) paymentAccountPayload).getEmail(); | ||
} | ||
|
||
@Override | ||
protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) { | ||
var field = super.getEmptyFormField(fieldId); | ||
if (field.getId() == PaymentAccountFormField.FieldId.TRADE_CURRENCIES) field.setValue(""); | ||
return field; | ||
} | ||
} |
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
96 changes: 96 additions & 0 deletions
96
core/src/main/java/haveno/core/payment/payload/PaysafeAccountPayload.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,96 @@ | ||
/* | ||
* This file is part of Haveno. | ||
* | ||
* Haveno 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. | ||
* | ||
* Haveno 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 Haveno. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package haveno.core.payment.payload; | ||
|
||
import com.google.protobuf.Message; | ||
import haveno.core.locale.Res; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@EqualsAndHashCode(callSuper = true) | ||
@ToString | ||
@Setter | ||
@Getter | ||
@Slf4j | ||
public final class PaysafeAccountPayload extends PaymentAccountPayload { | ||
private String email = ""; | ||
|
||
public PaysafeAccountPayload(String paymentMethod, String id) { | ||
super(paymentMethod, id); | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
// PROTO BUFFER | ||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
private PaysafeAccountPayload(String paymentMethod, | ||
String id, | ||
String email, | ||
long maxTradePeriod, | ||
Map<String, String> excludeFromJsonDataMap) { | ||
super(paymentMethod, | ||
id, | ||
maxTradePeriod, | ||
excludeFromJsonDataMap); | ||
|
||
this.email = email; | ||
} | ||
|
||
@Override | ||
public Message toProtoMessage() { | ||
return getPaymentAccountPayloadBuilder() | ||
.setPaysafeAccountPayload(protobuf.PaysafeAccountPayload.newBuilder().setEmail(email)) | ||
.build(); | ||
} | ||
|
||
public static PaysafeAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { | ||
return new PaysafeAccountPayload(proto.getPaymentMethodId(), | ||
proto.getId(), | ||
proto.getPaysafeAccountPayload().getEmail(), | ||
proto.getMaxTradePeriod(), | ||
new HashMap<>(proto.getExcludeFromJsonDataMap())); | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
// API | ||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
@Override | ||
public String getPaymentDetails() { | ||
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.email") + " " + email; | ||
} | ||
|
||
@Override | ||
public String getPaymentDetailsForTradePopup() { | ||
return getPaymentDetails(); | ||
} | ||
|
||
@Override | ||
public byte[] getAgeWitnessInputData() { | ||
return super.getAgeWitnessInputData(email.getBytes(StandardCharsets.UTF_8)); | ||
} | ||
} |
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.