导航菜单

页面标题

页面副标题

Rilo v2.0.21 - SupportedPaymentMethodKtxKt.java 源代码

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

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


package com.stripe.android.paymentsheet.model;

import com.stripe.android.model.Address;
import com.stripe.android.model.PaymentIntent;
import com.stripe.android.model.PaymentMethod;
import com.stripe.android.model.StripeIntent;
import com.stripe.android.payments.financialconnections.DefaultIsFinancialConnectionsAvailable;
import com.stripe.android.payments.financialconnections.IsFinancialConnectionsAvailable;
import com.stripe.android.paymentsheet.PaymentSheet;
import com.stripe.android.paymentsheet.forms.Delayed;
import com.stripe.android.paymentsheet.forms.PIRequirement;
import com.stripe.android.paymentsheet.forms.SIRequirement;
import com.stripe.android.paymentsheet.forms.ShippingAddress;
import com.stripe.android.ui.core.elements.LayoutFormDescriptor;
import com.stripe.android.ui.core.forms.resources.LpmRepository;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import kotlin.Metadata;
import kotlin.NoWhenBranchMatchedException;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.internal.Intrinsics;

@Metadata(d1 = {"\u0000L\n\u0000\n\u0002\u0010\u000b\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\"\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\u001a(\u0010\u0005\u001a\u00020\u00012\u000e\u0010\u0006\u001a\n\u0012\u0004\u0012\u00020\b\u0018\u00010\u00072\u0006\u0010\t\u001a\u00020\u00022\u0006\u0010\n\u001a\u00020\u000bH\u0002\u001a \u0010\f\u001a\u00020\u00012\u000e\u0010\u0006\u001a\n\u0012\u0004\u0012\u00020\r\u0018\u00010\u00072\u0006\u0010\n\u001a\u00020\u000bH\u0002\u001a2\u0010\u000e\u001a\b\u0012\u0004\u0012\u00020\u00100\u000f2\b\u0010\u0011\u001a\u0004\u0018\u00010\u00122\u0006\u0010\n\u001a\u00020\u000b2\u0006\u0010\u0013\u001a\u00020\u00142\b\b\u0002\u0010\u0015\u001a\u00020\u0016H\u0000\u001a(\u0010\u0017\u001a\b\u0012\u0004\u0012\u00020\u00100\u000f2\b\u0010\u0011\u001a\u0004\u0018\u00010\u00122\u0006\u0010\n\u001a\u00020\u000b2\u0006\u0010\u0013\u001a\u00020\u0014H\u0000\u001a\u001c\u0010\u0018\u001a\u00020\u0019*\u00020\u00102\u0006\u0010\u0011\u001a\u00020\u00122\u0006\u0010\n\u001a\u00020\u000bH\u0000\u001a\u001e\u0010\u001a\u001a\u0004\u0018\u00010\u0019*\u00020\u00102\u0006\u0010\u0011\u001a\u00020\u00122\u0006\u0010\n\u001a\u00020\u000bH\u0000\u001a\u001c\u0010\u001b\u001a\u00020\u0001*\u00020\u00102\u0006\u0010\t\u001a\u00020\u00022\u0006\u0010\n\u001a\u00020\u000bH\u0002\u001a\u001c\u0010\u001c\u001a\u00020\u0001*\u00020\u00102\u0006\u0010\t\u001a\u00020\u00022\u0006\u0010\n\u001a\u00020\u000bH\u0002\u001a\u001c\u0010\u001d\u001a\u00020\u0001*\u00020\u00102\u0006\u0010\t\u001a\u00020\u00022\u0006\u0010\n\u001a\u00020\u000bH\u0002\u001a\u0014\u0010\u001e\u001a\u00020\u0001*\u00020\u00102\u0006\u0010\n\u001a\u00020\u000bH\u0002\"\u0018\u0010\u0000\u001a\u00020\u0001*\u00020\u00028BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u0003\u0010\u0004¨\u0006\u001f"}, d2 = {"containsValidShippingInfo", "", "Lcom/stripe/android/model/PaymentIntent;", "getContainsValidShippingInfo", "(Lcom/stripe/android/model/PaymentIntent;)Z", "checkPaymentIntentRequirements", "requirements", "", "Lcom/stripe/android/paymentsheet/forms/PIRequirement;", "paymentIntent", "config", "Lcom/stripe/android/paymentsheet/PaymentSheet$Configuration;", "checkSetupIntentRequirements", "Lcom/stripe/android/paymentsheet/forms/SIRequirement;", "getPMsToAdd", "", "Lcom/stripe/android/ui/core/forms/resources/LpmRepository$SupportedPaymentMethod;", "stripeIntent", "Lcom/stripe/android/model/StripeIntent;", "lpmRepository", "Lcom/stripe/android/ui/core/forms/resources/LpmRepository;", "isFinancialConnectionsAvailable", "Lcom/stripe/android/payments/financialconnections/IsFinancialConnectionsAvailable;", "getSupportedSavedCustomerPMs", "getPMAddForm", "Lcom/stripe/android/ui/core/elements/LayoutFormDescriptor;", "getSpecWithFullfilledRequirements", "supportsPaymentIntentSfuNotSettable", "supportsPaymentIntentSfuSet", "supportsPaymentIntentSfuSettable", "supportsSetupIntent", "paymentsheet_release"}, k = 2, mv = {1, 8, 0}, xi = 48)
public final class SupportedPaymentMethodKtxKt {
    public static final LayoutFormDescriptor getPMAddForm(LpmRepository.SupportedPaymentMethod supportedPaymentMethod, StripeIntent stripeIntent, PaymentSheet.Configuration configuration) {
        Intrinsics.checkNotNullParameter(supportedPaymentMethod, "<this>");
        Intrinsics.checkNotNullParameter(stripeIntent, "stripeIntent");
        Intrinsics.checkNotNullParameter(configuration, "config");
        LayoutFormDescriptor specWithFullfilledRequirements = getSpecWithFullfilledRequirements(supportedPaymentMethod, stripeIntent, configuration);
        if (specWithFullfilledRequirements != null) {
            return specWithFullfilledRequirements;
        }
        throw new IllegalArgumentException("Required value was null.".toString());
    }

