MPOS-Windows-SDK Programming Manual V1.5
MPOS-Windows-SDK Programming Manual V1.5
MPOS-Windows-SDK
Programming Manual
V1.5
1/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
Catalogue
1. Project Settings.................................................................................................................... 3
1.1. Import SDK file ........................................................................................................ 3
2. Instructions ........................................................................................................................... 3
3. Interface function specification ...................................................................................... 5
3.1. Initializes connection mode....................................................................................... 5
3.2. Open mpos device ..................................................................................................... 6
3.3. Close device .............................................................................................................. 6
3.4. Enter the password .................................................................................................... 7
3.5. Load DUKPT ............................................................................................................ 7
3.6. Set key index ............................................................................................................. 8
3.7. Download master key................................................................................................ 8
3.8. Download work key .................................................................................................. 9
3.9. Calculation MAC ...................................................................................................... 9
3.10. Executes the card reading process........................................................................... 10
3.11. Perform online authorization................................................................................... 11
3.12. Read MPOS information ......................................................................................... 11
3.13. Gets random numbers ............................................................................................. 12
3.14. Set the terminal time ............................................................................................... 12
3.15. Reset MPOS ............................................................................................................ 12
3.16. ICAidManage .......................................................................................................... 12
3.17. ICPublicKeyManage ............................................................................................... 13
3.18. Show QRCode......................................................................................................... 13
3.19. Show Text................................................................................................................ 14
3.20. Show Bitmap ........................................................................................................... 14
3.21. SetEmvParam .......................................................................................................... 15
3.22. Set sleep time .......................................................................................................... 15
4. appendix ............................................................................................................................... 17
4.1. Appendix B ............................................................................................................. 17
4.2. Appendix C PIN Encryption Algorithm .................................................................. 18
4.3. Appendix D UPAY MAC ........................................................................................ 19
4.4. Appendix E X99 MAC............................................................................................ 20
4.5. Appendix F X9.19 MAC ......................................................................................... 20
4.6. Appendix G Key System Description ..................................................................... 21
2/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
1. PROJECT SETTINGS
2. INSTRUCTIONS
Please load the dll and initialize the function before the project runs
3/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
1. BOOL CsampleDlg::OnInitDialog()
2. {
3. CDialog::OnInitDialog();
4. mf_init(0, MFEU_CONNECTED_MODE_HID);
5. return TRUE;
6. }
mf_connect() or mf_connectBT("04:23:00:00:09:00")
After the connection is successful, you can call mf_card_exec to execute the
1. int ret = 0;
2. MFST_CARD_INFO param;
3. MFST_RETURN_CARD_INFO returnCardInfo;
4.
5. param.transName = "Sale";
6. param.cardmode = Card_RF | CARD_TRACE | Card_IC;
7. param.cardTimeout = 60;
8. param.transtype = TRANSTYPE_SALE;
9. param.tags = defaulTags;
10. param.tagslen = sizeof(defaulTags);
11. param.emvexectype = 0x06;
12. param.ecashpermit = 0x00;
13. param.forceonline = 0x31;
14. param.pinInput = 0x01;
15. param.pinMaxLen = 0x06;
16. param.pinTimeout = 60;
17. param.allowfallback = 0x01;
18. param.requiretype = 0x00;
19. param.orderid = (unsigned char*)" ";
20.
21. param.amount = 1;
22. param.cardstate = cardstate;
23.
24. ret = mf_card_exec(¶m, &returnCardInfo);
25.
26. if (ret == 0) {
27. CString cardType;
28. CString pan;
29. CString expData;
30. CString serviceCode;
31. CString track2Len;
4/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
5/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
6/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
7/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
8/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
9/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
10/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
11/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
3.16. ICAidManage
Prototype:
int mf_aidManager(MFEU_AID_ACTION action, const char *aid);
Explain:
12/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
3.17. ICPublicKeyManage
Prototype:
int mf_pukManager(MFEU_PUK_ACTION action, const char *puk);
Explain:
send IC card command, obtain command return
Parameters :
param Value meaning
action //0x01 clears all public keys, 0x02 adds a public key,
0x03 deletes a public key, 0x04 reads the list of public
keys, 0x05 reads the specified public key
* * clear all public key
CLEAR (0x01),
* * add a public key *
ADD (0x02),
* * delete the specified public key * /
DELETE (0x03),
* * read the public key list * /
READLIST (0x04),
* * read the specified public key * /
READAPPOINT (0x05);
publicKey public key information
13/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
14/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
3.21. SetEmvParam
Prototype:
int mf_SetEmvParamTlv(const char *tlv)
Explain:
Set the emv tag value and modify some tag values as needed.
This function is recommended to initialize once when your application
starts.
Parameters :
param Value meaning
tlv TLV such
as:9F01063132333435369F40057000F0A0019F150230319F160F313233343536373
8393031323334359F3901059F33036000009F1A0208409F1C0831323334353637389
F3501225F2A0208405F3601029F3C0208409F3D01029F1E086D665F36306220209F6
60434000080
* |__9F01(06)==313233343536 (Acquirer Identifier)
* |__9F40(05)==7000F0A001 (Additional Terminal Capability)
* |__9F15(02)==3031 (Merchant Category Code)
* |__9F16(0F)==313233343536373839303132333435 (Merchant Identifier)
* |__9F39(01)==05 (Point-of-Service Entry Mode)
* |__9F33(03)==600000 (Terminal Capabilities)
* |__9F1A(02)==0840 (Terminal Country Code)
* |__9F1C(08)==3132333435363738 (Terminal Identification)
* |__9F35(01)==22 (Terminal Type)
* |__5F2A(02)==0840 (Transaction Currency Code)
* |__5F36(01)==02 (Transaction Currency Exponent)
* |__9F3C(02)==0840 (Transaction Reference Currency Code)
* |__9F3D(01)==02 (Transaction Reference Currency Exponent)
* |__9F1E(08)==6D665F3630622020 (Interface Device Serial Number)
* |__9F66(04)==34000080 (Terminal transaction attribute)
* For example, if you need to modify the currency code,
* you can achieve this by changing the three tags: 9F1A, 5F2A, 9F3C.
15/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
16/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
4. APPENDIX
4.1. Appendix B
connectPos()
Connection
success
Readcard()
CalMac()
communication
disconnectPos()
17/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
3. PAN Format:
Table A.2 PIN format
18/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
19/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
f) Use the result of XOR to perform a single-length key algorithm operation again.
ENC BLOCK2 = eMAK (TE11 TE12 TE13 TE14 TE15 TE16 TE17 TE18)
= EN21 EN22 EN23 EN24 EN25 EN26 EN27 EN28
(1) The ANSI X9.19 MAC algorithm uses only double-length keys.
(2) MAC data is first grouped into 8 bytes and expressed as D0 ~ Dn. If Dn is less than 8
(3) Use the left half of the MAC key to encrypt D0, and XOR the encryption result with D1 as
20/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
(4) XOR the encryption result of the previous step with the next packet, and then encrypt
(6) Use the right half of the MAC key to decrypt the result of (5).
(7) Encrypt the result of (6) with the left half of the MAC key.
(8) Take the left half of the result of (7) as the MAC.
21/ 22
M P O S ( W i n d o w s ) P r o g r a m m i n g M a n u a l
int copyedLen = 0;
System.arraycopy (pinkey, 0, workKey, copyedLen, pinkey.length);
copyedLen + = pinkey.length;
System.arraycopy (macKey, 0, workKey, copyedLen, macKey.length);
copyedLen + = macKey.length;
System.arraycopy (trackKey, 0, workKey, copyedLen, trackKey.length);
copyedLen + = trackKey.length;
// The working key is 24 bits or 40 bits or 60 bits, that is, corresponding to single-length,
double-length, and double-length track encryption.
LoadWorkKeyResult result = Controler.LoadWorkKey (
CommEnum.KEYINDEX.INDEX0,
CommEnum.WORKKEYTYPE.DOUBLEMAG,
workKey,
workKey.length);
22/ 22