导航菜单

页面标题

页面副标题

Mint v5.7.3 - PartnerCouponCheckoutPage.java 源代码

正在查看: Mint v5.7.3 应用的 PartnerCouponCheckoutPage.java JAVA 源代码文件

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


package com.htmedia.mint.htsubscription.partnercoupon;

import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.text.Editable;
import android.text.Html;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import com.google.firebase.remoteconfig.RemoteConfigConstants;
import com.htmedia.mint.AppController;
import com.htmedia.mint.R;
import com.htmedia.mint.htsubscription.CheckSubscriptionFromLocal;
import com.htmedia.mint.htsubscription.ConvertMintPlanIntoZSPlan;
import com.htmedia.mint.htsubscription.GetSubscriptionIntent;
import com.htmedia.mint.htsubscription.GetUserSubscriptionDetail;
import com.htmedia.mint.htsubscription.ParseSubscriptionDetail;
import com.htmedia.mint.htsubscription.SubscriptionConverter;
import com.htmedia.mint.htsubscription.SubscriptionPlanSingleton;
import com.htmedia.mint.htsubscription.SubscriptionTrigger;
import com.htmedia.mint.htsubscription.WebEngageAnalytices;
import com.htmedia.mint.htsubscription.ZSErrorCodeHandling;
import com.htmedia.mint.htsubscription.planpagerewamp.ui.activities.PlanPageActivity;
import com.htmedia.mint.juspay.JuspayCheckout;
import com.htmedia.mint.pojo.Content;
import com.htmedia.mint.pojo.config.Config;
import com.htmedia.mint.pojo.config.Razorpay;
import com.htmedia.mint.pojo.mintsubscribenowmodel.SubscribeNowPerant;
import com.htmedia.mint.pojo.razorpay.CreateOrder;
import com.htmedia.mint.pojo.razorpay.Hostedpage;
import com.htmedia.mint.pojo.subscription.ErrorCode;
import com.htmedia.mint.pojo.subscription.SubscriptionError;
import com.htmedia.mint.pojo.subscription.plandetail.htapi.MintPlan;
import com.htmedia.mint.pojo.subscription.plandetail.htapi.MintPlanWithZSPlan;
import com.htmedia.mint.pojo.subscription.plandetail.htapi.MintServerPlan;
import com.htmedia.mint.pojo.subscription.plandetail.htapi.SubsPlans;
import com.htmedia.mint.pojo.subscription.userdetail.MintSubscriptionDetail;
import com.htmedia.mint.razorpay.JWTTokenBuilder;
import com.htmedia.mint.razorpay.presenter.OrderCreatePresenter;
import com.htmedia.mint.razorpay.presenter.OrderCreateViewInterface;
import com.htmedia.mint.razorpay.ui.SubscriptionCheckOutPage;
import com.htmedia.mint.ui.activity.HomeActivity;
import com.htmedia.mint.ui.activity.a;
import com.htmedia.mint.utils.f0;
import com.htmedia.mint.utils.n;
import com.htmedia.mint.utils.o0;
import com.htmedia.mint.utils.q;
import com.htmedia.mint.utils.s0;
import com.htmedia.sso.activities.LoginRegisterActivity;
import com.htmedia.sso.helpers.SSOSingleton;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import k6.c1;
import k6.d1;
import org.json.JSONException;
import org.json.JSONObject;
import x4.c2;

public class PartnerCouponCheckoutPage extends a implements d1, OrderCreateViewInterface, GetUserSubscriptionDetail.OnSubscriptionDetail, View.OnClickListener {
    private static final int SIGN_IN_REQUEST = 1001;
    private c2 activityPartnerCouponBinding;
    private String funnelName;
    private JuspayCheckout juspayCheckout;
    private String lastAccessUrl;
    private MintPlanWithZSPlan mintPlanWithZSPlan;
    private MintSubscriptionDetail mintSubscriptionDetail;
    private OrderCreatePresenter orderCreatePresenterInterface;
    private String orderId;
    private String partnerCouponCode;
    private PartnerCouponPojo partnerCouponPojo;
    private String partnerPlanCode;
    private String partnerPlanType;
    private SubsPlans subsPlans;
    private q.g0 subsscreen;

