导航菜单

页面标题

页面副标题

Hopscotch v9.7.2 - BinInfoTask.java 源代码

正在查看: Hopscotch v9.7.2 应用的 BinInfoTask.java JAVA 源代码文件

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


package com.payu.india.Tasks;

import android.os.AsyncTask;
import android.util.Log;
import com.facebook.appevents.internal.b;
import com.payu.custombrowser.util.CBConstant;
import com.payu.india.Interfaces.BinInfoApiListener;
import com.payu.india.Model.CardInformation;
import com.payu.india.Model.PayuConfig;
import com.payu.india.Model.PayuResponse;
import com.payu.india.Model.PostData;
import com.payu.india.Payu.PayuConstants;
import com.payu.india.Payu.PayuErrors;
import com.payu.india.Payu.PayuUtils;
import com.payu.upisdk.util.UpiConstant;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import org.json.JSONException;
import org.json.JSONObject;

public class BinInfoTask extends AsyncTask<PayuConfig, String, PayuResponse> {
    private final String TAG = getClass().getSimpleName();
    BinInfoApiListener apiListener;

    public BinInfoTask(BinInfoApiListener binInfoApiListener) {
        this.apiListener = binInfoApiListener;
    }

    @Override
    public PayuResponse doInBackground(PayuConfig... payuConfigArr) {
        PayuResponse payuResponse = new PayuResponse();
        PostData postData = new PostData();
        try {
            PayuConfig payuConfig = payuConfigArr[0];
            int environment = payuConfig.getEnvironment();
            HttpsURLConnection httpsConn = PayuUtils.getHttpsConn((environment != 0 ? environment != 1 ? environment != 2 ? environment != 3 ? new URL("https://info.payu.in/merchant/postservice.php?form=2") : new URL(PayuConstants.MOBILE_DEV_FETCH_DATA_URL) : new URL("https://test.payu.in/merchant/postservice?form=2") : new URL("https://test.payu.in/merchant/postservice?form=2") : new URL("https://info.payu.in/merchant/postservice.php?form=2")).toString(), payuConfig.getData());
            if (httpsConn != null) {
                InputStream inputStream = httpsConn.getInputStream();
                StringBuffer stringBuffer = new StringBuffer();
                byte[] bArr = new byte[1024];
                while (true) {
                    int read = inputStream.read(bArr);
                    if (read == -1) {
                        break;
                    }
                    stringBuffer.append(new String(bArr, 0, read));
                }
                JSONObject jSONObject = new JSONObject(stringBuffer.toString());
                payuResponse.setRawResponse(jSONObject);
                if (jSONObject.has("status") && jSONObject.optInt("status") == 0) {
                    postData.setCode(PayuErrors.GET_BIN_INFO_API_EXCEPTION);
                    postData.setStatus("ERROR");
                    postData.setResult(jSONObject.optString(UpiConstant.DATA) != null ? jSONObject.optString(UpiConstant.DATA) : "Something went wrong");
                } else if (jSONObject.optInt("status") == 1) {
                    postData.setCode(0);
                    postData.setStatus("SUCCESS");
                    CardInformation cardInformation = new CardInformation();
                    JSONObject jSONObject2 = jSONObject.getJSONObject(UpiConstant.DATA).getJSONObject("bins_data");
                    cardInformation.setIssuingBank(jSONObject2.getString(PayuConstants.BIN_INFO_ISSUING_BANK));
                    cardInformation.setBin(jSONObject2.getString("bin"));
                    cardInformation.setCardCategory(jSONObject2.getString("category").equalsIgnoreCase(PayuConstants.DEBITCARD) ? "DC" : "CC");
                    cardInformation.setCardType(jSONObject2.getString("card_type"));
                    cardInformation.setIsZeroRedirectSupported(Boolean.valueOf(jSONObject2.optInt(PayuConstants.BIN_INFO_IS_ZERO_REDIRECT_SUPPORTED) == 1));
                    cardInformation.setIsOtpOnTheFly(Boolean.valueOf(jSONObject2.optInt(PayuConstants.BIN_INFO_IS_OTP_ON_THE_FLY) == 1));
                    cardInformation.setIsAtmPinCard(Boolean.valueOf(jSONObject2.optString(PayuConstants.BIN_INFO_IS_ATM_PIN_CARD).contentEquals(CBConstant.TRANSACTION_STATUS_SUCCESS)));
                    cardInformation.setIsSiSupported(Boolean.valueOf(jSONObject2.optInt(PayuConstants.BIN_INFO_IS_SI_SUPPORTED) == 1));
                    cardInformation.setPgId(jSONObject2.optString("pgId"));
                    cardInformation.setIsDomestic(Boolean.valueOf(jSONObject2.getString(PayuConstants.BIN_INFO_IS_DOMESTIC).contentEquals(CBConstant.TRANSACTION_STATUS_SUCCESS)));
                    payuResponse.setCardInformation(cardInformation);
                }
            }
        } catch (MalformedURLException e) {
            Log.d(this.TAG, "MalformedURLException " + e.getMessage());
        } catch (ProtocolException e2) {
            Log.d(this.TAG, "ProtocolException " + e2.getMessage());
        } catch (IOException e3) {
            Log.d(this.TAG, "IOException " + e3.getMessage());
        } catch (JSONException e4) {
            b.k(e4, new StringBuilder("JSONException "), this.TAG);
        }
        payuResponse.setResponseStatus(postData);
        return payuResponse;
    }

    @Override
    public void onPostExecute(PayuResponse payuResponse) {
        super.onPostExecute((BinInfoTask) payuResponse);
        this.apiListener.onBinInfoApiResponse(payuResponse);
    }
}