support wise usd payment account over grpc api

This commit is contained in:
woodser 2025-06-20 08:01:12 -04:00
parent cf4956f458
commit 425dc1dd4d
No known key found for this signature in database
GPG key ID: 55A10DD48ADEE5EF
7 changed files with 40 additions and 17 deletions

View file

@ -81,7 +81,8 @@ public final class PaymentAccountForm implements PersistablePayload {
PAYSAFE,
WECHAT_PAY,
ALI_PAY,
SWISH;
SWISH,
TRANSFERWISE_USD;
public static PaymentAccountForm.FormId fromProto(protobuf.PaymentAccountForm.FormId formId) {
return ProtoUtil.enumFromProto(PaymentAccountForm.FormId.class, formId.name());

View file

@ -518,7 +518,8 @@ public abstract class PaymentAccount implements PersistablePayload {
case EXTRA_INFO:
break;
case HOLDER_ADDRESS:
throw new IllegalArgumentException("Not implemented");
processValidationResult(new LengthValidator(0, 100).validate(value));
break;
case HOLDER_EMAIL:
throw new IllegalArgumentException("Not implemented");
case HOLDER_NAME:
@ -668,11 +669,11 @@ public abstract class PaymentAccount implements PersistablePayload {
break;
case BENEFICIARY_ACCOUNT_NR:
field.setComponent(PaymentAccountFormField.Component.TEXT);
field.setLabel(Res.get("payment.swift.account"));
field.setLabel(Res.get("payment.swift.account")); // TODO: this is specific to swift
break;
case BENEFICIARY_ADDRESS:
field.setComponent(PaymentAccountFormField.Component.TEXTAREA);
field.setLabel(Res.get("payment.swift.address.beneficiary"));
field.setLabel(Res.get("payment.swift.address.beneficiary")); // TODO: this is specific to swift
break;
case BENEFICIARY_CITY:
field.setComponent(PaymentAccountFormField.Component.TEXT);
@ -717,7 +718,9 @@ public abstract class PaymentAccount implements PersistablePayload {
field.setLabel(Res.get("payment.shared.optionalExtra"));
break;
case HOLDER_ADDRESS:
throw new IllegalArgumentException("Not implemented");
field.setComponent(PaymentAccountFormField.Component.TEXTAREA);
field.setLabel(Res.get("payment.account.owner.address"));
break;
case HOLDER_EMAIL:
throw new IllegalArgumentException("Not implemented");
case HOLDER_NAME:

View file

@ -19,6 +19,7 @@ package haveno.core.payment;
import haveno.core.api.model.PaymentAccountFormField;
import haveno.core.locale.TraditionalCurrency;
import haveno.core.locale.Res;
import haveno.core.locale.TradeCurrency;
import haveno.core.payment.payload.PaymentAccountPayload;
import haveno.core.payment.payload.PaymentMethod;
@ -33,6 +34,15 @@ public final class TransferwiseUsdAccount extends CountryBasedPaymentAccount {
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
PaymentAccountFormField.FieldId.EMAIL,
PaymentAccountFormField.FieldId.HOLDER_NAME,
PaymentAccountFormField.FieldId.HOLDER_ADDRESS,
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
PaymentAccountFormField.FieldId.COUNTRY,
PaymentAccountFormField.FieldId.SALT
);
public TransferwiseUsdAccount() {
super(PaymentMethod.TRANSFERWISE_USD);
// this payment method is currently restricted to United States/USD
@ -61,11 +71,11 @@ public final class TransferwiseUsdAccount extends CountryBasedPaymentAccount {
}
public void setBeneficiaryAddress(String address) {
((TransferwiseUsdAccountPayload) paymentAccountPayload).setBeneficiaryAddress(address);
((TransferwiseUsdAccountPayload) paymentAccountPayload).setHolderAddress(address);
}
public String getBeneficiaryAddress() {
return ((TransferwiseUsdAccountPayload) paymentAccountPayload).getBeneficiaryAddress();
return ((TransferwiseUsdAccountPayload) paymentAccountPayload).getHolderAddress();
}
@Override
@ -90,6 +100,13 @@ public final class TransferwiseUsdAccount extends CountryBasedPaymentAccount {
@Override
public @NotNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
throw new RuntimeException("Not implemented");
return INPUT_FIELD_IDS;
}
@Override
protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) {
var field = super.getEmptyFormField(fieldId);
if (field.getId() == PaymentAccountFormField.FieldId.HOLDER_ADDRESS) field.setLabel(field.getLabel() + " " + Res.get("payment.transferwiseUsd.address"));
return field;
}
}

View file

@ -372,7 +372,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
PAYSAFE_ID,
WECHAT_PAY_ID,
ALI_PAY_ID,
SWISH_ID);
SWISH_ID,
TRANSFERWISE_USD_ID);
return paymentMethods.stream().filter(paymentMethod -> paymentMethodIds.contains(paymentMethod.getId())).collect(Collectors.toList());
}

View file

@ -39,7 +39,7 @@ import java.util.Map;
public final class TransferwiseUsdAccountPayload extends CountryBasedPaymentAccountPayload {
private String email = "";
private String holderName = "";
private String beneficiaryAddress = "";
private String holderAddress = "";
public TransferwiseUsdAccountPayload(String paymentMethod, String id) {
super(paymentMethod, id);
@ -51,7 +51,7 @@ public final class TransferwiseUsdAccountPayload extends CountryBasedPaymentAcco
List<String> acceptedCountryCodes,
String email,
String holderName,
String beneficiaryAddress,
String holderAddress,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
@ -63,7 +63,7 @@ public final class TransferwiseUsdAccountPayload extends CountryBasedPaymentAcco
this.email = email;
this.holderName = holderName;
this.beneficiaryAddress = beneficiaryAddress;
this.holderAddress = holderAddress;
}
@Override
@ -71,7 +71,7 @@ public final class TransferwiseUsdAccountPayload extends CountryBasedPaymentAcco
protobuf.TransferwiseUsdAccountPayload.Builder builder = protobuf.TransferwiseUsdAccountPayload.newBuilder()
.setEmail(email)
.setHolderName(holderName)
.setBeneficiaryAddress(beneficiaryAddress);
.setHolderAddress(holderAddress);
final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setTransferwiseUsdAccountPayload(builder);
@ -89,7 +89,7 @@ public final class TransferwiseUsdAccountPayload extends CountryBasedPaymentAcco
new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()),
accountPayloadPB.getEmail(),
accountPayloadPB.getHolderName(),
accountPayloadPB.getBeneficiaryAddress(),
accountPayloadPB.getHolderAddress(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

View file

@ -57,7 +57,7 @@ public class TransferwiseUsdForm extends PaymentMethodForm {
addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, 1, Res.get("payment.email"),
((TransferwiseUsdAccountPayload) paymentAccountPayload).getEmail());
String address = ((TransferwiseUsdAccountPayload) paymentAccountPayload).getBeneficiaryAddress();
String address = ((TransferwiseUsdAccountPayload) paymentAccountPayload).getHolderAddress();
if (address.length() > 0) {
TextArea textAddress = addCompactTopLabelTextArea(gridPane, gridRow, 0, Res.get("payment.account.address"), "").second;
textAddress.setMinHeight(70);
@ -96,7 +96,7 @@ public class TransferwiseUsdForm extends PaymentMethodForm {
updateFromInputs();
});
String addressLabel = Res.get("payment.account.owner.address") + Res.get("payment.transferwiseUsd.address");
String addressLabel = Res.get("payment.account.owner.address") + " " + Res.get("payment.transferwiseUsd.address");
TextArea addressTextArea = addTopLabelTextArea(gridPane, ++gridRow, addressLabel, addressLabel).second;
addressTextArea.setMinHeight(70);
addressTextArea.textProperty().addListener((ov, oldValue, newValue) -> {

View file

@ -1163,7 +1163,7 @@ message TransferwiseAccountPayload {
message TransferwiseUsdAccountPayload {
string email = 1;
string holder_name = 2;
string beneficiary_address = 3;
string holder_address = 3;
}
message PayseraAccountPayload {
@ -1906,6 +1906,7 @@ message PaymentAccountForm {
WECHAT_PAY = 20;
ALI_PAY = 21;
SWISH = 22;
TRANSFERWISE_USD = 23;
}
FormId id = 1;
repeated PaymentAccountFormField fields = 2;