Fix npe with token provider (#11)

* Fix nullable token provider

* Fix optional variable
This commit is contained in:
Pavel Popov 2022-02-24 17:22:05 +03:00 committed by GitHub
parent da9a36a4b0
commit a7b866b090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,8 @@ import dev.vality.swag_webhook_events.model.*;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Objects;
import java.util.Optional;
public class PaymentToolUtils {
@ -23,8 +25,11 @@ public class PaymentToolUtils {
.lastDigits(paymentTool.getBankCard().getLastDigits())
.cardNumberMask(
paymentTool.getBankCard().getBin() + "******" + paymentTool.getBankCard().getLastDigits())
.tokenProvider(PaymentToolDetailsBankCard.TokenProviderEnum.fromValue(
TokenProviderUtil.getTokenProviderName(paymentTool.getBankCard())))
.tokenProvider(
Optional.ofNullable(TokenProviderUtil.getTokenProviderName(paymentTool.getBankCard()))
.map(PaymentToolDetailsBankCard.TokenProviderEnum::fromValue)
.orElse(null)
)
.paymentSystem(PaymentSystemUtil.getPaymentSystemName(paymentTool.getBankCard()))
.issuerCountry(paymentTool.getBankCard().getIssuerCountry() != null
? paymentTool.getBankCard().getIssuerCountry().name() : null)