private function send_auth() { // initialize $dbTrans = Database::tDataConnect(); if (!$dbTrans) { return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND); // internal error, nothing sent (ok to retry) } $request = new PaycardGiftRequest($this->valutecIdentifier(CoreLocal::get('paycard_id'))); $program = 'Gift'; // valutec also has 'Loyalty' cards which store arbitrary point values $mode = ""; $logged_mode = $mode; $authMethod = ""; switch (CoreLocal::get("paycard_mode")) { case PaycardLib::PAYCARD_MODE_AUTH: $mode = $amount < 0 ? 'refund' : 'tender'; $logged_mode = $amount < 0 ? 'Return' : 'Sale'; $authMethod = $amount < 0 ? 'AddValue' : 'Sale'; break; case PaycardLib::PAYCARD_MODE_ADDVALUE: $mode = 'addvalue'; $logged_mode = 'Reload'; $authMethod = 'AddValue'; break; case PaycardLib::PAYCARD_MODE_ACTIVATE: $mode = 'activate'; $logged_mode = 'Issue'; $authMethod = 'ActivateCard'; break; default: return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND); } $termID = $this->getTermID(); $cardPAN = $this->getPAN(); $cardTr2 = $this->getTrack2(); $request->setPAN($cardPAN); $request->setIssuer('Valutec'); $request->setProcessor('Valutec'); $request->setMode($logged_mode); if ($cardTr2) { $request->setSent(0, 0, 0, 1); } else { $request->setSent(1, 0, 0, 0); } try { $request->saveRequest(); } catch (Exception $ex) { return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND); // internal error, nothing sent (ok to retry) } $authFields = array('ProgramType' => $program, 'CardNumber' => $cardTr2 ? $cardTr2 : $cardPAN, 'Amount' => $request->formattedAmount(), 'ServerID' => $request->cashierNo, 'Identifier' => $request->refNum); $this->GATEWAY = "https://www.valutec.net/customers/transactions/valutec.asmx/"; $getData = urlencode($authMethod) . "?"; $getData .= "TerminalID=" . urlencode($termID); foreach ($authFields as $field => $value) { $getData .= "&" . urlencode($field) . "=" . urlencode($value); } $this->last_request = $request; return $this->curlSend($getData, 'GET'); }
public function prepareDataCapGift($mode, $amount, $prompt) { $request = new PaycardGiftRequest($this->refnum(CoreLocal::get('paycard_id'))); $request->setProcessor('MercuryE2E'); $termID = $this->getTermID(); $operatorID = $request->cashierNo; $mcTerminalID = CoreLocal::get('PaycardsTerminalID'); if ($mcTerminalID === '') { $mcTerminalID = CoreLocal::get('laneno'); } $host = "g1.mercurypay.com"; if (CoreLocal::get("training") == 1) { $host = "g1.mercurydev.net"; $operatorID = 'test'; } $tran_code = 'Issue'; if ($mode == PaycardLib::PAYCARD_MODE_ADDVALUE) { $tran_code = 'Reload'; } $request->setMode($mode); $request->setManual($prompt ? 1 : 0); $request->setAmount($amount); try { $request->saveRequest(); } catch (Exception $ex) { // TODO: cancel request on JS side $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND); return 'Error'; } CoreLocal::set('LastEmvPcId', array($request->last_paycard_transaction_id, $request->last_req_id)); CoreLocal::set('LastEmvReqType', 'gift'); CoreLocal::set('paycard_amount', $amount); CoreLocal::set('paycard_id', CoreLocal::get('LastID' + 1)); CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_GIFT); CoreLocal::set('CacheCardType', 'GIFT'); CoreLocal::set('paycard_mode', $mode); $msgXml = '<?xml version="1.0"?' . '> <TStream> <Transaction> <MerchantID>' . $termID . '</MerchantID> <OperatorID>' . $operatorID . '</OperatorID> <LaneID>' . $mcTerminalID . '</LaneID> <TranType>PrePaid</TranType> <TranCode>' . $tran_code . '</TranCode> <SecureDevice>{{SecureDevice}}</SecureDevice> <ComPort>{{ComPort}}</ComPort> <InvoiceNo>' . $request->refNum . '</InvoiceNo> <RefNo>' . $request->refNum . '</RefNo> <Memo>CORE POS 1.0.0 PDCX</Memo> <Account> <AcctNo>SecureDevice</AcctNo> </Account> <Amount> <Purchase>' . $request->formattedAmount() . '</Purchase> </Amount> <IpPort>9100</IpPort>'; $msgXml .= '<IpAddress>' . $this->giftServerIP() . '</IpAddress>'; $msgXml .= '</Transaction></TStream>'; if ($prompt) { $msgXml = str_replace('<AcctNo>SecureDevice</AcctNo>', '<AcctNo>Prompt</AcctNo>', $msgXml); } $this->last_request = $request; return $msgXml; }