导航菜单

页面标题

页面副标题

Brevistay v5.8.2 - JuspayActivity.java 源代码

正在查看: Brevistay v5.8.2 应用的 JuspayActivity.java JAVA 源代码文件

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


package com.brevistay.app.view.booking;

import android.content.ComponentCallbacks;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.ComponentActivity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.WindowCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.ViewModelStore;
import androidx.lifecycle.viewmodel.CreationExtras;
import androidx.preference.PreferenceManager;
import com.brevistay.app.models.Apis;
import com.brevistay.app.models.Retrofithelper;
import com.brevistay.app.models.booking_model.create_booking.juspay.CreateBookingBodyJuspay;
import com.brevistay.app.models.booking_model.create_booking.juspay.CreateBookingResJuspay;
import com.brevistay.app.models.booking_model.create_booking.juspay.JuspayPayload;
import com.brevistay.app.models.booking_model.create_booking.juspay.Option;
import com.brevistay.app.models.booking_model.create_booking.juspay.Params;
import com.brevistay.app.models.booking_model.create_booking.juspay.PaymentFilter;
import com.brevistay.app.models.booking_model.hotel_availabilty.HotelAvailabiltyBody;
import com.brevistay.app.models.booking_model.hotel_availabilty.HotelAvailabiltyRes;
import com.brevistay.app.models.booking_model.payment_status_update.Booking;
import com.brevistay.app.models.booking_model.payment_status_update.Responsev2.TransactionStatusResv2;
import com.brevistay.app.models.juspay.JusPaySessionBody;
import com.brevistay.app.models.juspay.JusPaySessionRes;
import com.brevistay.app.models.login_model.login.LoginResFromPass;
import com.brevistay.app.models.login_model.room.UserDatabase;
import com.brevistay.app.models.search_model.hotel_details2.HotelDetail2;
import com.brevistay.app.repositories.HotelAvailabiltyRepo;
import com.brevistay.app.view.booking.fragments.BookingConfirmedActivity;
import com.brevistay.app.view.utils.EventsTrackingUtil;
import com.brevistay.app.view.utils.TimeUtils;
import com.brevistay.app.viewmodels.booking_viewmodel.BookingViewModel;
import com.clevertap.android.sdk.leanplum.Constants;
import com.facebook.appevents.integrity.IntegrityManager;
import com.facebook.internal.AnalyticsEvents;
import com.facebook.share.internal.ShareConstants;
import com.google.gson.Gson;
import in.juspay.hypersdk.data.JuspayResponseHandler;
import in.juspay.hypersdk.ui.HyperPaymentsCallbackAdapter;
import in.juspay.services.HyperServices;
import java.util.Calendar;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import kotlin.Lazy;
import kotlin.LazyKt;
import kotlin.LazyThreadSafetyMode;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlin.text.StringsKt;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineScopeKt;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Dispatchers;
import kotlinx.coroutines.Job;
import kotlinx.coroutines.SupervisorKt;
import org.json.JSONObject;
import org.koin.android.ext.android.AndroidKoinScopeExtKt;
import org.koin.core.qualifier.Qualifier;
import org.koin.viewmodel.GetViewModelKt;