    private void checkOut() {
        if (TextUtils.isEmpty(f0.G1(this, "userToken"))) {
            openLoginPage();
            return;
        }
        double priceAfterDiscount = this.mintPlanWithZSPlan.getSubsPlans().getPlanDiscount().getPriceAfterDiscount();
        if (priceAfterDiscount == 0.0d) {
            createOrderRequest();
        } else {
            openCheckoutPage(priceAfterDiscount);
        }
    }

    private void checkUserLoginStatus() {
        if (TextUtils.isEmpty(f0.G1(this, "userToken"))) {
            fetchPlanFromServer();
        } else {
            checkUserSubscriptionDetail();
        }
    }

    private void checkUserSubscriptionDetail() {
        new GetUserSubscriptionDetail(this, this).fetchUserSubscriptionDetail("subscribenowbutton", q.f0.d, true);
    }

    private void convertMintPlanIntoZOHOPlan(List<SubsPlans> list) {
        String str;
        Config g = AppController.j().g();
        MintPlanWithZSPlan convertMintPlanIntoZSPlan = ConvertMintPlanIntoZSPlan.convertMintPlanIntoZSPlan((g == null || g.getSso() == null) ? "" : g.getAdFreeSubscription().getAdFreeValue(), this.partnerPlanCode, list);
        this.mintPlanWithZSPlan = convertMintPlanIntoZSPlan;
        if (convertMintPlanIntoZSPlan == null || convertMintPlanIntoZSPlan.getSubsPlans() == null) {
            this.activityPartnerCouponBinding.x.setVisibility(8);
            this.partnerCouponPojo.setCouponFilled(false);
            Toast.makeText((Context) this, (CharSequence) "Something went wrong. Please try again", 0).show();
            goBack();
            return;
        }
        this.subsPlans = this.mintPlanWithZSPlan.getSubsPlans();
        if (this.mintPlanWithZSPlan.getSubsPlans().getPlanDiscount() != null) {
            this.mintPlanWithZSPlan.setCouponApplied(true);
            this.mintPlanWithZSPlan.setCouponCode(this.partnerCouponCode);
            this.mintPlanWithZSPlan.setAdFreePlan(true);
            SubscriptionPlanSingleton.getInstance().setMintPlanWithZSPlan(this.mintPlanWithZSPlan);
            double priceAfterDiscount = this.mintPlanWithZSPlan.getSubsPlans().getPlanDiscount().getPriceAfterDiscount();
            String currencySymbol = this.mintPlanWithZSPlan.getSubsPlans().getCurrencySymbol();
            this.mintPlanWithZSPlan.setDiscountPrice(priceAfterDiscount);
            this.mintPlanWithZSPlan.setFormatedDiscountPrice(currencySymbol + priceAfterDiscount);
            this.partnerCouponPojo.setEnableApplyButton(true);
            if (!this.partnerCouponPojo.isCouponFilled()) {
                this.activityPartnerCouponBinding.x.setVisibility(8);
                this.partnerCouponPojo.setValidCoupon(false);
                return;
            }
            this.partnerCouponPojo.setValidCoupon(true);
            if (priceAfterDiscount == 0.0d) {
                this.activityPartnerCouponBinding.x.setVisibility(8);
                this.activityPartnerCouponBinding.w.setText(String.format("You have won a %1$s free trial", getPlanDuration(this.mintPlanWithZSPlan.getSubsPlans().getInterval(), this.mintPlanWithZSPlan.getSubsPlans().getIntervalUnit())));
                return;
            }
            long trialPeriod = this.mintPlanWithZSPlan.getSubsPlans().getTrialPeriod();
            if (trialPeriod == 1) {
                str = "1 day";
            } else if (trialPeriod > 1) {
                str = trialPeriod + " days";
            } else {
                str = "";
            }
            this.activityPartnerCouponBinding.w.setText(String.format("You have won a %1$s free trial", str));
            String partnerCustomizedPageText = (g == null || g.getRazorpay() == null) ? "" : g.getRazorpay().getPartnerCustomizedPageText();
            this.activityPartnerCouponBinding.x.setText(Html.fromHtml(TextUtils.isEmpty(partnerCustomizedPageText) ? "" : partnerCustomizedPageText));
            this.activityPartnerCouponBinding.x.setVisibility(0);
        }
    }

