private static function basicAdminXml() { $e2e = new MercuryE2E(); $termID = $e2e->getTermID(); $operatorID = CoreLocal::get("CashierNo"); $mcTerminalID = CoreLocal::get('PaycardsTerminalID'); $refNum = $e2e->refnum(CoreLocal::get('LastID')); $dc_host = CoreLocal::get('PaycardsDatacapLanHost'); if (empty($dc_host)) { $dc_host = '127.0.0.1'; } $msgXml = '<?xml version="1.0"?' . '> <TStream> <Transaction> <HostOrIP>' . $dc_host . '</HostOrIP> <MerchantID>' . $termID . '</MerchantID> <TerminalID>' . $mcTerminalID . '</TerminalID> <OperatorID>' . $operatorID . '</OperatorID> <MerchantLanguage>' . self::caLanguage() . '</MerchantLanguage> <TranCode>{{TranCode}}</TranCode> <SecureDevice>{{SecureDevice}}</SecureDevice> <ComPort>{{ComPort}}</ComPort> <SequenceNo>{{SequenceNo}}</SequenceNo> <InvoiceNo>' . $refNum . '</InvoiceNo> <RefNo>' . $refNum . '</RefNo> </Transaction> </TStream>'; return $msgXml; }
function head_content() { if (!$this->run_transaction) { return ''; } $e2e = new MercuryE2E(); ?> <script type="text/javascript"> function emvSubmit() { $('div.baseHeight').html('Processing transaction'); // POST XML request to driver using AJAX var xmlData = '<?php echo json_encode($e2e->prepareDataCapBalance(CoreLocal::get('CacheCardType'), $this->prompt)); ?> '; if (xmlData == '"Error"') { // failed to save request info in database location = '<?php echo MiscLib::baseURL(); ?> gui-modules/boxMsg2.php'; return false; } $.ajax({ url: 'http://localhost:8999', type: 'POST', data: xmlData, dataType: 'text', success: function(resp) { // POST result to PHP page in POS to // process the result. console.log('success'); console.log(resp); var f = $('<form id="js-form"></form>'); f.append($('<input type="hidden" name="xml-resp" />').val(resp)); $('body').append(f); $('#js-form').submit(); }, error: function(resp) { // display error to user? // go to dedicated error page? console.log('error'); console.log(resp); var f = $('<form id="js-form"></form>'); f.append($('<input type="hidden" name="xml-resp" />').val(resp)); $('body').append(f); $('#js-form').submit(); } }); } </script> <?php }
public function testMercuryE2E() { if (!class_exists('lttLib')) { include dirname(__FILE__) . '/lttLib.php'; } lttLib::clear(); $plugins = CoreLocal::get('PluginList'); if (!in_array('Paycards', $plugins)) { $plugins[] = 'Paycards'; CoreLocal::set('PluginList', $plugins); } /** Initialize session stuff to run a test transaction */ CoreLocal::set('CCintegrate', 1); CoreLocal::set('RegisteredPaycardClasses', array('MercuryE2E')); CoreLocal::set('PaycardsTerminalID', '99'); CoreLocal::set('PaycardsTenderCodeCredit', 'CC'); CoreLocal::set('PaycardsTenderCodeVisa', ''); CoreLocal::set('CacheCardType', 'CREDIT'); CoreLocal::set('ttlflag', 1); CoreLocal::set('amtdue', 0.01); CoreLocal::set('CashierNo', 9999); CoreLocal::set('laneno', 99); CoreLocal::set('transno', 1); CoreLocal::set('training', 1); /** Run parser on test PAN. Verify result and appropriate session vars initialized */ $parser = new paycardEntered(); // source: Visa Test Card using Sign&Pay w/ test keys $pan = '02E600801F2E2700039B25423430303330302A2A2A2A2A2A363738315E544553542F4D50535E313531322A2A2A2A2A2A2A2A2A2A2A2A2A3F3B3430303330302A2A2A2A2A2A363738313D313531322A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A3FA7284186B3E8E1A3E2AD8548E732DBB5B33285117FB1B0CDBA6D732E5DF031DE3CB590DE2E02BDEF6182373B7401A3E3D304013C85D3BEFDEBF552A3C30914246B0145538F2E5856885CAA06FF64E201CB974CD506ADDCB22C9F3BF500C62310C9C88B56FD2BDF6E59481BC4B6C4F034264B2C38F8FF6F4405D563AA7D49B82221111010000000E001BFXXXX03'; $this->assertEquals(true, $parser->check($pan), 'Parser does not handle input'); $json = $parser->parse($pan); $url = 'plugins/Paycards/gui/paycardboxMsgAuth.php'; $this->assertEmpty($json['output'], 'Parser error message: ' . $json['output']); $this->assertEquals($url, substr($json['main_frame'], -1 * strlen($url)), 'No redirect to auth page'); $this->assertEquals(0.01, CoreLocal::get('paycard_amount')); $this->assertEquals(PaycardLib::PAYCARD_MODE_AUTH, CoreLocal::get('paycard_mode')); $this->assertEquals(PaycardLib::PAYCARD_TYPE_ENCRYPTED, CoreLocal::get('paycard_type')); // mercury's gateway is returning weird errors; // don't feel like addressing it right now return; /** Submit transaction to processor. Verify return value and check database for an appropriate auth record */ $this->emptyPaycardTables(); $processor = new MercuryE2E(); $auth_result = $processor->doSend(PaycardLib::PAYCARD_MODE_AUTH); $this->assertEquals(PaycardLib::PAYCARD_ERR_OK, $auth_result, 'Authorization attempt produced error: ' . $auth_result . ' : ' . CoreLocal::get('boxMsg')); $db = Database::tDataConnect(); $ptrans = $db->query('SELECT * FROM PaycardTransactions'); $row = $db->fetch_row($ptrans); $this->assertEquals(date('Ymd'), $row['dateID']); $this->assertEquals(9999, $row['empNo']); $this->assertEquals(99, $row['registerNo']); $this->assertEquals(1, $row['transNo']); $this->assertEquals(1, $row['transID']); $this->assertEquals('MercuryE2E', $row['processor']); $this->assertEquals('Credit', $row['cardType']); $this->assertEquals('Sale', $row['transType']); $this->assertEquals(0.01, $row['amount']); $this->assertEquals('Visa', $row['issuer']); $this->assertEquals(0, $row['commErr']); $this->assertEquals(200, $row['httpCode']); $this->assertEquals(1, $row['validResponse']); $this->assertEquals(1, $row['xResultCode']); $this->assertEquals(0, $row['xResponseCode']); $this->assertNotEmpty($row['xApprovalNumber']); $this->assertNotEmpty($row['xResultMessage']); $this->assertNotEmpty($row['xTransactionID']); $this->assertNotEmpty($row['xToken']); $this->assertNotEmpty($row['xProcessorRef']); $this->assertNotEmpty($row['xAcquirerRef']); $this->assertEquals('************', substr($row['PAN'], 0, 12)); /** cleanup test transaction record(s) */ $this->emptyPaycardTables(); }