Beispiel #1
0
 private function handleResponseBalance($balResult)
 {
     $xml = new xmlData($balResult["response"]);
     $program = 'Gift';
     if ($balResult['curlErr'] != CURLE_OK || $balResult['curlHTTP'] != 200) {
         if ($authResult['curlHTTP'] == '0') {
             CoreLocal::set("boxMsg", "No response from processor<br />\n                                          The transaction did not go through");
             return PaycardLib::PAYCARD_ERR_PROC;
         }
         return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_COMM);
         // comm error, try again
     }
     CoreLocal::set("paycard_response", array());
     CoreLocal::set("paycard_response", $xml->array_dump());
     $resp = CoreLocal::get("paycard_response");
     if (isset($resp["BALANCE"])) {
         $resp["Balance"] = $resp["BALANCE"];
         CoreLocal::set("paycard_response", $resp);
     }
     // there's less to verify for balance checks, just make sure all the fields are there
     if ($xml->isValid() && $xml->get('TRANSACTIONTYPE') && $xml->get('TRANSACTIONTYPE') == $program && $xml->get('AUTHORIZED') && $xml->get('AUTHORIZED') == 'true' && (!$xml->get('ERRORMSG') || $xml->get_first('ERRORMSG') == '') && $xml->get('BALANCE')) {
         return PaycardLib::PAYCARD_ERR_OK;
         // balance checked, no error
     }
     // the authorizor gave us some failure code
     CoreLocal::set("boxMsg", "Processor error: " . $xml->get_first("ERRORMSG"));
     return PaycardLib::PAYCARD_ERR_PROC;
 }
Beispiel #2
0
 private function handleResponseVoid($authResult)
 {
     $xml = new xmlData($authResult['response']);
     // prepare some fields to store the parsed response; we'll add more as we verify it
     $today = date('Ymd');
     // numeric date only, it goes in an 'int' field as part of the primary key
     $now = date('Y-m-d H:i:s');
     // full timestamp
     $cashierNo = CoreLocal::get("CashierNo");
     $laneNo = CoreLocal::get("laneno");
     $transNo = CoreLocal::get("transno");
     $transID = CoreLocal::get("paycard_id");
     $amount = CoreLocal::get("paycard_amount");
     $amountText = number_format(abs($amount), 2, '.', '');
     $refNum = $this->refnum($transID);
     $dbTrans = PaycardLib::paycard_db();
     // prepare some fields to store the request and the parsed response; we'll add more as we verify it
     $sqlColumns = $dbTrans->identifier_escape('date') . ",cashierNo,laneNo,transNo,transID," . $dbTrans->identifier_escape('datetime') . ",origAmount,mode,altRoute," . "seconds,commErr,httpCode";
     $sqlValues = sprintf("%d,%d,%d,%d,%d,'%s',", $today, $cashierNo, $laneNo, $transNo, $transID, $now) . sprintf("%s,'%s',%d,", $amountText, "VOID", 0) . sprintf("%f,%d,%d", $authResult['curlTime'], $authResult['curlErr'], $authResult['curlHTTP']);
     $validResponse = $xml->isValid() ? 1 : 0;
     $responseCode = $xml->get("STATUS1");
     if ($responseCode) {
         $sqlColumns .= ",xResponseCode";
         $sqlValues .= sprintf(",%d", $responseCode);
     } else {
         $validResponse = -3;
     }
     $resultCode = $xml->get_first("STATUS1");
     if ($resultCode) {
         $sqlColumns .= ",xResultCode";
         $sqlValues .= sprintf(",%d", $resultCode);
     }
     $resultMsg = $xml->get_first("RESPONSE1");
     if ($resultMsg) {
         $sqlColumns .= ",xResultMessage";
         $rMsg = $resultMsg;
         if (strlen($rMsg) > 100) {
             $rMsg = substr($rMsg, 0, 100);
         }
         $sqlValues .= sprintf(",'%s'", $rMsg);
     }
     $sqlColumns .= ",origTransactionID";
     $sqlValues .= sprintf(",'%s'", $this->voidTrans);
     $sqlColumns .= ",origRefNum";
     $sqlValues .= sprintf(",'%s'", $this->voidRef);
     $sqlColumns .= ",validResponse";
     $sqlValues .= sprintf(",%d", $validResponse);
     $sql = "INSERT INTO efsnetRequestMod (" . $sqlColumns . ") VALUES (" . $sqlValues . ")";
     if ($dbTrans->table_exists('efsnetRequestMod')) {
         PaycardLib::paycard_db_query($sql, $dbTrans);
     }
     $normalized = $validResponse == 0 ? 4 : 0;
     if ($resultCode == 1) {
         $normalized = 1;
     } else {
         if ($resultCode == 2) {
             $normalized = 2;
         } else {
             if ($resultCode == 0) {
                 $normalized = 3;
             }
         }
     }
     $finishQ = sprintf("UPDATE PaycardTransactions\n                            SET responseDatetime='%s',\n                                seconds=%f,\n                                commErr=%d,\n                                httpCode=%d,\n                                validResponse=%d,\n                                xResultCode=%d,\n                                xResponseCode=%d,\n                                xResultMessage='%s'\n                            WHERE paycardTransactionID=%d", $now, $authResult['curlTime'], $authResult['curlErr'], $authResult['curlHTTP'], $normalized, $responseCode, $resultCode, $rMsg, $this->last_paycard_transaction_id);
     $dbTrans->query($finishQ);
     if ($authResult['curlErr'] != CURLE_OK || $authResult['curlHTTP'] != 200) {
         if ($authResult['curlHTTP'] == '0') {
             CoreLocal::set("boxMsg", "No response from processor<br />\n                            The transaction did not go through");
             return PaycardLib::PAYCARD_ERR_PROC;
         }
         return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_COMM);
     }
     switch ($xml->get("STATUS1")) {
         case 1:
             // APPROVED
             return PaycardLib::PAYCARD_ERR_OK;
         case 2:
             // DECLINED
             CoreLocal::set("boxMsg", $resultMsg);
             break;
         case 0:
             // ERROR
             CoreLocal::set("boxMsg", "");
             $texts = $xml->get_first("ERROR1");
             CoreLocal::set("boxMsg", "Error: {$texts}");
             break;
         default:
             CoreLocal::set("boxMsg", "An unknown error occurred<br />at the gateway");
     }
     return PaycardLib::PAYCARD_ERR_PROC;
 }
Beispiel #3
0
 private function handleResponseBalance($balResult)
 {
     $resp = $this->desoapify("GiftTransactionResult", $balResult["response"]);
     $xml = new xmlData($resp);
     $program = 'Gift';
     if ($balResult['curlErr'] != CURLE_OK || $balResult['curlHTTP'] != 200) {
         if ($authResult['curlHTTP'] == '0') {
             if (!$this->second_try) {
                 $this->second_try = true;
                 return $this->send_balance("w2.backuppay.com");
             } else {
                 CoreLocal::set("boxMsg", "No response from processor<br />\n                                The transaction did not go through");
                 return PaycardLib::PAYCARD_ERR_PROC;
             }
         }
         return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_COMM);
         // comm error, try again
     }
     CoreLocal::set("paycard_response", array());
     CoreLocal::set("paycard_response", $xml->array_dump());
     $resp = CoreLocal::get("paycard_response");
     if (isset($resp["BALANCE"])) {
         $resp["Balance"] = $resp["BALANCE"];
         CoreLocal::set("paycard_response", $resp);
     }
     // there's less to verify for balance checks, just make sure all the fields are there
     if ($xml->isValid() && $xml->get('TRANTYPE') && $xml->get('TRANTYPE') == 'PrePaid' && $xml->get('CMDSTATUS') && $xml->get('CMDSTATUS') == 'Approved' && $xml->get('BALANCE')) {
         return PaycardLib::PAYCARD_ERR_OK;
         // balance checked, no error
     }
     // the authorizor gave us some failure code
     CoreLocal::set("boxMsg", "Processor error: " . $xml->get_first("TEXTRESPONSE"));
     return PaycardLib::PAYCARD_ERR_PROC;
 }
Beispiel #4
0
 function handleResponseVoid($authResult)
 {
     $xml = new xmlData($authResult['response']);
     $request = $this->last_request;
     $this->last_paycard_transaction_id = $request->last_paycard_transaction_id;
     $response = new PaycardResponse($request, $authResult);
     $validResponse = $xml->isValid() ? 1 : 0;
     $responseCode = $xml->get("RESPONSECODE");
     if ($responseCode === false) {
         $validResponse = -3;
     }
     $response->setResponseCode($responseCode);
     $resultCode = $xml->get_first("CODE");
     $response->setResultCode($resultCode);
     $resultMsg = $xml->get_first("DESCRIPTION");
     $response->setResultMsg($resultMsg);
     $response->setValid($validResponse);
     try {
         $response->saveResponse();
     } catch (Exception $ex) {
     }
     if ($authResult['curlErr'] != CURLE_OK || $authResult['curlHTTP'] != 200) {
         return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_COMM);
     }
     switch ($xml->get("RESPONSECODE")) {
         case 1:
             // APPROVED
             return PaycardLib::PAYCARD_ERR_OK;
         case 2:
             // DECLINED
             CoreLocal::set("boxMsg", "Transaction declined");
             if ($xml->get_first("ERRORCODE") == 4) {
                 CoreLocal::set("boxMsg", CoreLocal::get("boxMsg") . "<br />Pick up card");
             }
             break;
         case 3:
             // ERROR
             CoreLocal::set("boxMsg", "");
             $codes = $xml->get("ERRORCODE");
             $texts = $xml->get("ERRORTEXT");
             if (!is_array($codes)) {
                 CoreLocal::set("boxMsg", "EC{$codes}: {$texts}");
             } else {
                 for ($i = 0; $i < count($codes); $i++) {
                     CoreLocal::set("boxMsg", CoreLocal::get("boxMsg") . "EC" . $codes[$i] . ": " . $texts[$i]);
                     if ($i != count($codes) - 1) {
                         CoreLocal::set("boxMsg", CoreLocal::get("boxMsg") . "<br />");
                     }
                 }
             }
             break;
         default:
             CoreLocal::set("boxMsg", "An unknown error occurred<br />at the gateway");
     }
     return PaycardLib::PAYCARD_ERROR_PROC;
 }
Beispiel #5
0
 function handleResponseAuth($authResult)
 {
     $inner_xml = $this->desoapify("SOAP-ENV:Body", $authResult['response']);
     $xml = new xmlData($inner_xml);
     $request = $this->last_request;
     $this->last_paycard_transaction_id = $request->last_paycard_transaction_id;
     $response = new PaycardResponse($request, $authResult);
     $dbTrans = PaycardLib::paycard_db();
     $cvv2 = CoreLocal::get("paycard_cvv2");
     $validResponse = $xml->isValid() ? 1 : 0;
     $statusMsg = $xml->get("fdggwsapi:TransactionResult");
     $responseCode = 4;
     switch (strtoupper($statusMsg)) {
         case 'APPROVED':
             $responseCode = 1;
             break;
         case 'DECLINED':
         case 'FRAUD':
             $responseCode = 2;
             break;
         case 'FAILED':
         case 'DUPLICATE':
             $responseCode = 0;
             break;
     }
     $response->setResponseCode($responseCode);
     // aren't two separate codes from goemerchant
     $resultCode = $responseCode;
     $response->setResultCode($resultCode);
     $resultMsg = $statusMsg;
     // already gathered above
     $response->setResultMsg($resultMsg);
     $xTransID = $xml->get("fdggwsapi:ProcessorReferenceNumber");
     $response->setTransactionID($xTransID);
     $apprNumber = $xml->get("fdggwsapi:ApprovalCode");
     $response->setApprovalNum($apprNumber);
     // valid credit transactions don't have an approval number
     $response->setValid(0);
     try {
         $response->saveResponse();
     } catch (Exception $ex) {
     }
     if ($authResult['curlErr'] != CURLE_OK || $authResult['curlHTTP'] != 200) {
         TransRecord::addcomment("");
         if ($authResult['curlHTTP'] == '0') {
             CoreLocal::set("boxMsg", "No response from processor<br />\n                            The transaction did not go through");
             return PaycardLib::PAYCARD_ERR_PROC;
         }
         return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_COMM);
     }
     switch ($responseCode) {
         case 1:
             // APPROVED
             return PaycardLib::PAYCARD_ERR_OK;
         case 2:
             // DECLINED
             CoreLocal::set("boxMsg", 'Card Declined');
             break;
         case 0:
             // ERROR
             $texts = $xml->get_first("fdggwsapi:ProcessorResponseMessage");
             CoreLocal::set("boxMsg", "Error: {$texts}");
             break;
         default:
             CoreLocal::set("boxMsg", "An unknown error occurred<br />at the gateway");
     }
     return PaycardLib::PAYCARD_ERR_PROC;
 }
Beispiel #6
0
 /**
   Examine XML response from Datacap transaction,
   extract balance and/or error determine next step
   @return [int] PaycardLib error code
 */
 public function handleResponseDataCapBalance($xml)
 {
     $xml = new xmlData($xml);
     $validResponse = $xml->isValid() ? 1 : 0;
     $responseCode = $xml->get("CMDSTATUS");
     if ($responseCode) {
         $responseCode = $this->responseToNumber($responseCode);
     } else {
         $validResponse = -3;
     }
     $balance = $xml->get_first('BALANCE');
     switch (strtoupper($xml->get_first("CMDSTATUS"))) {
         case 'APPROVED':
             CoreLocal::set('DatacapBalanceCheck', $balance);
             return PaycardLib::PAYCARD_ERR_OK;
         case 'DECLINED':
             // intentional fallthrough
         // intentional fallthrough
         case 'ERROR':
             CoreLocal::set("boxMsg", "");
             $texts = $xml->get_first("TEXTRESPONSE");
             CoreLocal::set("boxMsg", "Error: {$texts}");
             TransRecord::addcomment("");
             break;
         default:
             CoreLocal::set("boxMsg", "An unknown error occurred<br />at the gateway");
             TransRecord::addcomment("");
     }
     return PaycardLib::PAYCARD_ERR_PROC;
 }