    private void createOrderRequest() {
        String str;
        SubsPlans subsPlans = this.subsPlans;
        if (subsPlans == null || TextUtils.isEmpty(subsPlans.getPlanCode()) || this.mintSubscriptionDetail == null) {
            return;
        }
        try {
            JSONObject jSONObject = new JSONObject();
            JSONObject jSONObject2 = new JSONObject();
            String mobile = this.mintSubscriptionDetail.getMobile();
            if (!TextUtils.isEmpty(mobile) && mobile.contains("+")) {
                mobile = mobile.replace("+", "").trim();
            }
            jSONObject2.put("mobile", mobile);
            jSONObject2.put("displayName", this.mintSubscriptionDetail.getDisplayName());
            jSONObject2.put("salutation", this.mintSubscriptionDetail.getSalutation());
            jSONObject2.put("firstName", this.mintSubscriptionDetail.getFirstName());
            jSONObject2.put("lastName", this.mintSubscriptionDetail.getLastName());
            jSONObject2.put("email", this.mintSubscriptionDetail.getEmail());
            jSONObject2.put("id", this.mintSubscriptionDetail.getId());
            jSONObject2.put("lastAccessUrl", this.lastAccessUrl);
            jSONObject.put("customer", jSONObject2);
            jSONObject.put("planCode", this.subsPlans.getPlanCode());
            if (this.mintPlanWithZSPlan.isCouponApplied()) {
                jSONObject.put("couponCode", this.mintPlanWithZSPlan.getCouponCode());
            }
            jSONObject.put("action", "subscribe");
            jSONObject.put("recurring", 0);
            jSONObject.put(RemoteConfigConstants.RequestFieldKey.COUNTRY_CODE, "IN");
            jSONObject.put("city", "others");
            jSONObject.put("platform", "Android");
            jSONObject.put("sourcePlatform", "ANDROID_RAZORPAY");
            jSONObject.put("paymentSource", "Razorpay");
            jSONObject.put("redirectionUrl", "https://www.livemint.com");
            String generateToken = JWTTokenBuilder.generateToken(this.mintSubscriptionDetail.getId() + "~" + this.mintSubscriptionDetail.getEmail());
            HashMap hashMap = new HashMap();
            hashMap.put("ProductId", getResources().getString(R.string.zs_product_id));
            hashMap.put("SubscriptionAuth", generateToken);
            Config g = AppController.j().g();
            Razorpay razorpay = g != null ? g.getRazorpay() : null;
            String domain = razorpay != null ? razorpay.getDomain() : "";
            String orderid = razorpay != null ? razorpay.getOrderid() : "";
            if (orderid.startsWith("http")) {
                str = orderid;
            } else {
                str = domain + orderid;
            }
            this.orderCreatePresenterInterface.createOrder(1, "OrderApi", str, jSONObject, hashMap, false, false);
        } catch (JSONException unused) {
        }
    }

    private void fetchPlanFromServer() {
        Config g = AppController.j().g();
        String str = (g.getSso() != null ? g.getSso().getPlanFetch() : "") + "?device=android&country=IN&id=" + this.partnerPlanCode;
        HashMap hashMap = new HashMap();
        hashMap.put("ProductId", getResources().getString(R.string.zs_product_id));
        new c1(this, this).a(0, "FetchSinglePlan", str, hashMap, (JSONObject) null, false, false, false, "");
    }

