public function PerformConfirmation($request, $response) { // // Verify that we have a transaction ID for the confirmation // message. // $confirmGUID = $response->Get(GatewayResponse::TRANSACT_ID()); if ($confirmGUID == NULL) { // Don't have reference? $response->Set(GatewayResponse::EXCEPTION(), "BUG-CHECK - Missing confirmation GUID"); $response->SetResults(GatewayCodes__RESPONSE_SYSTEM_ERROR, GatewayCodes__REASON_BUGCHECK); return FALSE; // Transaction failed } // // Add the GUID to the request and send it back to the // original server for confirmation. // $confirmResponse = new GatewayResponse(); // Need a new response object $request->Set(GatewayRequest::TRANSACTION_TYPE(), "CC_CONFIRM"); $request->Set(GatewayRequest::REFERENCE_GUID(), $confirmGUID); if ($this->PerformTargetedTransaction($request, $confirmResponse)) { return TRUE; } ////////////////////////////////////////////////////////////////////// // // 12-21-2011 darcy // // If we experienced a system error, retry the confirmation. // if ($confirmResponse->Get(GatewayResponse::RESPONSE_CODE()) == GatewayCodes__RESPONSE_SYSTEM_ERROR) { sleep(2); // Short delay if ($this->PerformTargetedTransaction($request, $confirmResponse)) { return TRUE; } } // ////////////////////////////////////////////////////////////////////// // // If the confirmation failed, copy the reason and response code // into the original response object to override the success. // $response->SetResults($confirmResponse->Get(GatewayResponse::RESPONSE_CODE()), $confirmResponse->Get(GatewayResponse::REASON_CODE())); $response->Set(GatewayResponse::EXCEPTION(), $confirmResponse->Get(GatewayResponse::EXCEPTION())); return FALSE; // And quit }
} if ($transaction_types[$trans_type] == 'AUTH_CAPTURE') { $service_response = $service->PerformPurchase($request, $response); $transaction_type = 'sale'; } elseif ($transaction_types[$trans_type] == 'AUTH_ONLY') { $service_response = $service->PerformAuthOnly($request, $response); $transaction_type = 'auth'; } // Gateway answered $pp_response = array(); if ($response->Get(GatewayResponse::RESPONSE_CODE()) == GatewayCodes__RESPONSE_SUCCESS) { // check CVV2 response $cvv_code = $response->Get(GatewayResponse::CVV2_CODE()); switch ($cvv_code) { case 'N': case 'P': case 'S': case 'U': $pp_response['order_status'] = 'F'; $pp_response['reason_text'] = $processor_error['cvv'][$cvv_code]; break; default: $pp_response['order_status'] = 'P'; $pp_response['reason_text'] = ''; break; } } else { $pp_response['order_status'] = 'F'; $pp_response['reason_text'] = $tran_error[$response->Get(GatewayResponse::REASON_CODE())]; } $pp_response['transaction_id'] = $response->Get(GatewayResponse::TRANSACT_ID());
public function SetResults($response, $reason) { $this->Set(GatewayResponse::RESPONSE_CODE(), $response); $this->Set(GatewayResponse::REASON_CODE(), $reason); }