Created
March 7, 2018 16:28
-
-
Save zhovner/d64dafb311f5404f2a3df559ed66eda6 to your computer and use it in GitHub Desktop.
EMV reader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const | |
// Begining APDU command. "Payment System Environment (PSE)" 2pay.sys.ddf01 | |
// The card should response with Application Identifier (AID) | |
PPSE = '00 a4 04 00 0e 32 50 41 59 2e 53 59 53 2e 44 44 46 30 31 00'; | |
// Application Identifier (AID) start command prefix | |
// Possible AID's: | |
// A0000000031010 Visa International | |
// A0000000032020 Visa International | |
// A0000000041010 Mastercard International | |
// A0000000043060 Mastercard International United States Maestro (Debit) | |
AIDPrefix = '00 a4 04 00 07'; | |
// Команда GET PROCESSING OPTIONS для случаев когда PDOL отсутствует в ответе на PPSE | |
GOP = '80 a8 00 00 02 83 00 00 '; | |
var | |
Response: TBuffer; | |
SW12: Word; | |
begin | |
// Transmit PPSE command and store response in Response var and status code in SW12. | |
TransmitAsStringSW(PPSE, Response, SW12); | |
// Print response | |
//WriteLnF('PPSE response = ' + BufferToHexString(Response)); | |
//WriteLnF(''); | |
//TODO: Тут нужно парсить ответ PPSE и находить AID по вхождению 4F 07 | |
TransmitAsStringSW(AIDPrefix + 'A0 00 00 00 03 10 10', Response, SW12); // альфа виза, айфон | |
//TransmitAsStringSW(AIDPrefix + 'A0 00 00 00 04 10 10', Response, SW12); // ебей, яндекс, мастеркард | |
// Если ответ содержит PDOL (вхождение 9F 38) тогда парсим его | |
// Тут парсим PDOL и посылаем 80 a8 00 00 + PDOL 00 | |
// айфон | |
// TransmitAsStringSW('80A80000238321F6000000000000000000000000000000000000000000000000000000000000000000', Response, SW12); | |
// айфон | |
// Если ответ НЕ содержит PDOL посылаем GET PROCESSING OPTIONS command with a value of 83 00 | |
// Зачем это нужно вообще? | |
// Если ответ содержил PDOL, карта вернут SW12=6985 (Command not allowed. Conditions of use not satisfied.) | |
//TransmitAsStringSW(GOP, Response, SW12); | |
TransmitAsStringSW('00 b2 01 1c 00', Response, SW12); // 1 | |
TransmitAsStringSW('00 b2 01 0c 00', Response, SW12); // 2 | |
TransmitAsStringSW('00 b2 02 0c 00', Response, SW12); // 3 | |
TransmitAsStringSW('00 b2 01 14 00', Response, SW12); // 4 | |
TransmitAsStringSW('00 b2 02 14 00', Response, SW12); // 5 | |
TransmitAsStringSW('00 b2 04 14 00', Response, SW12); // 6 | |
end. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment