Overview
This page covers EMV (Europay, MasterCard, and Visa) related functions available in the PruTAN application. These functions handle card generation, PIN management, encryption, key management, and EMV-specific operations.
What are EMV Functions?
EMV functions in PruTAN are specialized utility functions designed for testing and simulating payment card transactions.
It provide a comprehensive set of tools for developers and QA engineers who need to build, test, and validate payment applications without requiring access to real card infrastructure.
Why Use EMV Functions?
These functions help you:
- Simulate Real-World Transactions: Generate test card numbers, PIN blocks, and transaction data that mimic actual payment card behaviors
- Test Payment Flows: Validate entire EMV transaction workflows including card generation, PIN encryption, and key management
- Ensure Security Compliance: Test your application's ability to handle encrypted PINs and sensitive card data properly
- Accelerate Development: Quickly create test data without manual setup or external services
Key Benefits
- No External Dependencies: Generate all test data locally without connecting to payment networks
- Compliance Ready: Use test BINs and configurations that comply with payment industry standards
- Comprehensive Coverage: From basic card generation to advanced key translation between zones
- Developer Friendly: Simple JavaScript syntax that integrates easily into your existing test scripts
Common Use Cases
- Testing POS (Point of Sale) terminal applications
- Building automated test suites for card transaction flows
- Simulating card present and card not present transactions
- Testing key management and PIN security implementations
- Load testing payment systems with realistic transaction data
Accessing EMV Functions
- API module (Pre-request tab):
- Open the API request where you want to use EMV test data.
- Switch to the Pre-request tab for that request.
- Add a script that calls the desired
fn.*functions (for examplefn.generateCard()orfn.generatePinBlock()). - Store results in request variables or use
req.setBody(...)orres.setBody(...)so the generated values are available to the request. - Save and run the request to execute the pre-request script.
- Hostbox & Interceptor (Rules section):
- Open the Hostbox or Interceptor configuration in the workspace.
- Go to the Rules section and create or edit a rule for the target flow.
- In the rule script, call
fn.*functions to generate, translate, encrypt, or verify EMV data (for examplefn.verifyPinBlock()orfn.translatePinBlock()). - Attach the rule to the appropriate endpoint or host and enable it.
- Test the flow to ensure the rule executes and the EMV functions behave as expected.
Learn more:
- Pre-request Scripts: see Pre-request Scripts for examples and scripting guidance.
- Rules (Hostbox & Interceptor): see Hostbox ISO Rules and Interceptor ISO Rules.
Image 1 : API
Image 2 : Interceptor
EMV Functions
fn.generateEmvDates()
Search Label: Generate Alphabet: Generate a Emv Date.
Generates EMV-compliant dates for transaction processing.
Syntax:
fn.generateEmvDates()fn.generateCard()
Search Label: Generate Card: Generates a Card
Generates card numbers with various parameters for EMV testing and simulation.
Syntax Variations:
fn.generateCard(length, bin) // With length and BIN
fn.generateCard(length) // With length only
fn.generateCard() // Without parameters (default)Usage Example:
res.setBody("generateCard", "fn.generateCard(12, 45)");
// Returns: 452579365757 or 456434896547fn.generatePinBlock()
Search Label: Generate Pin Block: Generate a Pin Block
Generates a PIN block for EMV card verification.
Syntax:
fn.generatePinBlock(pin, keyName)fn.verifyPinBlock()
Search Label: Verify Pin Block: Verify the Pin Block.
Verifies the PIN block during EMV transaction processing.
Syntax:
fn.verifyPinBlock(encryptedPin, pin, keyName)fn.translatePinBlock()
Search Label: Translate Pin Block: Translate the Pin Block.
Translates PIN blocks between different keys (useful for switching between zones).
Syntax:
fn.translatePinBlock(encryptedPin, keyName1, keyName2)fn.encryptPin()
Search Label: Encrypt Pin: Encrypts a PIN
Encrypts a PIN using the provided TPK (Terminal PIN Key).
Syntax:
fn.encryptPin(pin, tpk)fn.decryptPin()
Search Label: Decrypt Pin: Decrypts an encrypted PIN
Decrypts an encrypted PIN using the provided TPK.
Syntax:
fn.decryptPin(encryptedPin, tpk)Key Management Functions
Key Generation
fn.generateTMK()
Search Label: Generate TMK/ZMK: Generates a TMK or ZMK
Generates a Terminal Master Key (TMK) or Zone Master Key (ZMK).
Syntax:
fn.generateTMK(masterKey)fn.generateTPK()
Search Label: Generate TPK/ZPK: Generates a TPK or ZPK
Generates a Terminal PIN Key (TPK) or Zone PIN Key (ZPK).
Syntax:
fn.generateTPK(encryptedTMK)Key Retrieval
fn.getPEK()
Search Label: Get PEK: get PEK.
Retrieves PIN Encryption Key (PEK).
Syntax:
fn.getPEK(keyManagementName)fn.getMAK()
Search Label: Get MAK: get MAK.
Retrieves Message Authentication Key (MAK).
Syntax:
fn.getMAK(keyManagementName)fn.getTEK()
Search Label: Get TEK: get TEK.
Retrieves Terminal Encryption Key (TEK).
Syntax:
fn.getTEK(keyManagementName)Key Setting
fn.setPEK()
Search Label: Set PEK: Set PEK using Key + KCV.
Sets PIN Encryption Key (PEK) using Key + KCV.
Syntax:
fn.setPEK(keyManagementName, keyKCV)fn.setMAK()
Search Label: Set MAK: Set MAK using Key + KCV.
Sets Message Authentication Key (MAK) using Key + KCV.
Syntax:
fn.setMAK(keyManagementName, keyKCV)fn.setTEK()
Search Label: Set TEK: Set TEK using Key + KCV.
Sets Terminal Encryption Key (TEK) using Key + KCV.
Syntax:
fn.setTEK(keyManagementName, keyKCV)Functions (Commonly Used with EMV)
fn.timestamp()
Search Label: UNIX Timestamp: Get current timestamp
Retrieves current UNIX timestamp for transaction logging.
Syntax:
fn.timestamp()fn.isoTimestamp()
Search Label: ISO Timestamp: Get current ISO timestamp
Retrieves current ISO timestamp for standardized transaction records.
Syntax:
fn.isoTimestamp()fn.generateAmount()
Search Label: Generate Amount: Generates a Amount
Generates random transaction amounts.
Syntax Variations:
fn.generateAmount(byt, decimal) // With bytes and decimal places
fn.generateAmount(byt) // With bytes only
fn.generateAmount() // Default (5 digits)fn.generateRandomNumber()
Search Label: Generate Random Numbers: Generate a Random Numbers.
Generates random numbers for transaction IDs, references, etc.
Syntax:
fn.generateRandomNumber(length)fn.compare()
Search Label: Compare: Compare Strings
Compares strings (PINs, transaction data, etc.).
Syntax:
fn.compare(original, compareValue)fn.typeOf()
Search Label: Type Of: Check the type of a value.
Checks the type of a value for data validation.
Syntax:
fn.typeOf(value, expectedType)fn.length()
Search Label: Length: Get the length of a string.
Gets the length of a string (PAN, track data, etc.).
Syntax:
fn.length(value)fn.concatenate()
Search Label: Concatenate: Concatenation of string is the operation of joining character string end-to-end.
Joins multiple strings (constructing track data, messages, etc.).
Syntax:
fn.concatenate(strings...)Quick EMV Transaction Flow Examples
Example 1: Basic PIN Verification Flow
javascript
// Step 1: Generate card
fn.generateCard(16, 4);
// Step 2: Encrypt PIN
fn.encryptPin(1234, "terminalKey");
// Step 3: Generate PIN block
fn.generatePinBlock(1234, "testKeys");
// Step 4: Verify PIN
fn.verifyPinBlock(pinBlock, 1234, "testKeys");Explore More Functions
The PruTAN application provides 120+ additional utility functions beyond EMV operations:
Available Function Categories:
- Data Generation - Random names, addresses, emails, phone numbers
- Image URLs - Profile avatars, stock photos, category-specific images
- Location Data - Cities, countries, coordinates, street addresses
- Business Data - Company names, catchphrases, job titles
- Network Data - IP addresses, MAC addresses, domains, user agents
- Financial Data - Bank accounts, IFSC codes, UPI addresses, currency codes
- String Manipulation - Substring, concatenation, JSON stringify
- Validation Functions - Type checking, pattern matching, date validation
- Random Generators - Colors, booleans, passwords, locales
How to Access All Functions:
- Editor Integration
- Press Ctrl+Space in the PruTAN script editor
- View all available functions with auto-completion
- See function signatures and descriptions inline
- Search Documentation
- Use the documentation search feature to find specific functions
- Filter by category, name, or use case
Quick Access to Popular Functions:
javascript
// Personal Information
fn.randomFullName() // Generate random person name
fn.randomEmail() // Generate random email address
fn.randomPhoneNumber() // Generate random phone number
// Location
fn.randomCity() // Generate random city name
fn.randomCountry() // Generate random country
fn.randomStreetAddress() // Generate complete address
// Business
fn.randomCompanyName() // Generate company name
fn.randomJobTitle() // Generate job title
fn.randomCatchPhrase() // Generate business catchphrase
// Digital
fn.randomIP() // Generate IPv4 address
fn.randomDomainName() // Generate domain name
fn.randomUserAgent() // Generate browser user agent
// Visual
fn.randomAvatarImage() // Generate avatar URL
fn.randomImageUrl() // Generate random image URL
fn.randomHexColor() // Generate hex color codeTips for Using Functions:
- Combine multiple functions to create realistic test data
- Use validation functions to ensure data quality
- Leverage timestamp functions for audit trails
- Explore the auto-complete in editor for discovering new functions
Best Practices
- Key Security: Never log or expose encryption keys in plain text
- PIN Handling: Always encrypt PINs immediately after capture
- Testing: Use fn.generateCard() with test BINs (e.g., 4 for Visa test cards)
- Validation: Always validate PAN length using fn.length() before processing
- Logging: Include ISO timestamps for all transactions using fn.isoTimestamp()