导航菜单

页面标题

页面副标题

Rilo v2.0.21 - DeferredIntentValidator.java 源代码

正在查看: Rilo v2.0.21 应用的 DeferredIntentValidator.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.stripe.android.paymentsheet;

import com.stripe.android.model.DeferredIntentParams;
import com.stripe.android.model.ElementsSessionParams;
import com.stripe.android.model.PaymentIntent;
import com.stripe.android.model.SetupIntent;
import com.stripe.android.model.StripeIntent;
import com.stripe.android.paymentsheet.PaymentSheet;
import com.stripe.android.paymentsheet.repositories.ElementsSessionRepositoryKt;
import java.util.Locale;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;

@Metadata(d1 = {"\u0000&\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\bÀ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0010\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006H\u0002J\u001e\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\n\u001a\u00020\u000b¨\u0006\f"}, d2 = {"Lcom/stripe/android/paymentsheet/DeferredIntentValidator;", "", "()V", "mapToDeferredIntentParams", "Lcom/stripe/android/model/DeferredIntentParams;", "intentConfiguration", "Lcom/stripe/android/paymentsheet/PaymentSheet$IntentConfiguration;", "validate", "Lcom/stripe/android/model/StripeIntent;", "stripeIntent", "isFlowController", "", "paymentsheet_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class DeferredIntentValidator {
    public static final DeferredIntentValidator INSTANCE = new DeferredIntentValidator();

    private DeferredIntentValidator() {
    }

    public final StripeIntent validate(StripeIntent stripeIntent, PaymentSheet.IntentConfiguration intentConfiguration, boolean isFlowController) {
        String str;
        Intrinsics.checkNotNullParameter(stripeIntent, "stripeIntent");
        Intrinsics.checkNotNullParameter(intentConfiguration, "intentConfiguration");
        DeferredIntentParams mapToDeferredIntentParams = mapToDeferredIntentParams(intentConfiguration);
        String str2 = null;
        if (stripeIntent instanceof PaymentIntent) {
            DeferredIntentParams.Mode mode = mapToDeferredIntentParams.getMode();
            DeferredIntentParams.Mode.Payment payment = mode instanceof DeferredIntentParams.Mode.Payment ? (DeferredIntentParams.Mode.Payment) mode : null;
            if (payment == null) {
                throw new IllegalArgumentException("You returned a PaymentIntent client secret but used a PaymentSheet.IntentConfiguration in setup mode.".toString());
            }
            String lowerCase = payment.getCurrency().toLowerCase(Locale.ROOT);
            Intrinsics.checkNotNullExpressionValue(lowerCase, "this as java.lang.String).toLowerCase(Locale.ROOT)");
            PaymentIntent paymentIntent = (PaymentIntent) stripeIntent;
            String currency = paymentIntent.getCurrency();
            if (currency != null) {
                str = currency.toLowerCase(Locale.ROOT);
                Intrinsics.checkNotNullExpressionValue(str, "this as java.lang.String).toLowerCase(Locale.ROOT)");
            } else {
                str = null;
            }
            if (!Intrinsics.areEqual(lowerCase, str)) {
                String currency2 = paymentIntent.getCurrency();
                if (currency2 != null) {
                    str2 = currency2.toLowerCase(Locale.ROOT);
                    Intrinsics.checkNotNullExpressionValue(str2, "this as java.lang.String).toLowerCase(Locale.ROOT)");
                }
                String lowerCase2 = payment.getCurrency().toLowerCase(Locale.ROOT);
                Intrinsics.checkNotNullExpressionValue(lowerCase2, "this as java.lang.String).toLowerCase(Locale.ROOT)");
                throw new IllegalArgumentException(("Your PaymentIntent currency (" + str2 + ") does not match the PaymentSheet.IntentConfiguration currency (" + lowerCase2 + ").").toString());
            }
            if ((payment.getSetupFutureUsage() == paymentIntent.getSetupFutureUsage()) == false) {
                throw new IllegalArgumentException(("Your PaymentIntent setupFutureUsage (" + paymentIntent.getSetupFutureUsage() + ") does not match the PaymentSheet.IntentConfiguration setupFutureUsage (" + payment.getSetupFutureUsage() + ").").toString());
            }
            if ((payment.getCaptureMethod() == paymentIntent.getCaptureMethod()) == false) {
                throw new IllegalArgumentException(("Your PaymentIntent captureMethod (" + paymentIntent.getCaptureMethod() + ") does not match the PaymentSheet.IntentConfiguration captureMethod (" + payment.getCaptureMethod() + ").").toString());
            }
            if (paymentIntent.getConfirmationMethod() == PaymentIntent.ConfirmationMethod.Manual && !isFlowController) {
                r2 = false;
            }
            if (!r2) {
                throw new IllegalArgumentException(("Your PaymentIntent confirmationMethod (" + paymentIntent.getConfirmationMethod() + ") can only be used with PaymentSheet.FlowController.").toString());
            }
        } else if (stripeIntent instanceof SetupIntent) {
            DeferredIntentParams.Mode mode2 = mapToDeferredIntentParams.getMode();
            DeferredIntentParams.Mode.Setup setup = mode2 instanceof DeferredIntentParams.Mode.Setup ? (DeferredIntentParams.Mode.Setup) mode2 : null;
            if (setup == null) {
                throw new IllegalArgumentException("You returned a SetupIntent client secret but used a PaymentSheet.IntentConfiguration in payment mode.".toString());
            }
            SetupIntent setupIntent = (SetupIntent) stripeIntent;
            if (!(setup.getSetupFutureUsage() == setupIntent.getUsage())) {
                throw new IllegalArgumentException(("Your SetupIntent usage (" + setupIntent.getUsage() + ") does not match the PaymentSheet.IntentConfiguration usage (" + setupIntent.getUsage() + ").").toString());
            }
        }
        return stripeIntent;
    }

    private final DeferredIntentParams mapToDeferredIntentParams(PaymentSheet.IntentConfiguration intentConfiguration) {
        ElementsSessionParams elementsSessionParams = ElementsSessionRepositoryKt.toElementsSessionParams(new PaymentSheet.InitializationMode.DeferredIntent(intentConfiguration));
        Intrinsics.checkNotNull(elementsSessionParams, "null cannot be cast to non-null type com.stripe.android.model.ElementsSessionParams.DeferredIntentType");
        return ((ElementsSessionParams.DeferredIntentType) elementsSessionParams).getDeferredIntentParams();
    }
}