正在查看: Chaupal v3.2 应用的 RzpGpayMerged.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Chaupal v3.2 应用的 RzpGpayMerged.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.razorpay;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
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 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() {
}
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));
}
}
private void genericOnPaymentSuccess() {
if (this.isUpiOnly) {
this.rzpInternalCallback.onPaymentSuccess(RzpGpayUtilMerged.makeExternalSDKPayload(this.apiResponse));
} else {
this.rzpInternalCallback.onPaymentSuccess(RzpGpayUtilMerged.makeMergedExternalSDKPayload(this.apiResponse));
}
}
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, "An internal error has occurred");
} else {
genericOnPaymentFailure("BAD_REQUEST_ERROR", 1, "There is a problem with your Google Pay account.");
}
}
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 {
return new JSONObject(new JSONObject(new JSONObject(str).getJSONObject("paymentMethodData").getJSONObject("tokenizationData").getString("token")).getString("signedMessage")).getJSONObject("paymentMethodDetails").getString("status").equals("SUCCESS");
} catch (JSONException unused) {
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_VERIFY_PAYMENT_EXCEPTION);
return false;
}
}
@Override
public boolean doesHandlePayload(String str, JSONObject jSONObject, Activity activity) {
if (jSONObject != null) {
try {
if (jSONObject.has("method") && jSONObject.getString("method").equalsIgnoreCase("upi") && jSONObject.getString("_[app]").equalsIgnoreCase("com.google.android.apps.nbu.paisa.user")) {
return true;
}
} catch (JSONException unused) {
}
}
if (jSONObject != null && jSONObject.has("type") && jSONObject.getString("type").equalsIgnoreCase("application")) {
if (jSONObject.getString("application_name").equalsIgnoreCase("google_pay")) {
return true;
}
}
return false;
}
@Override
public RzpPluginCompatibilityResponse isCompatible(String str, int i, String str2) {
if (str.equalsIgnoreCase("custom") && i > 27) {
return new RzpPluginCompatibilityResponse(true, null);
}
if (!str.equalsIgnoreCase(BuildConfig.SDK_TYPE) || i <= 18) {
return new RzpPluginCompatibilityResponse(false, str.equalsIgnoreCase("custom") ? "Razorpay's GooglePay plugin requires a min SDK Version 3.8.8 Please update." : 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(true, null);
}
@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);
PaymentsClient paymentsClient = this.mPaymentClient;
JSONObject isReadyToPayRequest = RzpGpayUtilMerged.getIsReadyToPayRequest();
Objects.requireNonNull(isReadyToPayRequest);
JSONObject jSONObject = isReadyToPayRequest;
this.upiTask = paymentsClient.isReadyToPay(context, isReadyToPayRequest.toString());
PaymentsClient paymentsClient2 = this.mPaymentClient;
JSONObject cardsIsReadyToPayRequest = RzpGpayUtilMerged.getCardsIsReadyToPayRequest();
Objects.requireNonNull(cardsIsReadyToPayRequest);
JSONObject jSONObject2 = cardsIsReadyToPayRequest;
this.cardsTask = paymentsClient2.isReadyToPay(context, cardsIsReadyToPayRequest.toString());
} catch (NoSuchAlgorithmException e) {
AnalyticsUtil.reportError(getClass().getName(), "error:exception", e.getMessage());
}
Task<Boolean> task = this.cardsTask;
Objects.requireNonNull(task);
task.addOnCompleteListener(this);
Task<Boolean> task2 = this.upiTask;
Objects.requireNonNull(task2);
task2.addOnCompleteListener(this);
}
@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));
}
}
}
@Override
public void onComplete(@NonNull Task<Boolean> task) {
boolean booleanValue = task.getResult().booleanValue();
if (!task.equals(this.cardsTask)) {
BaseUtils.setCompatibleWithGooglePay(booleanValue);
} else {
BaseUtils.setIsGpayCardsUpiRegistered(booleanValue);
this.registerCallback.onResponse(booleanValue);
}
}
@Override
public void processPayment(String str, HashMap<String, Object> hashMap, Activity activity, RzpInternalCallback rzpInternalCallback) {
}
@Override
public void processPayment(String str, JSONObject jSONObject, Activity activity, RzpInternalCallback rzpInternalCallback) {
try {
this.rzpInternalCallback = rzpInternalCallback;
this.mPaymentClient = Wallet.getPaymentsClient();
if (jSONObject.has("type") && jSONObject.getString("type").equalsIgnoreCase("application")) {
this.apiResponse = jSONObject;
JSONObject jSONObject2 = jSONObject.getJSONObject("request").getJSONArray("content").getJSONObject(0);
try {
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_PROCESS_PAYMENT_CARDS_UPI_CALLED);
this.mPaymentClient.loadPaymentData(activity, jSONObject2.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 occurred");
return;
}
}
if (!jSONObject.has("url_data")) {
HashMap hashMap = new HashMap();
hashMap.put("Content-Type", "application/x-www-form-urlencoded");
e.a("https://api.razorpay.com/v1/payments/create/ajax", RzpGpayUtilMerged.makeApiPayload(jSONObject), hashMap, new w(this, activity, jSONObject));
return;
}
this.isUpiOnly = true;
try {
String obj = jSONObject.get("url_data").toString();
try {
this.apiResponse = RzpGpayUtilMerged.getUpiData(obj);
AnalyticsUtil.trackEvent(AnalyticsEvent.GOOGLEPAY_PROCESS_PAYMENT_CUSTOMUI_CALLED);
this.mPaymentClient.loadPaymentData(activity, RzpGpayUtilMerged.getPaymentRequestData(obj, jSONObject), LOAD_PAYMENT_DATA_REQUEST_CODE);
return;
} catch (Exception unused) {
genericOnPaymentFailure("BAD_REQUEST_ERROR", 1, "An internal error has occurred");
return;
}
} catch (Exception e2) {
AnalyticsUtil.reportError(getClass().getName(), "error:exception", e2.getMessage());
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.");
}
AnalyticsUtil.reportError(getClass().getName(), "error:exception", e3.getMessage());
genericOnPaymentFailure("BAD_REQUEST_ERROR", 1, "An internal error has occurred.");
}
public void setApiResponse(JSONObject jSONObject) {
this.apiResponse = jSONObject;
}
public void setIsUpiOnly(boolean z) {
this.isUpiOnly = z;
}
public void setRzpInternalCallback(RzpInternalCallback rzpInternalCallback) {
this.rzpInternalCallback = rzpInternalCallback;
}
@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);
PaymentsClient paymentsClient = this.mPaymentClient;
JSONObject isReadyToPayRequest = RzpGpayUtilMerged.getIsReadyToPayRequest();
Objects.requireNonNull(isReadyToPayRequest);
JSONObject jSONObject = isReadyToPayRequest;
task = paymentsClient.isReadyToPay(context, isReadyToPayRequest.toString());
try {
PaymentsClient paymentsClient2 = this.mPaymentClient;
JSONObject cardsIsReadyToPayRequest = RzpGpayUtilMerged.getCardsIsReadyToPayRequest();
Objects.requireNonNull(cardsIsReadyToPayRequest);
JSONObject jSONObject2 = cardsIsReadyToPayRequest;
task2 = paymentsClient2.isReadyToPay(context, cardsIsReadyToPayRequest.toString());
} catch (NoSuchAlgorithmException e) {
e = e;
AnalyticsUtil.reportError(getClass().getName(), "error:exception", e.getMessage());
Objects.requireNonNull(task2);
task2.addOnCompleteListener(new x(this));
Objects.requireNonNull(task);
task.addOnCompleteListener(new y(this));
}
} catch (NoSuchAlgorithmException e2) {
e = e2;
task = null;
}
Objects.requireNonNull(task2);
task2.addOnCompleteListener(new x(this));
Objects.requireNonNull(task);
task.addOnCompleteListener(new y(this));
}
}