    private String getPlanDuration(long j, String str) {
        String str2 = "";
        if (TextUtils.isEmpty(str) || j <= 0) {
            return "";
        }
        str.hashCode();
        switch (str) {
            case "months":
                if (j != 1) {
                    str2 = "months";
                    break;
                } else {
                    str2 = "month";
                    break;
                }
            case "weeks":
                if (j != 1) {
                    str2 = "weeks";
                    break;
                } else {
                    str2 = "week";
                    break;
                }
            case "years":
                if (j <= 1) {
                    str2 = "years";
                    break;
                } else {
                    str2 = "year";
                    break;
                }
        }
        return j + " " + str2;
    }

    private void goBack() {
        if (getIntent().getExtras() != null && getIntent().getExtras().containsKey("isNotification") && getIntent().getExtras().getInt("isNotification") > q.m.a.ordinal()) {
            startActivity(new Intent((Context) this, (Class<?>) HomeActivity.class));
        }
        setSubscriptionIntent();
        finish();
    }

    private void goBackWithoutSubscription() {
        if (getIntent().getExtras() != null && getIntent().getExtras().containsKey("isNotification") && getIntent().getExtras().getInt("isNotification") > q.m.a.ordinal()) {
            startActivity(new Intent((Context) this, (Class<?>) HomeActivity.class));
        }
        finish();
    }

    private void handlePartnerPages() {
        if (isPartnerpage()) {
            checkUserLoginStatus();
        } else {
            goBack();
        }
    }

    private void initJuspay() {
        JuspayCheckout juspayCheckout = new JuspayCheckout(this, false);
        this.juspayCheckout = juspayCheckout;
        juspayCheckout.o(this);
    }

    private void initVars() {
        PartnerCouponPojo partnerCouponPojo = new PartnerCouponPojo();
        this.partnerCouponPojo = partnerCouponPojo;
        this.activityPartnerCouponBinding.c(partnerCouponPojo);
        this.orderCreatePresenterInterface = new OrderCreatePresenter(this, this);
        this.lastAccessUrl = "https://www.livemint.com/";
        this.subsscreen = SubscriptionPlanSingleton.getInstance().getSubsscreen();
        this.funnelName = SubscriptionPlanSingleton.getInstance().getFunnelName();
    }

    private boolean isPartnerpage() {
        Set<String> queryParameterNames;
        Bundle extras = getIntent().getExtras();
        if (extras == null || !extras.containsKey("urlkey") || !extras.containsKey("FromPartner")) {
            return false;
        }
        String string = extras.getString("urlkey", "");
        if (TextUtils.isEmpty(string)) {
            return false;
        }
        Uri parse = Uri.parse(string);
        parse.getHost();
        parse.getScheme();
        if (!parse.getPath().equalsIgnoreCase(s0.Q0.b()) || (queryParameterNames = parse.getQueryParameterNames()) == null || queryParameterNames.isEmpty()) {
            return false;
        }
        this.partnerPlanCode = parse.getQueryParameter("android_code");
        this.partnerPlanType = parse.getQueryParameter("android_category");
        if (TextUtils.isEmpty(this.partnerPlanCode)) {
            this.partnerPlanCode = parse.getQueryParameter("code");
        }
        if (TextUtils.isEmpty(this.partnerPlanType)) {
            this.partnerPlanType = parse.getQueryParameter("category");
        }
        return (TextUtils.isEmpty(this.partnerPlanCode) || TextUtils.isEmpty(this.partnerPlanType)) ? false : true;
    }

