正在查看: Crafto v9.3.3 应用的 PaymentFlowActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Crafto v9.3.3 应用的 PaymentFlowActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.stripe.android.view;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;
import android.view.ViewGroup;
import androidx.lifecycle.u0;
import androidx.lifecycle.v0;
import androidx.lifecycle.x0;
import androidx.viewpager.widget.ViewPager;
import com.stripe.android.CustomerSession;
import com.stripe.android.PaymentSessionConfig;
import com.stripe.android.PaymentSessionData;
import com.stripe.android.R;
import com.stripe.android.databinding.PaymentFlowActivityBinding;
import com.stripe.android.model.Customer;
import com.stripe.android.model.PaymentMethod;
import com.stripe.android.model.ShippingInformation;
import com.stripe.android.model.ShippingMethod;
import com.stripe.android.view.PaymentFlowActivityStarter;
import com.stripe.android.view.PaymentFlowViewModel;
import java.util.List;
import java.util.Set;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import org.jetbrains.annotations.NotNull;
@Metadata
public final class PaymentFlowActivity extends StripeActivity {
@NotNull
public static final String PRODUCT_TOKEN = "PaymentFlowActivity";
@NotNull
public static final Companion Companion = new Companion(null);
public static final int $stable = 8;
@NotNull
private final Hk.k viewBinding$delegate = Hk.l.b(new Function0<PaymentFlowActivityBinding>() {
{
super(0);
}
@Override
@NotNull
public final PaymentFlowActivityBinding invoke() {
PaymentFlowActivity.this.getViewStub$payments_core_release().setLayoutResource(R.layout.payment_flow_activity);
View inflate = PaymentFlowActivity.this.getViewStub$payments_core_release().inflate();
if (inflate == null) {
throw new NullPointerException("null cannot be cast to non-null type android.view.ViewGroup");
}
PaymentFlowActivityBinding bind = PaymentFlowActivityBinding.bind((ViewGroup) inflate);
Intrinsics.checkNotNullExpressionValue(bind, "bind(root)");
return bind;
}
});
@NotNull
private final Hk.k viewPager$delegate = Hk.l.b(new Function0<PaymentFlowViewPager>() {
{
super(0);
}
@Override
@NotNull
public final PaymentFlowViewPager invoke() {
PaymentFlowActivityBinding viewBinding;
viewBinding = PaymentFlowActivity.this.getViewBinding();
PaymentFlowViewPager paymentFlowViewPager = viewBinding.shippingFlowViewpager;
Intrinsics.checkNotNullExpressionValue(paymentFlowViewPager, "viewBinding.shippingFlowViewpager");
return paymentFlowViewPager;
}
});
@NotNull
private final Hk.k customerSession$delegate = Hk.l.b(new Function0<CustomerSession>() {
@Override
@NotNull
public final CustomerSession invoke() {
return CustomerSession.Companion.getInstance();
}
});
@NotNull
private final Hk.k args$delegate = Hk.l.b(new Function0<PaymentFlowActivityStarter.Args>() {
{
super(0);
}
@Override
@NotNull
public final PaymentFlowActivityStarter.Args invoke() {
PaymentFlowActivityStarter.Args.Companion companion = PaymentFlowActivityStarter.Args.Companion;
Intent intent = PaymentFlowActivity.this.getIntent();
Intrinsics.checkNotNullExpressionValue(intent, "intent");
return companion.create(intent);
}
});
@NotNull
private final Hk.k paymentSessionConfig$delegate = Hk.l.b(new Function0<PaymentSessionConfig>() {
{
super(0);
}
@Override
@NotNull
public final PaymentSessionConfig invoke() {
PaymentFlowActivityStarter.Args args;
args = PaymentFlowActivity.this.getArgs();
return args.getPaymentSessionConfig$payments_core_release();
}
});
@NotNull
private final Hk.k viewModel$delegate = new u0(Reflection.getOrCreateKotlinClass(PaymentFlowViewModel.class), new Function0<x0>() {
{
super(0);
}
@Override
@NotNull
public final x0 invoke() {
x0 viewModelStore = this.getViewModelStore();
Intrinsics.checkNotNullExpressionValue(viewModelStore, "viewModelStore");
return viewModelStore;
}
}, new Function0<v0.b>() {
{
super(0);
}
@Override
@NotNull
public final v0.b invoke() {
CustomerSession customerSession;
PaymentFlowActivityStarter.Args args;
customerSession = PaymentFlowActivity.this.getCustomerSession();
args = PaymentFlowActivity.this.getArgs();
return new PaymentFlowViewModel.Factory(customerSession, args.getPaymentSessionData$payments_core_release());
}
});
@NotNull
private final Hk.k paymentFlowPagerAdapter$delegate = Hk.l.b(new Function0<PaymentFlowPagerAdapter>() {
{
super(0);
}
@Override
@NotNull
public final PaymentFlowPagerAdapter invoke() {
PaymentSessionConfig paymentSessionConfig;
PaymentSessionConfig paymentSessionConfig2;
?? r1 = PaymentFlowActivity.this;
paymentSessionConfig = r1.getPaymentSessionConfig();
paymentSessionConfig2 = PaymentFlowActivity.this.getPaymentSessionConfig();
Set allowedShippingCountryCodes = paymentSessionConfig2.getAllowedShippingCountryCodes();
final PaymentFlowActivity paymentFlowActivity = PaymentFlowActivity.this;
return new PaymentFlowPagerAdapter(r1, paymentSessionConfig, allowedShippingCountryCodes, new Function1<ShippingMethod, Unit>() {
{
super(1);
}
@Override
public Unit invoke(ShippingMethod shippingMethod) {
invoke2(shippingMethod);
return Unit.a;
}
public final void invoke2(@NotNull ShippingMethod it) {
PaymentFlowViewModel viewModel;
Intrinsics.checkNotNullParameter(it, "it");
viewModel = PaymentFlowActivity.this.getViewModel();
viewModel.setSelectedShippingMethod$payments_core_release(it);
}
});
}
});
@NotNull
private final Hk.k keyboardController$delegate = Hk.l.b(new Function0<KeyboardController>() {
{
super(0);
}
@Override
@NotNull
public final KeyboardController invoke() {
return new KeyboardController(PaymentFlowActivity.this);
}
});
@Metadata
public static final class Companion {
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
}
private final void finishWithData(PaymentSessionData paymentSessionData) {
setResult(-1, new Intent().putExtra("extra_payment_session_data", (Parcelable) paymentSessionData));
finish();
}
public final PaymentFlowActivityStarter.Args getArgs() {
return (PaymentFlowActivityStarter.Args) this.args$delegate.getValue();
}
public final CustomerSession getCustomerSession() {
return (CustomerSession) this.customerSession$delegate.getValue();
}
private final KeyboardController getKeyboardController() {
return (KeyboardController) this.keyboardController$delegate.getValue();
}
public final PaymentFlowPagerAdapter getPaymentFlowPagerAdapter() {
return (PaymentFlowPagerAdapter) this.paymentFlowPagerAdapter$delegate.getValue();
}
public final PaymentSessionConfig getPaymentSessionConfig() {
return (PaymentSessionConfig) this.paymentSessionConfig$delegate.getValue();
}
private final ShippingInformation getShippingInfo() {
return ((ShippingInfoWidget) getViewPager().findViewById(R.id.shipping_info_widget)).getShippingInformation();
}
public final PaymentFlowActivityBinding getViewBinding() {
return (PaymentFlowActivityBinding) this.viewBinding$delegate.getValue();
}
public final PaymentFlowViewModel getViewModel() {
return (PaymentFlowViewModel) this.viewModel$delegate.getValue();
}
private final PaymentFlowViewPager getViewPager() {
return (PaymentFlowViewPager) this.viewPager$delegate.getValue();
}
private final boolean hasNextPage() {
return getViewPager().getCurrentItem() + 1 < getPaymentFlowPagerAdapter().getCount();
}
private final boolean hasPreviousPage() {
return getViewPager().getCurrentItem() != 0;
}
private final void onShippingInfoError(Throwable th) {
String message = th.getMessage();
setProgressBarVisible(false);
if (message == null || message.length() == 0) {
String string = getString(R.string.invalid_shipping_information);
Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.invalid_shipping_information)");
showError(string);
} else {
showError(message);
}
getViewModel().setPaymentSessionData$payments_core_release(PaymentSessionData.copy$default(getViewModel().getPaymentSessionData$payments_core_release(), false, false, 0L, 0L, (ShippingInformation) null, (ShippingMethod) null, (PaymentMethod) null, false, 239, (Object) null));
}
public static void onShippingInfoSaved$payments_core_release$default(PaymentFlowActivity paymentFlowActivity, ShippingInformation shippingInformation, List list, int i, Object obj) {
if ((i & 2) != 0) {
list = kotlin.collections.F.a;
}
paymentFlowActivity.onShippingInfoSaved$payments_core_release(shippingInformation, list);
}
private final void onShippingInfoSubmitted() {
getKeyboardController().hide();
ShippingInformation shippingInfo = getShippingInfo();
if (shippingInfo != null) {
getViewModel().setPaymentSessionData$payments_core_release(PaymentSessionData.copy$default(getViewModel().getPaymentSessionData$payments_core_release(), false, false, 0L, 0L, shippingInfo, (ShippingMethod) null, (PaymentMethod) null, false, 239, (Object) null));
setProgressBarVisible(true);
validateShippingInformation(getPaymentSessionConfig().getShippingInformationValidator$payments_core_release(), getPaymentSessionConfig().getShippingMethodsFactory$payments_core_release(), shippingInfo);
}
}
private final void onShippingInfoValidated(final List<ShippingMethod> list) {
ShippingInformation shippingInformation = getViewModel().getPaymentSessionData$payments_core_release().getShippingInformation();
if (shippingInformation != null) {
getViewModel().saveCustomerShippingInformation$payments_core_release(shippingInformation).observe(this, new androidx.lifecycle.T() {
public final void onChanged(Object obj) {
PaymentFlowActivity.m182onShippingInfoValidated$lambda4$lambda3(PaymentFlowActivity.this, list, (Hk.p) obj);
}
});
}
}
public static final void m182onShippingInfoValidated$lambda4$lambda3(PaymentFlowActivity this$0, List shippingMethods, Hk.p result) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
Intrinsics.checkNotNullParameter(shippingMethods, "$shippingMethods");
Intrinsics.checkNotNullExpressionValue(result, "result");
Object obj = result.a;
Throwable a = Hk.p.a(obj);
if (a == null) {
this$0.onShippingInfoSaved$payments_core_release(((Customer) obj).getShippingInformation(), shippingMethods);
return;
}
String message = a.getMessage();
if (message == null) {
message = "";
}
this$0.showError(message);
}
private final void onShippingMethodSave() {
finishWithData(PaymentSessionData.copy$default(getViewModel().getPaymentSessionData$payments_core_release(), false, false, 0L, 0L, (ShippingInformation) null, ((SelectShippingMethodWidget) getViewPager().findViewById(R.id.select_shipping_method_widget)).getSelectedShippingMethod(), (PaymentMethod) null, false, 223, (Object) null));
}
private final void onShippingMethodsReady(List<ShippingMethod> list) {
setProgressBarVisible(false);
getPaymentFlowPagerAdapter().setShippingMethods$payments_core_release(list);
getPaymentFlowPagerAdapter().setShippingInfoSubmitted$payments_core_release(true);
if (!hasNextPage()) {
finishWithData(getViewModel().getPaymentSessionData$payments_core_release());
return;
}
PaymentFlowViewModel viewModel = getViewModel();
viewModel.setCurrentPage$payments_core_release(viewModel.getCurrentPage$payments_core_release() + 1);
getViewPager().setCurrentItem(getViewModel().getCurrentPage$payments_core_release());
}
private final void validateShippingInformation(PaymentSessionConfig.ShippingInformationValidator shippingInformationValidator, PaymentSessionConfig.ShippingMethodsFactory shippingMethodsFactory, ShippingInformation shippingInformation) {
getViewModel().validateShippingInformation$payments_core_release(shippingInformationValidator, shippingMethodsFactory, shippingInformation).observe(this, new androidx.lifecycle.T() {
public final void onChanged(Object obj) {
PaymentFlowActivity.m183validateShippingInformation$lambda7(PaymentFlowActivity.this, (Hk.p) obj);
}
});
}
public static final void m183validateShippingInformation$lambda7(PaymentFlowActivity this$0, Hk.p result) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
Intrinsics.checkNotNullExpressionValue(result, "result");
Object obj = result.a;
Throwable a = Hk.p.a(obj);
if (a == null) {
this$0.onShippingInfoValidated((List) obj);
} else {
this$0.onShippingInfoError(a);
}
}
@Override
public void onActionSave() {
if (PaymentFlowPage.ShippingInfo == getPaymentFlowPagerAdapter().getPageAt$payments_core_release(getViewPager().getCurrentItem())) {
onShippingInfoSubmitted();
} else {
onShippingMethodSave();
}
}
public void onBackPressed() {
if (!hasPreviousPage()) {
super/*androidx.activity.ComponentActivity*/.onBackPressed();
return;
}
getViewModel().setCurrentPage$payments_core_release(r0.getCurrentPage$payments_core_release() - 1);
getViewPager().setCurrentItem(getViewModel().getCurrentPage$payments_core_release());
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
PaymentFlowActivityStarter.Args.Companion companion = PaymentFlowActivityStarter.Args.Companion;
Intent intent = getIntent();
Intrinsics.checkNotNullExpressionValue(intent, "intent");
Integer windowFlags$payments_core_release = companion.create(intent).getWindowFlags$payments_core_release();
if (windowFlags$payments_core_release != null) {
getWindow().addFlags(windowFlags$payments_core_release.intValue());
}
ShippingInformation submittedShippingInfo$payments_core_release = getViewModel().getSubmittedShippingInfo$payments_core_release();
if (submittedShippingInfo$payments_core_release == null) {
submittedShippingInfo$payments_core_release = getPaymentSessionConfig().getPrepopulatedShippingInfo();
}
getPaymentFlowPagerAdapter().setShippingMethods$payments_core_release(getViewModel().getShippingMethods$payments_core_release());
getPaymentFlowPagerAdapter().setShippingInfoSubmitted$payments_core_release(getViewModel().isShippingInfoSubmitted$payments_core_release());
getPaymentFlowPagerAdapter().setShippingInformation$payments_core_release(submittedShippingInfo$payments_core_release);
getPaymentFlowPagerAdapter().setSelectedShippingMethod$payments_core_release(getViewModel().getSelectedShippingMethod$payments_core_release());
getViewPager().setAdapter(getPaymentFlowPagerAdapter());
getViewPager().addOnPageChangeListener(new ViewPager.i() {
public void onPageSelected(int i) {
PaymentFlowPagerAdapter paymentFlowPagerAdapter;
PaymentFlowPagerAdapter paymentFlowPagerAdapter2;
PaymentFlowViewModel viewModel;
PaymentFlowPagerAdapter paymentFlowPagerAdapter3;
?? r0 = PaymentFlowActivity.this;
paymentFlowPagerAdapter = r0.getPaymentFlowPagerAdapter();
r0.setTitle(paymentFlowPagerAdapter.getPageTitle(i));
paymentFlowPagerAdapter2 = PaymentFlowActivity.this.getPaymentFlowPagerAdapter();
if (paymentFlowPagerAdapter2.getPageAt$payments_core_release(i) == PaymentFlowPage.ShippingInfo) {
viewModel = PaymentFlowActivity.this.getViewModel();
viewModel.setShippingInfoSubmitted$payments_core_release(false);
paymentFlowPagerAdapter3 = PaymentFlowActivity.this.getPaymentFlowPagerAdapter();
paymentFlowPagerAdapter3.setShippingInfoSubmitted$payments_core_release(false);
}
}
public void onPageScrollStateChanged(int i) {
}
public void onPageScrolled(int i, float f, int i2) {
}
});
getViewPager().setCurrentItem(getViewModel().getCurrentPage$payments_core_release());
setTitle(getPaymentFlowPagerAdapter().getPageTitle(getViewPager().getCurrentItem()));
}
public final void onShippingInfoSaved$payments_core_release(ShippingInformation shippingInformation, List shippingMethods) {
Intrinsics.checkNotNullParameter(shippingMethods, "shippingMethods");
onShippingMethodsReady(shippingMethods);
getViewModel().setPaymentSessionData$payments_core_release(PaymentSessionData.copy$default(getViewModel().getPaymentSessionData$payments_core_release(), false, false, 0L, 0L, shippingInformation, (ShippingMethod) null, (PaymentMethod) null, false, 239, (Object) null));
}
}