コード例 #1
0
ファイル: FirstData.php プロジェクト: phpsmith/IS4C
 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
ファイル: AuthorizeDotNet.php プロジェクト: phpsmith/IS4C
 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
ファイル: MercuryE2E.php プロジェクト: phpsmith/IS4C
 /**
   Prepare an XML request body for an PDCX
   or EMVX transaction
   @param $type [string] card type
   @param $amount [number] authorization amount
   @return [string] XML request body
 */
 public function prepareDataCapAuth($type, $amount, $prompt = false)
 {
     $request = new PaycardRequest($this->refnum(CoreLocal::get('paycard_id')));
     $request->setProcessor('MercuryE2E');
     $operatorID = $request->cashierNo;
     $termID = $this->getTermID();
     $mcTerminalID = CoreLocal::get('PaycardsTerminalID');
     if ($mcTerminalID === '') {
         $mcTerminalID = CoreLocal::get('laneno');
     }
     $tran_code = $amount > 0 ? 'Sale' : 'Return';
     if ($type == 'EMV') {
         $tran_code = 'EMV' . $tran_code;
     } elseif ($type == 'GIFT') {
         $tran_code = $amount > 0 ? 'NoNSFSale' : 'Return';
     } else {
         if (CoreLocal::get("ebt_authcode") != "" && CoreLocal::get("ebt_vnum") != "") {
             $tran_code = 'Voucher';
         }
     }
     $host = "x1.mercurypay.com";
     if (CoreLocal::get("training") == 1) {
         $host = "x1.mercurydev.net";
         $operatorID = 'test';
     }
     $tran_type = 'Credit';
     $card_type = false;
     if ($type == 'DEBIT') {
         $tran_type = 'Debit';
     } elseif ($type == 'EBTFOOD') {
         $tran_type = 'EBT';
         $card_type = 'Foodstamp';
     } elseif ($type == 'EBTCASH') {
         $tran_type = 'EBT';
         $card_type = 'Cash';
     } elseif ($type == 'GIFT') {
         $tran_type = 'PrePaid';
     }
     $request->setManual($prompt ? 1 : 0);
     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', 'normal');
     // start with fields common to PDCX and EMVX
     $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>' . $request->refNum . '</RefNo>
         <Amount>
             <Purchase>' . $request->formattedAmount() . '</Purchase>';
     if ($request->cashback) {
         $msgXml .= '<CashBack>' . $request->formattedCashBack() . '</CashBack>';
     }
     $msgXml .= '</Amount>
         <RecordNo>RecordNumberRequested</RecordNo>
         <Frequency>OneTime</Frequency>';
     if ($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 ($prompt) {
             $msgXml .= '
                 <Account>
                     <AcctNo>Prompt</AcctNo>
                 </Account>';
         }
         if (CoreLocal::get('PaycardsDatacapMode') == 2) {
             $msgXml .= '<MerchantLanguage>English</MerchantLanguage>';
         } elseif (CoreLocal::get('PaycardsDatacapMode') == 3) {
             $msgXml .= '<MerchantLanguage>French</MerchantLanguage>';
         }
     } else {
         $msgXml .= '
         <Memo>CORE POS 1.0.0 PDCX</Memo>
         <Account>
             <AcctNo>' . ($prompt ? 'Prompt' : 'SecureDevice') . '</AcctNo>
         </Account>
         <TranType>' . $tran_type . '</TranType>';
         if ($card_type) {
             $msgXml .= '<CardType>' . $card_type . '</CardType>';
         }
         if ($type == 'CREDIT') {
             $msgXml .= '<PartialAuth>Allow</PartialAuth>';
         }
         if ($type == 'GIFT') {
             $msgXml .= '<IpPort>9100</IpPort>';
             $msgXml .= '<IpAddress>' . $this->giftServerIP() . '</IpAddress>';
         }
         if (CoreLocal::get("ebt_authcode") != "" && CoreLocal::get("ebt_vnum") != "") {
             $msgXml .= $this->ebtVoucherXml();
         }
     }
     $msgXml .= '
         </Transaction>
         </TStream>';
     $this->last_request = $request;
     return $msgXml;
 }