    private void openCheckoutPage(double d) {
        SubscriptionPlanSingleton subscriptionPlanSingleton = SubscriptionPlanSingleton.getInstance();
        SSOSingleton.getInstance().setPlanPageReason("Partner Coupon");
        subscriptionPlanSingleton.setSubsscreen(q.g0.f);
        subscriptionPlanSingleton.setFunnelName("Partner Coupon");
        subscriptionPlanSingleton.setLastAccessUrl("");
        subscriptionPlanSingleton.setMintPlanWithZSPlan(this.mintPlanWithZSPlan);
        subscriptionPlanSingleton.setPianoExpName("");
        subscriptionPlanSingleton.setMintSubscriptionDetail(null);
        SSOSingleton.getInstance().setPaywallReson("");
        Intent intent = new Intent((Context) this, (Class<?>) SubscriptionCheckOutPage.class);
        intent.putExtra("funnelName", this.partnerPlanType + "Partner Coupon");
        intent.putExtra("KeyPlanPrice", d);
        intent.putExtra("needSetPassword", false);
        startActivityForResult(intent, 9002);
    }

    private void openOnboardingFlow() {
        SubscriptionTrigger.openOnBoardJourneyVideo(this);
    }

    private void setOnClickListner() {
        this.activityPartnerCouponBinding.i.setOnClickListener(this);
        this.activityPartnerCouponBinding.g.setOnClickListener(this);
        this.activityPartnerCouponBinding.y.setOnClickListener(this);
    }

    private void setSubscriptionIntent() {
        if (GetSubscriptionIntent.getSubscriptionIntent() != null) {
            setResult(-1, GetSubscriptionIntent.getSubscriptionIntent());
        }
    }

