batchupload is fixed now

This commit is contained in:
kizzy 2026-07-21 18:02:18 +07:00
parent 4ae46e9e99
commit f544ea7547
2 changed files with 20 additions and 15 deletions

View File

@ -60,8 +60,11 @@ public class BatchUploadProcess {
payDetail.setPINCipher("");
payDetail.setReferNo(oldPayDetail.getReferNo());
payDetail.setCardInfo(oldPayDetail.getCardInfo());
payDetail.setApprovalCode(oldPayDetail.getApprovalCode());
String field60 = FINANCIAL_MTI + oldPayDetail.getVoucherNo();
payDetail.setVoucherNo(oldPayDetail.voucherNo);
String field60 = oldPayDetail.getMsgType() + oldPayDetail.getVoucherNo();
newTradeData.setField60(field60);

View File

@ -10,6 +10,7 @@ import com.utsmyanmar.paylibs.utils.secure.TerminalSecure;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
@ -171,15 +172,14 @@ public class EncodePackage {
// need to fix this one later for field 62
if (hostName == HostName.BPC) {
len += msgField.getLengthType() + msgField.getDataLength();
} else if (msgField.getLengthType() == 2) {
// MPU F60/F62/F63: FieldUtils prepends a 4-digit ASCII length,
// then packing BCD-encodes those 4 digits to 2 bytes + ASC body.
// Wire size = 2 + (dataLength - 4) = dataLength - 2.
len += Math.max(0, msgField.getDataLength() - 2);
} else {
// len += (msgField.getLengthType() + 1) / 2 + msgField.getDataLength(); // Nov19,2025
len += msgField.getDataLength();
}
// len += (msgField.getLengthType() + 1) / 2 + msgField.getDataLength();
// len += msgField.getLengthType() + msgField.getDataLength();
// msgField.getLengthType() => 2
// len+=msgField.getDataLength()-msgField.getLengthType();
} else {
len += msgField.getDataLength();
}
@ -280,14 +280,15 @@ public class EncodePackage {
System.arraycopy(fieldBody.getBytes(StandardCharsets.ISO_8859_1), 0, body, index, fieldBody.length());
index += fieldBody.length();
} else {
// MPU
String fieldHead = msgField.getDataStr().substring(0,4);
// MPU: 4-digit ASCII length -> 2-byte BCD, then ASC body
String dataStr = msgField.getDataStr();
String fieldHead = dataStr.substring(0, 4);
int bcdLen = (fieldHead.length() / 2) + (fieldHead.length() % 2);
byte dat[] = new byte[bcdLen];
Utils.BCDEncode(fieldHead, dat, msgField.getAlignType(), msgField.getFillChar());
System.arraycopy(dat, 0, body, index, bcdLen);
index += bcdLen;
String fieldBody = msgField.getDataStr().substring(4,msgField.getDataLength());
String fieldBody = dataStr.substring(4);
System.arraycopy(fieldBody.getBytes(StandardCharsets.ISO_8859_1), 0, body, index, fieldBody.length());
LogUtil.d(Constant.TAG,"fieldBody : "+fieldBody);
index += fieldBody.length();
@ -352,10 +353,11 @@ public class EncodePackage {
// body = ByteUtil.hexStr2Bytes("000060310010000000000000000100702404802080120016551580000000002631000000000000000000053626020051000355515800000000026D2602201100000028303036333232303031EDC4362D733DEA1801495F2A0201045F340100820239008407A0000000041010950504800410009A032108139C01319F02060000000000009F03060000000000009F090200209F10120110A00001220000000000000000000000FF9F1A0201049F1E0830303030303930359F26084D513EF2B4B7C6AE9F2701809F33036060C89F34034203009F3501229F3602001B9F370498AF7E7C9F41030000909F5300");
//Calculate message length
body[0] = (byte) ((body.length - 2) / 256);
body[1] = (byte) ((body.length - 2) % 256);
return body;
// Trim to bytes actually packed so unused buffer padding (e.g. trailing 0000) is not sent.
byte[] packed = Arrays.copyOf(body, index);
packed[0] = (byte) ((index - 2) / 256);
packed[1] = (byte) ((index - 2) % 256);
return packed;
}