正在查看: Biko v2.0.23 应用的 CheckoutPresenterImpl.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Biko v2.0.23 应用的 CheckoutPresenterImpl.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.razorpay;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.ParcelFileDescriptor;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.webkit.WebView;
import androidx.core.app.ActivityCompat;
import com.google.android.gms.auth.api.phone.SmsRetriever;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.tasks.Task;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.messaging.Constants;
import com.razorpay.AnalyticsProperty;
import com.razorpay.CheckoutBridge;
import com.razorpay.CheckoutPresenterImpl;
import com.razorpay.CheckoutUtils;
import com.razorpay.b;
import com.razorpay.c;
import com.stripe.android.core.networking.AnalyticsFields;
import com.stripe.android.core.networking.AnalyticsRequestV2Factory;
import com.stripe.android.core.networking.NetworkConstantsKt;
import com.stripe.android.core.networking.RequestHeadersFactory;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import org.apache.commons.sudcompress.utils.CharsetNames;
import org.json.JSONException;
import org.json.JSONObject;
class CheckoutPresenterImpl implements CheckoutInteractor, CheckoutPresenter {
protected Activity activity;
private AutoReadOtpHelper autoReadOtpHelper;
private long checkoutLoadStartAt;
O_$v$ checkoutOptions;
private String checkoutUrl;
private boolean clearHistory;
private String dashOptions;
private JSONObject dashOptionsJSON;
private Task<Void> loginOtpSmsTask;
String merchantKey;
private long preloadAbortDuration;
private long preloadCompleteDuration;
protected CheckoutView view;
private String checkoutContent = "{}";
private int paymentAttempts = 0;
private boolean isPaymentSuccessful = false;
private boolean isTwoWebViewFlow = false;
private boolean isMagic = false;
private int merchantLogoResourceId = 0;
private boolean isActivityCreated = false;
private boolean sendSmsHash = false;
private boolean allowRotation = false;
private String sanitizedChallanEncodedString = "";
private String payment_id = null;
private F_$o_ magicBase = null;
private BroadcastReceiver otpAutoReadBroadcast = new BroadcastReceiver() {
@Override
public final void onReceive(Context context, Intent intent) {
BroadcastReceiver broadcastReceiver;
Activity activity = CheckoutPresenterImpl.this.activity;
broadcastReceiver = CheckoutPresenterImpl.this.otpAutoReadBroadcast;
activity.unregisterReceiver(broadcastReceiver);
if ("com.google.android.gms.auth.api.phone.SMS_RETRIEVED".equals(intent.getAction())) {
Bundle extras = intent.getExtras();
int statusCode = ((Status) extras.get("com.google.android.gms.auth.api.phone.EXTRA_STATUS")).getStatusCode();
if (statusCode != 0) {
if (statusCode != 15) {
return;
}
AnalyticsUtil.trackEvent(AnalyticsEvent.AUTO_READ_OTP_SMS_RETRIEVER_API_TIMEOUT);
} else {
String str = (String) extras.get("com.google.android.gms.auth.api.phone.EXTRA_SMS_MESSAGE");
Intent intent2 = new Intent();
intent2.putExtra("com.google.android.gms.auth.api.phone.EXTRA_SMS_MESSAGE", str);
CheckoutPresenterImpl.this.onActivityResultReceived(1001, -1, intent2);
}
}
}
};
Queue<String> checkoutMessageQueue = new LinkedList();
private boolean isCheckoutLoaded = false;
interface CheckoutView {
void addJavascriptInterfaceToPrimaryWebview(Object obj, String str);
void checkSmsPermission();
void clearWebViewHistory(int i);
void destroy(int i, String str);
WebView getWebView(int i);
void hideProgressBar();
boolean isWebViewVisible(int i);
void loadData(int i, String str, String str2, String str3);
void loadDataWithBaseURL(int i, String str, String str2, String str3, String str4, String str5);
void loadUrl(int i, String str);
void makeWebViewVisible(int i);
void showProgressBar(int i);
void showToast(String str, int i);
}
protected void helpersReset() {
}
@Override
public boolean isMagicPresent() {
return false;
}
@Override
public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
}
@Override
public void relay(String str) {
}
@Override
public void requestOtpPermission() {
}
public CheckoutPresenterImpl(Activity activity, CheckoutView checkoutView) {
this.activity = activity;
this.view = checkoutView;
}
@Override
public boolean setOptions(Bundle bundle, boolean z) {
this.isActivityCreated = z;
if (bundle == null) {
destroyActivity(0, this.activity.getResources().getString(R.string.activity_result_invalid_parameters));
return false;
}
O_$v$ o_$v$ = new O_$v$(bundle.getString("OPTIONS"));
this.checkoutOptions = o_$v$;
JSONObject d = o_$v$.d();
if (d.has("retry")) {
g$_H$.a().a(d);
}
this.merchantKey = this.checkoutOptions.a();
this.sendSmsHash = this.checkoutOptions.b();
this.allowRotation = this.checkoutOptions.c();
int i = bundle.getInt("IMAGE", 0);
this.merchantLogoResourceId = i;
this.checkoutOptions.a(this.activity, i);
AnalyticsUtil.setup(this.activity, this.merchantKey, g$_H$.a, g$_H$.c, g$_H$.b);
d.has("ep");
O_$v$ o_$v$2 = this.checkoutOptions;
String a = CheckoutUtils.a("https://api.razorpay.com/v1/checkout/public", "version", g$_H$.b);
Map<String, String> g = g$_H$.a().g();
for (String str : g.keySet()) {
a = CheckoutUtils.a(a, str, g.get(str));
}
Iterator<String> it = g$_H$.a().h().iterator();
while (it.hasNext()) {
String next = it.next();
if (o_$v$2.a(next)) {
a = CheckoutUtils.a(a, next, (String) o_$v$2.c(next));
}
}
this.checkoutUrl = a;
if (a == null) {
destroyActivity(3, this.activity.getResources().getString(R.string.activity_result_invalid_url));
}
if (!z) {
this.checkoutOptions.h();
Activity activity = this.activity;
String str2 = this.merchantKey;
String string = l.a(activity).getString("pref_merchant_options_" + str2, null);
this.dashOptions = string;
if (string != null) {
try {
this.dashOptionsJSON = new JSONObject(this.dashOptions);
} catch (Exception e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getLocalizedMessage());
}
}
String string2 = bundle.getString("FRAMEWORK");
if (string2 != null) {
AnalyticsUtil.addProperty("framework", new AnalyticsProperty(string2, AnalyticsProperty.Scope.ORDER));
}
AnalyticsUtil.setFramework(string2);
String string3 = bundle.getString("FRAMEWORK_VERSION");
if (string3 != null) {
AnalyticsUtil.addProperty("frameworkVersion", new AnalyticsProperty(string3, AnalyticsProperty.Scope.ORDER));
}
if (bundle.getBoolean("DISABLE_FULL_SCREEN", false)) {
CheckoutUtils.a(this.activity);
}
if (bundle.containsKey("PRELOAD_COMPLETE_DURATION")) {
this.preloadCompleteDuration = bundle.getLong("PRELOAD_COMPLETE_DURATION");
}
if (!bundle.containsKey("PRELOAD_ABORT_DURATION")) {
return true;
}
this.preloadAbortDuration = bundle.getLong("PRELOAD_ABORT_DURATION");
return true;
}
this.dashOptions = bundle.getString("DASH_OPTIONS");
if (!bundle.getBoolean("DISABLE_FULL_SCREEN", false)) {
return true;
}
CheckoutUtils.a(this.activity);
return true;
}
private void injectJs(String str) {
this.view.getWebView(1).loadUrl(String.format("javascript: %s", str));
}
@Override
public void onActivityResultReceived(int i, int i2, Intent intent) {
Intent intent2;
if (i == 77) {
if (i2 != -1 || intent.getData() == null) {
return;
}
Uri data = intent.getData();
try {
try {
ParcelFileDescriptor openFileDescriptor = this.activity.getContentResolver().openFileDescriptor(data, "w");
FileOutputStream fileOutputStream = new FileOutputStream(openFileDescriptor.getFileDescriptor());
fileOutputStream.write(Base64.decode(this.sanitizedChallanEncodedString, 0));
fileOutputStream.close();
openFileDescriptor.close();
intent2 = new Intent("android.intent.action.VIEW");
} catch (IOException e) {
e.printStackTrace();
intent2 = new Intent("android.intent.action.VIEW");
}
intent2.setDataAndType(data, "application/pdf");
intent2.addFlags(1);
data = this.activity;
data.startActivity(intent2);
return;
} catch (Throwable th) {
Intent intent3 = new Intent("android.intent.action.VIEW");
intent3.setDataAndType(data, "application/pdf");
intent3.addFlags(1);
this.activity.startActivity(intent3);
throw th;
}
}
if (i != 1001) {
if (i == 99) {
JSONObject jSONFromIntentData = BaseUtils.getJSONFromIntentData(intent);
loadResultToWebView(jSONFromIntentData, String.format("javascript: upiIntentResponse(%s)", jSONFromIntentData.toString()));
return;
}
if (i == 20) {
try {
JSONObject jSONObject = new JSONObject("{'data':" + i2 + "}");
jSONObject.put("provider", "CRED");
loadResultToWebView(jSONObject, String.format("javascript:externalAppResponse(%s)", jSONObject.toString()));
return;
} catch (JSONException e2) {
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e2.getMessage());
return;
}
}
return;
}
if (i2 == -1) {
AnalyticsUtil.trackEvent(AnalyticsEvent.AUTO_READ_OTP_SMS_RETRIEVER_API_RECEIVED_SMS);
String stringExtra = intent.getStringExtra("com.google.android.gms.auth.api.phone.EXTRA_SMS_MESSAGE");
if (this.isCheckoutLoaded) {
try {
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("sender", "razorpay");
jSONObject2.put("message", stringExtra);
String.format("javascript: OTPElf.elfBridge.setSms(%s)", jSONObject2.toString());
injectJs(String.format("OTPElf.showOTP('%s','%s')", stringExtra, "razorpay"));
AnalyticsUtil.trackEvent(AnalyticsEvent.AUTO_READ_OTP_SMS_RETRIEVER_API_OTP_POPULATION_JS);
return;
} catch (JSONException e3) {
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e3.getLocalizedMessage());
e3.printStackTrace();
return;
}
}
return;
}
AnalyticsUtil.trackEvent(AnalyticsEvent.AUTO_READ_OTP_SMS_RETRIEVER_API_CONSENT_DECLINED);
}
private void loadResultToWebView(JSONObject jSONObject, String str) {
HashMap hashMap = new HashMap();
hashMap.put("result", jSONObject);
AnalyticsUtil.trackEvent(AnalyticsEvent.NATIVE_INTENT_ONACTIVITY_RESULT, AnalyticsUtil.getJSONResponse(hashMap));
if (this.isCheckoutLoaded) {
this.view.loadUrl(1, str);
return;
}
if (this.checkoutMessageQueue == null) {
this.checkoutMessageQueue = new LinkedList();
}
this.checkoutMessageQueue.add(str);
}
@Override
public void verifyGPaySdkResponse(String str) {
String format = String.format("javascript: window.externalSDKResponse(%s)", str);
if (this.isCheckoutLoaded) {
this.view.loadUrl(1, format);
return;
}
if (this.checkoutMessageQueue == null) {
this.checkoutMessageQueue = new LinkedList();
}
this.checkoutMessageQueue.add(format);
}
@Override
public void unregisterReceivers() {
try {
BroadcastReceiver broadcastReceiver = this.otpAutoReadBroadcast;
if (broadcastReceiver != null) {
this.activity.unregisterReceiver(broadcastReceiver);
}
} catch (Exception e) {
AnalyticsUtil.reportError("CxPrntrImpl", "S2", e.getMessage());
}
try {
AutoReadOtpHelper autoReadOtpHelper = this.autoReadOtpHelper;
if (autoReadOtpHelper != null) {
this.activity.unregisterReceiver(autoReadOtpHelper);
}
} catch (Exception e2) {
AnalyticsUtil.reportError("CxPrntrImpl", "S2", e2.getMessage());
}
}
@Override
public String getSdkPlugins() {
HashMap<String, String> allPluginsFromManifest = BaseUtils.getAllPluginsFromManifest(this.activity);
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("isAmazonPluginIntegrated", false);
jSONObject.put("isGooglePayPluginIntegrated", false);
} catch (JSONException e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getLocalizedMessage());
e.printStackTrace();
}
if (allPluginsFromManifest != null && allPluginsFromManifest.size() != 0) {
for (String str : allPluginsFromManifest.values()) {
if (allPluginsFromManifest.size() > 0 && str.equalsIgnoreCase("com.razorpay.RazorpayAmazon")) {
jSONObject.put("isAmazonPluginIntegrated", true);
}
if (allPluginsFromManifest.size() > 0 && str.equalsIgnoreCase("com.razorpay.RzpGpayMerged")) {
jSONObject.put("isGooglePayPluginIntegrated", true);
}
}
return jSONObject.toString();
}
return jSONObject.toString();
}
@Override
public void onCheckoutRendered() {
AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_RENDERED_COMPLETE);
}
@Override
public void getPdfString(String str, String str2) {
if (TextUtils.isEmpty(str2) || !str2.contains("base64,")) {
return;
}
String str3 = str2.split("base64,")[1];
this.sanitizedChallanEncodedString = str3;
BaseUtils.pdfDownloadHelper(this.activity, str, str3);
}
@Override
public O_$v$ getCheckoutOptions() {
return this.checkoutOptions;
}
@Override
public void setUpAddOn() {
this.magicBase = new F_$o_(this.activity, this.view.getWebView(2));
}
@Override
public void loadForm(String str) {
if (this.paymentAttempts != 0) {
AnalyticsUtil.postData();
}
int i = this.paymentAttempts + 1;
this.paymentAttempts = i;
AnalyticsUtil.addProperty("payment_attempt", new AnalyticsProperty(i, AnalyticsProperty.Scope.ORDER));
this.clearHistory = true;
this.view.loadUrl(1, (this.checkoutUrl + str).replace(" ", "%20"));
}
@Override
public void passPrefillToSegment() {
String k = this.checkoutOptions.k();
if (!TextUtils.isEmpty(k)) {
AnalyticsUtil.addProperty("email", new AnalyticsProperty(k, AnalyticsProperty.Scope.ORDER));
}
String j = this.checkoutOptions.j();
if (TextUtils.isEmpty(j)) {
return;
}
AnalyticsUtil.addProperty("contact", new AnalyticsProperty(j, AnalyticsProperty.Scope.ORDER));
}
@Override
public void handleCardSaving() {
AnalyticsUtil.trackEvent(AnalyticsEvent.CARD_SAVING_START);
f$_G$.a(this.activity.getApplicationContext());
}
@Override
public void saveInstanceState(Bundle bundle) {
if (this.merchantLogoResourceId != 0) {
bundle.putString("OPTIONS", this.checkoutOptions.i());
bundle.putInt("IMAGE", this.merchantLogoResourceId);
} else {
bundle.putString("OPTIONS", this.checkoutOptions.e());
}
bundle.putString("DASH_OPTIONS", this.dashOptions);
if (this.activity.getIntent() != null) {
bundle.putBoolean("DISABLE_FULL_SCREEN", this.activity.getIntent().getBooleanExtra("DISABLE_FULL_SCREEN", false));
}
}
@Override
public void setCheckoutLoadStartAt() {
this.checkoutLoadStartAt = System.nanoTime();
}
@Override
public void destroyActivity(int i, String str) {
AnalyticsUtil.addProperty("destroy_resultCode", new AnalyticsProperty(String.valueOf(i), AnalyticsProperty.Scope.ORDER));
AnalyticsUtil.addProperty("destroy_result", new AnalyticsProperty(str, AnalyticsProperty.Scope.ORDER));
AnalyticsUtil.trackEvent(AnalyticsEvent.INTERNAL_DESTROY_METHOD_CALLED);
cleanUpOnDestroy();
this.view.destroy(i, str);
}
@Override
public void onCheckoutBackPress() {
AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_SOFT_BACK_PRESSED);
destroyActivity(0, BaseUtils.getPaymentCancelledResponse(BaseUtils.getInstance().getMetadata()));
}
protected void enableAddon(JSONObject jSONObject) {
try {
if (jSONObject.has("magic")) {
boolean z = jSONObject.getBoolean("magic");
this.isMagic = z;
F_$o_ f_$o_ = this.magicBase;
if (f_$o_ != null) {
f_$o_.c = z;
}
AnalyticsUtil.addProperty("is_magic", new AnalyticsProperty(this.isMagic, AnalyticsProperty.Scope.PAYMENT));
}
} catch (JSONException e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getLocalizedMessage());
e.printStackTrace();
}
}
@Override
public void invokePopup(final String str) {
this.isTwoWebViewFlow = true;
try {
this.activity.runOnUiThread(new Runnable() {
@Override
public final void run() {
try {
JSONObject jSONObject = new JSONObject(str);
CheckoutPresenterImpl.this.enableAddon(jSONObject);
if (jSONObject.has(FirebaseAnalytics.Param.CONTENT)) {
CheckoutPresenterImpl.this.view.loadDataWithBaseURL(2, "about:blank", jSONObject.getString(FirebaseAnalytics.Param.CONTENT), "text/html", CharsetNames.UTF_8, null);
}
if (jSONObject.has("url")) {
CheckoutPresenterImpl.this.view.loadUrl(2, jSONObject.getString("url"));
}
if (jSONObject.has("focus") && !jSONObject.getBoolean("focus")) {
CheckoutPresenterImpl.this.view.makeWebViewVisible(1);
} else {
CheckoutPresenterImpl.this.view.makeWebViewVisible(2);
}
} catch (Exception e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getLocalizedMessage());
e.printStackTrace();
}
AnalyticsUtil.addProperty("two_webview_flow", new AnalyticsProperty(true, AnalyticsProperty.Scope.PAYMENT));
}
});
} catch (Exception e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getLocalizedMessage());
e.printStackTrace();
}
}
@Override
public void fetchCondfig() {
g$_H$.d = isMagicPresent();
g$_H$.a(this.activity, this.merchantKey);
}
@Override
public void onProgressChanges(int i, int i2) {
if (i != 1) {
return;
}
this.view.showProgressBar(i2);
}
@Override
public void onPageStarted(int i, WebView webView, String str) {
F_$o_ f_$o_;
if (i == 1) {
CheckoutUtils.e(this.activity);
} else if (i == 2 && (f_$o_ = this.magicBase) != null && this.isMagic) {
f_$o_.d = false;
}
}
@Override
public void onPageFinished(int i, WebView webView, String str) {
F_$o_ f_$o_;
if (i == 1) {
primaryWebviewPageFinished(str, webView);
} else if (i == 2 && (f_$o_ = this.magicBase) != null && this.isMagic) {
f_$o_.a();
}
}
private void sendQueuedMessagesToCheckout() {
Queue<String> queue = this.checkoutMessageQueue;
if (queue == null || queue.isEmpty()) {
return;
}
Iterator<String> it = this.checkoutMessageQueue.iterator();
while (it.hasNext()) {
this.view.loadUrl(1, it.next());
}
this.checkoutMessageQueue.clear();
}
protected void primaryWebviewPageFinished(String str, WebView webView) {
long nanoTime = System.nanoTime();
CheckoutUtils.a();
this.view.hideProgressBar();
if (str.contains("https://api.razorpay.com") && str.contains("android") && str.contains(BuildConfig.VERSION_NAME)) {
if (this.paymentAttempts == 1) {
this.isCheckoutLoaded = true;
sendQueuedMessagesToCheckout();
HashMap hashMap = new HashMap();
long j = nanoTime - this.checkoutLoadStartAt;
hashMap.put("checkout_load_duration", Long.valueOf(j));
BaseUtils.nanoTimeToSecondsString(j, 2);
long j2 = this.preloadCompleteDuration;
if (j2 > 0) {
hashMap.put("preload_finish_duration", Long.valueOf(j2));
BaseUtils.nanoTimeToSecondsString(this.preloadCompleteDuration, 2);
} else {
long j3 = this.preloadAbortDuration;
if (j3 > 0) {
hashMap.put("preload_abort_duration", Long.valueOf(j3));
BaseUtils.nanoTimeToSecondsString(this.preloadAbortDuration, 2);
}
}
long j4 = this.preloadCompleteDuration - j;
if (j4 > 0) {
hashMap.put("time_shaved_off", Long.valueOf(j4));
BaseUtils.nanoTimeToSecondsString(j4, 2);
}
AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_LOADED, AnalyticsUtil.getJSONResponse(hashMap));
}
if (this.clearHistory) {
this.view.clearWebViewHistory(1);
this.clearHistory = false;
}
}
}
@Override
public String getProgressBarColor() {
JSONObject jSONObject;
String str = null;
try {
if (this.checkoutOptions.d() != null) {
String string = this.checkoutOptions.d().getJSONObject("theme").getString("color");
Color.parseColor(string);
return string;
}
throw new Exception("No options defined");
} catch (Exception e) {
try {
jSONObject = this.dashOptionsJSON;
} catch (Exception e2) {
AnalyticsUtil.reportError("CxPsntrImpl", "S2", e2.getMessage());
}
if (jSONObject != null) {
str = jSONObject.getJSONObject("theme").getString("color");
Color.parseColor(str);
AnalyticsUtil.reportError("CxPsntrImpl", "S2", e.getMessage());
return str;
}
throw new Exception("No dash options defined");
}
}
@Override
public void sendOtpPermissionCallback(final boolean z) {
this.activity.runOnUiThread(new Runnable() {
@Override
public final void run() {
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("granted", z);
CheckoutPresenterImpl.this.view.loadUrl(1, String.format("javascript: otpPermissionCallback(%s)", jSONObject.toString()));
} catch (Exception e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S2", e.getLocalizedMessage());
}
}
});
}
protected void addOnFlowEnd() {
F_$o_ f_$o_ = this.magicBase;
if (f_$o_ != null) {
f_$o_.b.b(f_$o_);
f_$o_.b.b((Activity) f_$o_.a);
}
}
@Override
public void cleanUpOnDestroy() {
try {
markPaymentCancelled();
this.activity.unregisterReceiver(this.autoReadOtpHelper);
this.activity.unregisterReceiver(this.otpAutoReadBroadcast);
J$_M_.a();
} catch (Exception e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S2", e.getLocalizedMessage());
}
}
public void markPaymentCancelled() {
if (this.payment_id == null || this.isPaymentSuccessful) {
return;
}
try {
String constructBasicAuth = BaseUtils.constructBasicAuth(this.merchantKey);
HashMap hashMap = new HashMap();
hashMap.put(NetworkConstantsKt.HEADER_AUTHORIZATION, "Basic " + constructBasicAuth);
M$_3_.a("https://api.razorpay.com/v1/payments/" + this.payment_id + "/cancel?platform=android_sdk", hashMap, new Callback(this) {
@Override
public final void run(ResponseObject responseObject) {
responseObject.getResponseResult();
}
});
this.payment_id = null;
} catch (Exception e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getLocalizedMessage());
}
}
@Override
public void backPressed(final Map<String, Object> map) {
AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_HARD_BACK_PRESSED, AnalyticsUtil.getJSONResponse(map));
WebView webView = this.view.getWebView(1);
if ((webView.getTag() == null ? "" : webView.getTag().toString()).contains(g$_H$.a().getCheckoutEndpoint()) && !this.view.isWebViewVisible(2)) {
this.view.loadUrl(1, "javascript: window.backPressed ? window.backPressed('onCheckoutBackPress') : CheckoutBridge.onCheckoutBackPress();");
map.put("in_checkout", "true");
} else if (!g$_H$.a().k()) {
destroyActivity(0, "BackPressed");
} else {
CheckoutUtils.a(this.activity, g$_H$.a().l(), g$_H$.a().j(), g$_H$.a().i(), new CheckoutUtils.BackButtonDialogCallback() {
@Override
public final void onPositiveButtonClick() {
AnalyticsUtil.trackEvent(AnalyticsEvent.ALERT_PAYMENT_CONTINUE, AnalyticsUtil.getJSONResponse((Map<String, Object>) map));
}
@Override
public final void onNegativeButtonClick() {
boolean z;
AnalyticsUtil.trackEvent(AnalyticsEvent.ALERT_PAYMENT_CANCELLED, AnalyticsUtil.getJSONResponse((Map<String, Object>) map));
z = CheckoutPresenterImpl.this.isTwoWebViewFlow;
if (!z) {
CheckoutPresenterImpl.this.handleRetry(null);
CheckoutPresenterImpl.this.markPaymentCancelled();
} else {
CheckoutPresenterImpl.this.view.makeWebViewVisible(1);
CheckoutPresenterImpl.this.view.loadUrl(2, "about:blank");
CheckoutPresenterImpl.this.view.loadUrl(1, "javascript: window.onpaymentcancel()");
}
CheckoutPresenterImpl.this.isTwoWebViewFlow = false;
}
});
}
}
@Override
public void onLoad() {
this.activity.runOnUiThread(new Runnable() {
@Override
public final void run() {
String handleMessageFormattedString;
CheckoutPresenterImpl.CheckoutView checkoutView = CheckoutPresenterImpl.this.view;
handleMessageFormattedString = CheckoutPresenterImpl.this.getHandleMessageFormattedString();
checkoutView.loadUrl(1, handleMessageFormattedString);
CheckoutPresenterImpl.this.view.loadUrl(1, String.format("javascript: CheckoutBridge.sendAnalyticsData({data: %s})", AnalyticsUtil.getAnalyticsDataForCheckout(CheckoutPresenterImpl.this.activity).toString()));
}
});
if (Build.VERSION.SDK_INT >= 29 || ActivityCompat.checkSelfPermission(this.activity, "android.permission.RECEIVE_SMS") != 0) {
if (this.sendSmsHash) {
this.loginOtpSmsTask = SmsRetriever.getClient(this.activity).startSmsRetriever();
try {
final long j = 2000;
final long j2 = 1000;
new CountDownTimer(j, j2) {
@Override
public final void onTick(long j3) {
}
{
super(2000L, 1000L);
}
@Override
public final void onFinish() {
Task task;
BroadcastReceiver broadcastReceiver;
try {
task = CheckoutPresenterImpl.this.loginOtpSmsTask;
if (!task.isSuccessful()) {
CheckoutPresenterImpl.this.startSmsRetrieverForSavedCardsOTP();
return;
}
IntentFilter intentFilter = new IntentFilter("com.google.android.gms.auth.api.phone.SMS_RETRIEVED");
Activity activity = CheckoutPresenterImpl.this.activity;
broadcastReceiver = CheckoutPresenterImpl.this.otpAutoReadBroadcast;
activity.registerReceiver(broadcastReceiver, intentFilter, "com.google.android.gms.auth.api.phone.permission.SEND", null);
} catch (AbstractMethodError e) {
AnalyticsUtil.reportError(e.getMessage(), "S2", e.getMessage());
CheckoutPresenterImpl.this.startSmsRetrieverForSavedCardsOTP();
} catch (Exception e2) {
AnalyticsUtil.reportError("CxPsntrImpl", "S2", e2.getMessage());
CheckoutPresenterImpl.this.startSmsRetrieverForSavedCardsOTP();
}
}
}.start();
return;
} catch (Exception e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S2", e.getMessage());
startSmsRetrieverForSavedCardsOTP();
return;
}
}
startSmsRetrieverForSavedCardsOTP();
}
}
public void startSmsRetrieverForSavedCardsOTP() {
this.loginOtpSmsTask = SmsRetriever.getClient(this.activity).startSmsUserConsent((String) null);
this.autoReadOtpHelper = new AutoReadOtpHelper(this.activity);
this.activity.registerReceiver(this.autoReadOtpHelper, new IntentFilter("com.google.android.gms.auth.api.phone.SMS_RETRIEVED"));
}
protected JSONObject getOptionsForHandleMessage() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("options", this.checkoutOptions.d());
jSONObject.put(Constants.ScionAnalytics.MessageType.DATA_MESSAGE, this.checkoutContent);
jSONObject.put("id", AnalyticsUtil.getLocalOrderId());
jSONObject.put("pdf_download_supported", true);
jSONObject.put("key_id", this.merchantKey);
jSONObject.put("externalSDKs", new JSONObject());
if (this.checkoutOptions.b()) {
jSONObject.put("sms_hash", new AppSignatureHelper(this.activity).getAppSignatures().get(0));
}
jSONObject.put("upi_intents_data", CheckoutUtils.c(this.activity));
jSONObject.put("uri_data", CheckoutUtils.d(this.activity));
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("openedAt", System.currentTimeMillis());
jSONObject.put("metadata", jSONObject2);
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("framework", AnalyticsUtil.getFramework());
jSONObject3.put(RequestHeadersFactory.TYPE, g$_H$.a);
jSONObject3.put("name", g$_H$.a + "_android_" + AnalyticsUtil.getFramework());
jSONObject3.put("version", BuildConfig.VERSION_NAME);
jSONObject3.put("platform", "android");
jSONObject.put("sdk", jSONObject3);
String b = f$_G$.b(this.activity.getApplicationContext());
if (!TextUtils.isEmpty(b)) {
jSONObject.put("device_token", b);
}
jSONObject.put("sdk_popup", true);
jSONObject.put("magic", true);
jSONObject.put(AnalyticsFields.NETWORK_TYPE, BaseUtils.getNetworkType(this.activity));
jSONObject.put("activity_recreated", this.isActivityCreated);
} catch (JSONException e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S2", e.getLocalizedMessage());
}
return jSONObject;
}
public String getHandleMessageFormattedString() {
return String.format("javascript: handleMessage(%s)", getOptionsForHandleMessage().toString());
}
@Override
public void setAppToken(String str) {
l.b(this.activity).putString("rzp_app_token", str).apply();
}
@Override
public void setDeviceToken(String str) {
f$_G$.a(this.activity, str);
}
@Override
public void callNativeIntent(String str, String str2) {
BaseUtils.startActivityForResult(str, str2, this.activity);
HashMap hashMap = new HashMap();
if (str == null) {
str = com.google.maps.android.BuildConfig.TRAVIS;
}
hashMap.put("url", str);
if (str2 == null) {
str2 = com.google.maps.android.BuildConfig.TRAVIS;
}
hashMap.put(AnalyticsRequestV2Factory.PARAM_PACKAGE_NAME, str2);
AnalyticsUtil.trackEvent(AnalyticsEvent.NATIVE_INTENT_CALLED, AnalyticsUtil.getJSONResponse(hashMap));
}
@Override
public void setPaymentID(String str) {
this.payment_id = str;
BaseUtils.getInstance().setPaymentId(str);
if (this.checkoutOptions.f() != null) {
BaseUtils.getInstance().setOrderId(this.checkoutOptions.f());
}
AnalyticsUtil.addProperty("payment_id", new AnalyticsProperty(str, AnalyticsProperty.Scope.PAYMENT));
AnalyticsUtil.trackEvent(AnalyticsEvent.PAYMENT_ID_ATTACHED);
}
@Override
public void setMerchantOptions(java.lang.String r5) {
throw new UnsupportedOperationException("Method not decompiled: com.razorpay.CheckoutPresenterImpl.setMerchantOptions(java.lang.String):void");
}
protected void addAnalyticsData(JSONObject jSONObject) {
AnalyticsUtil.addFilteredPropertiesFromPayload(jSONObject);
}
@Override
public void onSubmit(String str) {
if (this.paymentAttempts > 1) {
AnalyticsUtil.refreshPaymentSession();
}
if (this.autoReadOtpHelper != null && this.loginOtpSmsTask.isComplete()) {
try {
this.activity.unregisterReceiver(this.autoReadOtpHelper);
} catch (IllegalArgumentException unused) {
}
}
try {
JSONObject jSONObject = new JSONObject(str);
this.checkoutContent = str;
addAnalyticsData(jSONObject);
savePrefillData(jSONObject);
if (jSONObject.has(FirebaseAnalytics.Param.METHOD)) {
String string = jSONObject.getString(FirebaseAnalytics.Param.METHOD);
if (!string.equalsIgnoreCase("netbanking") && !string.equalsIgnoreCase("card")) {
if (string.equals("wallet") && jSONObject.has("wallet")) {
String string2 = jSONObject.getString("wallet");
if (this.checkoutOptions.b(string2)) {
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("external_wallet", string2);
AnalyticsUtil.addProperty("external_wallet", new AnalyticsProperty(string2, AnalyticsProperty.Scope.ORDER));
AnalyticsUtil.trackEvent(AnalyticsEvent.EXTERNAL_WALLET_SELECTED);
onComplete(jSONObject2);
}
}
}
if (Build.VERSION.SDK_INT >= 29 || ActivityCompat.checkSelfPermission(this.activity, "android.permission.RECEIVE_SMS") != 0) {
Log.d("SMS", "received method as netbanking");
startSmsRetrieverForSavedCardsOTP();
}
}
AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_SUBMIT);
AnalyticsUtil.postData();
} catch (Exception e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getMessage());
d__1_.a("Error in submit", e);
}
}
protected void onComplete(JSONObject jSONObject) {
try {
if (jSONObject.has(Constants.IPC_BUNDLE_KEY_SEND_ERROR)) {
AnalyticsUtil.addProperty("payment_status", new AnalyticsProperty("fail", AnalyticsProperty.Scope.PAYMENT));
AnalyticsUtil.addProperty("payload", new AnalyticsProperty(jSONObject.toString(), AnalyticsProperty.Scope.PAYMENT));
AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_PAYMENT_COMPLETE);
if (this.isTwoWebViewFlow) {
this.view.makeWebViewVisible(1);
}
onError(jSONObject);
} else if (jSONObject.has("razorpay_fund_account_id")) {
destroyActivity(1, jSONObject.toString());
} else if (jSONObject.has("razorpay_payment_id")) {
String string = jSONObject.getString("razorpay_payment_id");
this.payment_id = string;
AnalyticsUtil.addProperty("payment_id", new AnalyticsProperty(string, AnalyticsProperty.Scope.PAYMENT));
AnalyticsUtil.addProperty("payment_status", new AnalyticsProperty(FirebaseAnalytics.Param.SUCCESS, AnalyticsProperty.Scope.PAYMENT));
AnalyticsUtil.addProperty("payload", new AnalyticsProperty(jSONObject.toString(), AnalyticsProperty.Scope.PAYMENT));
AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_PAYMENT_COMPLETE);
this.isPaymentSuccessful = true;
destroyActivity(1, jSONObject.toString());
} else if (jSONObject.has("external_wallet")) {
destroyActivity(4, jSONObject.toString());
} else {
destroyActivity(0, "Post payment parsing error");
}
} catch (Exception e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getMessage());
destroyActivity(0, e.getMessage());
}
this.isTwoWebViewFlow = false;
}
protected void onError(final JSONObject jSONObject) {
if (this.isTwoWebViewFlow) {
this.view.loadUrl(1, String.format("javascript: window.onComplete(%s)", jSONObject.toString()));
} else {
this.activity.runOnUiThread(new Runnable() {
@Override
public final void run() {
CheckoutPresenterImpl.this.handleRetry(jSONObject.toString());
}
});
}
}
public void handleRetry(String str) {
int i = this.paymentAttempts;
int f = g$_H$.a().f();
if (g$_H$.a().e() && (f == -1 || f > i)) {
try {
if (str != null) {
JSONObject jSONObject = new JSONObject(str);
if (jSONObject.has(Constants.IPC_BUNDLE_KEY_SEND_ERROR)) {
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.append(this.checkoutUrl.contains("?") ? "&" : "?");
str = sb.toString();
if (jSONObject.get(Constants.IPC_BUNDLE_KEY_SEND_ERROR) instanceof JSONObject) {
str = str + "error=" + ((JSONObject) jSONObject.get(Constants.IPC_BUNDLE_KEY_SEND_ERROR)).toString();
}
}
helpersReset();
loadForm(str);
return;
}
destroyActivity(0, "");
return;
} catch (Exception e) {
destroyActivity(0, "");
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getMessage());
return;
}
}
destroyActivity(0, str);
}
private void savePrefillData(JSONObject jSONObject) {
try {
if (jSONObject.has("contact")) {
CheckoutUtils.b(this.activity, jSONObject.getString("contact"));
this.checkoutOptions.a("contact", jSONObject.getString("contact"));
}
if (jSONObject.has("email")) {
CheckoutUtils.a(this.activity, jSONObject.getString("email"));
this.checkoutOptions.a("email", jSONObject.getString("email"));
}
} catch (JSONException e) {
d__1_.a("Error parsing JSON", e);
}
}
@Override
public void onFault(String str) {
try {
destroyActivity(3, new JSONObject(str).toString());
} catch (JSONException unused) {
destroyActivity(3, BaseUtils.getGenericPaymentErrorResponse(str, BaseUtils.getInstance().getMetadata()));
}
}
@Override
public void onComplete(final String str) {
this.activity.runOnUiThread(new Runnable() {
@Override
public final void run() {
try {
CheckoutPresenterImpl.this.onComplete(new JSONObject(str));
} catch (Exception e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getMessage());
CheckoutPresenterImpl.this.destroyActivity(0, BaseUtils.getPaymentCancelledResponse(BaseUtils.getInstance().getMetadata()));
}
}
});
}
@Override
public void setDimensions(int i, int i2) {
if (b.a(this.activity)) {
this.activity.runOnUiThread(new c._2_(this, i2, i));
}
}
@Override
public void onDismiss() {
destroyActivity(0, BaseUtils.getPaymentCancelledResponse(BaseUtils.getInstance().getMetadata()));
}
@Override
public void onDismiss(String str) {
try {
destroyActivity(0, new JSONObject(str).toString());
} catch (JSONException unused) {
destroyActivity(0, BaseUtils.getGenericPaymentErrorResponse(str, BaseUtils.getInstance().getMetadata()));
}
}
@Override
public void requestExtraAnalyticsData() {
final JSONObject extraAnalyticsPayload = AnalyticsUtil.getExtraAnalyticsPayload();
this.activity.runOnUiThread(new Runnable() {
@Override
public final void run() {
try {
CheckoutPresenterImpl.this.view.loadUrl(1, String.format("javascript: CheckoutBridge.sendExtraAnalyticsData(%s)", extraAnalyticsPayload.toString()));
} catch (Exception e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S2", e.getLocalizedMessage());
}
}
});
}
@Override
public void onError(String str) {
try {
onError(new JSONObject(str));
} catch (Exception e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getMessage());
this.activity.runOnUiThread(new Runnable() {
@Override
public final void run() {
CheckoutPresenterImpl.this.helpersReset();
CheckoutPresenterImpl.this.loadForm("");
}
});
}
}
@Override
public void toast(final String str, final int i) {
this.activity.runOnUiThread(new Runnable() {
@Override
public final void run() {
CheckoutPresenterImpl.this.view.showToast(str, i);
}
});
}
@Override
public void showAlertDialog(String str, String str2, String str3) {
this.activity.runOnUiThread(new H$$i_(this, str, str3, str2));
}
@Override
public void sendDataToWebView(final int i, final String str) {
this.activity.runOnUiThread(new Runnable() {
@Override
public final void run() {
int i2 = i;
if (i2 == 1) {
CheckoutPresenterImpl.this.view.loadUrl(1, String.format("javascript: handleRelay(%s)", str));
} else {
if (i2 != 2) {
return;
}
CheckoutPresenterImpl.this.view.loadUrl(2, String.format("javascript: Magic.handleRelay(%s)", str));
}
}
});
}
@Override
public void checkSmsPermission() {
this.view.checkSmsPermission();
}
@Override
public void isWebViewSafeOnUI(int i, CheckoutBridge.WebViewSafeCheckCallback webViewSafeCheckCallback) {
this.activity.runOnUiThread(new b._f_(this, i, webViewSafeCheckCallback));
}
public void executeWebViewCallback(int i, CheckoutBridge.WebViewSafeCheckCallback webViewSafeCheckCallback) {
CheckoutView checkoutView;
int i2 = 1;
if (i == 1) {
checkoutView = this.view;
} else {
checkoutView = this.view;
i2 = 2;
}
try {
String host = new URL(checkoutView.getWebView(i2).getTag().toString()).getHost();
if (host != null && (host.endsWith("razorpay.com") || host.endsWith("razorpay.in"))) {
webViewSafeCheckCallback.secure();
} else {
webViewSafeCheckCallback.unSecure();
}
} catch (Exception e) {
AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getLocalizedMessage());
webViewSafeCheckCallback.unSecure();
}
}
@Override
public void isWebViewSafe(int i, CheckoutBridge.WebViewSafeCheckCallback webViewSafeCheckCallback) {
executeWebViewCallback(i, webViewSafeCheckCallback);
}
@Override
public boolean isUserRegisteredOnUPI(String str) {
return BaseUtils.checkUpiRegisteredApp(this.activity, str);
}
@Override
public boolean isUserRegistered(String str) {
return BaseUtils.checkGpayCardsUpiRegistered(this.activity, str);
}
@Override
public boolean isAllowRotation() {
return this.allowRotation;
}
}