导航菜单

页面标题

页面副标题

Crafto v9.3.3 - PaymentFlowFailureMessageFactory.java 源代码

正在查看: Crafto v9.3.3 应用的 PaymentFlowFailureMessageFactory.java JAVA 源代码文件

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


package com.stripe.android.payments;

import android.content.Context;
import com.stripe.android.model.PaymentIntent;
import com.stripe.android.model.PaymentMethod;
import com.stripe.android.model.SetupIntent;
import com.stripe.android.model.StripeIntent;
import kotlin.Metadata;
import kotlin.NoWhenBranchMatchedException;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;

@Metadata
public final class PaymentFlowFailureMessageFactory {

    @NotNull
    private final Context context;

    public PaymentFlowFailureMessageFactory(@NotNull Context context) {
        Intrinsics.checkNotNullParameter(context, "context");
        this.context = context;
    }

    private final String createForPaymentIntent(PaymentIntent paymentIntent) {
        PaymentMethod paymentMethod;
        PaymentMethod.Type type;
        if (paymentIntent.getStatus() != StripeIntent.Status.RequiresAction || ((paymentMethod = paymentIntent.getPaymentMethod()) != null && (type = paymentMethod.type) != null && type.isVoucher)) {
            PaymentIntent.Error lastPaymentError = paymentIntent.getLastPaymentError();
            if (!Intrinsics.areEqual(lastPaymentError != null ? lastPaymentError.getCode() : null, PaymentIntent.Error.CODE_AUTHENTICATION_ERROR)) {
                PaymentIntent.Error lastPaymentError2 = paymentIntent.getLastPaymentError();
                if ((lastPaymentError2 != null ? lastPaymentError2.getType() : null) == PaymentIntent.Error.Type.CardError) {
                    return paymentIntent.getLastPaymentError().getMessage();
                }
                return null;
            }
        }
        return this.context.getResources().getString(com.stripe.android.R.string.stripe_failure_reason_authentication);
    }

    private final String createForSetupIntent(SetupIntent setupIntent) {
        SetupIntent.Error lastSetupError = setupIntent.getLastSetupError();
        if (Intrinsics.areEqual(lastSetupError != null ? lastSetupError.getCode() : null, SetupIntent.Error.CODE_AUTHENTICATION_ERROR)) {
            return this.context.getResources().getString(com.stripe.android.R.string.stripe_failure_reason_authentication);
        }
        SetupIntent.Error lastSetupError2 = setupIntent.getLastSetupError();
        if ((lastSetupError2 != null ? lastSetupError2.getType() : null) == SetupIntent.Error.Type.CardError) {
            return setupIntent.getLastSetupError().getMessage();
        }
        return null;
    }

    public final String create(@NotNull StripeIntent stripeIntent, int i) {
        Intrinsics.checkNotNullParameter(stripeIntent, "intent");
        if (i == 4) {
            return this.context.getResources().getString(com.stripe.android.R.string.stripe_failure_reason_timed_out);
        }
        if (stripeIntent.getStatus() != StripeIntent.Status.RequiresPaymentMethod && stripeIntent.getStatus() != StripeIntent.Status.RequiresAction) {
            return null;
        }
        if (stripeIntent instanceof PaymentIntent) {
            return createForPaymentIntent((PaymentIntent) stripeIntent);
        }
        if (stripeIntent instanceof SetupIntent) {
            return createForSetupIntent((SetupIntent) stripeIntent);
        }
        throw new NoWhenBranchMatchedException();
    }
}