# P2PE Format # Ingenico On-Guard SDE - Format 03 When using Ingenico On-Guard SDE format for P2PE, the following fields should be set: - `p2pe.format` should be set to "03". - `p2pe.data` should be set depending on the input method, as described in the sections below: When using Ingenico On-Guard SDE, the API request must be processed through our hosted REST servers. It cannot be processed through a locally installed UTG. ## EMV The `emv.tlvdata` field should contain all EMV tags in standard TLV format except for tags 5A (Primary Account Number) & 57 (Track 2 Equivalent Data) The `p2pe.data` field should contain the encrypted TLV data for tags 5A and 57. ## Track information The `p2pe.data` field should contain the encrypted data. After decryption, the format would look like standard track data including start and end sentinels: `%B4444333327271111^MICROS TEST CARD^1612999999?;4444333327271111=1612999999?` ## Manual Entry The `p2pe.data` field should contain the encrypted data. After decryption, the format would look like: `cardnumber|expirationdate|CSC`. # TDES DUKPT - Format 05 When using Shift4 TDES DUKPT format for P2PE, the following fields should be set: - `p2pe.ksn` should be set to the key serial number which was used to encrypt the data. - `p2pe.format` should be set to "05". - additional fields should be set depending on the input method, as described in the sections below: ## EMV The `emv.tlvdata` field should contain all EMV tags in standard TLV format including the P2PE encrypted tags (5A & 57) ### Tag 57 Track 2 Equivalent Data 1. Get Track 2 data and remove the beginning, end sentinel sentinels. Replace separator between the card number and expiration date with D and add F at the end if needed to ensure whole bytes. `5413330089020508D25122010727005691234F` 2. TLV encode the data adding tag - 57 and tag Length in hex – 13 (19 bytes) for the above data. `57135413330089020508D25122010727005691234F` 3. Add zero padding as needed. In my example below, I padded up to 24 bytes (18-hex) 48 characters. `57135413330089020508D25122010727005691234F000000` 4. Encrypt the data. `4F56E663EBCE800B767C683BDFCA3B247166BF950CE3B065` 5. TLV encode the encrypted data adding tag -57 and tag length in hex 18 (24 bytes) for the above data. `57184F56E663EBCE800B767C683BDFCA3B247166BF950CE3B065` ### Tag 5A Primary Account Number 1. Get the card number and pad with F to ensure whole bytes if needed. `4761730000000011` (Example of Visa card) `6799998900000070017F` (Example of a 19 digit Maestro card) 2. TLV encode the data adding tag - 5A and tag Length in hex 08 (8 bytes) `5A084761730000000011` `5A0A6799998900000070017F` 3. Add zero padding as needed. In the examples below it is always padding up to 16 bytes (10-Hex) 32 characters `5A084761730000000011000000000000` `5A0A6799998900000070017F00000000` 4. Encrypt the data `20F0C8FA57D52C07D4A829200D200D7D` `5DA37134CCF54D3892606E9B0AD7736E` 5. TLV encode the data adding tag 5A and tag length 10 (16 bytes) `5A1020F0C8FA57D52C07D4A829200D200D7D` `5A105DA37134CCF54D3892606E9B0AD7736E` ## Track information The `p2pe.data` field should contain the encrypted data. After decryption, the format would look like: `%B4444333327271111^MICROS TEST CARD^1612999999?;4444333327271111=1612999999?` ## Manual Entry The `p2pe.data` field should contain the encrypted data. After decryption, the format would look like: `cardnumber|expirationdate|CSC`.