mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-30 18:28:52 -04:00
support amazon e-gift card payment account over grpc api
This commit is contained in:
parent
425dc1dd4d
commit
49005d604e
6 changed files with 25 additions and 4 deletions
|
@ -82,7 +82,8 @@ public final class PaymentAccountForm implements PersistablePayload {
|
|||
WECHAT_PAY,
|
||||
ALI_PAY,
|
||||
SWISH,
|
||||
TRANSFERWISE_USD;
|
||||
TRANSFERWISE_USD,
|
||||
AMAZON_GIFT_CARD;
|
||||
|
||||
public static PaymentAccountForm.FormId fromProto(protobuf.PaymentAccountForm.FormId formId) {
|
||||
return ProtoUtil.enumFromProto(PaymentAccountForm.FormId.class, formId.name());
|
||||
|
|
|
@ -46,6 +46,14 @@ public final class AmazonGiftCardAccount extends PaymentAccount {
|
|||
new TraditionalCurrency("USD")
|
||||
);
|
||||
|
||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||
PaymentAccountFormField.FieldId.EMAIL_OR_MOBILE_NR,
|
||||
PaymentAccountFormField.FieldId.COUNTRY,
|
||||
PaymentAccountFormField.FieldId.TRADE_CURRENCIES,
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||
PaymentAccountFormField.FieldId.SALT
|
||||
);
|
||||
|
||||
@Nullable
|
||||
private Country country;
|
||||
|
||||
|
@ -65,7 +73,7 @@ public final class AmazonGiftCardAccount extends PaymentAccount {
|
|||
|
||||
@Override
|
||||
public @NotNull List<PaymentAccountFormField.FieldId> getInputFieldIds() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
return INPUT_FIELD_IDS;
|
||||
}
|
||||
|
||||
public String getEmailOrMobileNr() {
|
||||
|
@ -97,4 +105,11 @@ public final class AmazonGiftCardAccount extends PaymentAccount {
|
|||
private AmazonGiftCardAccountPayload getAmazonGiftCardAccountPayload() {
|
||||
return (AmazonGiftCardAccountPayload) paymentAccountPayload;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) {
|
||||
var field = super.getEmptyFormField(fieldId);
|
||||
if (field.getId() == PaymentAccountFormField.FieldId.TRADE_CURRENCIES) field.setComponent(PaymentAccountFormField.Component.SELECT_ONE);
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ import static haveno.common.util.Utilities.decodeFromHex;
|
|||
import static haveno.core.locale.CountryUtil.findCountryByCode;
|
||||
import static haveno.core.locale.CurrencyUtil.getTradeCurrenciesInList;
|
||||
import static haveno.core.locale.CurrencyUtil.getTradeCurrency;
|
||||
import static haveno.core.payment.payload.PaymentMethod.AMAZON_GIFT_CARD_ID;
|
||||
import static haveno.core.payment.payload.PaymentMethod.MONEY_GRAM_ID;
|
||||
import static java.lang.String.format;
|
||||
import static java.util.Arrays.stream;
|
||||
|
@ -438,6 +439,8 @@ class PaymentAccountTypeAdapter extends TypeAdapter<PaymentAccount> {
|
|||
// account.setSingleTradeCurrency(fiatCurrency);
|
||||
} else if (account.hasPaymentMethodWithId(MONEY_GRAM_ID)) {
|
||||
((MoneyGramAccount) account).setCountry(country.get());
|
||||
} else if (account.hasPaymentMethodWithId(AMAZON_GIFT_CARD_ID)) {
|
||||
((AmazonGiftCardAccount) account).setCountry(country.get());
|
||||
} else {
|
||||
String errMsg = format("cannot set the country on a %s",
|
||||
paymentAccountType.getSimpleName());
|
||||
|
|
|
@ -373,7 +373,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
|
|||
WECHAT_PAY_ID,
|
||||
ALI_PAY_ID,
|
||||
SWISH_ID,
|
||||
TRANSFERWISE_USD_ID);
|
||||
TRANSFERWISE_USD_ID,
|
||||
AMAZON_GIFT_CARD_ID);
|
||||
return paymentMethods.stream().filter(paymentMethod -> paymentMethodIds.contains(paymentMethod.getId())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ public class AmazonGiftCardForm extends PaymentMethodForm {
|
|||
|
||||
@Override
|
||||
protected void autoFillNameTextField() {
|
||||
setAccountNameWithString(amazonGiftCardAccount.getEmailOrMobileNr());
|
||||
setAccountNameWithString(amazonGiftCardAccount.getEmailOrMobileNr() == null ? "" : amazonGiftCardAccount.getEmailOrMobileNr());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1907,6 +1907,7 @@ message PaymentAccountForm {
|
|||
ALI_PAY = 21;
|
||||
SWISH = 22;
|
||||
TRANSFERWISE_USD = 23;
|
||||
AMAZON_GIFT_CARD = 24;
|
||||
}
|
||||
FormId id = 1;
|
||||
repeated PaymentAccountFormField fields = 2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue