private function handleResponseVoid($vdResult) { $xml = new xmlData($vdResult["response"]); $request = $this->last_request; $this->last_paycard_transaction_id = $request->last_paycard_transaction_id; $response = new PaycardResponse($request, $authResult); $mode = 'void'; $authcode = $this->temp; $program = "Gift"; $validResponse = 0; // verify that echo'd fields match our request if ($xml->get('TRANSACTIONTYPE') && $xml->get('TRANSACTIONTYPE') == $program && $xml->get('AUTHORIZED') && $xml->get('AUTHORIZATIONCODE') && $xml->get('BALANCE')) { $validResponse = 1; // response was parsed normally, echo'd fields match, and other required fields are present } else { $validResponse = 4; // response was parsed as XML but fields didn't match } $resultCode = 0; $apprNumber = $xml->get('AUTHORIZATIONCODE'); $response->setApprovalNum($apprNumber); $rMsg = ''; if ($apprNumber != '' && $xml->get('AUTHORIZED') == 'true') { $validResponse = 1; $resultCode = 1; $rMsg = 'Voided'; } else { $rMsg = substr($xml->get_first('ERRORMSG'), 0, 100); } $response->setResultMsg($rMsg); $response->setResultCode($resultCode); $response->setResponseCode($resultCode); $response->setNormalizedCode($resultCode); $response->setValid($validResponse); try { $response->saveResponse(); } catch (Exception $ex) { } if ($vdResult['curlErr'] != CURLE_OK || $vdResult['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 } // check for data errors (any failure to parse response XML or echo'd field mismatch) // invalid server response, we don't know if the transaction was voided (use carbon) if ($validResponse != 1) { return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_DATA); } // put the parsed response into session so the caller, receipt printer, etc can get the data they need CoreLocal::set("paycard_response", array()); CoreLocal::set("paycard_response", $xml->array_dump()); $temp = CoreLocal::get("paycard_response"); $temp["Balance"] = $temp["BALANCE"]; CoreLocal::set("paycard_response", $temp); // comm successful, check the Authorized, AuthorizationCode and ErrorMsg fields if ($xml->get('AUTHORIZED') == 'true' && $xml->get('AUTHORIZATIONCODE') != '' && $xml->get_first('ERRORMSG') == '') { return PaycardLib::PAYCARD_ERR_OK; // void successful, no error } // the authorizor gave us some failure code CoreLocal::set("boxMsg", "PROCESSOR ERROR: " . $xml->get_first("ERRORMSG")); return PaycardLib::PAYCARD_ERR_PROC; }
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; }
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; }
/** Updated for E2E */ private function handleResponseVoid($authResult) { $resp = $this->desoapify("CreditTransactionResult", $authResult["response"]); $xml = new xmlData($resp); $dbTrans = PaycardLib::paycard_db(); $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("CMDSTATUS"); if ($responseCode) { $responseCode = $this->responseToNumber($responseCode); } else { $validResponse = -3; } $response->setResponseCode($responseCode); $resultCode = $xml->get_first("DSIXRETURNCODE"); $response->setResultCode($resultCode); $resultMsg = $xml->get_first("CMDSTATUS"); if ($resultMsg) { $rMsg = $resultMsg; } $response->setResultMsg($resultMsg); $response->setValid($validResponse); $normalized = $validResponse == 0 ? 4 : 0; if ($responseCode == 1) { $normalized = 1; } else { if ($responseCode == 2) { $normalized = 2; } else { if ($responseCode == 0) { $normalized = 3; } } } $response->setNormalizedCode($normalized); $response->setToken($xml->get_first('RECORDNO'), $xml->get_first('PROCESSDATA'), $xml->get_first('ACQREFDATA')); try { $response->saveResponse(); } catch (Exception $ex) { } // void still happened even if logging the result failed $tokenRef = $xml->get_first("INVOICENO"); $sql = sprintF("DELETE FROM efsnetTokens WHERE refNum='%s'", $tokenRef); if ($dbTrans->table_exists('efsnetTokens')) { PaycardLib::paycard_db_query($sql, $dbTrans); } 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 (strtoupper($xml->get("CMDSTATUS"))) { case 'APPROVED': return PaycardLib::PAYCARD_ERR_OK; case 'DECLINED': // if declined, try again with a regular Void op // and no reversal information $skipReversal = CoreLocal::get("MercuryE2ESkipReversal"); if ($skipReversal == true) { CoreLocal::set("MercuryE2ESkipReversal", false); } else { return $this->send_void(true); } case 'ERROR': CoreLocal::set("boxMsg", ""); $texts = $xml->get_first("TEXTRESPONSE"); CoreLocal::set("boxMsg", "Error: {$texts}"); break; default: CoreLocal::set("boxMsg", "An unknown error occurred<br />at the gateway"); } return PaycardLib::PAYCARD_ERR_PROC; }