    public static final com.stripe.android.ui.core.elements.LayoutFormDescriptor getSpecWithFullfilledRequirements(com.stripe.android.ui.core.forms.resources.LpmRepository.SupportedPaymentMethod r6, com.stripe.android.model.StripeIntent r7, com.stripe.android.paymentsheet.PaymentSheet.Configuration r8) {
        throw new UnsupportedOperationException("Method not decompiled: com.stripe.android.paymentsheet.model.SupportedPaymentMethodKtxKt.getSpecWithFullfilledRequirements(com.stripe.android.ui.core.forms.resources.LpmRepository$SupportedPaymentMethod, com.stripe.android.model.StripeIntent, com.stripe.android.paymentsheet.PaymentSheet$Configuration):com.stripe.android.ui.core.elements.LayoutFormDescriptor");
    }

    private static final boolean supportsSetupIntent(LpmRepository.SupportedPaymentMethod supportedPaymentMethod, PaymentSheet.Configuration configuration) {
        return supportedPaymentMethod.getRequirement().getConfirmPMFromCustomer(supportedPaymentMethod.getCode()) && checkSetupIntentRequirements(supportedPaymentMethod.getRequirement().getSiRequirements(), configuration);
    }

    private static final boolean supportsPaymentIntentSfuSet(LpmRepository.SupportedPaymentMethod supportedPaymentMethod, PaymentIntent paymentIntent, PaymentSheet.Configuration configuration) {
        return supportedPaymentMethod.getRequirement().getConfirmPMFromCustomer(supportedPaymentMethod.getCode()) && checkSetupIntentRequirements(supportedPaymentMethod.getRequirement().getSiRequirements(), configuration) && checkPaymentIntentRequirements(supportedPaymentMethod.getRequirement().getPiRequirements(), paymentIntent, configuration);
    }

