コード例 #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
 /**
   Updated for E2E
   Status: Should be functional once device is available
 */
 private function send_auth($domain = "w1.mercurypay.com")
 {
     // initialize
     $dbTrans = PaycardLib::paycard_db();
     if (!$dbTrans) {
         PaycardLib::paycard_reset();
         // database error, nothing sent (ok to retry)
         return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND);
     }
     $request = new PaycardRequest($this->refnum(CoreLocal::get('paycard_id')));
     $request->setProcessor('MercuryE2E');
     if (CoreLocal::get("paycard_voiceauthcode") != "") {
         $request->setMode("VoiceAuth");
     } else {
         if (CoreLocal::get("ebt_authcode") != "" && CoreLocal::get("ebt_vnum") != "") {
             $request->setMode("Voucher");
         }
     }
     $termID = $this->getTermID();
     $password = $this->getPw();
     $mcTerminalID = CoreLocal::get('PaycardsTerminalID');
     if ($mcTerminalID === '') {
         $mcTerminalID = CoreLocal::get('laneno');
     }
     $e2e = EncBlock::parseEncBlock(CoreLocal::get("paycard_PAN"));
     $pin = EncBlock::parsePinBlock(CoreLocal::get("CachePinEncBlock"));
     $request->setIssuer($e2e['Issuer']);
     CoreLocal::set('paycard_issuer', $e2e['Issuer']);
     $request->setCardholder($e2e['Name']);
     $request->setPAN($e2e['Last4']);
     CoreLocal::set('paycard_partial', false);
     $request->setSent(0, 0, 0, 1);
     // store request in the database before sending it
     try {
         $request->saveRequest();
     } catch (Exception $ex) {
         PaycardLib::paycard_reset();
         // internal error, nothing sent (ok to retry)
         return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND);
     }
     // weird string concat here so vim's color highlighting
     // doesn't screw up with what LOOKS LIKE a close-PHP tag
     $msgXml = '<?xml version="1.0"?' . '>
         <TStream>
         <Transaction>
         <MerchantID>' . $termID . '</MerchantID>
         <OperatorID>' . $request->cashierNo . '</OperatorID>
         <LaneID>' . $mcTerminalID . '</LaneID>';
     if (substr($request->type, 0, 3) == 'EBT') {
         $msgXml .= '<TranType>EBT</TranType>';
         if ($request->type == 'EBTFOOD') {
             CoreLocal::set('EbtFsBalance', 'unknown');
             $request->msgXml .= '<CardType>Foodstamp</CardType>';
         } else {
             if ($request->type == 'EBTCASH') {
                 $msgXml .= '<CardType>Cash</CardType>';
                 CoreLocal::set('EbtCaBalance', 'unknown');
             }
         }
     } else {
         $msgXml .= '<TranType>' . $request->type . '</TranType>';
     }
     $msgXml .= '<TranCode>' . $request->mode . '</TranCode>
         <InvoiceNo>' . $request->refNum . '</InvoiceNo>
         <RefNo>' . $request->refNum . '</RefNo>
         <Memo>CORE POS 1.0.0</Memo>';
     if ($request->type == 'Credit' && $request->mode == 'Sale') {
         $msgXml .= "<PartialAuth>Allow</PartialAuth>";
     }
     $msgXml .= '<RecordNo>RecordNumberRequested</RecordNo>';
     $msgXml .= '<Frequency>OneTime</Frequency>';
     $msgXml .= '<Account>
             <EncryptedFormat>' . $e2e['Format'] . '</EncryptedFormat>
             <AccountSource>' . ($request->manual ? 'Keyed' : 'Swiped') . '</AccountSource>
             <EncryptedBlock>' . $e2e['Block'] . '</EncryptedBlock>
             <EncryptedKey>' . $e2e['Key'] . '</EncryptedKey>
         </Account>
         <Amount>
             <Purchase>' . $request->formattedAmount() . '</Purchase>';
     if ($request->cashback > 0 && ($request->type == "Debit" || $request->type == "EBTCASH")) {
         $msgXml .= "<CashBack>" . $request->formattedCashBack() . "</CashBack>";
     }
     $msgXml .= "</Amount>";
     if ($request->type == "Debit" || substr($request->type, 0, 3) == "EBT" && $request->mode != "Voucher") {
         $msgXml .= "<PIN>\n                <PINBlock>" . $pin['block'] . "</PINBlock>\n                <DervdKey>" . $pin['key'] . "</DervdKey>\n                </PIN>";
     }
     if (CoreLocal::get("paycard_voiceauthcode") != "") {
         $msgXml .= "<TransInfo>";
         $msgXml .= "<AuthCode>";
         $msgXml .= CoreLocal::get("paycard_voiceauthcode");
         $msgXml .= "</AuthCode>";
         $msgXml .= "</TransInfo>";
     } else {
         if (CoreLocal::get("ebt_authcode") != "" && CoreLocal::get("ebt_vnum") != "") {
             $msgXml .= $this->ebtVoucherXml();
         }
     }
     $msgXml .= "</Transaction>\n            </TStream>";
     $soaptext = $this->soapify("CreditTransaction", array("tran" => $msgXml, "pw" => $password), "http://www.mercurypay.com");
     /**
       In switched mode, use the backup URL first
       then retry on the primary URL
     
       Switched mode is triggered when a request to
       the primary URL fails with some kind of
       cURL error and the subsequent request to the
       backup URL succeeds. The idea is to use the
       backup URL for a few transactions before trying
       the primary again. The most common error is
       a timeout and waiting 30 seconds for the primary
       to fail every single transaction isn't ideal.
     */
     if (CoreLocal::get('MercurySwitchUrls') > 0) {
         if (!$this->second_try) {
             $domain = self::BACKUP_URL;
         } else {
             $domain = self::PRIMARY_URL;
         }
     } else {
         if (!$this->second_try) {
             $domain = self::PRIMARY_URL;
         } else {
             $domain = self::BACKUP_URL;
         }
     }
     /**
       SwitchUrls is a counter
       Go back to normal order when it reaches zero 
     */
     if (CoreLocal::get('MercurySwitchUrls') > 0) {
         $switch_count = CoreLocal::get('MercurySwitchUrls');
         $switch_count--;
         CoreLocal::set('MercurySwitchUrls', $switch_count);
     }
     if (CoreLocal::get("training") == 1) {
         $this->GATEWAY = "https://w1.mercurydev.net/ws/ws.asmx";
     } else {
         $this->GATEWAY = "https://{$domain}/ws/ws.asmx";
     }
     $this->last_request = $request;
     return $this->curlSend($soaptext, 'SOAP');
 }