Add support for not recognized payment methods

This commit is contained in:
Manfred Karrer 2016-08-26 15:05:38 +02:00
parent bf0489d5e7
commit 2f1ea286e0
2 changed files with 7 additions and 1 deletions

View File

@ -28,6 +28,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
// Don't use Enum as it breaks serialisation when changing entries and we want to stay flexible here
public final class PaymentMethod implements Persistable, Comparable {
@ -109,7 +110,11 @@ public final class PaymentMethod implements Persistable, Comparable {
}
public static PaymentMethod getPaymentMethodById(String name) {
return ALL_VALUES.stream().filter(e -> e.getId().equals(name)).findFirst().get();
Optional<PaymentMethod> paymentMethodOptional = ALL_VALUES.stream().filter(e -> e.getId().equals(name)).findFirst();
if (paymentMethodOptional.isPresent())
return paymentMethodOptional.get();
else
return new PaymentMethod("N/A", 1, DAY, Coin.parseCoin("0"));
}
public String getId() {

View File

@ -160,6 +160,7 @@ TRANSFER_WISE=TransferWise
US_POSTAL_MONEY_ORDER=US Postal money order
BLOCK_CHAINS=Altcoins
N/A_SHORT=Not available
OK_PAY_SHORT=OKPay
PERFECT_MONEY_SHORT=Perfect Money
ALI_PAY_SHORT=AliPay