    private static final boolean supportsPaymentIntentSfuNotSettable(LpmRepository.SupportedPaymentMethod supportedPaymentMethod, PaymentIntent paymentIntent, PaymentSheet.Configuration configuration) {
        return checkPaymentIntentRequirements(supportedPaymentMethod.getRequirement().getPiRequirements(), paymentIntent, configuration);
    }

    private static final boolean supportsPaymentIntentSfuSettable(LpmRepository.SupportedPaymentMethod supportedPaymentMethod, PaymentIntent paymentIntent, PaymentSheet.Configuration configuration) {
        return configuration.getCustomer() != null && supportedPaymentMethod.getRequirement().getConfirmPMFromCustomer(supportedPaymentMethod.getCode()) && checkPaymentIntentRequirements(supportedPaymentMethod.getRequirement().getPiRequirements(), paymentIntent, configuration) && checkSetupIntentRequirements(supportedPaymentMethod.getRequirement().getSiRequirements(), configuration);
    }

    private static final boolean checkSetupIntentRequirements(Set<? extends SIRequirement> set, PaymentSheet.Configuration configuration) {
        if (set == null) {
            return false;
        }
        Set<? extends SIRequirement> set2 = set;
        ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(set2, 10));
        Iterator<T> it2 = set2.iterator();
        while (it2.hasNext()) {
            if (!Intrinsics.areEqual((SIRequirement) it2.next(), Delayed.INSTANCE)) {
                throw new NoWhenBranchMatchedException();
            }
            arrayList.add(Boolean.valueOf(configuration.getAllowsDelayedPaymentMethods()));
        }
        return !arrayList.contains(false);
    }

    private static final boolean checkPaymentIntentRequirements(Set<? extends PIRequirement> set, PaymentIntent paymentIntent, PaymentSheet.Configuration configuration) {
        boolean z;
        if (set != null) {
            Set<? extends PIRequirement> set2 = set;
            ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(set2, 10));
            for (PIRequirement pIRequirement : set2) {
                if (Intrinsics.areEqual(pIRequirement, Delayed.INSTANCE)) {
                    z = configuration.getAllowsDelayedPaymentMethods();
                } else if (Intrinsics.areEqual(pIRequirement, ShippingAddress.INSTANCE)) {
                    z = getContainsValidShippingInfo(paymentIntent) || configuration.getAllowsPaymentMethodsRequiringShippingAddress();
                } else {
                    throw new NoWhenBranchMatchedException();
                }
                arrayList.add(Boolean.valueOf(z));
            }
            if (!arrayList.contains(false)) {
                return true;
            }
        }
        return false;
    }

    private static final boolean getContainsValidShippingInfo(PaymentIntent paymentIntent) {
        Address address;
        Address address2;
        Address address3;
        PaymentIntent.Shipping shipping = paymentIntent.getShipping();
        String str = null;
        if ((shipping != null ? shipping.getName() : null) != null) {
            PaymentIntent.Shipping shipping2 = paymentIntent.getShipping();
            if (((shipping2 == null || (address3 = shipping2.getAddress()) == null) ? null : address3.getLine1()) != null) {
                PaymentIntent.Shipping shipping3 = paymentIntent.getShipping();
                if (((shipping3 == null || (address2 = shipping3.getAddress()) == null) ? null : address2.getCountry()) != null) {
                    PaymentIntent.Shipping shipping4 = paymentIntent.getShipping();
                    if (shipping4 != null && (address = shipping4.getAddress()) != null) {
                        str = address.getPostalCode();
                    }
                    if (str != null) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public static final List<LpmRepository.SupportedPaymentMethod> getSupportedSavedCustomerPMs(StripeIntent stripeIntent, PaymentSheet.Configuration configuration, LpmRepository lpmRepository) {
        List<String> paymentMethodTypes;
        Intrinsics.checkNotNullParameter(configuration, "config");
        Intrinsics.checkNotNullParameter(lpmRepository, "lpmRepository");
        if (stripeIntent == null || (paymentMethodTypes = stripeIntent.getPaymentMethodTypes()) == null) {
            return CollectionsKt.emptyList();
        }
        ArrayList arrayList = new ArrayList();
        Iterator<T> it2 = paymentMethodTypes.iterator();
        while (it2.hasNext()) {
            LpmRepository.SupportedPaymentMethod fromCode = lpmRepository.fromCode((String) it2.next());
            if (fromCode != null) {
                arrayList.add(fromCode);
            }
        }
        ArrayList arrayList2 = new ArrayList();
        for (Object obj : arrayList) {
            LpmRepository.SupportedPaymentMethod supportedPaymentMethod = (LpmRepository.SupportedPaymentMethod) obj;
            if (supportedPaymentMethod.supportsCustomerSavedPM() && getSpecWithFullfilledRequirements(supportedPaymentMethod, stripeIntent, configuration) != null) {
                arrayList2.add(obj);
            }
        }
        return arrayList2;
    }

    public static List getPMsToAdd$default(StripeIntent stripeIntent, PaymentSheet.Configuration configuration, LpmRepository lpmRepository, IsFinancialConnectionsAvailable isFinancialConnectionsAvailable, int i2, Object obj) {
        if ((i2 & 8) != 0) {
            isFinancialConnectionsAvailable = new DefaultIsFinancialConnectionsAvailable();
        }
        return getPMsToAdd(stripeIntent, configuration, lpmRepository, isFinancialConnectionsAvailable);
    }

    public static final List<LpmRepository.SupportedPaymentMethod> getPMsToAdd(StripeIntent stripeIntent, PaymentSheet.Configuration configuration, LpmRepository lpmRepository, IsFinancialConnectionsAvailable isFinancialConnectionsAvailable) {
        List<String> paymentMethodTypes;
        Intrinsics.checkNotNullParameter(configuration, "config");
        Intrinsics.checkNotNullParameter(lpmRepository, "lpmRepository");
        Intrinsics.checkNotNullParameter(isFinancialConnectionsAvailable, "isFinancialConnectionsAvailable");
        if (stripeIntent == null || (paymentMethodTypes = stripeIntent.getPaymentMethodTypes()) == null) {
            return CollectionsKt.emptyList();
        }
        ArrayList arrayList = new ArrayList();
        Iterator<T> it2 = paymentMethodTypes.iterator();
        while (it2.hasNext()) {
            LpmRepository.SupportedPaymentMethod fromCode = lpmRepository.fromCode((String) it2.next());
            if (fromCode != null) {
                arrayList.add(fromCode);
            }
        }
        ArrayList arrayList2 = new ArrayList();
        Iterator it3 = arrayList.iterator();
        while (true) {
            if (!it3.hasNext()) {
                break;
            }
            Object next = it3.next();
            if (getSpecWithFullfilledRequirements((LpmRepository.SupportedPaymentMethod) next, stripeIntent, configuration) != null) {
                arrayList2.add(next);
            }
        }
        ArrayList arrayList3 = new ArrayList();
        for (Object obj : arrayList2) {
            if (!(stripeIntent.isLiveMode() && stripeIntent.getUnactivatedPaymentMethods().contains(((LpmRepository.SupportedPaymentMethod) obj).getCode()))) {
                arrayList3.add(obj);
            }
        }
        ArrayList arrayList4 = new ArrayList();
        for (Object obj2 : arrayList3) {
            if (!(!isFinancialConnectionsAvailable.invoke() && Intrinsics.areEqual(((LpmRepository.SupportedPaymentMethod) obj2).getCode(), PaymentMethod.Type.USBankAccount.code))) {
                arrayList4.add(obj2);
            }
        }
        return arrayList4;
    }
}