示例#1
0
 function send_auth()
 {
     $dbTrans = PaycardLib::paycard_db();
     if (!$dbTrans) {
         PaycardLib::paycard_reset();
         return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND);
         // database error, nothing sent (ok to retry)
     }
     $request = new PaycardRequest($this->refnum(CoreLocal::get('paycard_id')));
     $request->setProcessor('FirstData');
     $mode = 'sale';
     $this->trans_pan['pan'] = CoreLocal::get("paycard_PAN");
     $cardPAN = $this->trans_pan['pan'];
     $cardExM = substr(CoreLocal::get("paycard_exp"), 0, 2);
     $cardExY = substr(CoreLocal::get("paycard_exp"), 2, 2);
     $cardTr1 = CoreLocal::get("paycard_tr1");
     $cardTr2 = CoreLocal::get("paycard_tr2");
     $cardTr3 = CoreLocal::get("paycard_tr3");
     $request->setCardholder(CoreLocal::get("paycard_name"));
     $cvv2 = CoreLocal::get("paycard_cvv2");
     if (CoreLocal::get("training") == 1) {
         $cardPAN = "4111111111111111";
         $cardPANmasked = "xxxxxxxxxxxxTEST";
         $cardIssuer = "Visa";
         $cardTr1 = False;
         $cardTr2 = False;
         $request->setCardholder("Just Testing");
         $nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1);
         $cardExM = date("m", $nextyear);
         $cardExY = date("y", $nextyear);
     }
     $request->setPAN($cardPAN);
     $request->setIssuer(CoreLocal::get("paycard_issuer"));
     $sendPAN = 0;
     $sendExp = 0;
     $sendTr1 = 0;
     $sendTr2 = 0;
     $magstripe = "";
     if (!$cardTr1 && !$cardTr2) {
         $sendPAN = 1;
         $sendExp = 1;
     }
     if ($cardTr1) {
         $sendTr1 = 1;
         $magstripe .= "%" . $cardTr1 . "?";
     }
     if ($cardTr2) {
         $sendTr2 = 1;
         $magstripe .= ";" . $cardTr2 . "?";
     }
     if ($cardTr2 && $cardTr3) {
         $sendPAN = 1;
         $magstripe .= ";" . $cardTr3 . "?";
     }
     $request->setSent($sendPAN, $sendExp, $sendTr1, $sendTr2);
     try {
         $request->saveRequest();
     } catch (Exception $ex) {
         PaycardLib::paycard_reset();
         return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND);
         // internal error, nothing sent (ok to retry)
     }
     $this->last_request = $request;
     $xml = '<fdggwsapi:FDGGWSApiOrderRequest  
          xmlns:v1="http://secure.linkpt.net/fdggwsapi/schemas_us/v1" 
           xmlns:fdggwsapi="http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi"> 
          <v1:Transaction>';
     $xml .= "<v1:CreditCardTxType> \n               <v1:Type>{$mode}</v1:Type> \n              </v1:CreditCardTxType>";
     $xml .= "<v1:CreditCardData> \n               <v1:CardNumber>{$pan}</v1:CardNumber> \n               <v1:ExpMonth>{$cardExM}</v1:ExpMonth> \n               <v1:ExpYear>{$cardExY}</v1:ExpYear> \n               <v1:CardCodeValue>{$cvv2}</v1:CardCodeValue>\n              </v1:CreditCardData>";
     $xml .= "<v1:Payment>\n            <v1:ChargeTotal>" . $request->formattedAmount() . "</v1:ChargeTotal> \n            </v1:Payment>";
     $xml .= "<v1:TransactionDetails>\n            <v1:OrderId>" . $request->refNum . "</v1:OrderId>\n            <v1:Ip>" . filter_input(INPUT_SERVER, 'REMOTE_ADDR') . "</v1:Ip>\n            </v1:TransactionDetails>";
     $xml .= '</v1:Transaction> 
         </fdggwsapi:FDGGWSApiOrderRequest>';
     $this->GATEWAY = "https://ws.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl";
     if ($live == 0) {
         $this->GATEWAY = "https://ws.merchanttest.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl";
     }
     $extraCurlSetup = array(CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => "WS" . FD_STORE_ID . "._.1:" . FD_PASSWD, CURLOPT_SSLCERT => FD_CERT_PATH . "/WS" . FD_STORE_ID . "._.1.pem", CURLOPT_SSLKEY => FD_CERT_PATH . "/WS" . FD_STORE_ID . "._.1.key", CURLOPT_SSLKEYPASSWD => FD_KEY_PASSWD);
     $soaptext = $this->soapify('', array('xml' => $xml), '', False);
     return $this->curlSend($soaptext, 'SOAP', True, $extraCurlSetup);
 }