    private void setTextWatcher() {
        this.activityPartnerCouponBinding.a.addTextChangedListener(new TextWatcher() {
            @Override
            public void afterTextChanged(Editable editable) {
            }

            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                if (i3 == 1) {
                    PartnerCouponCheckoutPage.this.partnerCouponPojo.setEnableApplyButton(true);
                } else if (i3 < 1) {
                    PartnerCouponCheckoutPage.this.partnerCouponPojo.setEnableApplyButton(false);
                }
            }
        });
    }

    private void setUserInfo(MintSubscriptionDetail mintSubscriptionDetail) {
        this.mintSubscriptionDetail = mintSubscriptionDetail;
        if (mintSubscriptionDetail == null) {
            this.mintSubscriptionDetail = new MintSubscriptionDetail();
        }
        this.mintSubscriptionDetail.setId(f0.G1(this, "userClient"));
        String G1 = f0.G1(this, "userName");
        this.mintSubscriptionDetail.setEmail(f0.F1(this));
        this.mintSubscriptionDetail.setSalutation("");
        if (TextUtils.isEmpty(G1)) {
            this.mintSubscriptionDetail.setDisplayName("");
            this.mintSubscriptionDetail.setFirstName("");
            this.mintSubscriptionDetail.setLastName("");
        } else {
            this.mintSubscriptionDetail.setDisplayName(G1);
            if (G1.contains(" ")) {
                String substring = G1.substring(G1.lastIndexOf(" "));
                if (!TextUtils.isEmpty(substring)) {
                    substring = substring.trim();
                }
                this.mintSubscriptionDetail.setFirstName(G1.substring(0, G1.lastIndexOf(" ")));
                this.mintSubscriptionDetail.setLastName(substring);
            } else {
                this.mintSubscriptionDetail.setFirstName(G1);
                this.mintSubscriptionDetail.setLastName(G1);
            }
        }
        String G12 = f0.G1(this, "userPhoneNumber");
        if (!TextUtils.isEmpty(G12) && !G12.contains("+")) {
            G12 = "+" + G12;
        }
        if (TextUtils.isEmpty(G12)) {
            this.mintSubscriptionDetail.setMobile("");
        } else {
            this.mintSubscriptionDetail.setMobile(G12);
        }
    }

    private void syncPaymentWithServer(MintSubscriptionDetail mintSubscriptionDetail, boolean z) {
        n.A(this, n.h1, "plan_page", n.t0, (Content) null, (String) null);
        WebEngageAnalytices.trackPaymentStatus(WebEngageAnalytices.PAYMENT_SUCESS, mintSubscriptionDetail, this.mintPlanWithZSPlan, null, this.funnelName, "", (z ? WebEngageAnalytices.PAYMENTSTORE.RAZOR_PAY : WebEngageAnalytices.PAYMENTSTORE.PLAY_STORE).getStore(), "Other", false);
        getIntent().putExtra("needSetPassword", SubscriptionPlanSingleton.getInstance().ismNeedToSetPassword());
        GetUserSubscriptionDetail.SyncSubscriptionAsyncTask syncSubscriptionAsyncTask = new GetUserSubscriptionDetail.SyncSubscriptionAsyncTask(this);
        syncSubscriptionAsyncTask.setUserSubscriptionStatus("new");
        syncSubscriptionAsyncTask.setSubsscreen(q.g0.f);
        if (z) {
            syncSubscriptionAsyncTask.setOrderId(this.orderId);
        }
        syncSubscriptionAsyncTask.setPaidPrice(0.0d);
        syncSubscriptionAsyncTask.setMintPlanWithZSPlan(this.mintPlanWithZSPlan);
        syncSubscriptionAsyncTask.setPaymentFromRzorPay(z);
        syncSubscriptionAsyncTask.execute(mintSubscriptionDetail);
    }

    private void syncSubscriptionSuccess(MintSubscriptionDetail mintSubscriptionDetail) {
        MintPlanWithZSPlan mintPlanWithZSPlan = this.mintPlanWithZSPlan;
        if (mintPlanWithZSPlan != null && mintPlanWithZSPlan.getSubsPlans() != null) {
            CheckSubscriptionFromLocal.updateAdFreeUserFromPlan(mintSubscriptionDetail, this.mintPlanWithZSPlan.getSubsPlans(), this);
        }
        syncPaymentWithServer(mintSubscriptionDetail, true);
    }

    private void validateUserSubscriptionAndInitatePayment(MintSubscriptionDetail mintSubscriptionDetail) {
        setUserInfo(mintSubscriptionDetail);
        if (mintSubscriptionDetail != null && mintSubscriptionDetail.isSubscriptionActive()) {
            AppController.j().V(mintSubscriptionDetail);
            f0.c4(this, mintSubscriptionDetail);
            this.partnerCouponPojo.setSubscriptionStatus(true);
        } else {
            this.partnerCouponPojo.setSubscriptionStatus(false);
            if (this.partnerCouponPojo.isValidCoupon()) {
                checkOut();
            } else {
                fetchPlanFromServer();
            }
        }
    }

    public void getMintPlan(MintPlan mintPlan) {
        convertMintPlanIntoZOHOPlan(mintPlan.getPlans().getPartnerPlan());
    }

    public void getMintServerPlan(MintServerPlan mintServerPlan) {
    }

    public void getPremiumPlan(SubscribeNowPerant subscribeNowPerant) {
    }

    @Override
    public void getUserSubscriptionDetail(MintSubscriptionDetail mintSubscriptionDetail) {
        validateUserSubscriptionAndInitatePayment(mintSubscriptionDetail);
    }

    protected void onActivityResult(int i, int i2, @Nullable Intent intent) {
        super/*androidx.fragment.app.FragmentActivity*/.onActivityResult(i, i2, intent);
        if (i == 1002 && i2 == -1) {
            openOnboardingFlow();
            return;
        }
        boolean z = false;
        if (i == 1003 && i2 == -1) {
            Intent intent2 = getIntent();
            if (intent2 != null && intent2.getExtras() != null && intent2.getExtras().containsKey("needSetPassword")) {
                z = intent2.getExtras().getBoolean("needSetPassword");
            }
            if (z) {
                Intent intent3 = new Intent((Context) this, (Class<?>) LoginRegisterActivity.class);
                intent3.putExtra("origin", "Subscription After");
                intent3.setFlags(603979776);
                startActivityForResult(intent3, PlanPageActivity.AFTER_SUBSCRIPTION_REQUEST);
                return;
            }
            if (f0.R0(this) == q.n.c) {
                openOnboardingFlow();
                return;
            }
            Intent intent4 = new Intent((Context) this, (Class<?>) LoginRegisterActivity.class);
            intent4.putExtra("origin", "Linking");
            intent4.putExtra("linkingType", f0.R0(this).ordinal());
            intent4.setFlags(603979776);
            startActivityForResult(intent4, PlanPageActivity.AFTER_SUBSCRIPTION_REQUEST);
            return;
        }
        if (i != SIGN_IN_REQUEST || i2 != -1) {
            if (i == 1004 && i2 == -1) {
                goBack();
                return;
            } else {
                if (i == 9002 && i2 == -1) {
                    goBack();
                    return;
                }
                return;
            }
        }
        if (intent != null && intent.hasExtra("isSignUp")) {
            boolean booleanExtra = intent.getBooleanExtra("isSignUp", false);
            getIntent().putExtra("needSetPassword", booleanExtra);
            SubscriptionPlanSingleton.getInstance().setmNeedToSetPassword(booleanExtra);
        }
        HashMap hashMap = new HashMap();
        String F1 = f0.F1(this);
        if (F1 != null) {
            hashMap.put("userEmail", F1);
        }
        if (f0.G1(this, "userName") != null) {
            hashMap.put("userName", f0.G1(this, "userName"));
        }
        if (hashMap.isEmpty()) {
            Toast.makeText((Context) this, (CharSequence) "Login Failed!, please try again", 0).show();
            goBack();
        } else {
            o0.i(hashMap);
            checkUserSubscriptionDetail();
        }
    }

    public void onBackPressed() {
        goBack();
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == 2131428883) {
            goBack();
            return;
        }
        if (id != 2131429611) {
            if (id != 2131431865) {
                return;
            }
            this.activityPartnerCouponBinding.a.setText("");
            this.partnerCouponPojo.setCouponFilled(false);
            this.partnerCouponPojo.setValidCoupon(false);
            this.partnerCouponPojo.setEnableApplyButton(true);
            this.activityPartnerCouponBinding.x.setText("");
            this.activityPartnerCouponBinding.x.setVisibility(8);
            this.activityPartnerCouponBinding.w.setText(String.format("You have won a %1$s free trial", ""));
            return;
        }
        if (this.partnerCouponPojo.isEnableApplyButton()) {
            if (TextUtils.isEmpty(this.activityPartnerCouponBinding.a.getText().toString())) {
                Toast.makeText((Context) this, (CharSequence) "Please enter coupon code", 0).show();
            } else if (this.partnerCouponPojo.isValidCoupon()) {
                checkOut();
            } else {
                onCouponApply(this.activityPartnerCouponBinding.a.getText().toString(), this.partnerPlanCode, this.partnerPlanType);
            }
        }
    }

    public void onConfigurationChanged(@NonNull Configuration configuration) {
        super/*androidx.appcompat.app.AppCompatActivity*/.onConfigurationChanged(configuration);
        AppController.e(getIntent(), this);
    }

    public void onCouponApply(String str, String str2, String str3) {
        this.partnerCouponCode = str;
        this.partnerCouponPojo.setCouponFilled(true);
        Config g = AppController.j().g();
        String str4 = (g.getRazorpay() != null ? g.getRazorpay().getCouponAPI() : "") + String.format("%1$s/IN?plan=%2$s", str, str2);
        if (!str4.startsWith("http")) {
            str4 = (g.getRazorpay() != null ? g.getRazorpay().getDomain() : "") + str4;
        }
        if (!TextUtils.isEmpty(str4)) {
            Uri.Builder buildUpon = Uri.parse(str4).buildUpon();
            buildUpon.appendQueryParameter("platform", "app");
            str4 = buildUpon.build().toString();
        }
        HashMap hashMap = new HashMap();
        hashMap.put("ProductId", getResources().getString(R.string.zs_product_id));
        hashMap.put("Content-Type", "application/json; charset=utf-8");
        new c1(this, this).a(4, "FetchCouponPlan", str4, hashMap, (JSONObject) null, false, true, true, str3);
    }

    protected void onCreate(Bundle bundle) {
        super/*androidx.fragment.app.FragmentActivity*/.onCreate(bundle);
        this.activityPartnerCouponBinding = (c2) DataBindingUtil.setContentView(this, R.layout.activity_partner_coupon);
        initVars();
        initJuspay();
        handlePartnerPages();
        setTextWatcher();
        setOnClickListner();
    }

    public void onCreateOrder(CreateOrder createOrder) {
        this.orderId = createOrder.getOrderId();
        String status = createOrder.getSubscription() != null ? createOrder.getSubscription().getStatus() : "";
        if (!TextUtils.isEmpty(this.orderId) || TextUtils.isEmpty(status) || !"live".equalsIgnoreCase(status)) {
            Toast.makeText((Context) this, (CharSequence) "", 1).show();
            return;
        }
        MintSubscriptionDetail parseCouponSubscriptionObject = ParseSubscriptionDetail.parseCouponSubscriptionObject(createOrder.getSubscription());
        Hostedpage hostedpage = createOrder.getHostedpage();
        this.orderId = hostedpage != null ? hostedpage.getHostedpageId() : "";
        syncSubscriptionSuccess(parseCouponSubscriptionObject);
    }

    public void onError(int i, String str) {
    }

    public void onError(String str) {
    }

    public void onError(String str, String str2) {
        this.partnerCouponPojo.setEnableApplyButton(false);
        this.partnerCouponPojo.setValidCoupon(false);
        this.activityPartnerCouponBinding.x.setVisibility(8);
        Toast.makeText((Context) this, (CharSequence) str2, 1).show();
    }

    @Override
    public void onSubscriptionError(SubscriptionError subscriptionError) {
        if (subscriptionError.getErrorCode() == ErrorCode.TOKEN_API_FAILED || subscriptionError.getErrorCode() == ErrorCode.UNKNOWN_ERROR) {
            Toast.makeText((Context) this, (CharSequence) "Something went wrong. Please try later.", 0).show();
        } else if (subscriptionError.getErrorCode() == ErrorCode.ITEM_ALREADY_PURCHASED) {
            Toast.makeText((Context) this, (CharSequence) ZSErrorCodeHandling.ZSErrorCodeMessages.PURCHASE_ALREADY_PROCESSED, 1).show();
        }
        this.partnerCouponPojo.setSubscriptionStatus(false);
        o0.e(subscriptionError.getErrorCode().name(), subscriptionError.getMessage(), getClass().getName());
    }

    public void openLoginPage() {
        Intent intent = new Intent((Context) this, (Class<?>) LoginRegisterActivity.class);
        intent.putExtra("origin", "Subscription Funnel");
        intent.putExtra("isDiscountCoupon", true);
        intent.setFlags(603979776);
        startActivityForResult(intent, SIGN_IN_REQUEST);
    }

    public boolean startCheckout() {
        Config g = AppController.j().g();
        if (!SubscriptionConverter.isJuspayEnable(g)) {
            return false;
        }
        if (this.juspayCheckout == null) {
            initJuspay();
        }
        JuspayCheckout juspayCheckout = this.juspayCheckout;
        if (juspayCheckout == null) {
            return false;
        }
        juspayCheckout.u(this, SubscriptionConverter.isJuspayAutoRecurring(g), this.mintPlanWithZSPlan);
        return true;
    }
}