导航菜单

页面标题

页面副标题

Hopscotch v9.7.2 - EligibleBinsForEMITask.java 源代码

正在查看: Hopscotch v9.7.2 应用的 EligibleBinsForEMITask.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.india.Interfaces.EligibleBinsForEMIApiListener;
import com.payu.india.Model.EligibleEmiBins;
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 java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import javax.net.ssl.HttpsURLConnection;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

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

    public EligibleBinsForEMITask(EligibleBinsForEMIApiListener eligibleBinsForEMIApiListener) {
        this.apiListener = eligibleBinsForEMIApiListener;
    }

    @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(PayuConstants.MSG)) {
                    postData.setResult(jSONObject.getString(PayuConstants.MSG));
                }
                if (jSONObject.has("status") && jSONObject.getInt("status") == 0) {
                    postData.setCode(PayuErrors.INVALID_HASH);
                    postData.setStatus("ERROR");
                } else {
                    postData.setCode(0);
                    postData.setStatus("SUCCESS");
                }
                if (jSONObject.has("details") && jSONObject.get("details") != null) {
                    JSONObject jSONObject2 = jSONObject.getJSONObject("details");
                    Iterator<String> keys = jSONObject2.keys();
                    ArrayList<EligibleEmiBins> arrayList = new ArrayList<>();
                    while (true) {
                        if (!keys.hasNext()) {
                            break;
                        }
                        EligibleEmiBins eligibleEmiBins = new EligibleEmiBins();
                        String next = keys.next();
                        if (jSONObject2.optJSONObject(next) == null) {
                            eligibleEmiBins.setIsEligible(Integer.valueOf(jSONObject2.optInt(PayuConstants.IS_ELIGIBLE)));
                            eligibleEmiBins.setBankShortName(jSONObject2.optString("bank"));
                            eligibleEmiBins.setMinAmount(Integer.valueOf(jSONObject2.optInt(PayuConstants.MIN_AMOUNT)));
                            if (jSONObject2.has(PayuConstants.MSG)) {
                                eligibleEmiBins.setIsEligible(0);
                            }
                            arrayList.add(eligibleEmiBins);
                        } else {
                            JSONObject optJSONObject = jSONObject2.optJSONObject(next);
                            eligibleEmiBins.setBankShortName(next);
                            eligibleEmiBins.setMinAmount(Integer.valueOf(optJSONObject.optInt(PayuConstants.MIN_AMOUNT)));
                            eligibleEmiBins.setIsEligible(1);
                            ArrayList<String> arrayList2 = new ArrayList<>();
                            if (optJSONObject.has(PayuConstants.CARD_BINS) && optJSONObject.optJSONArray(PayuConstants.CARD_BINS) != null && optJSONObject.optJSONArray(PayuConstants.CARD_BINS).length() > 0) {
                                JSONArray jSONArray = optJSONObject.getJSONArray(PayuConstants.CARD_BINS);
                                for (int i = 0; i < jSONArray.length(); i++) {
                                    arrayList2.add(jSONArray.getString(i));
                                }
                            }
                            eligibleEmiBins.setCardBins(arrayList2);
                            arrayList.add(eligibleEmiBins);
                        }
                    }
                    payuResponse.setEligibleEmiBins(arrayList);
                }
            }
        } 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((EligibleBinsForEMITask) payuResponse);
        this.apiListener.onEligibleBinsForEMIApiResponse(payuResponse);
    }
}