integration with cz host
This commit is contained in:
parent
142716caa4
commit
349d1eed2c
@ -13,12 +13,29 @@ data class MockCardData(
|
||||
|
||||
object MockData {
|
||||
|
||||
// private val mockCardData: MockCardData = MockCardData(
|
||||
// cardNo="9503712156912514",
|
||||
// expDate="2912",
|
||||
// cardScheme="MPU",
|
||||
// cardHolderName="Htin Kyaw Win",
|
||||
// iccData="9503712156912514=29121010000000000000"
|
||||
// )
|
||||
|
||||
// production card
|
||||
// private val mockCardData: MockCardData = MockCardData(
|
||||
// cardNo="9503220100322798",
|
||||
// expDate="2912",
|
||||
// cardScheme="MPU",
|
||||
// cardHolderName="Htin Kyaw Win",
|
||||
// iccData="9503220100322798=300110100000942"
|
||||
// )
|
||||
|
||||
private val mockCardData: MockCardData = MockCardData(
|
||||
cardNo="9503712156912514",
|
||||
expDate="2912",
|
||||
cardNo="9503032443884321",
|
||||
expDate="3102",
|
||||
cardScheme="MPU",
|
||||
cardHolderName="Htin Kyaw Win",
|
||||
iccData="9503712156912514=29121010000000000000"
|
||||
iccData="9503032443884321=310220100"
|
||||
)
|
||||
|
||||
fun generateMPUCard(): CardDataX = CardDataX().apply {
|
||||
|
||||
@ -28,7 +28,8 @@ public final class TerminalKeyUtil {
|
||||
|
||||
SecurityOptV2 mSecurityOptV2 = BaseApplication.getInstance().mSecurityOptV2;
|
||||
byte[] cvByte = ByteUtil.hexStr2Bytes("B7B520");
|
||||
byte[] dataByte = ByteUtil.hexStr2Bytes("e121249099a677e8b7d4f6a9d49fe8d1".toUpperCase());
|
||||
// byte[] dataByte = ByteUtil.hexStr2Bytes("e121249099a677e8b7d4f6a9d49fe8d1".toUpperCase()); // mpu
|
||||
byte[] dataByte = ByteUtil.hexStr2Bytes("05FFB893726A5F1E59692D24E72E36AC");
|
||||
|
||||
byte[] makBytes = ByteUtil.hexStr2Bytes("250738083EC15BD3BA67D66B8A7AA13B");
|
||||
// byte[] makCvBytes = ByteUtil.hexStr2Bytes("204E449B97");
|
||||
@ -46,6 +47,7 @@ public final class TerminalKeyUtil {
|
||||
int result = 0;
|
||||
|
||||
SystemParamsOperation.getInstance().setTMKIndex("9");
|
||||
// SystemParamsOperation.getInstance().setInjectOnce(false);
|
||||
if(!SystemParamsOperation.getInstance().isInjectOnce()) {
|
||||
try {
|
||||
// result = mSecurityOptV2.saveKeyDukpt(AidlConstantsV2.Security.KEY_TYPE_DUPKT_IPEK,IPEKByte,IPEKKCVByte,KSNByte,AidlConstantsV2.Security.KEY_ALG_TYPE_3DES,9);
|
||||
|
||||
@ -124,6 +124,7 @@ public class ISOMsgX extends BaseISOMsgX{
|
||||
|
||||
Map<String, MsgField> map = FieldUtils.fillEachFieldValue(rm, tradeData);
|
||||
|
||||
tradeData.payDetail.setMsgType(MTI);
|
||||
return packByte(map, MTI,hostName,isoMode);
|
||||
}
|
||||
|
||||
|
||||
@ -26,14 +26,11 @@ import java.security.KeyManagementException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.regex.Matcher;
|
||||
@ -67,7 +64,6 @@ import sunmi.sunmiui.utils.LogUtil;
|
||||
|
||||
public class ISOSocket {
|
||||
|
||||
private static final String TAG = ISOSocket.class.getSimpleName();
|
||||
private static final int DEFAULT_TIMEOUT = 30 * 1000;
|
||||
private String serverIP;
|
||||
private int serverPort;
|
||||
@ -152,7 +148,7 @@ public class ISOSocket {
|
||||
private SSLSocketFactory getSSLSocketFactory()
|
||||
throws CertificateException, KeyStoreException, IOException, NoSuchAlgorithmException, KeyManagementException {
|
||||
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
||||
InputStream caInput = context.getResources().openRawResource(R.raw.mob_uat); // this cert file stored in \app\src\main\res\raw folder path
|
||||
InputStream caInput = context.getResources().openRawResource(R.raw.mob); // this cert file stored in \app\src\main\res\raw folder path
|
||||
|
||||
Certificate ca = cf.generateCertificate(caInput);
|
||||
caInput.close();
|
||||
@ -179,7 +175,7 @@ public class ISOSocket {
|
||||
private OkHttpClient getClient()
|
||||
throws CertificateException, KeyStoreException, IOException, NoSuchAlgorithmException, KeyManagementException {
|
||||
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
||||
InputStream caInput = context.getResources().openRawResource(R.raw.mob_uat); // this cert file stored in \app\src\main\res\raw folder path
|
||||
InputStream caInput = context.getResources().openRawResource(R.raw.mob); // this cert file stored in \app\src\main\res\raw folder path
|
||||
|
||||
Certificate ca = cf.generateCertificate(caInput);
|
||||
caInput.close();
|
||||
@ -330,16 +326,9 @@ public class ISOSocket {
|
||||
}
|
||||
return port;
|
||||
}
|
||||
private String formatDate(Date d) { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(d); }
|
||||
|
||||
public void switchIp() {
|
||||
isSwitchIp = true;
|
||||
// serverIP = "posuat.myanmarorientalbank.com";
|
||||
// serverPort = 5033;
|
||||
// serverIP = "192.168.0.100";
|
||||
// serverPort = 5001;
|
||||
// serverIP = "103.84.101.82";
|
||||
// serverPort = 60147;
|
||||
serverIP = getSecondaryIp();
|
||||
serverPort = getSecondaryPort();
|
||||
}
|
||||
@ -360,13 +349,6 @@ public class ISOSocket {
|
||||
if (!isSwitchIp) {
|
||||
serverIP = getIp();
|
||||
serverPort = getPort();
|
||||
// serverIP = "192.168.0.100";
|
||||
// serverPort = 5001;
|
||||
// serverIP = "103.84.101.82";
|
||||
// serverPort = 60147;
|
||||
// SystemParamsOperation.getInstance().setSslSwitchStatus(true);
|
||||
// serverIP = "posuat.myanmarorientalbank.com";
|
||||
// serverPort = 5033;
|
||||
} else {
|
||||
isSwitchIp = false;
|
||||
}
|
||||
@ -402,51 +384,16 @@ public class ISOSocket {
|
||||
if (SystemParamsOperation.getInstance().isSslOn()) {
|
||||
|
||||
try {
|
||||
|
||||
// For MPU
|
||||
TrustManager[] trustAll = new TrustManager[]{new X509TrustManager() {
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {}
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {}
|
||||
public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; }
|
||||
}};
|
||||
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||
ctx.init(null, trustAll, new SecureRandom());
|
||||
|
||||
SSLSocketFactory factory = ctx.getSocketFactory();
|
||||
|
||||
|
||||
|
||||
|
||||
sslSocket = (SSLSocket) factory.createSocket();
|
||||
sslSocket.setEnabledProtocols(new String[]{"TLSv1.2"});
|
||||
|
||||
OkHttpClient client = getClient();
|
||||
sslSocket = (SSLSocket) client.sslSocketFactory().createSocket();
|
||||
// while (!isSSLOnline(timeout,subscriber)) {
|
||||
// Thread.sleep(150);
|
||||
// subscriber.onError(new Throwable("java.net.SocketTimeoutException: connect timed out"));
|
||||
// }
|
||||
|
||||
sslSocket.setSoTimeout(60000);
|
||||
sslSocket.connect(new InetSocketAddress(serverIP, serverPort), connectTimeout);
|
||||
|
||||
// MPU
|
||||
sslSocket.startHandshake();
|
||||
|
||||
SSLSession session = sslSocket.getSession();
|
||||
|
||||
LogUtil.d(TAG, "SSL handshake success to " + serverIP + ":" + serverPort + "\n");
|
||||
LogUtil.d(TAG, "TLS handshake success to " + serverIP + ":" + serverPort + "\n");
|
||||
LogUtil.d(TAG, "TLS version: " + session.getProtocol() + "\n");
|
||||
LogUtil.d(TAG,"Cipher suite: " + session.getCipherSuite() + "\n");
|
||||
|
||||
try {
|
||||
java.security.cert.Certificate[] chain = session.getPeerCertificates();
|
||||
if (chain != null && chain.length > 0) {
|
||||
LogUtil.d(TAG,"Peer certificates:\n");
|
||||
for (int i = 0; i < chain.length; i++) {
|
||||
X509Certificate x = (X509Certificate) chain[i];
|
||||
LogUtil.d(TAG, " [" + i + "] Subject: " + x.getSubjectX500Principal().getName() + "\n");
|
||||
LogUtil.d(TAG," Issuer: " + x.getIssuerX500Principal().getName() + "\n");
|
||||
LogUtil.d(TAG," Valid: " + formatDate(x.getNotBefore()) + " - " + formatDate(x.getNotAfter()) + "\n");
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) { }
|
||||
|
||||
inputStream = sslSocket.getInputStream();
|
||||
outputStream = sslSocket.getOutputStream();
|
||||
|
||||
@ -460,11 +407,6 @@ public class ISOSocket {
|
||||
int len = -1;
|
||||
if (reversalTestCaseFlag) {
|
||||
len = inputStream.read(recBuff);
|
||||
} else {
|
||||
int lenn = inputStream.read(recBuff);
|
||||
|
||||
String received = ByteUtil.bytes2HexStr(recBuff);
|
||||
LogUtil.d(TAG,"Received Response :"+received);
|
||||
}
|
||||
|
||||
rLen = len;
|
||||
@ -479,7 +421,7 @@ public class ISOSocket {
|
||||
subscriber.onComplete();
|
||||
|
||||
|
||||
} catch (IOException |
|
||||
} catch (CertificateException | KeyStoreException | IOException |
|
||||
NoSuchAlgorithmException | KeyManagementException e) {
|
||||
e.printStackTrace();
|
||||
subscriber.onError(e);
|
||||
@ -516,11 +458,6 @@ public class ISOSocket {
|
||||
int len = -1;
|
||||
if (reversalTestCaseFlag) {
|
||||
len = inputStream.read(recBuff);
|
||||
} else {
|
||||
int lenn = inputStream.read(recBuff);
|
||||
|
||||
String received = ByteUtil.bytes2HexStr(recBuff);
|
||||
LogUtil.d(TAG,"Received Response :"+received);
|
||||
}
|
||||
|
||||
rLen = len;
|
||||
|
||||
@ -94,6 +94,7 @@ public class SignOnProcess {
|
||||
|
||||
System.arraycopy(field62, 0, encryptedPIK, 0, 8);
|
||||
System.arraycopy(field62, 0, encryptedPIK, 8, 8);
|
||||
// System.arraycopy(field62, 0, encryptedPIK, 0, 16);
|
||||
try {
|
||||
byte[] kcv = ByteUtil.hexStr2Bytes(TriDes.getKcv(encryptedPIK));
|
||||
LogUtil.d(TAG, "Encrypted PIK:" + ByteUtil.bytes2HexStr(encryptedPIK));
|
||||
@ -122,6 +123,7 @@ public class SignOnProcess {
|
||||
|
||||
System.arraycopy(field62, 0, encryptedPIK, 0, 8);
|
||||
System.arraycopy(field62, 0, encryptedPIK, 8, 8);
|
||||
|
||||
// System.arraycopy(field62, 0, encryptedPIK, 0, 16);
|
||||
|
||||
try {
|
||||
|
||||
@ -5,7 +5,8 @@ public enum HostName {
|
||||
FINEXUS("FINEXUS"),
|
||||
CARDZONE("CARDZONE"),
|
||||
|
||||
MPU("MPU");
|
||||
MPU("MPU"),
|
||||
MOB("MOB");
|
||||
|
||||
|
||||
public final String name;
|
||||
|
||||
@ -44,7 +44,7 @@ public class HostUtils {
|
||||
if (hostName == HostName.MPU) {
|
||||
bitmap = BitmapConfig.MPU_NEW_VOID;
|
||||
} else {
|
||||
bitmap = BitmapConfig.FINEXUS_VOID;
|
||||
bitmap = BitmapConfig.CZ_VOID;
|
||||
}
|
||||
break;
|
||||
case SETTLEMENT:
|
||||
|
||||
@ -193,6 +193,7 @@ public class BitmapConfig {
|
||||
public static final String MPU_NEW_CASH_ADVANCE="7020058020C09000";
|
||||
|
||||
public static final String CZ_SALE="7020058020C09000";
|
||||
public static final String CZ_VOID="723805802CC08010";
|
||||
|
||||
public static final String UPI_SALE = "7020058020C09200";
|
||||
|
||||
|
||||
@ -247,7 +247,7 @@ public class FieldConfig {
|
||||
// for TTIP MPU
|
||||
// /* FLD 35 */ {2, SDK_8583_LEN_BCD, 37, SDK_8583_DATA_BCD, SDK_8583_ALIGN_L, '0'},
|
||||
|
||||
/* FLD 35 */ {2, SDK_8583_LEN_BCD, 37, SDK_8583_DATA_BCD, SDK_8583_ALIGN_R, '0'},
|
||||
/* FLD 35 */ {2, SDK_8583_LEN_BCD, 37, SDK_8583_DATA_BCD, SDK_8583_ALIGN_R, ' '},
|
||||
/* FLD 36 */ {3, SDK_8583_LEN_BCD, 999, SDK_8583_DATA_BIT, SDK_8583_ALIGN_L, '0'},
|
||||
|
||||
/* FLD 37 */ {0, SDK_8583_LEN_BCD, 12, SDK_8583_DATA_ASC, SDK_8583_ALIGN_R, '0'},
|
||||
|
||||
@ -4,11 +4,13 @@ import android.text.TextUtils;
|
||||
|
||||
import com.sunmi.pay.hardware.aidl.AidlConstants;
|
||||
import com.utsmyanmar.paylibs.Constant;
|
||||
import com.utsmyanmar.paylibs.batch_upload.BatchUploadProcess;
|
||||
import com.utsmyanmar.paylibs.model.MsgField;
|
||||
import com.utsmyanmar.paylibs.model.PayDetail;
|
||||
import com.utsmyanmar.paylibs.model.TradeData;
|
||||
import com.utsmyanmar.paylibs.model.enums.TransCVM;
|
||||
import com.utsmyanmar.paylibs.utils.enums.CardScheme;
|
||||
import com.utsmyanmar.paylibs.utils.enums.HostName;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Iterator;
|
||||
@ -504,9 +506,12 @@ public class FieldUtils {
|
||||
|
||||
break;
|
||||
case 60: //Private(oldMPU) //original Amount Void(new MPU)
|
||||
|
||||
String field60 = tradeData.getField60();
|
||||
String lengthValue = String.format(Locale.getDefault(),"%04d", field60.length())+field60;
|
||||
field.setDataStr(lengthValue);
|
||||
|
||||
|
||||
break;
|
||||
case 61:
|
||||
// TODO
|
||||
|
||||
@ -83,7 +83,7 @@ public class Params {
|
||||
payDetail.transNum = System.currentTimeMillis() / 1000;
|
||||
// need to add host logic in another place
|
||||
// payDetail.setHostName("MPU");
|
||||
payDetail.setHostName("MPU");
|
||||
payDetail.setHostName("MOB");
|
||||
// payDetail.setHostName("MOB");
|
||||
|
||||
payDetail.setOriginalTransDate(SystemDateTime.getMMDD()+SystemDateTime.getYYYY());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user