正在查看: Rilo v2.0.21 应用的 RzpGpayMerged.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Rilo v2.0.21 应用的 RzpGpayMerged.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.razorpay;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import com.google.android.apps.nbu.paisa.inapp.client.api.PaymentsClient;
import com.google.android.apps.nbu.paisa.inapp.client.api.Wallet;
import com.google.android.apps.nbu.paisa.inapp.client.api.WalletUtils;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.stripe.android.core.networking.NetworkConstantsKt;
import com.stripe.android.core.networking.RequestHeadersFactory;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Objects;
import org.json.JSONException;
import org.json.JSONObject;
class RzpGpayMerged implements OnCompleteListener<Boolean>, RzpPlugin {
private static int LOAD_PAYMENT_DATA_REQUEST_CODE = 1;
private JSONObject apiResponse;
private PaymentsClient mPaymentClient;
private RzpPluginRegisterCallback registerCallback;
private RzpInternalCallback rzpInternalCallback;
private boolean isUpiOnly = false;
private Task<Boolean> cardsTask = null;
private Task<Boolean> upiTask = null;
RzpGpayMerged() {
}
@Override
public RzpPluginCompatibilityResponse isCompatible(String str, int i, String str2) {
String str3;
if (str.equalsIgnoreCase("custom") && i > 27) {
return new RzpPluginCompatibilityResponse(true, null);
}
if (str.equalsIgnoreCase(BuildConfig.SDK_TYPE) && i > 18) {
return new RzpPluginCompatibilityResponse(true, null);
}
if (str.equalsIgnoreCase("custom")) {
str3 = "Razorpay's GooglePay plugin requires a min SDK Version 3.8.8 Please update.";
} else {
str3 = str.equalsIgnoreCase(BuildConfig.SDK_TYPE) ? "Razorpay's GooglePay plugin requires a min SDK Version 1.5.6 Please update." : "Incompatible Razorpay sdk version. Please update the base sdk";
}
return new RzpPluginCompatibilityResponse(false, str3);
}
@Override
public boolean doesHandlePayload(String str, JSONObject jSONObject, Activity activity) {
if (jSONObject != null) {
try {
if (jSONObject.has(FirebaseAnalytics.Param.METHOD) && jSONObject.getString(FirebaseAnalytics.Param.METHOD).equalsIgnoreCase("upi") && jSONObject.getString("_[app]").equalsIgnoreCase("com.google.android.apps.nbu.paisa.user")) {
return true;
}
} catch (JSONException e) {
e.printStackTrace();
}
}
if (jSONObject != null && jSONObject.has(RequestHeadersFactory.TYPE) && jSONObject.getString(RequestHeadersFactory.TYPE).equalsIgnoreCase("application")) {
if (jSONObject.getString("application_name").equalsIgnoreCase("google_pay")) {
return true;
}
}
return false;
}
@Override
public void processPayment(String str, JSONObject jSONObject, Activity activity, RzpInternalCallback rzpInternalCallback) {
try {
this.rzpInternalCallback = rzpInternalCallback;
this.mPaymentClient = Wallet.getPaymentsClient();
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_PROCESS_PAYMENT_CALLED);
if (jSONObject.has(RequestHeadersFactory.TYPE) && jSONObject.getString(RequestHeadersFactory.TYPE).equalsIgnoreCase("application")) {
this.apiResponse = jSONObject;
try {
this.mPaymentClient.loadPaymentData(activity, jSONObject.getJSONObject("request").getJSONArray(FirebaseAnalytics.Param.CONTENT).getJSONObject(0).toString(), LOAD_PAYMENT_DATA_REQUEST_CODE);
return;
} catch (Exception e) {
AnalyticsUtil.reportError(getClass().getName(), "S0", e.getMessage());
genericOnPaymentFailure("BAD_REQUEST", 1, "An internal error has occured");
return;
}
}
if (jSONObject.has("url_data")) {
this.isUpiOnly = true;
try {
String obj = jSONObject.get("url_data").toString();
try {
this.apiResponse = RzpGpayUtilMerged.getUpiData(obj);
this.mPaymentClient.loadPaymentData(activity, RzpGpayUtilMerged.getPaymentRequestData(obj, jSONObject), LOAD_PAYMENT_DATA_REQUEST_CODE);
return;
} catch (Exception e2) {
e2.printStackTrace();
genericOnPaymentFailure("BAD_REQUEST_ERROR", 1, "An internal error has occurred");
return;
}
} catch (Exception e3) {
AnalyticsUtil.reportError(getClass().getName(), "error:exception", e3.getMessage());
genericOnPaymentFailure("BAD_REQUEST_ERROR", 1, "An internal error has occurred");
return;
}
}
HashMap hashMap = new HashMap();
hashMap.put(NetworkConstantsKt.HEADER_CONTENT_TYPE, "application/x-www-form-urlencoded");
M$_3_.a("https://api.razorpay.com/v1/payments/create/ajax", RzpGpayUtilMerged.makeApiPayload(jSONObject), hashMap, new h(this, activity, jSONObject));
return;
} catch (Exception e4) {
AnalyticsUtil.reportError(getClass().getName(), "error:exception", e4.getMessage());
genericOnPaymentFailure("BAD_REQUEST_ERROR", 1, "An internal error has occurred.");
}
AnalyticsUtil.reportError(getClass().getName(), "error:exception", e4.getMessage());
genericOnPaymentFailure("BAD_REQUEST_ERROR", 1, "An internal error has occurred.");
}
@Override
public void onActivityResult(String str, int i, int i2, Intent intent) {
if (i == LOAD_PAYMENT_DATA_REQUEST_CODE) {
if (i2 == -1) {
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_PAYMENT_CALLBACK_SUCCESS);
processPaymentResponse(WalletUtils.getPaymentDataFromIntent(intent));
} else if (i2 == 0) {
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_PAYMENT_CALLBACK_CANCELLED);
genericOnPaymentFailure("BAD_REQUEST_ERROR", 0, "Payment canceled.");
} else {
if (i2 != 1) {
return;
}
handleResultStatusCode(intent.getIntExtra("errorCode", 8));
}
}
}
private void handleResultStatusCode(int i) {
if (i == 405) {
genericOnPaymentFailure("BAD_REQUEST_ERROR", 1, "There is a problem with merchant's account.");
} else if (i == 409) {
genericOnPaymentFailure("BAD_REQUEST_ERROR", 1, "There is a problem with your Google Pay account.");
} else {
genericOnPaymentFailure("BAD_REQUEST_ERROR", 1, "An internal error has occurred");
}
}
@Override
public void isRegistered(Context context, RzpPluginRegisterCallback rzpPluginRegisterCallback) {
this.registerCallback = rzpPluginRegisterCallback;
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_CHECK_REGISTER_CALLED);
try {
this.mPaymentClient = Wallet.getPaymentsClient();
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_PAYMENT_IS_REGISTERED_CALLED);
this.upiTask = this.mPaymentClient.isReadyToPay(context, ((JSONObject) Objects.requireNonNull(RzpGpayUtilMerged.getIsReadyToPayRequest())).toString());
this.cardsTask = this.mPaymentClient.isReadyToPay(context, ((JSONObject) Objects.requireNonNull(RzpGpayUtilMerged.getCardsIsReadyToPayRequest())).toString());
} catch (NoSuchAlgorithmException e) {
AnalyticsUtil.reportError(getClass().getName(), "error:exception", e.getMessage());
}
((Task) Objects.requireNonNull(this.cardsTask)).addOnCompleteListener(this);
((Task) Objects.requireNonNull(this.upiTask)).addOnCompleteListener(this);
}
@Override
public void isRegistered(Context context) {
Task task;
this.mPaymentClient = Wallet.getPaymentsClient();
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_CHECK_REGISTER_CALLED);
Task task2 = null;
try {
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_PAYMENT_IS_REGISTERED_CALLED);
task = this.mPaymentClient.isReadyToPay(context, ((JSONObject) Objects.requireNonNull(RzpGpayUtilMerged.getIsReadyToPayRequest())).toString());
try {
task2 = this.mPaymentClient.isReadyToPay(context, ((JSONObject) Objects.requireNonNull(RzpGpayUtilMerged.getCardsIsReadyToPayRequest())).toString());
} catch (NoSuchAlgorithmException e) {
e = e;
AnalyticsUtil.reportError(getClass().getName(), "error:exception", e.getMessage());
((Task) Objects.requireNonNull(task2)).addOnCompleteListener(new i(this));
((Task) Objects.requireNonNull(task)).addOnCompleteListener(new j(this));
}
} catch (NoSuchAlgorithmException e2) {
e = e2;
task = null;
}
((Task) Objects.requireNonNull(task2)).addOnCompleteListener(new i(this));
((Task) Objects.requireNonNull(task)).addOnCompleteListener(new j(this));
}
private void processPaymentResponse(String str) {
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_VERIFY_PAYMENT_CALLED);
if (verifyPaymentResponse(str)) {
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_VERIFY_PAYMENT_SUCCESS_CALLED);
genericOnPaymentSuccess();
} else {
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_VERIFY_PAYMENT_ERROR_CALLED);
genericOnPaymentFailure("BAD_REQUEST_ERROR", 1, "Payment was not successful.");
}
}
private static boolean verifyPaymentResponse(String str) {
try {
String string = new JSONObject(str).getJSONObject("paymentMethodData").getJSONObject("tokenizationData").getString("token");
if (string == null) {
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_VERIFY_PAYMENT_EXCEPTION);
return false;
}
String string2 = new JSONObject(new JSONObject(string).getString("signedMessage")).getJSONObject("paymentMethodDetails").getString("status");
return string2 != null && string2.equals("SUCCESS");
} catch (JSONException unused) {
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_VERIFY_PAYMENT_EXCEPTION);
return false;
}
}
private void genericOnPaymentSuccess() {
if (this.isUpiOnly) {
this.rzpInternalCallback.onPaymentSuccess(RzpGpayUtilMerged.makeExternalSDKPayload(this.apiResponse));
} else {
this.rzpInternalCallback.onPaymentSuccess(RzpGpayUtilMerged.makeMergedExternalSDKPayload(this.apiResponse));
}
}
public void genericOnPaymentFailure(String str, int i, String str2) {
if (this.isUpiOnly) {
this.rzpInternalCallback.onPaymentError(5, RzpGpayUtilMerged.makeErrorPayload(str, str2));
} else {
this.rzpInternalCallback.onPaymentError(5, RzpGpayUtilMerged.makeMergedExternalSDKErrorPayload(this.apiResponse, i, str2));
}
}
public void onComplete(Task<Boolean> task) {
boolean booleanValue = ((Boolean) task.getResult()).booleanValue();
if (task.equals(this.cardsTask)) {
BaseUtils.setIsGpayCardsUpiRegistered(booleanValue);
this.registerCallback.onResponse(booleanValue);
} else {
BaseUtils.setCompatibleWithGooglePay(booleanValue);
}
}
}