示例#2
0
 function send_auth()
 {
     // initialize
     $dbTrans = PaycardLib::paycard_db();
     if (!$dbTrans) {
         PaycardLib::paycard_reset();
         return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND);
         // database error, nothing sent (ok to retry)
     }
     $request = new PaycardRequest($this->refnum(CoreLocal::get('paycard_id')));
     $request->setProcessor('AuthDotNot');
     $mode = $request->amount < 0 ? 'refund' : 'tender';
     $cardPAN = $this->trans_pan['pan'];
     $request->setPAN($cardPAN);
     $request->setIssuer(CoreLocal::get("paycard_issuer"));
     $cardExM = substr(CoreLocal::get("paycard_exp"), 0, 2);
     $cardExY = substr(CoreLocal::get("paycard_exp"), 2, 2);
     $cardTr1 = $this->trans_pan['tr1'];
     $cardTr2 = $this->trans_pan['tr2'];
     $request->setCardholder(CoreLocal::get("paycard_name"));
     // x_login & x_tran_key need to be
     // filled in to work
     $postValues = array("x_login" => AUTHDOTNET_LOGIN, "x_tran_key" => AUTHDOTNET_TRANS_KEY, "x_market_type" => "2", "x_device_type" => "5", "cp_version" => "1.0", "x_test_request" => "0", "x_amount" => $request->formattedAmount(), "x_user_ref" => $request->refNum);
     if (CoreLocal::get("training") == 1) {
         $postValues["x_test_request"] = "1";
     }
     if ($mode == "refund") {
         $postValues["x_type"] = "CREDIT";
     } else {
         $postValues["x_type"] = "AUTH_CAPTURE";
     }
     if (!$cardTr1 && !$cardTr2 || $mode == "refund") {
         $postValues["x_card_num"] = $cardPAN;
         $postValues["x_exp_date"] = $cardExM . $cardExY;
         $request->setSent(1, 1, 0, 0);
     } elseif ($cardTr1) {
         $postValues["x_track1"] = $cardTr1;
         $request->setSent(0, 0, 1, 0);
     } elseif ($cardTr2) {
         $postValues["x_track2"] = $cardTr2;
         $request->setSent(0, 0, 0, 1);
     }
     try {
         $request->saveRequest();
     } catch (Exception $ex) {
         return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND);
         // internal error, nothing sent (ok to retry)
     }
     $this->last_request = $request;
     $postData = $this->array2post($postValues);
     $this->GATEWAY = "https://test.authorize.net/gateway/transact.dll";
     return $this->curlSend($postData, 'POST', False);
 }
