正在查看: Mint v5.7.3 应用的 JuspayCheckout.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Mint v5.7.3 应用的 JuspayCheckout.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.htmedia.mint.juspay;
import android.app.ProgressDialog;
import android.content.Context;
import android.text.TextUtils;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
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.GetUserSubscriptionDetail;
import com.htmedia.mint.htsubscription.MSError;
import com.htmedia.mint.htsubscription.ParseSubscriptionDetail;
import com.htmedia.mint.htsubscription.SnowplowSubscriptionAnalytices;
import com.htmedia.mint.htsubscription.SubscriptionConverter;
import com.htmedia.mint.htsubscription.SubscriptionPlanSingleton;
import com.htmedia.mint.htsubscription.WebEngageAnalytices;
import com.htmedia.mint.htsubscription.subsutils.RenewalAppConstant;
import com.htmedia.mint.piano.PianoResponse;
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.razorpay.CreateOrder;
import com.htmedia.mint.pojo.razorpay.Hostedpage;
import com.htmedia.mint.pojo.subscription.plandetail.htapi.MintPlanWithZSPlan;
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.OrderCreatePresenterInterface;
import com.htmedia.mint.razorpay.presenter.OrderCreateViewInterface;
import com.htmedia.mint.razorpay.presenter.PaymentValidationPresenter;
import com.htmedia.mint.razorpay.presenter.PaymentValidationPresenterInterface;
import com.htmedia.mint.razorpay.presenter.PaymentValidationViewInterface;
import com.htmedia.mint.utils.f0;
import com.htmedia.mint.utils.n;
import com.htmedia.mint.utils.o1;
import com.htmedia.mint.utils.q;
import com.zoho.zsm.inapppurchase.model.ZSError;
import com.zoho.zsm.inapppurchase.model.ZSPlan;
import f6.d;
import in.juspay.hyperinteg.HyperServiceHolder;
import in.juspay.hypersdk.ui.HyperPaymentsCallbackAdapter;
import java.util.HashMap;
import java.util.UUID;
import n4.b;
import n4.e;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class JuspayCheckout implements OrderCreateViewInterface, PaymentValidationViewInterface {
private AppCompatActivity a;
private SubsPlans c;
private MintPlanWithZSPlan d;
private MintSubscriptionDetail e;
private q.g0 f;
private ProgressDialog g;
private OrderCreatePresenterInterface h;
private PaymentValidationPresenterInterface i;
private String j;
private Content p;
private String q;
private boolean t;
private boolean u;
private HyperServiceHolder v;
private final boolean x;
private ZSPlan y;
private double z;
private String b = "https://www.livemint.com";
private int o = 0;
private String r = "";
private String s = "";
private String w = "";
class a extends HyperPaymentsCallbackAdapter {
a() {
}
public void onEvent(org.json.JSONObject r10, in.juspay.hypersdk.data.JuspayResponseHandler r11) {
throw new UnsupportedOperationException("Method not decompiled: com.htmedia.mint.juspay.JuspayCheckout.a.onEvent(org.json.JSONObject, in.juspay.hypersdk.data.JuspayResponseHandler):void");
}
}
public JuspayCheckout(AppCompatActivity appCompatActivity, boolean z) {
this.a = appCompatActivity;
this.x = z;
n(appCompatActivity);
}
public JuspayCheckout(AppCompatActivity appCompatActivity, boolean z, boolean z2) {
this.a = appCompatActivity;
this.t = z;
this.x = z2;
n(appCompatActivity);
}
private HyperPaymentsCallbackAdapter e() {
return new a();
}
private JSONObject f() {
JSONObject jSONObject = new JSONObject();
JSONObject jSONObject2 = new JSONObject();
try {
jSONObject2.put("action", "initiate");
jSONObject2.put("merchantId", "livemint");
jSONObject2.put("clientId", "livemint");
jSONObject2.put("environment", "production");
jSONObject.put("requestId", "" + UUID.randomUUID());
jSONObject.put("service", "in.juspay.hyperpay");
jSONObject.put("payload", jSONObject2);
} catch (Exception e) {
e.printStackTrace();
}
return jSONObject;
}
private void g() {
String str;
SubsPlans subsPlans = this.c;
if (subsPlans == null || TextUtils.isEmpty(subsPlans.getPlanCode()) || this.e == null) {
return;
}
try {
JSONObject jSONObject = new JSONObject();
JSONObject jSONObject2 = new JSONObject();
String mobile = this.e.getMobile();
if (!TextUtils.isEmpty(mobile) && mobile.contains("+")) {
mobile = mobile.replace("+", "").trim();
}
jSONObject2.put("mobile", mobile);
jSONObject2.put("displayName", this.e.getDisplayName());
jSONObject2.put("salutation", this.e.getSalutation());
jSONObject2.put("firstName", this.e.getFirstName());
jSONObject2.put("lastName", this.e.getLastName());
jSONObject2.put("email", this.e.getEmail());
jSONObject2.put("id", this.e.getId());
jSONObject2.put("lastAccessUrl", this.b);
if (this.f == q.g0.e) {
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("platform", "Android");
jSONObject3.put("device_id", d.b(this.a));
jSONObject3.put("device_type", "Android");
jSONObject2.put("device_details", jSONObject3);
jSONObject.put("creationMode", "campaign");
}
if (this.p == null) {
this.p = SubscriptionPlanSingleton.getInstance().getContent();
}
Content content = this.p;
if (content != null && content.getMetadata() != null && !TextUtils.isEmpty(this.p.getMetadata().getUrl())) {
jSONObject.put("articleUrl", this.p.getMetadata().getUrl());
}
if (!TextUtils.isEmpty(this.r)) {
jSONObject.put("transactionPlatform", this.r);
}
jSONObject.put("platformSource", "Android");
jSONObject.put("source", "LM");
String i = i();
jSONObject.put("action", i);
String j = j(i);
if (!TextUtils.isEmpty(j)) {
jSONObject.put("orderType", j);
}
jSONObject.put("userAgent", "LM Android App");
if (!TextUtils.isEmpty(WebEngageAnalytices.VALUE_CAMPAIGN_SOURCE)) {
jSONObject.put("utmSource", WebEngageAnalytices.VALUE_CAMPAIGN_SOURCE);
}
if (!TextUtils.isEmpty(WebEngageAnalytices.VALUE_CAMPAIGN_MEDIUM)) {
jSONObject.put("utmMedium", WebEngageAnalytices.VALUE_CAMPAIGN_MEDIUM);
}
if (!TextUtils.isEmpty(WebEngageAnalytices.VALUE_CAMPAIGN_NAME)) {
jSONObject.put("utmCampaign", WebEngageAnalytices.VALUE_CAMPAIGN_NAME);
}
jSONObject.put("customer", jSONObject2);
if (SubscriptionConverter.isSubscriptionUpgradeOrRenewal(this.f)) {
jSONObject.put("subscriptionId", this.e.getSubscriptionID());
}
jSONObject.put("planCode", this.c.getPlanCode());
if (this.d.isCouponApplied()) {
jSONObject.put("couponCode", this.d.getCouponCode());
}
jSONObject.put("recurring", this.t ? 1 : 0);
jSONObject.put(RemoteConfigConstants.RequestFieldKey.COUNTRY_CODE, "IN");
jSONObject.put("city", "others");
jSONObject.put("platform", "Android");
jSONObject.put("sourcePlatform", "ANDROID_JUSPAY");
jSONObject.put("paymentSource", "Juspay");
jSONObject.put("paymentGateway", "JUSPAY");
JSONArray jSONArray = new JSONArray();
JSONObject jSONObject4 = new JSONObject();
jSONObject4.put("gatewayName", "Juspay");
jSONObject4.put("paymentGateway", "Juspay");
jSONArray.put(jSONObject4);
jSONObject.put("paymentGateways", jSONArray);
jSONObject.put("redirectionUrl", "https://www.livemint.com");
String generateToken = JWTTokenBuilder.generateToken(this.e.getId() + "~" + this.e.getEmail());
HashMap hashMap = new HashMap();
hashMap.put("ProductId", this.a.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 (SubscriptionConverter.isSubscriptionUpgradeOrRenewal(this.f)) {
orderid = razorpay != null ? razorpay.getChangeplan() : "";
}
if (orderid.startsWith("http")) {
str = orderid;
} else {
str = domain + orderid;
}
if (SubscriptionConverter.isSubscriptionNew(this.f)) {
this.h.createOrder(1, "OrderApi", str, jSONObject, hashMap, false, false);
} else if (SubscriptionConverter.isSubscriptionUpgradeOrRenewal(this.f)) {
this.h.createOrder(4, "ChangePlan", str, jSONObject, hashMap, false, false);
}
} catch (JSONException e) {
o1.b("TAG", "createOrderRequest: " + e, e);
}
}
private String i() {
MintPlanWithZSPlan mintPlanWithZSPlan;
q.g0 g0Var = this.f;
if (g0Var == q.g0.e || g0Var == q.g0.f) {
return "trial";
}
if (g0Var == q.g0.a && (mintPlanWithZSPlan = this.d) != null && mintPlanWithZSPlan.isTrialCoupon() && this.d.isCouponApplied()) {
return TextUtils.isEmpty(this.d.getDiscountType()) ? "trial" : this.d.getDiscountType();
}
q.g0 g0Var2 = this.f;
if (g0Var2 == q.g0.b) {
return "change";
}
if (g0Var2 != q.g0.c) {
return g0Var2 == q.g0.g ? "upgrade" : "subscribe";
}
MintSubscriptionDetail mintSubscriptionDetail = this.e;
return (mintSubscriptionDetail == null || !mintSubscriptionDetail.isSubscriptionActive()) ? "post_expiry" : "advance_renew";
}
private String j(String str) {
return !TextUtils.isEmpty(str) ? (str.equalsIgnoreCase("post_expiry") || str.equalsIgnoreCase("advance_renew")) ? "Android Renewal" : (str.equalsIgnoreCase("change") || str.equalsIgnoreCase("upgrade")) ? "Android Upgrade" : str.equalsIgnoreCase("trial") ? "Android Trial" : "Android Fresh" : "";
}
private void k(MintPlanWithZSPlan mintPlanWithZSPlan) {
MintPlanWithZSPlan mintPlanWithZSPlan2 = SubscriptionPlanSingleton.getInstance().getMintPlanWithZSPlan();
this.d = mintPlanWithZSPlan2;
if (mintPlanWithZSPlan2 == null && mintPlanWithZSPlan != null) {
this.d = mintPlanWithZSPlan;
}
MintPlanWithZSPlan mintPlanWithZSPlan3 = this.d;
if (mintPlanWithZSPlan3 != null) {
this.c = mintPlanWithZSPlan3.getSubsPlans();
this.y = this.d.getZsPlan();
}
}
private String l() {
q.g0 g0Var = this.f;
return (g0Var == q.g0.a || g0Var == q.g0.d || g0Var == q.g0.e || g0Var == q.g0.f) ? "new" : g0Var == q.g0.b ? "upgraded" : g0Var == q.g0.c ? "advance_renew" : "";
}
private void m() {
this.b = TextUtils.isEmpty(SubscriptionPlanSingleton.getInstance().getLastAccessUrl()) ? this.b : SubscriptionPlanSingleton.getInstance().getLastAccessUrl();
this.r = SubscriptionPlanSingleton.getInstance().getFunnelName();
this.q = SubscriptionPlanSingleton.getInstance().getPremiumStory();
this.f = SubscriptionPlanSingleton.getInstance().getSubsscreen();
this.s = SubscriptionPlanSingleton.getInstance().getPianoExpName();
}
private void n(AppCompatActivity appCompatActivity) {
if (this.a == null) {
this.a = appCompatActivity;
}
this.v = new HyperServiceHolder(appCompatActivity);
q(appCompatActivity);
}
private void p() {
ProgressDialog progressDialog = this.g;
if (progressDialog != null && !progressDialog.isShowing()) {
this.g.show();
return;
}
if (this.g == null) {
ProgressDialog progressDialog2 = new ProgressDialog(this.a);
this.g = progressDialog2;
progressDialog2.setMessage("Please wait...!");
this.g.setCancelable(false);
if (this.g.isShowing()) {
return;
}
this.g.show();
}
}
private void q(AppCompatActivity appCompatActivity) {
if (this.v == null) {
n(appCompatActivity);
}
HyperServiceHolder hyperServiceHolder = this.v;
if (hyperServiceHolder == null || hyperServiceHolder.isInitialised()) {
return;
}
this.v.initiate(f());
}
private void s() {
MintSubscriptionDetail mintSubscriptionDetail = SubscriptionPlanSingleton.getInstance().getMintSubscriptionDetail();
this.e = mintSubscriptionDetail;
if (mintSubscriptionDetail == null) {
this.e = new MintSubscriptionDetail();
}
this.e.setId(f0.G1(this.a, "userClient"));
String G1 = f0.G1(this.a, "userName");
this.e.setEmail(f0.F1(this.a));
this.e.setSalutation("");
if (TextUtils.isEmpty(G1)) {
this.e.setDisplayName("");
this.e.setFirstName("");
this.e.setLastName("");
} else {
this.e.setDisplayName(G1);
if (G1.contains(" ")) {
String substring = G1.substring(G1.lastIndexOf(" "));
if (!TextUtils.isEmpty(substring)) {
substring = substring.trim();
}
this.e.setFirstName(G1.substring(0, G1.lastIndexOf(" ")));
this.e.setLastName(substring);
} else {
this.e.setFirstName(G1);
this.e.setLastName(G1);
}
}
String G12 = f0.G1(this.a, "userPhoneNumber");
if (!TextUtils.isEmpty(G12) && !G12.contains("+")) {
G12 = "+" + G12;
}
if (TextUtils.isEmpty(G12)) {
this.e.setMobile("");
} else {
this.e.setMobile(G12);
}
}
private void t() {
String planName;
SubsPlans subsPlans;
MintSubscriptionDetail l = AppController.j().l();
if (l == null) {
RenewalAppConstant.eventLabele4Value = "fresh";
RenewalAppConstant.planNameBeforeRenewal = "";
} else {
if (l.getCreatedAt() == null) {
RenewalAppConstant.eventLabele4Value = "fresh";
RenewalAppConstant.planNameBeforeRenewal = "";
} else {
RenewalAppConstant.eventLabele4Value = "renewal";
if (TextUtils.isEmpty(l.getPlanDescription())) {
StringBuilder sb = new StringBuilder();
sb.append(" ");
sb.append(l);
planName = (sb.toString() == null || TextUtils.isEmpty(l.getPlanName())) ? "" : l.getPlanName();
} else {
planName = l.getPlanDescription();
}
RenewalAppConstant.planNameBeforeRenewal = planName;
RenewalAppConstant.subscriptionNumber = !TextUtils.isEmpty(l.getSubscriptionNumber()) ? l.getSubscriptionNumber() : "";
}
RenewalAppConstant.amountPaidBeforePlan = l.getUpgradedPlanActualPrice();
}
MintPlanWithZSPlan mintPlanWithZSPlan = SubscriptionPlanSingleton.getInstance().getMintPlanWithZSPlan();
if (mintPlanWithZSPlan == null || (subsPlans = mintPlanWithZSPlan.getSubsPlans()) == null) {
return;
}
String renewalDiscount = subsPlans.getPlanDiscount() != null ? subsPlans.getPlanDiscount().getRenewalDiscount() : "0";
if (TextUtils.isEmpty(renewalDiscount)) {
RenewalAppConstant.renewalDiscountForBE = "0";
} else {
RenewalAppConstant.renewalDiscountForBE = renewalDiscount;
}
RenewalAppConstant.renewalExpiryPeriod = l != null ? e.b(l) : "";
double recurringPrice = subsPlans.getRecurringPrice();
String planCode = subsPlans.getPlanCode();
if (l != null) {
RenewalAppConstant.renewalType = e.g(planCode, l.getPlanCode(), l.getRecurringPrice(), recurringPrice);
}
}
private void w(MintSubscriptionDetail mintSubscriptionDetail, boolean z, String str, boolean z2) {
h();
MintPlanWithZSPlan mintPlanWithZSPlan = this.d;
if (mintPlanWithZSPlan != null) {
mintPlanWithZSPlan.setOrderId(this.j);
}
Content content = this.r.equalsIgnoreCase(WebEngageAnalytices.SUBSCRIPTION_POP_UP) ? SubscriptionPlanSingleton.getInstance().getContent() : null;
f5.a.e(this.a, "payment_success", f5.a.d, f5.a.f, content, null);
q.g0 g0Var = this.f;
if (g0Var != null && g0Var == q.g0.e) {
b.N("campaign_subs_success", true, this.z, mintSubscriptionDetail, this.d, null, this.r, "", (z ? WebEngageAnalytices.PAYMENTSTORE.JUSPAY : WebEngageAnalytices.PAYMENTSTORE.PLAY_STORE).getStore());
n.A(this.a, n.n1, "plan_page", n.t0, content, (String) null);
} else if (g0Var != null && g0Var == q.g0.c) {
if (this.p == null) {
this.p = SubscriptionPlanSingleton.getInstance().getContent();
}
e.h("payment_success", this.p, this.r, mintSubscriptionDetail, this.d);
} else if (this.x) {
if (this.p == null) {
this.p = SubscriptionPlanSingleton.getInstance().getContent();
}
e.h("payment_success", this.p, this.r, mintSubscriptionDetail, this.d);
} else {
WebEngageAnalytices.trackPaymentStatus(g0Var == q.g0.b ? WebEngageAnalytices.CHANGE_PLAN_PAYMENT_SUCESS : WebEngageAnalytices.PAYMENT_SUCESS, mintSubscriptionDetail, this.d, null, this.r, this.q, (z ? WebEngageAnalytices.PAYMENTSTORE.JUSPAY : WebEngageAnalytices.PAYMENTSTORE.PLAY_STORE).getStore(), str, !z || z2);
n.A(this.a, n.h1, "plan_page", n.t0, content, (String) null);
}
this.a.getIntent().putExtra("needSetPassword", SubscriptionPlanSingleton.getInstance().ismNeedToSetPassword());
GetUserSubscriptionDetail.SyncSubscriptionAsyncTask syncSubscriptionAsyncTask = new GetUserSubscriptionDetail.SyncSubscriptionAsyncTask(this.a);
if (!TextUtils.isEmpty(this.q)) {
syncSubscriptionAsyncTask.setPremiumStory(this.q);
}
if (!TextUtils.isEmpty(this.r)) {
syncSubscriptionAsyncTask.setFunnelEntry(this.r);
}
syncSubscriptionAsyncTask.setZsPlan(this.y);
syncSubscriptionAsyncTask.setPianoExp(this.s);
q.g0 g0Var2 = this.f;
if (g0Var2 != null && (g0Var2 == q.g0.a || g0Var2 == q.g0.d || g0Var2 == q.g0.e || g0Var2 == q.g0.f)) {
syncSubscriptionAsyncTask.setUserSubscriptionStatus("new");
} else if (g0Var2 != null && (g0Var2 == q.g0.b || g0Var2 == q.g0.g)) {
syncSubscriptionAsyncTask.setUserSubscriptionStatus("upgraded");
} else if (g0Var2 != null && g0Var2 == q.g0.c) {
syncSubscriptionAsyncTask.setUserSubscriptionStatus("advance_renew");
}
syncSubscriptionAsyncTask.setSubsscreen(this.f);
q.g0 g0Var3 = this.f;
if (g0Var3 != null && (g0Var3 == q.g0.e || g0Var3 == q.g0.f)) {
syncSubscriptionAsyncTask.setPaidPrice(this.z);
}
if (z) {
syncSubscriptionAsyncTask.setOrderId(this.j);
}
syncSubscriptionAsyncTask.setMintPlanWithZSPlan(this.d);
syncSubscriptionAsyncTask.setPaymentFromRzorPay(z);
syncSubscriptionAsyncTask.execute(mintSubscriptionDetail);
}
private void x(MintSubscriptionDetail mintSubscriptionDetail, String str) {
q.g0 g0Var;
MintPlanWithZSPlan mintPlanWithZSPlan = this.d;
if (mintPlanWithZSPlan != null && mintPlanWithZSPlan.getSubsPlans() != null && ((g0Var = this.f) == q.g0.a || g0Var == q.g0.c || g0Var == q.g0.d || g0Var == q.g0.e || g0Var == q.g0.f)) {
CheckSubscriptionFromLocal.updateAdFreeUserFromPlan(mintSubscriptionDetail, this.d.getSubsPlans(), this.a);
}
w(mintSubscriptionDetail, true, str, SubscriptionConverter.isPlanAutoRenew(mintSubscriptionDetail));
}
private void y(boolean z, String str, String str2, String str3, String str4) {
String str5;
p();
try {
JSONObject jSONObject = new JSONObject();
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("email", this.e.getEmail());
jSONObject2.put("id", this.e.getId());
jSONObject.put("customer", jSONObject2);
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("razorpay_order_id", str4);
if (z) {
jSONObject3.put("status", "payment_captured");
jSONObject3.put("razorpay_payment_id", "");
jSONObject3.put("signature", "");
} else {
jSONObject3.put("status", "payment_failed");
jSONObject3.put("description", str2);
jSONObject3.put("reason", str);
jSONObject3.put("code", str3);
}
JSONObject jSONObject4 = new JSONObject();
jSONObject4.put("platform", "Android");
String s = AppController.j().s();
if (TextUtils.isEmpty(s)) {
s = "_ABTestGroup_COOKIE_NOT_FOUND";
}
jSONObject4.put("vendor", s);
jSONObject4.put("paywallReason", this.q);
jSONObject4.put("userSubscriptionStatus", l());
jSONObject4.put("userLoggedInStatus", WebEngageAnalytices.getUserState());
jSONObject4.put("funnelEntry", this.r);
jSONObject4.put("experiment1", this.s);
if (TextUtils.isEmpty(WebEngageAnalytices.VALUE_CAMPAIGN_NAME)) {
jSONObject4.put("campaignName", "");
} else {
jSONObject4.put("campaignName", WebEngageAnalytices.VALUE_CAMPAIGN_NAME);
}
if (TextUtils.isEmpty(WebEngageAnalytices.VALUE_CAMPAIGN_SOURCE)) {
jSONObject4.put("campaignSource", "");
} else {
jSONObject4.put("campaignSource", WebEngageAnalytices.VALUE_CAMPAIGN_SOURCE);
}
if (TextUtils.isEmpty(WebEngageAnalytices.VALUE_CAMPAIGN_MEDIUM)) {
jSONObject4.put("campaignMedium", "");
} else {
jSONObject4.put("campaignMedium", WebEngageAnalytices.VALUE_CAMPAIGN_MEDIUM);
}
String ltsPiano = PianoResponse.getLtsPiano();
if (!TextUtils.isEmpty(ltsPiano)) {
jSONObject4.put("pianoLTS", ltsPiano);
}
JSONObject jSONObject5 = new JSONObject();
jSONObject5.put("eventData", jSONObject4);
jSONObject5.put("customerId", this.e.getId());
jSONObject5.put("email", this.e.getEmail());
jSONObject.put("subscriptionEvent", jSONObject5);
jSONObject3.put("gateway", "Juspay");
jSONObject.put("payment", jSONObject3);
jSONObject.put("paymentGateway", "JUSPAY");
jSONObject.put("order_id", str4);
String generateToken = JWTTokenBuilder.generateToken(this.e.getId() + "~" + this.e.getEmail());
HashMap hashMap = new HashMap();
hashMap.put("ProductId", this.a.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 validatepayment = razorpay != null ? razorpay.getValidatepayment() : "";
if (validatepayment.startsWith("http")) {
str5 = validatepayment;
} else {
str5 = domain + validatepayment;
}
this.i.checkPayment(1, "OrderApi", str5, this.f, this.c, jSONObject, hashMap, false, false);
} catch (JSONException unused) {
}
}
public void h() {
try {
ProgressDialog progressDialog = this.g;
if (progressDialog != null && progressDialog.isShowing()) {
this.g.dismiss();
}
} catch (IllegalArgumentException unused) {
} catch (Throwable th2) {
this.g = null;
throw th2;
}
this.g = null;
}
public void o(AppCompatActivity appCompatActivity) {
if (this.a == null) {
this.a = appCompatActivity;
}
if (this.v == null) {
n(appCompatActivity);
}
HyperServiceHolder hyperServiceHolder = this.v;
if (hyperServiceHolder != null) {
hyperServiceHolder.setCallback(e());
}
}
public void onCreateOrder(CreateOrder createOrder) {
h();
String message = createOrder.getMessage();
JSONObject sdkPayload = createOrder.getSdkPayload();
if (sdkPayload == null) {
if (SubscriptionConverter.isSubscriptionUpgradeOrRenewal(this.f)) {
return;
}
String status = createOrder.getSubscription() != null ? createOrder.getSubscription().getStatus() : "";
if (TextUtils.isEmpty(status) || !"live".equalsIgnoreCase(status)) {
Toast.makeText((Context) this.a, (CharSequence) message, 1).show();
return;
}
MintSubscriptionDetail parseCouponSubscriptionObject = ParseSubscriptionDetail.parseCouponSubscriptionObject(createOrder.getSubscription());
Hostedpage hostedpage = createOrder.getHostedpage();
this.j = hostedpage != null ? hostedpage.getHostedpageId() : "";
x(parseCouponSubscriptionObject, "Unknow");
return;
}
MintPlanWithZSPlan mintPlanWithZSPlan = this.d;
double recurringPrice = (mintPlanWithZSPlan == null || !mintPlanWithZSPlan.isCouponApplied()) ? this.c.getRecurringPrice() : this.d.getDiscountPrice();
if (createOrder.getSubscription() != null && createOrder.getSubscription().getPlan() != null) {
recurringPrice = createOrder.getSubscription().getPlan().getPrice();
}
this.d.setTrialDaysDiscountPrice(this.c.getCurrencySymbol() + ((int) recurringPrice));
String juspayOrderId = createOrder.getJuspayOrderId();
this.j = juspayOrderId;
v(juspayOrderId, sdkPayload);
}
public void onError(int i, String str) {
onError(str);
}
public void onError(String str) {
h();
if (this.u) {
return;
}
Toast.makeText((Context) this.a, (CharSequence) str, 0).show();
}
public void onPaymentError(String str, String str2, String str3, String str4, String str5, boolean z) {
MSError mSError = new MSError();
mSError.setCode(str + "");
mSError.setMessage(str2);
WebEngageAnalytices.trackPaymentStatus(this.f == q.g0.b ? WebEngageAnalytices.CHANGE_PLAN_PAYMENT_FAILED : WebEngageAnalytices.PAYMENT_FAILED, null, this.d, mSError, this.r, this.q, WebEngageAnalytices.PAYMENTSTORE.JUSPAY.getStore(), str5, z);
MintPlanWithZSPlan mintPlanWithZSPlan = SubscriptionPlanSingleton.getInstance().getMintPlanWithZSPlan();
if (mintPlanWithZSPlan != null && mintPlanWithZSPlan.getSubsPlans() != null && mintPlanWithZSPlan.getSubsPlans().getPlanType() != null) {
String planType = mintPlanWithZSPlan.getSubsPlans().getPlanType();
if (SubscriptionConverter.PLAN_CATEGORY.MINT.getPlanCategory().equalsIgnoreCase(planType)) {
n.x(this.a, n.i1, "plan_page", n.u0, this.p, (String) null, mSError, (ZSError) null);
} else if (SubscriptionConverter.PLAN_CATEGORY.WSJ.getPlanCategory().equalsIgnoreCase(planType)) {
n.x(this.a, n.j1, "plan_page", n.u0, this.p, (String) null, mSError, (ZSError) null);
} else if (SubscriptionConverter.PLAN_CATEGORY.ECO.getPlanCategory().equalsIgnoreCase(planType)) {
n.x(this.a, n.m1, "plan_page", n.u0, this.p, (String) null, mSError, (ZSError) null);
} else if (SubscriptionConverter.PLAN_CATEGORY.BARRONS.getPlanCategory().equalsIgnoreCase(planType)) {
n.x(this.a, n.k1, "plan_page", n.u0, this.p, (String) null, mSError, (ZSError) null);
} else if (SubscriptionConverter.PLAN_CATEGORY.WSJ_BARRONS.getPlanCategory().equalsIgnoreCase(planType)) {
n.x(this.a, n.l1, "plan_page", n.u0, this.p, (String) null, mSError, (ZSError) null);
}
}
y(false, str3, str2, str, str4);
if (this.u) {
w9.e eVar = new w9.e();
eVar.b("Payment_Status", SnowplowSubscriptionAnalytices.PAYMENT_FAILED);
eVar.b("Payment_Method", TextUtils.isEmpty(this.w) ? "" : this.w);
eVar.b("Payment Source", "Juspay");
eVar.b("Platform", "Android");
eVar.b("Domain", "LM");
eVar.b("Failed_Reason", n.s0(str2, 100));
b.w("Autopay Setup Status", eVar);
}
}
public void onPaymentSuccess(String str, String str2) {
if (this.u) {
w9.e eVar = new w9.e();
eVar.b("Payment_Status", SnowplowSubscriptionAnalytices.PAYMENT_SUCCESS);
eVar.b("Payment_Method", this.w);
eVar.b("Payment Source", "Juspay");
eVar.b("Platform", "Android");
eVar.b("Domain", "LM");
b.w("Autopay Setup Status", eVar);
f0.L3(this.a, "Congratulations, you've now claimed " + this.o + "% discount on your next auto-debit");
}
y(true, str, "", "", str2);
}
public void paymentSuccess(MintSubscriptionDetail mintSubscriptionDetail) {
x(mintSubscriptionDetail, this.w);
}
public boolean r() {
HyperServiceHolder hyperServiceHolder = this.v;
if (hyperServiceHolder != null) {
return hyperServiceHolder.onBackPressed();
}
return false;
}
public void u(AppCompatActivity appCompatActivity, boolean z, MintPlanWithZSPlan mintPlanWithZSPlan) {
this.a = appCompatActivity;
this.t = z;
this.h = new OrderCreatePresenter(appCompatActivity, this);
this.i = new PaymentValidationPresenter(appCompatActivity, this);
m();
s();
k(mintPlanWithZSPlan);
t();
g();
p();
}
public void v(String str, JSONObject jSONObject) {
try {
HyperServiceHolder hyperServiceHolder = this.v;
if (hyperServiceHolder != null) {
hyperServiceHolder.process(jSONObject);
}
} catch (Exception e) {
Toast.makeText((Context) this.a, (CharSequence) ("Error in payment: " + e.getMessage()), 0).show();
e.printStackTrace();
}
}
}