public function PerformCURLTransaction($host, $request, $response) { // // Reset the response object and turn the request into // a string that can be transmitted. // $response->Reset(); // Clear old contents $requestBytes = $request->ToXMLString(); // Change to XML request // // Gather override attibutes used for the connection URL. // $urlServlet = $request->Get("gatewayServlet"); $urlProtocol = $request->Get("gatewayProtocol"); $urlPortNo = $request->Get("gatewayPortNo"); // // If the parameters were not set in the request, // use the system defaults. // if ($urlServlet == NULL) { $urlServlet = $this->rocketGateServlet; } if ($urlProtocol == NULL) { $urlProtocol = $this->rocketGateProtocol; } if ($urlPortNo == NULL) { $urlPortNo = $this->rocketGatePortNo; } // // Build the URL for the gateway service. // $url = $urlProtocol . "://" . $host . ":" . $urlPortNo . "/" . $urlServlet; // Add servlet path // // Gather the override timeout values that will be used // for the connection. // $connectTimeout = $request->Get("gatewayConnectTimeout"); $readTimeout = $request->Get("gatewayReadTimeout"); // // Use default values if the parameters were not set. // if ($connectTimeout == NULL) { // No connect timeout specified? $connectTimeout = $this->rocketGateConnectTimeout; } if ($readTimeout == NULL) { $readTimeout = $this->rocketGateReadTimeout; } // // Create a handle that can be used for the URL operation. // if (!($handle = curl_init())) { // Failed to initialize? $response->Set(GatewayResponse::EXCEPTION(), "curl_init() error"); $response->SetResults(GatewayCodes__RESPONSE_REQUEST_ERROR, GatewayCodes__REASON_INVALID_URL); return GatewayCodes__RESPONSE_REQUEST_ERROR; } // // Set timeout values used in the operation. // curl_setopt($handle, CURLOPT_NOSIGNAL, TRUE); curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, $connectTimeout); curl_setopt($handle, CURLOPT_TIMEOUT, $readTimeout); // // Setup verification for SSL connections. // curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, FALSE); // // Setup the call to the URL. // curl_setopt($handle, CURLOPT_POST, TRUE); curl_setopt($handle, CURLOPT_POSTFIELDS, $requestBytes); curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($handle, CURLOPT_URL, $url); curl_setopt($handle, CURLOPT_FAILONERROR, TRUE); ////////////////////////////////////////////////////////////////////// // // 04-30-2013 darcy // // Updated user agent. // // 12-20-2011 darcy // // Updated user agent. // // 08-25-2011 darcy // // Updated user agent. // // 05-31-2009 darcy // // Updated the user agent. // // 04-27-2009 darcy // // Set the user-agent. // // curl_setopt($handle, CURLOPT_USERAGENT, "RG PHP Client 2.0"); // curl_setopt($handle, CURLOPT_USERAGENT, "RG PHP Client 2.1"); // curl_setopt($handle, CURLOPT_USERAGENT, "RG PHP Client 3.0"); // ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// // // 2/21/2010 Jason. Set content-type. // curl_setopt($handle, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); ////////////////////////////////////////////////////////////////////// // // Execute the operation. // $results = curl_exec($handle); // Execute the operation if (!$results) { // Did it fail? $errorCode = curl_errno($handle); // Get the error code $errorString = curl_error($handle); // Get the error text curl_close($handle); // Done with handle // // Translate the CURL error code into a Gateway code. // switch ($errorCode) { // Classify error code case CURLE_SSL_CONNECT_ERROR: // Connection failures // Connection failures case CURLE_COULDNT_CONNECT: $internalCode = GatewayCodes__REASON_UNABLE_TO_CONNECT; break; // Done with request // Done with request case CURLE_SEND_ERROR: // Failed sending data $internalCode = GatewayCodes__REASON_REQUEST_XMIT_ERROR; break; // Done with request // Done with request case CURLE_OPERATION_TIMEOUTED: // Time-out reached $internalCode = GatewayCodes__REASON_RESPONSE_READ_TIMEOUT; break; // Done with request // Done with request case CURLE_RECV_ERROR: // Failed reading data // Failed reading data case CURLE_READ_ERROR: default: $internalCode = GatewayCodes__REASON_RESPONSE_READ_ERROR; } // // If the operation failed, return an error code. // if (strlen($errorString) != 0) { // Have an error? $response->Set(GatewayResponse::EXCEPTION(), $errorString); } $response->SetResults(GatewayCodes__RESPONSE_SYSTEM_ERROR, $internalCode); return GatewayCodes__RESPONSE_SYSTEM_ERROR; } // // Parse the returned message into the response // object. // curl_close($handle); // Done with handle $response->SetFromXML($results); // Set response return $response->Get(GatewayResponse::RESPONSE_CODE()); }
if (!empty($order_info['email'])) { $request->Set(GatewayRequest::EMAIL(), $order_info['email']); } if ($processor_data['processor_params']['mode'] == 'test') { $service->SetTestMode(TRUE); } 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; }
public function SetResults($response, $reason) { $this->Set(GatewayResponse::RESPONSE_CODE(), $response); $this->Set(GatewayResponse::REASON_CODE(), $reason); }