示例#3
0
 /**
   Prepare an XML request body to void an PDCX
   or EMVX transaction
   @param $pcID [int] PaycardTransactions record ID
   @return [string] XML request
 */
 public function prepareDataCapVoid($pcID)
 {
     $request = new PaycardRequest($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 = "x1.mercurypay.com";
     if (CoreLocal::get("training") == 1) {
         $host = "x1.mercurydev.net";
         $operatorID = 'test';
     }
     $request->last_paycard_transaction_id = $pcID;
     try {
         $prev = $request->findOriginal();
     } catch (Exception $ex) {
         CoreLocal::set('boxMsg', 'Transaction not found');
         return 'Error';
     }
     try {
         $request->saveRequest();
         CoreLocal::set('LastEmvPcId', array($request->last_paycard_transaction_id, $request->last_req_id));
         CoreLocal::set('LastEmvReqType', 'void');
     } catch (Exception $ex) {
         $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND);
         return 'Error';
     }
     /* Determine reversal method based on
           original transaction.
           EMV and Credit are voided
           PIN Debit and EBT run an opposite transaction
           (e.g., Return after a Sale)
        */
     $tran_code = '';
     $tran_type = '';
     $card_type = false;
     if ($prev['transType'] == 'EMVSale') {
         $tran_code = 'EMVVoidSale';
         $tran_type = 'EMV';
     } elseif ($prev['transType'] == 'EMVReturn') {
         $tran_code = 'EMVVoidReturn';
         $tran_type = 'EMV';
     } elseif ($prev['transType'] == 'NoNSFSale') {
         $tran_type = 'PrePaid';
         $tran_code = 'VoidSale';
     } else {
         switch ($prev['cardType']) {
             case 'Credit':
                 $tran_code = $prev['transType'] == 'Sale' ? 'VoidSaleByRecordNo' : 'VoidReturnByRecordNo';
                 $tran_type = 'Credit';
                 break;
             case 'Debit':
                 $tran_code = $prev['transType'] == 'Sale' ? 'ReturnByRecordNo' : 'SaleByRecordNo';
                 $tran_type = 'Debit';
                 break;
             case 'EBT':
                 $tran_code = $prev['transType'] == 'Sale' ? 'ReturnByRecordNo' : 'SaleByRecordNo';
                 $tran_type = 'EBT';
                 $card_type = $prev['issuer'];
                 break;
         }
     }
     // common fields
     $msgXml = '<?xml version="1.0"?' . '>
         <TStream>
         <Transaction>
         <MerchantID>' . $termID . '</MerchantID>
         <OperatorID>' . $operatorID . '</OperatorID>
         <LaneID>' . $mcTerminalID . '</LaneID>
         <TranCode>' . $tran_code . '</TranCode>
         <SecureDevice>{{SecureDevice}}</SecureDevice>
         <ComPort>{{ComPort}}</ComPort>
         <InvoiceNo>' . $request->refNum . '</InvoiceNo>
         <RefNo>' . $prev['xTransactionID'] . '</RefNo>
         <Amount>
             <Purchase>' . sprintf('%.2f', abs($prev['amount'])) . '</Purchase>
         </Amount>
         <RecordNo>RecordNumberRequested</RecordNo>
         <Frequency>OneTime</Frequency>';
     if ($tran_type == 'EMV') {
         // add EMV specific fields
         $dc_host = CoreLocal::get('PaycardsDatacapLanHost');
         if (empty($dc_host)) {
             $dc_host = '127.0.0.1';
         }
         $msgXml .= '
         <HostOrIP>' . $dc_host . '</HostOrIP>
         <SequenceNo>{{SequenceNo}}</SequenceNo>
         <CollectData>CardholderName</CollectData>
         <Memo>CORE POS 1.0.0 EMVX</Memo>
         <PartialAuth>Allow</PartialAuth>';
         if (CoreLocal::get('PaycardsDatacapMode') == 2) {
             $msgXml .= '<MerchantLanguage>English</MerchantLanguage>';
         } elseif (CoreLocal::get('PaycardsDatacapMode') == 3) {
             $msgXml .= '<MerchantLanguage>French</MerchantLanguage>';
         }
     } else {
         // add non-EMV fields
         $msgXml .= '
         <Memo>CORE POS 1.0.0 PDCX</Memo>
         <Account>
             <AcctNo>SecureDevice</AcctNo>
         </Account>
         <TranType>' . $tran_type . '</TranType>';
         if ($card_type) {
             $msgXml .= '<CardType>' . $card_type . '</CardType>';
         }
         if ($tran_type == 'Credit') {
             $msgXml .= '<PartialAuth>Allow</PartialAuth>';
         }
         if ($tran_type == 'PrePaid') {
             $msgXml .= '<IpPort>9100</IpPort>';
             $msgXml .= '<IpAddress>' . $this->giftServerIP() . '</IpAddress>';
         }
     }
     /**
       Add token and reversal data fields if available
     */
     if ($prev['xToken']) {
         $msgXml .= '<RecordNo>' . $prev['xToken'] . '</RecordNo>';
     }
     if ($prev['xProcessorRef']) {
         $msgXml .= '<ProcessData>' . $prev['xProcessorRef'] . '</ProcessData>';
     }
     if ($prev['xAcquirerRef']) {
         $msgXml .= '<AcqRefData>' . $prev['xAcquirerRef'] . '</AcqRefData>';
     }
     $msgXml .= '
         <AuthCode>' . $prev['xApprovalNumber'] . '</AuthCode>
         </Transaction>
         </TStream>';
     $this->last_request = $request;
     return $msgXml;
 }