@Metadata(d1 = {"\u0000n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0002\u0010\u0003J\u0012\u0010%\u001a\u00020&2\b\u0010'\u001a\u0004\u0018\u00010(H\u0014J\u000e\u0010)\u001a\u00020&2\u0006\u0010*\u001a\u00020\u001aJ\b\u0010+\u001a\u00020&H\u0002J\b\u0010,\u001a\u00020&H\u0014J\b\u0010-\u001a\u00020\u001aH\u0002J\b\u0010.\u001a\u00020/H\u0002J\b\u00100\u001a\u00020&H\u0016J \u00101\u001a\u0002022\u0006\u00103\u001a\u0002022\u0006\u00104\u001a\u0002052\u0006\u00106\u001a\u000205H\u0002J\b\u00107\u001a\u00020&H\u0002J\u0010\u00108\u001a\u00020&2\u0006\u00109\u001a\u00020:H\u0002R\u001b\u0010\u0004\u001a\u00020\u00058BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\b\u0010\t\u001a\u0004\b\u0006\u0010\u0007R\u000e\u0010\n\u001a\u00020\u000bX\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\u000bX\u0082.¢\u0006\u0002\n\u0000R\u001a\u0010\r\u001a\u00020\u000eX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\u000f\u0010\u0010\"\u0004\b\u0011\u0010\u0012R\u001c\u0010\u0013\u001a\u0004\u0018\u00010\u0014X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0015\u0010\u0016\"\u0004\b\u0017\u0010\u0018R\u001c\u0010\u0019\u001a\u0004\u0018\u00010\u001aX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u001b\u0010\u001c\"\u0004\b\u001d\u0010\u001eR\u000e\u0010\u001f\u001a\u00020 X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010!\u001a\u00020 X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\"\u001a\u00020 X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010#\u001a\u00020$X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006;"}, d2 = {"Lcom/brevistay/app/view/booking/JuspayActivity;", "Landroidx/appcompat/app/AppCompatActivity;", "<init>", "()V", "viewmodel", "Lcom/brevistay/app/viewmodels/booking_viewmodel/BookingViewModel;", "getViewmodel", "()Lcom/brevistay/app/viewmodels/booking_viewmodel/BookingViewModel;", "viewmodel$delegate", "Lkotlin/Lazy;", "repository2", "Lcom/brevistay/app/repositories/HotelAvailabiltyRepo;", "repoPayments", "sharedPreferences", "Landroid/content/SharedPreferences;", "getSharedPreferences", "()Landroid/content/SharedPreferences;", "setSharedPreferences", "(Landroid/content/SharedPreferences;)V", "hyperServicesHolder", "Lin/juspay/services/HyperServices;", "getHyperServicesHolder", "()Lin/juspay/services/HyperServices;", "setHyperServicesHolder", "(Lin/juspay/services/HyperServices;)V", "initiatePayload", "Lorg/json/JSONObject;", "getInitiatePayload", "()Lorg/json/JSONObject;", "setInitiatePayload", "(Lorg/json/JSONObject;)V", "JuspayLoaderTxt", "Landroid/widget/TextView;", "JuspayLoaderTxtTitle", "JuspayLoaderWarning", "activityScope", "Lkotlinx/coroutines/CoroutineScope;", "onCreate", "", "savedInstanceState", "Landroid/os/Bundle;", "startPayments", "sdk_payload", "initiatePaymentsSDK", "onStart", "createInitiatePayload", "createHyperPaymentsCallbackAdapter", "Lin/juspay/hypersdk/ui/HyperPaymentsCallbackAdapter;", "onBackPressed", "getCheckOutDate", "", "value", "pack", "", "time", "trackAbandonCart", "trackBookingInitiated", "createBookingResJuspay", "Lcom/brevistay/app/models/booking_model/create_booking/juspay/CreateBookingResJuspay;", "app_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
public final class JuspayActivity extends AppCompatActivity {
    private TextView JuspayLoaderTxt;
    private TextView JuspayLoaderTxtTitle;
    private TextView JuspayLoaderWarning;
    private final CoroutineScope activityScope = CoroutineScopeKt.CoroutineScope(Dispatchers.getIO().plus(SupervisorKt.SupervisorJob$default((Job) null, 1, (Object) null)));
    private HyperServices hyperServicesHolder;
    private JSONObject initiatePayload;
    private HotelAvailabiltyRepo repoPayments;
    private HotelAvailabiltyRepo repository2;
    public SharedPreferences sharedPreferences;

    private final Lazy viewmodel;

    public JuspayActivity() {
        final ComponentActivity componentActivity = (ComponentActivity) this;
        final Qualifier qualifier = null;
        this.viewmodel = LazyKt.lazy(LazyThreadSafetyMode.NONE, new Function0<BookingViewModel>() {
            public final BookingViewModel m17invoke() {
                CreationExtras defaultViewModelCreationExtras;
                ComponentCallbacks componentCallbacks = componentActivity;
                Qualifier qualifier2 = qualifier;
                Function0 function0 = qualifier;
                Function0 function02 = qualifier;
                ViewModelStore viewModelStore = componentCallbacks.getViewModelStore();
                if (function0 == null || (defaultViewModelCreationExtras = (CreationExtras) function0.invoke()) == null) {
                    defaultViewModelCreationExtras = componentCallbacks.getDefaultViewModelCreationExtras();
                }
                return GetViewModelKt.resolveViewModel$default(Reflection.getOrCreateKotlinClass(BookingViewModel.class), viewModelStore, (String) null, defaultViewModelCreationExtras, qualifier2, AndroidKoinScopeExtKt.getKoinScope(componentCallbacks), function02, 4, (Object) null);
            }
        });
    }

    public final BookingViewModel getViewmodel() {
        return (BookingViewModel) this.viewmodel.getValue();
    }

    public final SharedPreferences getSharedPreferences() {
        SharedPreferences sharedPreferences = this.sharedPreferences;
        if (sharedPreferences != null) {
            return sharedPreferences;
        }
        Intrinsics.throwUninitializedPropertyAccessException("sharedPreferences");
        return null;
    }

    public final void setSharedPreferences(SharedPreferences sharedPreferences) {
        Intrinsics.checkNotNullParameter(sharedPreferences, "<set-?>");
        this.sharedPreferences = sharedPreferences;
    }

    public final HyperServices getHyperServicesHolder() {
        return this.hyperServicesHolder;
    }

    public final void setHyperServicesHolder(HyperServices hyperServices) {
        this.hyperServicesHolder = hyperServices;
    }

    public final JSONObject getInitiatePayload() {
        return this.initiatePayload;
    }

    public final void setInitiatePayload(JSONObject jSONObject) {
        this.initiatePayload = jSONObject;
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(2131558431);
        WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
        this.hyperServicesHolder = new HyperServices((FragmentActivity) this);
        setSharedPreferences(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()));
        this.JuspayLoaderTxt = (TextView) findViewById(2131363105);
        this.JuspayLoaderTxtTitle = (TextView) findViewById(2131363106);
        this.JuspayLoaderWarning = (TextView) findViewById(2131363107);
        Apis apis = (Apis) Retrofithelper.INSTANCE.getInstance("https://api.juspay.in/").create(Apis.class);
        UserDatabase.Companion companion = UserDatabase.Companion;
        Context applicationContext = getApplicationContext();
        Intrinsics.checkNotNullExpressionValue(applicationContext, "getApplicationContext(...)");
        UserDatabase userDatabase = companion.getdatabase(applicationContext);
        Intrinsics.checkNotNull(apis);
        this.repository2 = new HotelAvailabiltyRepo(apis, userDatabase);
        Apis apis2 = (Apis) Retrofithelper.INSTANCE.getInstance("https://cst.brevistay.com/payments/").create(Apis.class);
        UserDatabase.Companion companion2 = UserDatabase.Companion;
        Context applicationContext2 = getApplicationContext();
        Intrinsics.checkNotNullExpressionValue(applicationContext2, "getApplicationContext(...)");
        UserDatabase userDatabase2 = companion2.getdatabase(applicationContext2);
        Intrinsics.checkNotNull(apis2);
        this.repoPayments = new HotelAvailabiltyRepo(apis2, userDatabase2);
        final boolean booleanExtra = getIntent().getBooleanExtra("paynow", false);
        HotelAvailabiltyRepo hotelAvailabiltyRepo = null;
        if (booleanExtra) {
            String stringExtra = getIntent().getStringExtra("final_discounted_amount");
            String str = stringExtra == null ? "" : stringExtra;
            String stringExtra2 = getIntent().getStringExtra("email");
            String str2 = stringExtra2 == null ? "" : stringExtra2;
            String stringExtra3 = getIntent().getStringExtra("mobile_number");
            String str3 = stringExtra3 == null ? "" : stringExtra3;
            String stringExtra4 = getIntent().getStringExtra("orderId");
            JusPaySessionBody jusPaySessionBody = new JusPaySessionBody("paymentPage", str, str2, "brevistay", str3, stringExtra4 == null ? "" : stringExtra4, "brevistay");
            Log.d("juspay session body", jusPaySessionBody.toString());
            BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getIO()), (CoroutineContext) null, (CoroutineStart) null, new JuspayActivity$onCreate$1(jusPaySessionBody, this, null), 3, (Object) null);
        } else {
            String stringExtra5 = getIntent().getStringExtra(IntegrityManager.INTEGRITY_TYPE_ADDRESS);
            String str4 = stringExtra5 == null ? "" : stringExtra5;
            int intExtra = getIntent().getIntExtra("adults", 2);
            String stringExtra6 = getIntent().getStringExtra("checkin_date");
            String str5 = stringExtra6 == null ? "" : stringExtra6;
            String stringExtra7 = getIntent().getStringExtra("checkin_time");
            String str6 = stringExtra7 == null ? "" : stringExtra7;
            int intExtra2 = getIntent().getIntExtra("children", 0);
            String stringExtra8 = getIntent().getStringExtra("coupon_code");
            String str7 = stringExtra8 == null ? "" : stringExtra8;
            String stringExtra9 = getIntent().getStringExtra("email");
            String str8 = stringExtra9 == null ? "" : stringExtra9;
            String stringExtra10 = getIntent().getStringExtra("fullname");
            String str9 = stringExtra10 == null ? "" : stringExtra10;
            int intExtra3 = getIntent().getIntExtra("hotel_id", 0);
            String stringExtra11 = getIntent().getStringExtra("hotel_name");
            String str10 = stringExtra11 == null ? "" : stringExtra11;
            String stringExtra12 = getIntent().getStringExtra("is_wallet");
            if (stringExtra12 == null) {
                stringExtra12 = "false";
            }
            String str11 = stringExtra12;
            String stringExtra13 = getIntent().getStringExtra("mobile_number");
            String str12 = stringExtra13 == null ? "" : stringExtra13;
            int intExtra4 = getIntent().getIntExtra("pack", 3);
            String stringExtra14 = getIntent().getStringExtra("room_type");
            CreateBookingBodyJuspay createBookingBodyJuspay = new CreateBookingBodyJuspay(str4, intExtra, str5, str6, intExtra2, str7, str8, str9, intExtra3, str10, str11, str12, intExtra4, "https://www.brevistay.com", stringExtra14 == null ? "" : stringExtra14, getIntent().getIntExtra("rooms", 1), "JUSPAY", "androidNative", getIntent().getIntExtra("opt_for_whatsapp", 0));
            Log.d("createBookingBody1", String.valueOf(createBookingBodyJuspay));
            String stringExtra15 = getIntent().getStringExtra("token");
            Log.d("tokennn", String.valueOf(stringExtra15));
            BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getIO()), (CoroutineContext) null, (CoroutineStart) null, new JuspayActivity$onCreate$2(this, createBookingBodyJuspay, stringExtra15, null), 3, (Object) null);
        }
        LifecycleOwner lifecycleOwner = (LifecycleOwner) this;
        getViewmodel().getCreateBookingJuspay().observe(lifecycleOwner, new JuspayActivity$sam$androidx_lifecycle_Observer$0(new Function1() {
            public final Object invoke(Object obj) {
                Unit onCreate$lambda$0;
                onCreate$lambda$0 = JuspayActivity.onCreate$lambda$0(JuspayActivity.this, (CreateBookingResJuspay) obj);
                return onCreate$lambda$0;
            }
        }));
        HotelAvailabiltyRepo hotelAvailabiltyRepo2 = this.repository2;
        if (hotelAvailabiltyRepo2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("repository2");
            hotelAvailabiltyRepo2 = null;
        }
        hotelAvailabiltyRepo2.getJuspaySessionRes().observe(lifecycleOwner, new JuspayActivity$sam$androidx_lifecycle_Observer$0(new Function1() {
            public final Object invoke(Object obj) {
                Unit onCreate$lambda$1;
                onCreate$lambda$1 = JuspayActivity.onCreate$lambda$1(JuspayActivity.this, (JusPaySessionRes) obj);
                return onCreate$lambda$1;
            }
        }));
        HotelAvailabiltyRepo hotelAvailabiltyRepo3 = this.repoPayments;
        if (hotelAvailabiltyRepo3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("repoPayments");
        } else {
            hotelAvailabiltyRepo = hotelAvailabiltyRepo3;
        }
        hotelAvailabiltyRepo.getTransactionStatusResv2().observe(lifecycleOwner, new JuspayActivity$sam$androidx_lifecycle_Observer$0(new Function1() {
            public final Object invoke(Object obj) {
                Unit onCreate$lambda$3;
                onCreate$lambda$3 = JuspayActivity.onCreate$lambda$3(booleanExtra, this, (TransactionStatusResv2) obj);
                return onCreate$lambda$3;
            }
        }));
    }

    public static final Unit onCreate$lambda$0(JuspayActivity juspayActivity, CreateBookingResJuspay createBookingResJuspay) {
        JuspayPayload juspay_payload;
        Log.d("juspay booking", "createBookingJuspay");
        if (createBookingResJuspay != null) {
            Log.d("juspay_booking", createBookingResJuspay.toString());
            if (Intrinsics.areEqual(createBookingResJuspay.getStatus(), "SUCCESS")) {
                juspayActivity.trackBookingInitiated(createBookingResJuspay);
                if (Intrinsics.areEqual(createBookingResJuspay.getPay_mode(), "JUSPAY")) {
                    Params params = createBookingResJuspay.getParams();
                    Log.d("juspay_res", String.valueOf((params == null || (juspay_payload = params.getJuspay_payload()) == null) ? null : juspay_payload.getSdk_payload()));
                    Gson gson = new Gson();
                    Params params2 = createBookingResJuspay.getParams();
                    JSONObject jSONObject = new JSONObject(gson.toJson(params2 != null ? params2.getJuspay_payload() : null).toString()).getJSONObject("sdk_payload");
                    Log.d("juspay_json", jSONObject.toString());
                    Intrinsics.checkNotNull(jSONObject);
                    juspayActivity.startPayments(jSONObject);
                } else if (Intrinsics.areEqual(createBookingResJuspay.getPay_mode(), "BREVISTAY_CREDITS") && Intrinsics.areEqual(createBookingResJuspay.getStatus(), "SUCCESS")) {
                    Intent intent = new Intent((Context) juspayActivity, (Class<?>) BookingConfirmedActivity.class);
                    intent.putExtra("jwtId", createBookingResJuspay.getJwt_booking_id());
                    LoginResFromPass loginResFromPass = (LoginResFromPass) juspayActivity.getViewmodel().getUserDetails().getValue();
                    String token = loginResFromPass != null ? loginResFromPass.getToken() : null;
                    Intrinsics.checkNotNull(token);
                    intent.putExtra("token", token);
                    intent.putExtra("opt_for_whatsapp", intent.getIntExtra("opt_for_whatsapp", 0));
                    String stringExtra = intent.getStringExtra("mobile_number");
                    if (stringExtra == null) {
                        stringExtra = "";
                    }
                    intent.putExtra("mobile_number", stringExtra);
                    HotelDetail2 hotelDetail2 = (HotelDetail2) juspayActivity.getViewmodel().getHotelDetail().getValue();
                    intent.putExtra("type", hotelDetail2 != null ? hotelDetail2.getHotel_category() : null);
                    HotelDetail2 hotelDetail22 = (HotelDetail2) juspayActivity.getViewmodel().getHotelDetail().getValue();
                    intent.putExtra("rating", hotelDetail22 != null ? hotelDetail22.getRating() : null);
                    HotelDetail2 hotelDetail23 = (HotelDetail2) juspayActivity.getViewmodel().getHotelDetail().getValue();
                    intent.putExtra("category", (String) (hotelDetail23 != null ? hotelDetail23.getCouple_policy() : null));
                    juspayActivity.startActivity(intent);
                    juspayActivity.finish();
                }
            } else {
                Toast.makeText(juspayActivity.getApplicationContext(), createBookingResJuspay.getMsg(), 1).show();
                super.onBackPressed();
            }
        }
        return Unit.INSTANCE;
    }

    public static final Unit onCreate$lambda$1(JuspayActivity juspayActivity, JusPaySessionRes jusPaySessionRes) {
        if (jusPaySessionRes != null) {
            Log.d("juspay_res", jusPaySessionRes.getSdk_payload().toString());
            jusPaySessionRes.getSdk_payload().getPayload().setPaymentFilter(new PaymentFilter(true, CollectionsKt.listOf(new Option(false, "CASH", CollectionsKt.listOf("CASH")))));
            JSONObject jSONObject = new JSONObject(new Gson().toJson(jusPaySessionRes).toString()).getJSONObject("sdk_payload");
            Log.d("juspay_json", jSONObject.toString());
            Intrinsics.checkNotNull(jSONObject);
            juspayActivity.startPayments(jSONObject);
        } else {
            Log.d("juspay_res", "null");
        }
        return Unit.INSTANCE;
    }

    public static final Unit onCreate$lambda$3(boolean z, JuspayActivity juspayActivity, TransactionStatusResv2 transactionStatusResv2) {
        Booking booking;
        String booking_status;
        Log.d("txnstatus", "repoPayments.transactionStatusRes.observe: " + transactionStatusResv2);
        if (transactionStatusResv2 != null && (booking = transactionStatusResv2.getBooking()) != null) {
            String booking_status2 = booking.getBooking_status();
            if ((booking_status2 == null || !StringsKt.contains$default(booking_status2, "COMPLETE", false, 2, (Object) null)) && ((booking_status = booking.getBooking_status()) == null || !StringsKt.contains$default(booking_status, "ONLINE", false, 2, (Object) null))) {
                String booking_status3 = booking.getBooking_status();
                if (booking_status3 != null && StringsKt.contains$default(booking_status3, "PAYMENT_FAIL", false, 2, (Object) null)) {
                    CoroutineScopeKt.cancel$default(juspayActivity.activityScope, (CancellationException) null, 1, (Object) null);
                    Toast.makeText(juspayActivity.getApplicationContext(), String.valueOf(transactionStatusResv2.getBookingErrorMessage()), 1).show();
                    juspayActivity.onBackPressed();
                } else {
                    BuildersKt.launch$default(juspayActivity.activityScope, (CoroutineContext) null, (CoroutineStart) null, new JuspayActivity$onCreate$5$1$1(System.currentTimeMillis(), 180000, booking, juspayActivity, null), 3, (Object) null);
                }
            } else if (z) {
                Intent intent = new Intent((Context) juspayActivity, (Class<?>) CreatedBookingActivity.class);
                intent.putExtra("jwtId", booking.getJwt_booking_id());
                LoginResFromPass loginResFromPass = (LoginResFromPass) juspayActivity.getViewmodel().getUserDetails().getValue();
                String token = loginResFromPass != null ? loginResFromPass.getToken() : null;
                Intrinsics.checkNotNull(token);
                intent.putExtra("token", token);
                intent.putExtra(ShareConstants.FEED_SOURCE_PARAM, "brevistay");
                String stringExtra = intent.getStringExtra("mobile_number");
                if (stringExtra == null) {
                    Object value = juspayActivity.getViewmodel().getUserDetails().getValue();
                    Intrinsics.checkNotNull(value);
                    stringExtra = ((LoginResFromPass) value).getUser_mobile_number();
                }
                intent.putExtra("mobile_number", stringExtra);
                juspayActivity.startActivity(intent);
                juspayActivity.finish();
            } else {
                Log.d("txnstatus", "inside else");
                try {
                    Intent intent2 = new Intent((Context) juspayActivity, (Class<?>) BookingConfirmedActivity.class);
                    intent2.putExtra("jwtId", booking.getJwt_booking_id());
                    LoginResFromPass loginResFromPass2 = (LoginResFromPass) juspayActivity.getViewmodel().getUserDetails().getValue();
                    String token2 = loginResFromPass2 != null ? loginResFromPass2.getToken() : null;
                    Intrinsics.checkNotNull(token2);
                    intent2.putExtra("token", token2);
                    String stringExtra2 = intent2.getStringExtra("mobile_number");
                    if (stringExtra2 == null) {
                        Object value2 = juspayActivity.getViewmodel().getUserDetails().getValue();
                        Intrinsics.checkNotNull(value2);
                        stringExtra2 = ((LoginResFromPass) value2).getUser_mobile_number();
                    }
                    intent2.putExtra("mobile_number", stringExtra2);
                    HotelDetail2 hotelDetail2 = (HotelDetail2) juspayActivity.getViewmodel().getHotelDetail().getValue();
                    intent2.putExtra("type", hotelDetail2 != null ? hotelDetail2.getHotel_category() : null);
                    HotelDetail2 hotelDetail22 = (HotelDetail2) juspayActivity.getViewmodel().getHotelDetail().getValue();
                    intent2.putExtra("rating", hotelDetail22 != null ? hotelDetail22.getRating() : null);
                    HotelDetail2 hotelDetail23 = (HotelDetail2) juspayActivity.getViewmodel().getHotelDetail().getValue();
                    intent2.putExtra("category", hotelDetail23 != null ? hotelDetail23.getCouple_policy() : null);
                    juspayActivity.startActivity(intent2);
                    juspayActivity.finish();
                    Unit unit = Unit.INSTANCE;
                } catch (Exception e) {
                    Log.d("txnstatus error", String.valueOf(e.getMessage()));
                    e.printStackTrace();
                    Integer.valueOf(Log.d("txnstatus error", String.valueOf(Unit.INSTANCE)));
                }
            }
        }
        return Unit.INSTANCE;
    }

    public final void startPayments(JSONObject sdk_payload) {
        Intrinsics.checkNotNullParameter(sdk_payload, "sdk_payload");
        HyperServices hyperServices = this.hyperServicesHolder;
        if (hyperServices != null) {
            hyperServices.process(sdk_payload);
        }
    }

    private final void initiatePaymentsSDK() {
        HyperServices hyperServices = this.hyperServicesHolder;
        if (hyperServices != null) {
            Intrinsics.checkNotNull(hyperServices);
            if (hyperServices.isInitialised()) {
                return;
            }
            this.initiatePayload = createInitiatePayload();
            HyperServices hyperServices2 = this.hyperServicesHolder;
            Intrinsics.checkNotNull(hyperServices2);
            hyperServices2.initiate(createInitiatePayload(), createHyperPaymentsCallbackAdapter());
        }
    }

    protected void onStart() {
        super.onStart();
        initiatePaymentsSDK();
    }

    private final JSONObject createInitiatePayload() {
        JSONObject jSONObject = new JSONObject();
        JSONObject jSONObject2 = new JSONObject();
        try {
            jSONObject2.put("action", "initiate");
            jSONObject2.put("merchantId", "brevistay");
            jSONObject2.put("clientId", "brevistay");
            jSONObject2.put("environment", "production");
            UUID randomUUID = UUID.randomUUID();
            StringBuilder sb = new StringBuilder();
            sb.append(randomUUID);
            jSONObject.put("requestId", sb.toString());
            jSONObject.put("service", "in.juspay.hyperpay");
            jSONObject.put("payload", jSONObject2);
            return jSONObject;
        } catch (Exception e) {
            e.printStackTrace();
            return jSONObject;
        }
    }

    private final HyperPaymentsCallbackAdapter createHyperPaymentsCallbackAdapter() {
        return new HyperPaymentsCallbackAdapter() {
            public void onEvent(JSONObject jsonObject, JuspayResponseHandler responseHandler) {
                TextView textView;
                TextView textView2;
                TextView textView3;
                TextView textView4;
                TextView textView5;
                TextView textView6;
                TextView textView7;
                TextView textView8;
                TextView textView9;
                TextView textView10;
                BookingViewModel viewmodel;
                String stringExtra;
                BookingViewModel viewmodel2;
                String stringExtra2;
                Params params;
                Intrinsics.checkNotNullParameter(jsonObject, "jsonObject");
                Log.d("juspay responsePayload", jsonObject.toString());
                try {
                    String string = jsonObject.getString(Constants.CHARGED_EVENT_PARAM);
                    if (Intrinsics.areEqual(string, "hide_loader") || !Intrinsics.areEqual(string, "process_result")) {
                        return;
                    }
                    boolean optBoolean = jsonObject.optBoolean("error");
                    String optString = jsonObject.optJSONObject("payload").optString(AnalyticsEvents.PARAMETER_SHARE_DIALOG_CONTENT_STATUS);
                    if (!optBoolean) {
                        if (!Intrinsics.areEqual(optString, "charged")) {
                            if (Intrinsics.areEqual(optString, "cod_initiated")) {
                                textView9 = JuspayActivity.this.JuspayLoaderTxt;
                                if (textView9 == null) {
                                    Intrinsics.throwUninitializedPropertyAccessException("JuspayLoaderTxt");
                                    textView9 = null;
                                }
                                textView9.setText("Initiating Booking");
                                BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getIO()), (CoroutineContext) null, (CoroutineStart) null, new JuspayActivity$createHyperPaymentsCallbackAdapter$1$onEvent$2(JuspayActivity.this, JuspayActivity.this.getSharedPreferences().getString("trackier_id", ""), null), 3, (Object) null);
                                return;
                            }
                            return;
                        }
                        textView10 = JuspayActivity.this.JuspayLoaderTxt;
                        if (textView10 == null) {
                            Intrinsics.throwUninitializedPropertyAccessException("JuspayLoaderTxt");
                            textView10 = null;
                        }
                        textView10.setText("Processing Payment");
                        viewmodel = JuspayActivity.this.getViewmodel();
                        LoginResFromPass loginResFromPass = (LoginResFromPass) viewmodel.getUserDetails().getValue();
                        if (loginResFromPass == null || (stringExtra = loginResFromPass.getToken()) == null) {
                            stringExtra = JuspayActivity.this.getIntent().getStringExtra("token");
                        }
                        viewmodel2 = JuspayActivity.this.getViewmodel();
                        CreateBookingResJuspay createBookingResJuspay = (CreateBookingResJuspay) viewmodel2.getCreateBookingJuspay().getValue();
                        if (createBookingResJuspay == null || (params = createBookingResJuspay.getParams()) == null || (stringExtra2 = params.getOrderId()) == null) {
                            stringExtra2 = JuspayActivity.this.getIntent().getStringExtra("orderId");
                        }
                        Log.d("juspay_charged", stringExtra + ", " + stringExtra2);
                        BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getIO()), (CoroutineContext) null, (CoroutineStart) null, new JuspayActivity$createHyperPaymentsCallbackAdapter$1$onEvent$1(JuspayActivity.this, JuspayActivity.this.getSharedPreferences().getString("trackier_id", ""), null), 3, (Object) null);
                    }
                    if (optString != null) {
                        switch (optString.hashCode()) {
                            case -1875974461:
                                if (!optString.equals("authorization_failed")) {
                                    break;
                                } else {
                                    JuspayActivity.this.onBackPressed();
                                    break;
                                }
                            case -592873500:
                                if (!optString.equals("authentication_failed")) {
                                    break;
                                } else {
                                    JuspayActivity.this.onBackPressed();
                                    break;
                                }
                            case 330873691:
                                if (!optString.equals("user_aborted")) {
                                    break;
                                } else {
                                    JuspayActivity.this.onBackPressed();
                                    break;
                                }
                            case 722587238:
                                if (!optString.equals("authorizing")) {
                                    break;
                                } else {
                                    textView = JuspayActivity.this.JuspayLoaderTxtTitle;
                                    if (textView == null) {
                                        Intrinsics.throwUninitializedPropertyAccessException("JuspayLoaderTxtTitle");
                                        textView = null;
                                    }
                                    textView.setVisibility(0);
                                    textView2 = JuspayActivity.this.JuspayLoaderWarning;
                                    if (textView2 == null) {
                                        Intrinsics.throwUninitializedPropertyAccessException("JuspayLoaderWarning");
                                        textView2 = null;
                                    }
                                    textView2.setVisibility(0);
                                    textView3 = JuspayActivity.this.JuspayLoaderTxtTitle;
                                    if (textView3 == null) {
                                        Intrinsics.throwUninitializedPropertyAccessException("JuspayLoaderTxtTitle");
                                        textView3 = null;
                                    }
                                    textView3.setText("Your payment is being processed");
                                    textView4 = JuspayActivity.this.JuspayLoaderTxt;
                                    if (textView4 == null) {
                                        Intrinsics.throwUninitializedPropertyAccessException("JuspayLoaderTxt");
                                        textView4 = null;
                                    }
                                    textView4.setText("Please hold on as it may take up to 3 minutes in some cases.");
                                    BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getIO()), (CoroutineContext) null, (CoroutineStart) null, new JuspayActivity$createHyperPaymentsCallbackAdapter$1$onEvent$4(JuspayActivity.this, JuspayActivity.this.getSharedPreferences().getString("trackier_id", ""), null), 3, (Object) null);
                                    break;
                                }
                            case 1039967579:
                                if (!optString.equals("backpressed")) {
                                    break;
                                } else {
                                    JuspayActivity.this.onBackPressed();
                                    break;
                                }
                            case 1113644194:
                                if (!optString.equals("pending_vbv")) {
                                    break;
                                } else {
                                    textView5 = JuspayActivity.this.JuspayLoaderTxtTitle;
                                    if (textView5 == null) {
                                        Intrinsics.throwUninitializedPropertyAccessException("JuspayLoaderTxtTitle");
                                        textView5 = null;
                                    }
                                    textView5.setVisibility(0);
                                    textView6 = JuspayActivity.this.JuspayLoaderWarning;
                                    if (textView6 == null) {
                                        Intrinsics.throwUninitializedPropertyAccessException("JuspayLoaderWarning");
                                        textView6 = null;
                                    }
                                    textView6.setVisibility(0);
                                    textView7 = JuspayActivity.this.JuspayLoaderTxtTitle;
                                    if (textView7 == null) {
                                        Intrinsics.throwUninitializedPropertyAccessException("JuspayLoaderTxtTitle");
                                        textView7 = null;
                                    }
                                    textView7.setText("Your payment is being processed");
                                    textView8 = JuspayActivity.this.JuspayLoaderTxt;
                                    if (textView8 == null) {
                                        Intrinsics.throwUninitializedPropertyAccessException("JuspayLoaderTxt");
                                        textView8 = null;
                                    }
                                    textView8.setText("Please hold on as it may take up to 3 minutes in some cases.");
                                    BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getIO()), (CoroutineContext) null, (CoroutineStart) null, new JuspayActivity$createHyperPaymentsCallbackAdapter$1$onEvent$3(JuspayActivity.this, JuspayActivity.this.getSharedPreferences().getString("trackier_id", ""), null), 3, (Object) null);
                                    break;
                                }
                            case 1722194021:
                                if (!optString.equals("api_failure")) {
                                    break;
                                } else {
                                    JuspayActivity.this.onBackPressed();
                                    break;
                                }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    Log.d("juspayRed", Unit.INSTANCE + " " + e.getMessage());
                }
            }
        };
    }

    public void onBackPressed() {
        trackAbandonCart();
        super.onBackPressed();
    }

    private final String getCheckOutDate(String value, int pack, int time) {
        if (time + pack < 24) {
            return value;
        }
        Calendar calendar = Calendar.getInstance();
        List split$default = StringsKt.split$default(value, new String[]{"-"}, false, 0, 6, (Object) null);
        calendar.set(Integer.parseInt((String) split$default.get(0)), Integer.parseInt((String) split$default.get(1)) - 1, Integer.parseInt((String) split$default.get(2)), pack, time);
        calendar.add(6, 1);
        return TimeUtils.INSTANCE.convertLongToTime(calendar.getTimeInMillis());
    }

    private final void trackAbandonCart() {
        String str;
        String stringExtra;
        String str2;
        int room1_rate6;
        HotelAvailabiltyRes hotelAvailabiltyRes;
        Integer slot_6hr_rate;
        HotelAvailabiltyRes hotelAvailabiltyRes2;
        Integer slot_12hr_rate;
        HotelAvailabiltyRes hotelAvailabiltyRes3;
        Integer slot_3hr_rate;
        HotelDetail2 hotelDetail2;
        String str3;
        String str4;
        int i;
        int i2;
        int i3;
        String str5;
        String str6;
        String str7;
        List hotel_images;
        String str8;
        HotelAvailabiltyRes hotelAvailabiltyRes4;
        Integer slot_12hr_rate2;
        HotelDetail2 hotelDetail22;
        String hotel_category;
        String rating;
        try {
            EventsTrackingUtil.Companion companion = EventsTrackingUtil.INSTANCE;
            Context context = (Context) this;
            Integer num = (Integer) getViewmodel().getPack().getValue();
            int intValue = num != null ? num.intValue() : 3;
            HotelAvailabiltyBody hotelAvailabiltyBody = (HotelAvailabiltyBody) getViewmodel().getHotelAvailabiltyBody().getValue();
            int hotel_id = hotelAvailabiltyBody != null ? hotelAvailabiltyBody.getHotel_id() : 0;
            HotelDetail2 hotelDetail23 = (HotelDetail2) getViewmodel().getHotelDetail().getValue();
            int parseDouble = (hotelDetail23 == null || (rating = hotelDetail23.getRating()) == null) ? 0 : (int) Double.parseDouble(rating);
            Integer num2 = (Integer) getViewmodel().getTime().getValue();
            String valueOf = String.valueOf(num2 != null ? num2.intValue() : 0);
            HotelDetail2 hotelDetail24 = (HotelDetail2) getViewmodel().getHotelDetail().getValue();
            if (hotelDetail24 == null || (str = hotelDetail24.getCity_name()) == null) {
                str = "";
            }
            HotelDetail2 hotelDetail25 = (HotelDetail2) getViewmodel().getHotelDetail().getValue();
            if ((hotelDetail25 == null || (stringExtra = hotelDetail25.getHotelName()) == null) && (stringExtra = getIntent().getStringExtra("hotel_name")) == null) {
                stringExtra = "";
            }
            HotelDetail2 hotelDetail26 = (HotelDetail2) getViewmodel().getHotelDetail().getValue();
            if (hotelDetail26 == null || (str2 = hotelDetail26.getHotelAddress()) == null) {
                str2 = "";
            }
            HotelDetail2 hotelDetail27 = (HotelDetail2) getViewmodel().getHotelDetail().getValue();
            String str9 = "standard";
            if (!Intrinsics.areEqual(hotelDetail27 != null ? hotelDetail27.getHotel_category() : null, "budget") && (hotelDetail22 = (HotelDetail2) getViewmodel().getHotelDetail().getValue()) != null && (hotel_category = hotelDetail22.getHotel_category()) != null) {
                str9 = hotel_category;
            }
            HotelAvailabiltyBody hotelAvailabiltyBody2 = (HotelAvailabiltyBody) getViewmodel().getHotelAvailabiltyBody().getValue();
            if ((hotelAvailabiltyBody2 != null ? Integer.valueOf(hotelAvailabiltyBody2.getPack()) : null) == null && getViewmodel().getPack().getValue() == null) {
                LiveData<HotelAvailabiltyRes> availabiltyLiveData = getViewmodel().getAvailabiltyLiveData();
                if (availabiltyLiveData == null || (hotelAvailabiltyRes4 = (HotelAvailabiltyRes) availabiltyLiveData.getValue()) == null || (slot_12hr_rate2 = hotelAvailabiltyRes4.getSlot_12hr_rate()) == null) {
                    Object value = getViewmodel().getHotelDetail().getValue();
                    Intrinsics.checkNotNull(value);
                    room1_rate6 = ((HotelDetail2) value).getRoom1_rate3();
                } else {
                    room1_rate6 = slot_12hr_rate2.intValue();
                }
                hotelDetail2 = (HotelDetail2) getViewmodel().getHotelDetail().getValue();
                if (hotelDetail2 != null && (hotel_images = hotelDetail2.getHotel_images()) != null && (str8 = (String) hotel_images.get(0)) != null) {
                    String str10 = stringExtra;
                    i = room1_rate6;
                    i2 = hotel_id;
                    i3 = parseDouble;
                    str5 = str;
                    str6 = str2;
                    str7 = str8;
                    str3 = valueOf;
                    str4 = str10;
                    companion.trackAbandonCartClevertap(context, intValue, i2, i3, str3, str5, str4, str6, str9, i, str7);
                }
                str3 = valueOf;
                str4 = stringExtra;
                i = room1_rate6;
                i2 = hotel_id;
                i3 = parseDouble;
                str5 = str;
                str6 = str2;
                str7 = "";
                companion.trackAbandonCartClevertap(context, intValue, i2, i3, str3, str5, str4, str6, str9, i, str7);
            }
            HotelAvailabiltyBody hotelAvailabiltyBody3 = (HotelAvailabiltyBody) getViewmodel().getHotelAvailabiltyBody().getValue();
            Integer valueOf2 = hotelAvailabiltyBody3 != null ? Integer.valueOf(hotelAvailabiltyBody3.getPack()) : (Integer) getViewmodel().getPack().getValue();
            if (valueOf2 != null && valueOf2.intValue() == 3) {
                LiveData<HotelAvailabiltyRes> availabiltyLiveData2 = getViewmodel().getAvailabiltyLiveData();
                if (availabiltyLiveData2 == null || (hotelAvailabiltyRes3 = (HotelAvailabiltyRes) availabiltyLiveData2.getValue()) == null || (slot_3hr_rate = hotelAvailabiltyRes3.getSlot_3hr_rate()) == null) {
                    HotelDetail2 hotelDetail28 = (HotelDetail2) getViewmodel().getHotelDetail().getValue();
                    room1_rate6 = hotelDetail28 != null ? hotelDetail28.getRoom1_rate3() : getIntent().getIntExtra("amount", 0);
                } else {
                    room1_rate6 = slot_3hr_rate.intValue();
                }
            } else {
                HotelAvailabiltyBody hotelAvailabiltyBody4 = (HotelAvailabiltyBody) getViewmodel().getHotelAvailabiltyBody().getValue();
                Integer valueOf3 = hotelAvailabiltyBody4 != null ? Integer.valueOf(hotelAvailabiltyBody4.getPack()) : (Integer) getViewmodel().getPack().getValue();
                if (valueOf3 != null && valueOf3.intValue() == 6) {
                    LiveData<HotelAvailabiltyRes> availabiltyLiveData3 = getViewmodel().getAvailabiltyLiveData();
                    if (availabiltyLiveData3 == null || (hotelAvailabiltyRes = (HotelAvailabiltyRes) availabiltyLiveData3.getValue()) == null || (slot_6hr_rate = hotelAvailabiltyRes.getSlot_6hr_rate()) == null) {
                        HotelDetail2 hotelDetail29 = (HotelDetail2) getViewmodel().getHotelDetail().getValue();
                        room1_rate6 = hotelDetail29 != null ? hotelDetail29.getRoom1_rate6() : getIntent().getIntExtra("amount", 0);
                    } else {
                        room1_rate6 = slot_6hr_rate.intValue();
                    }
                }
                LiveData<HotelAvailabiltyRes> availabiltyLiveData4 = getViewmodel().getAvailabiltyLiveData();
                if (availabiltyLiveData4 == null || (hotelAvailabiltyRes2 = (HotelAvailabiltyRes) availabiltyLiveData4.getValue()) == null || (slot_12hr_rate = hotelAvailabiltyRes2.getSlot_12hr_rate()) == null) {
                    HotelDetail2 hotelDetail210 = (HotelDetail2) getViewmodel().getHotelDetail().getValue();
                    room1_rate6 = hotelDetail210 != null ? hotelDetail210.getRoom1_rate12() : getIntent().getIntExtra("amount", 0);
                } else {
                    room1_rate6 = slot_12hr_rate.intValue();
                }
            }
            hotelDetail2 = (HotelDetail2) getViewmodel().getHotelDetail().getValue();
            if (hotelDetail2 != null) {
                String str102 = stringExtra;
                i = room1_rate6;
                i2 = hotel_id;
                i3 = parseDouble;
                str5 = str;
                str6 = str2;
                str7 = str8;
                str3 = valueOf;
                str4 = str102;
                companion.trackAbandonCartClevertap(context, intValue, i2, i3, str3, str5, str4, str6, str9, i, str7);
            }
            str3 = valueOf;
            str4 = stringExtra;
            i = room1_rate6;
            i2 = hotel_id;
            i3 = parseDouble;
            str5 = str;
            str6 = str2;
            str7 = "";
            companion.trackAbandonCartClevertap(context, intValue, i2, i3, str3, str5, str4, str6, str9, i, str7);
        } catch (Exception unused) {
        }
    }

    private final void trackBookingInitiated(com.brevistay.app.models.booking_model.create_booking.juspay.CreateBookingResJuspay r35) {
        throw new UnsupportedOperationException("Method not decompiled: com.brevistay.app.view.booking.JuspayActivity.trackBookingInitiated(com.brevistay.app.models.booking_model.create_booking.juspay.CreateBookingResJuspay):void");
    }
}