public function generate($generator, $generationContextData) { $cardData = $this->cardData[array_rand($this->cardData)]; $generatedCardNumber = DataType_PAN::generateCreditCardNumber($cardData["prefix"], $cardData["length"]); $calendar = date("ym", mt_rand()); $serviceCode = mt_rand(111, 999); $discretionaryData = array(rand(1, 9), rand(111, 999), rand(1111, 9999)); $discData = array_rand($discretionaryData); $LRC_array = array(" ", rand(1, 9)); $LRC = array_rand($LRC_array); /* Source - http://en.wikipedia.org/wiki/Magnetic_stripe_card#Financial_cards Start sentinel ó one character (generally ';') Primary account number (PAN) ó up to 19 characters. Usually, but not always, matches the credit card number printed on the front of the card. Separator ó one char (generally '=') Expiration date ó four characters in the form YYMM. Service code ó three digits. The first digit specifies the interchange rules, the second specifies authorisation processing and the third specifies the range of services Discretionary data ó as in track one End sentinel ó one character (generally '?') Longitudinal redundancy check (LRC) ó it is one character and a validity character calculated from other data on the track. Most reader devices do not return this value when the card is swiped to the presentation layer, and use it only to verify the input internally to the reader. */ $track2 = ";{$generatedCardNumber}={$calendar}{$serviceCode}{$discretionaryData[$discData]}?{$LRC_array[$LRC]}"; return array("display" => $track2); }
public function generate($generator, $generationContextData) { $cardData = $this->cardData[array_rand($this->cardData)]; $generatedCardNumber = DataType_PAN::generateCreditCardNumber($cardData["prefix"], $cardData["length"]); $characters = array("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); $totalChars = count($characters); $chars = array(); while (count($chars) < 4) { $char = $characters[mt_rand(0, $totalChars - 1)]; if (!in_array($char, $chars)) { $chars[] = $char; } } $calendar = date("ym", mt_rand()); $serviceCode = mt_rand(111, 999); $discretionaryData = array(rand(1, 9), rand(111, 999), rand(1111, 9999)); $disc_data = array_rand($discretionaryData); $LRC_array = array(" ", rand(1, 9)); $LRC = array_rand($LRC_array); $firstName = $this->firstNames[mt_rand(0, $this->numFirstNames - 1)]; $lastName = $this->lastNames[mt_rand(0, $this->numLastNames - 1)]; /* Source - http://en.wikipedia.org/wiki/Magnetic_stripe_card#Financial_cards Start sentinel — one character (generally '%') Format code = "B" — one character (alpha only) Primary account number (PAN) — up to 19 characters. Usually, but not always, matches the credit card number printed on the front of the card. Field Separator — one character (generally '^') Name — two to 26 characters Field Separator — one character (generally '^') Expiration date — four characters in the form YYMM. Service code — three characters Discretionary data — may include Pin Verification Key Indicator (PVKI, 1 character), PIN Verification Value (PVV, 4 characters), Card Verification Value or Card Verification Code (CVV or CVC, 3 characters) End sentinel — one character (generally '?') Longitudinal redundancy check (LRC) — it is one character and a validity character calculated from other data on the track. */ $track1 = "%B{$generatedCardNumber}^{$firstName}{$lastName}^{$calendar}{$serviceCode}{$discretionaryData[$disc_data]}?{$LRC_array[$LRC]}"; return array("display" => $track1); }