导航菜单

页面标题

页面副标题

Hopscotch v9.7.2 - GetTokenisedCardDetailsTask.java 源代码

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

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


package com.payu.india.Tasks;

import android.os.AsyncTask;
import com.payu.custombrowser.util.CBConstant;
import com.payu.india.Interfaces.GetTokenisedCardDetailsApiListener;
import com.payu.india.Model.IssuerToken;
import com.payu.india.Model.NetworkToken;
import com.payu.india.Model.PayuConfig;
import com.payu.india.Model.PayuResponse;
import com.payu.india.Model.PostData;
import com.payu.india.Model.TokenisedCardDetail;
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 javax.net.ssl.HttpsURLConnection;
import org.json.JSONException;
import org.json.JSONObject;

public class GetTokenisedCardDetailsTask extends AsyncTask<PayuConfig, String, PayuResponse> {
    private GetTokenisedCardDetailsApiListener mGetTokenisedCardDetailsApiListener;

    public GetTokenisedCardDetailsTask(GetTokenisedCardDetailsApiListener getTokenisedCardDetailsApiListener) {
        this.mGetTokenisedCardDetailsApiListener = getTokenisedCardDetailsApiListener;
    }

    @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("details")) {
                    JSONObject jSONObject2 = jSONObject.getJSONObject("details");
                    TokenisedCardDetail tokenisedCardDetail = new TokenisedCardDetail();
                    tokenisedCardDetail.setCryptogram(jSONObject2.getString(PayuConstants.TOKENISED_CARD_CRYPTOGRAM));
                    tokenisedCardDetail.setCardPAR(jSONObject2.optString(PayuConstants.CARD_PAR));
                    tokenisedCardDetail.setCardNo(jSONObject2.getString(PayuConstants.CARD_NO));
                    tokenisedCardDetail.setCardToken(jSONObject2.getString("card_token"));
                    tokenisedCardDetail.setCardName(jSONObject2.getString("card_name"));
                    tokenisedCardDetail.setTrid(jSONObject2.getString("trid"));
                    tokenisedCardDetail.setTokenRefernceId(jSONObject2.getString(PayuConstants.TOKENISED_CARD_TOKEN_REFERENCE_ID));
                    tokenisedCardDetail.setCardMode(jSONObject2.getString(PayuConstants.CARD_MODE));
                    if (jSONObject2.has(PayuConstants.TOKENISED_CARD_ISSUER_TOKEN)) {
                        JSONObject jSONObject3 = jSONObject2.getJSONObject(PayuConstants.TOKENISED_CARD_ISSUER_TOKEN);
                        IssuerToken issuerToken = new IssuerToken();
                        issuerToken.setTokenExpMon(jSONObject3.getString(PayuConstants.TOKENISED_CARD_TOKEN_EXP_MON));
                        issuerToken.setTokenExpYr(jSONObject3.getString(PayuConstants.TOKENISED_CARD_TOKEN_EXP_YR));
                        issuerToken.setTokenValue(jSONObject3.getString(PayuConstants.TOKENISED_CARD_TOKEN_VALUE));
                        tokenisedCardDetail.setIssuerToken(issuerToken);
                    }
                    if (jSONObject2.has(PayuConstants.TOKENISED_CARD_NETWORK_TOKEN)) {
                        JSONObject jSONObject4 = jSONObject2.getJSONObject(PayuConstants.TOKENISED_CARD_NETWORK_TOKEN);
                        NetworkToken networkToken = new NetworkToken();
                        networkToken.setTokenExpMon(jSONObject4.getString(PayuConstants.TOKENISED_CARD_TOKEN_EXP_MON));
                        networkToken.setTokenExpYr(jSONObject4.getString(PayuConstants.TOKENISED_CARD_TOKEN_EXP_YR));
                        networkToken.setTokenValue(jSONObject4.getString(PayuConstants.TOKENISED_CARD_TOKEN_VALUE));
                        tokenisedCardDetail.setNetworkToken(networkToken);
                    }
                    payuResponse.setTokenisedCardDetail(tokenisedCardDetail);
                }
                if (jSONObject.has("status") && jSONObject.getString("status").contentEquals(PayuConstants.STRING_ZERO)) {
                    postData.setCode(PayuErrors.INVALID_HASH);
                    postData.setStatus("ERROR");
                }
                if (jSONObject.has("status") && jSONObject.getString("status").contentEquals(CBConstant.TRANSACTION_STATUS_SUCCESS)) {
                    postData.setStatus("SUCCESS");
                    postData.setCode(0);
                }
                if (jSONObject.has(PayuConstants.MSG)) {
                    postData.setResult(jSONObject.getString(PayuConstants.MSG));
                }
            }
        } catch (MalformedURLException e) {
            postData.setCode(5022);
            postData.setStatus("ERROR");
            postData.setResult(e.getMessage());
        } catch (ProtocolException e2) {
            postData.setCode(5016);
            postData.setStatus("ERROR");
            postData.setResult(e2.getMessage());
        } catch (IOException e3) {
            postData.setCode(5016);
            postData.setStatus("ERROR");
            postData.setResult(e3.getMessage());
        } catch (JSONException e4) {
            postData.setCode(5014);
            postData.setStatus("ERROR");
            postData.setResult(e4.getMessage());
        }
        payuResponse.setResponseStatus(postData);
        return payuResponse;
    }

    @Override
    public void onPostExecute(PayuResponse payuResponse) {
        super.onPostExecute((GetTokenisedCardDetailsTask) payuResponse);
        this.mGetTokenisedCardDetailsApiListener.onTokenisedCardDetailsResponse(payuResponse);
    }
}