package com.wangyin.payment.jdpaysdk.netnew; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.jdpay.bury.JPBury; import com.jdpay.sdk.netlib.Net; import com.jdpay.sdk.netlib.converter.ResponseType; import com.wangyin.payment.jdpaysdk.bury.BuryManager; import com.wangyin.payment.jdpaysdk.core.record.Record; import com.wangyin.payment.jdpaysdk.core.record.RecordStore; import com.wangyin.payment.jdpaysdk.counter.entity.CPPayConfig; import com.wangyin.payment.jdpaysdk.counter.entity.ControlInfo; import com.wangyin.payment.jdpaysdk.counter.entity.PayWayResultData; import com.wangyin.payment.jdpaysdk.counter.protocol.CommonEncryptParam; import com.wangyin.payment.jdpaysdk.counter.protocol.ConfigInfoEncryptParam; import com.wangyin.payment.jdpaysdk.counter.protocol.ConfigInfoResult; import com.wangyin.payment.jdpaysdk.counter.protocol.JDPayAccessReturnModel; import com.wangyin.payment.jdpaysdk.counter.protocol.QuickBindCardVerifyResult; import com.wangyin.payment.jdpaysdk.net.crypto.CryptoManager; import com.wangyin.payment.jdpaysdk.netnew.bean.request.impl.CPISShowParam; import com.wangyin.payment.jdpaysdk.netnew.bean.request.impl.CPPayAccessParam; import com.wangyin.payment.jdpaysdk.netnew.bean.request.impl.CPPayPrepareParam; import com.wangyin.payment.jdpaysdk.netnew.bean.request.impl.CPSmallFreeParam; import com.wangyin.payment.jdpaysdk.netnew.bean.request.impl.CPSmallFreeSwitchParam; import com.wangyin.payment.jdpaysdk.netnew.bean.request.impl.ConfigInfoParam; import com.wangyin.payment.jdpaysdk.netnew.bean.request.impl.QuickBindCardVerifyParam; import com.wangyin.payment.jdpaysdk.netnew.bean.request.impl.QuickBindCardVerifyTypeParam; import com.wangyin.payment.jdpaysdk.netnew.bean.response.Response; import com.wangyin.payment.jdpaysdk.netnew.bean.response.impl.ShowPayWayResultData; import com.wangyin.payment.jdpaysdk.netnew.callback.BusinessCallback; import com.wangyin.payment.jdpaysdk.netnew.callback.DispatchCallback; import com.wangyin.payment.jdpaysdk.netnew.converter.GsonRequestConverter; import com.wangyin.payment.jdpaysdk.netnew.converter.GsonResponseConverter; import com.wangyin.payment.jdpaysdk.netnew.converter.GsonResponseConverterV3; import com.wangyin.payment.jdpaysdk.netnew.converter.GsonResponseEncrptConverterV3; import com.wangyin.payment.jdpaysdk.netnew.converter.processor.Preprocessor; public class NetApi { public static void access(final int i, CPPayAccessParam cPPayAccessParam, Net.RawCallback rawCallback, @NonNull BusinessCallback<JDPayAccessReturnModel, Void> businessCallback) { CryptoManager.EncryptInfo emptyEncryptInfo = CryptoManager.getInstance().getEmptyEncryptInfo(i); Net.asyncCall(i, cPPayAccessParam, new Net.CallConfig("https://msjdpay.jd.com/service/access", new GsonRequestConverter(emptyEncryptInfo), new GsonResponseConverterV3(new ResponseType(Response.class, JDPayAccessReturnModel.class, Void.class), emptyEncryptInfo, new Preprocessor<Response<JDPayAccessReturnModel, Void>>() { /* class com.wangyin.payment.jdpaysdk.netnew.NetApi.AnonymousClass1 */ public Response<JDPayAccessReturnModel, Void> process(@Nullable Response<JDPayAccessReturnModel, Void> response) { if (response != null) { JDPayAccessReturnModel resultData = response.getResultData(); if (resultData != null) { RecordStore.getRecord(i).setPin(resultData.getDecryptPin()); RecordStore.getRecord(i).setPayAccount(resultData.getAppId(), resultData.getPayParam()); } else { JPBury jPBury = BuryManager.getJPBury(); jPBury.e("NetApi_access_process_ERROR", " jdPayAccessReturnModel=" + resultData + " msg=" + response.getResultMsg() + " "); } } return response; } }), null), rawCallback, new DispatchCallback(businessCallback)); } public static void preparePay(int i, final CPPayPrepareParam cPPayPrepareParam, Net.RawCallback rawCallback, @NonNull BusinessCallback<CPPayConfig, ControlInfo> businessCallback) { final CryptoManager.EncryptInfo emptyEncryptInfo = CryptoManager.getInstance().getEmptyEncryptInfo(i); final Record record = RecordStore.getRecord(i); String str = record.isExternal() ? "https://msjdpay.jd.com/service/external/preparePay" : "https://msjdpay.jd.com/service/preparePay"; ResponseType responseType = new ResponseType(Response.class, CPPayConfig.class, ControlInfo.class); AnonymousClass2 r4 = new Preprocessor<Response<CPPayConfig, ControlInfo>>() { /* class com.wangyin.payment.jdpaysdk.netnew.NetApi.AnonymousClass2 */ public Response<CPPayConfig, ControlInfo> process(@Nullable Response<CPPayConfig, ControlInfo> response) { CPPayConfig resultData; if (!(response == null || (resultData = response.getResultData()) == null)) { record.updateFidoUserCenter(resultData.getServerPin(), emptyEncryptInfo.getRsaKey()); record.setEncryptSupport(resultData.isEncryptSupport(cPPayPrepareParam.getNonceStr(), cPPayPrepareParam.getTimeStamp())); record.setShortSecureKeyboardCanUse(resultData.isShortSecureKeyboardCanUse(cPPayPrepareParam.getNonceStr(), cPPayPrepareParam.getTimeStamp())); record.setLongSecureKeyboardCanUse(resultData.isLongSecureKeyboardCanUse(cPPayPrepareParam.getNonceStr(), cPPayPrepareParam.getTimeStamp())); record.setEncryptSetting(resultData.isEncryptSetting(cPPayPrepareParam.getNonceStr(), cPPayPrepareParam.getTimeStamp())); record.setCashier(resultData.isNewSdkRound()); } return response; } }; if (record.isFullEncrypt()) { Net.asyncCall(i, new CommonEncryptParam(cPPayPrepareParam), new Net.CallConfig(str, new GsonRequestConverter(emptyEncryptInfo), new GsonResponseEncrptConverterV3(responseType, emptyEncryptInfo, r4), null), rawCallback, new DispatchCallback(businessCallback)); } else { Net.asyncCall(i, cPPayPrepareParam, new Net.CallConfig(str, new GsonRequestConverter(emptyEncryptInfo), new GsonResponseConverterV3(responseType, emptyEncryptInfo, r4), null), rawCallback, new DispatchCallback(businessCallback)); } } public static void showPayWayList(final int i, CPISShowParam cPISShowParam, Net.RawCallback rawCallback, @NonNull BusinessCallback<ShowPayWayResultData, Void> businessCallback) { final CryptoManager.EncryptInfo emptyEncryptInfo = CryptoManager.getInstance().getEmptyEncryptInfo(i); if (RecordStore.getRecord(i).isEncryptSetting()) { Net.asyncCall(i, new CommonEncryptParam(cPISShowParam), new Net.CallConfig("https://msjdpay.jd.com/service/showPayWayList", new GsonRequestConverter(emptyEncryptInfo), new GsonResponseEncrptConverterV3(new ResponseType(Response.class, ShowPayWayResultData.class, Void.class), emptyEncryptInfo, new Preprocessor<Response<ShowPayWayResultData, Void>>() { /* class com.wangyin.payment.jdpaysdk.netnew.NetApi.AnonymousClass3 */ public Response<ShowPayWayResultData, Void> process(@Nullable Response<ShowPayWayResultData, Void> response) { ShowPayWayResultData resultData; if (!(response == null || (resultData = response.getResultData()) == null)) { RecordStore.getRecord(i).updateFidoUserCenter(resultData.getServerPin(), emptyEncryptInfo.getRsaKey()); } return response; } }), null), rawCallback, new DispatchCallback(businessCallback)); return; } Net.asyncCall(i, cPISShowParam, new Net.CallConfig("https://msjdpay.jd.com/service/showPayWayList", new GsonRequestConverter(emptyEncryptInfo), new GsonResponseConverterV3(new ResponseType(Response.class, ShowPayWayResultData.class, Void.class), emptyEncryptInfo, new Preprocessor<Response<ShowPayWayResultData, Void>>() { /* class com.wangyin.payment.jdpaysdk.netnew.NetApi.AnonymousClass4 */ public Response<ShowPayWayResultData, Void> process(@Nullable Response<ShowPayWayResultData, Void> response) { ShowPayWayResultData resultData; if (!(response == null || (resultData = response.getResultData()) == null)) { RecordStore.getRecord(i).updateFidoUserCenter(resultData.getServerPin(), emptyEncryptInfo.getRsaKey()); } return response; } }), null), rawCallback, new DispatchCallback(businessCallback)); } public static void queryPayWayStatus(int i, CPSmallFreeParam cPSmallFreeParam, Net.RawCallback rawCallback, @NonNull BusinessCallback<PayWayResultData, Void> businessCallback) { CryptoManager.EncryptInfo emptyEncryptInfo = CryptoManager.getInstance().getEmptyEncryptInfo(i); if (RecordStore.getRecord(i).isEncryptSetting()) { Net.asyncCall(i, new CommonEncryptParam(cPSmallFreeParam), new Net.CallConfig("https://msjdpay.jd.com/service/queryPayWayStatus", new GsonRequestConverter(emptyEncryptInfo), new GsonResponseEncrptConverterV3(new ResponseType(Response.class, PayWayResultData.class, Void.class), emptyEncryptInfo), null), rawCallback, new DispatchCallback(businessCallback)); return; } Net.asyncCall(i, cPSmallFreeParam, new Net.CallConfig("https://msjdpay.jd.com/service/queryPayWayStatus", new GsonRequestConverter(), new GsonResponseConverter(new ResponseType(Response.class, PayWayResultData.class, Void.class)), null), rawCallback, new DispatchCallback(businessCallback)); } public static void queryQuickBindCardVerifyType(int i, QuickBindCardVerifyTypeParam quickBindCardVerifyTypeParam, Net.RawCallback rawCallback, BusinessCallback<QuickBindCardVerifyResult, Void> businessCallback) { CryptoManager.EncryptInfo emptyEncryptInfo = CryptoManager.getInstance().getEmptyEncryptInfo(i); Net.asyncCall(i, new CommonEncryptParam(quickBindCardVerifyTypeParam), new Net.CallConfig("https://msjdpay.jd.com/service/query/bindCardCheckType", new GsonRequestConverter(emptyEncryptInfo), new GsonResponseEncrptConverterV3(new ResponseType(Response.class, QuickBindCardVerifyResult.class, Void.class), emptyEncryptInfo), null), rawCallback, new DispatchCallback(businessCallback)); } public static void verifyQuickBindCard(int i, QuickBindCardVerifyParam quickBindCardVerifyParam, Net.RawCallback rawCallback, BusinessCallback<QuickBindCardVerifyResult, Void> businessCallback) { CryptoManager.EncryptInfo emptyEncryptInfo = CryptoManager.getInstance().getEmptyEncryptInfo(i); Net.asyncCall(i, new CommonEncryptParam(quickBindCardVerifyParam), new Net.CallConfig("https://msjdpay.jd.com/service/query/checkBindCard", new GsonRequestConverter(emptyEncryptInfo), new GsonResponseEncrptConverterV3(new ResponseType(Response.class, QuickBindCardVerifyResult.class, Void.class), emptyEncryptInfo), null), rawCallback, new DispatchCallback(businessCallback)); } public static void unifiedSwitch(int i, CPSmallFreeSwitchParam cPSmallFreeSwitchParam, Net.RawCallback rawCallback, @NonNull BusinessCallback<PayWayResultData, ControlInfo> businessCallback) { CryptoManager.EncryptInfo emptyEncryptInfo = CryptoManager.getInstance().getEmptyEncryptInfo(i); if (RecordStore.getRecord(i).isEncryptSetting()) { Net.asyncCall(i, new CommonEncryptParam(cPSmallFreeSwitchParam), new Net.CallConfig("https://msjdpay.jd.com/service/unifiedSwitch", new GsonRequestConverter(emptyEncryptInfo), new GsonResponseEncrptConverterV3(new ResponseType(Response.class, PayWayResultData.class, ControlInfo.class), emptyEncryptInfo), null), rawCallback, new DispatchCallback(businessCallback)); return; } Net.asyncCall(i, cPSmallFreeSwitchParam, new Net.CallConfig("https://msjdpay.jd.com/service/unifiedSwitch", new GsonRequestConverter(), new GsonResponseConverter(new ResponseType(Response.class, PayWayResultData.class, ControlInfo.class)), null), rawCallback, new DispatchCallback(businessCallback)); } public static void configInfo(int i, ConfigInfoParam configInfoParam, BusinessCallback<ConfigInfoResult, Void> businessCallback) { ConfigInfoEncryptParam configInfoEncryptParam = new ConfigInfoEncryptParam(i); configInfoEncryptParam.setConfigInfoParam(configInfoParam); CryptoManager.EncryptInfo emptyEncryptInfo = CryptoManager.getInstance().getEmptyEncryptInfo(i); Net.asyncCallWithTimeOut(i, configInfoEncryptParam, new Net.CallConfig("https://msjdpay.jd.com/service/switch/configParam", new GsonRequestConverter(emptyEncryptInfo), new GsonResponseEncrptConverterV3(new ResponseType(Response.class, ConfigInfoResult.class, Void.class), emptyEncryptInfo, null), null), new DispatchCallback(businessCallback)); } }