示例#1
0
 /**
  * Process the (dummy) transaction
  *
  * @return mixed  Payment_Process_Result instance or PEAR_Error
  */
 function &process()
 {
     // Sanity check
     if (PEAR::isError($res = $this->validate())) {
         return $res;
     }
     if ($this->_options['randomResult']) {
         srand(microtime());
         $n = rand(0, count($this->_returnValues) - 1);
         $code =& $this->_returnValues[$n]['code'];
         $message =& $this->_returnValues[$n]['message'];
     } else {
         $code =& $this->_options['returnCode'];
         $message =& $this->_options['returnMessage'];
     }
     return Payment_Process_Result::factory('Dummy');
 }
示例#2
0
 /**
  * Processes a callback from payment gateway
  *
  * Success here doesn't mean the transaction was approved. It means
  * the callback was received and processed without technical difficulties.
  *
  * @return mixed Payment_Process_Result on success, PEAR_Error on failure
  */
 function &processCallback()
 {
     $this->_responseBody = $_POST;
     $this->_processed = true;
     $response =& Payment_Process_Result::factory($this->_driver, $this->_responseBody);
     if (!PEAR::isError($response)) {
         $response->_request = $this;
         $response->parseCallback();
         $r = $response->isLegitimate();
         if (PEAR::isError($r)) {
             return $r;
         } elseif ($r === false) {
             return PEAR::raiseError('Illegitimate callback from gateway.');
         }
     }
     return $response;
 }
示例#3
0
 /**
  * Process the transaction.
  *
  * @return mixed Payment_Process_Result on success, PEAR_Error on failure
  */
 function &process()
 {
     // Sanity check
     if (PEAR::isError($res = $this->validate())) {
         return $res;
     }
     // Prepare the data
     $this->_prepare();
     // Don't die partway through
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $req =& new Net_Curl($this->_options['authorizeUri']);
     if (PEAR::isError($req)) {
         PEAR::popErrorHandling();
         return $req;
     }
     $req->type = 'POST';
     $req->fields = $this->_prepareQueryString();
     $req->userAgent = 'PEAR Payment_Process_Transfirst 0.1';
     $res =& $req->execute();
     $req->close();
     if (PEAR::isError($res)) {
         PEAR::popErrorHandling();
         return $res;
     }
     $this->_processed = true;
     // Restore error handling
     PEAR::popErrorHandling();
     $response = trim($res);
     print "Response: {$response}\n";
     $result =& Payment_Process_Result::factory('Transfirst', $response);
     $result->_request =& $this;
     $this->_result =& $result;
     return $result;
     /*
      * HTTP_Request doesn't do SSL until PHP 4.3.0, but it
      * might be useful later...
     $req = &new HTTP_Request($this->_authUri);
     $this->_setPostData();
     $req->sendRequest();
     */
 }
 /**
  * Processes the transaction.
  *
  * Success here doesn't mean the transaction was approved. It means
  * the transaction was sent and processed without technical difficulties.
  *
  * @return mixed Payment_Process_Result on success, PEAR_Error on failure
  * @access public
  */
 function &process()
 {
     // Sanity check
     $result = $this->validate();
     if (PEAR::isError($result)) {
         return $result;
     }
     // Prepare the data
     $result = $this->_prepare();
     if (PEAR::isError($result)) {
         return $result;
     }
     //        error_log( 'AuthorizeNetSubscriptions->process(),Ê_data: ' . print_r( $this->_data, true ) );
     $xml = $this->_prepareXml();
     if (PEAR::isError($xml)) {
         return $xml;
     }
     // Don't die partway through
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $result = null;
     if (function_exists('curl_init')) {
         // Use CURL if installed...
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $this->_options['authorizeUri']);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_USERAGENT, 'PEAR Payment_Process_AuthorizeNetSubscriptions 0.1');
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
         curl_setopt($ch, CURLOPT_CAINFO, "path:/ca-bundle.crt");
         curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
         //			error_log( 'about to curl, sending xml: ' . "\n" . $xml );
         $result = curl_exec($ch);
         if (!$result) {
             $ce = curl_error($ch);
             // Throw an exception if there is a communication failure
             throw new Exception("Exception during communication: {$ce} ( {$this->_options}[ 'authorizeUri' ] )");
         }
         curl_close($ch);
     } else {
         return PEAR::raiseError("Curl must be installed in order to send subscription requests to Authorize.Net");
         //      		// Non-CURL based version...
         //      		$context = array('http' =>
         //      			array('method' => 'POST',
         //                'header' => 'Content-type: application/x-www-form-urlencoded'."\r\n".
         //                    'User-Agent: PEAR Payment_Process_AuthorizeNetSubscriptions 0.1 (non-curl) '.phpversion()."\r\n".
         //                    'Content-length: ' . strlen( $xml ),
         //                	'content' => $xml ) );
         //        	error_log( 'about to send: ' . print_r( $context, true ) );
         //      		$contextid = stream_context_create( $context );
         ////      		error_log( 'sent.  result: ' . $result );
         //		    $sock = fopen( $this->_options[ 'authorizeUri' ], 'r', false, $contextid );
         //      		if ( $sock ) {
         //         		$result='';
         //         		while ( !feof( $sock ) )
         //					$result.=fgets($sock, 4096);
         //				fclose($sock);
         //			}
     }
     //
     $this->_responseBody = trim($result);
     //        error_log( 'AuthorizeNetSubscriptions->process(),Ê_responseBody: ' . "\n" . print_r( $this->_responseBody, true ) );
     // Restore error handling
     PEAR::popErrorHandling();
     $response = Payment_Process_Result::factory($this->_driver, $this->_responseBody, $this);
     if (!PEAR::isError($response)) {
         $response->parse();
         $r = $response->isLegitimate();
         if (PEAR::isError($r)) {
             return $r;
         } elseif ($r === false) {
             return PEAR::raiseError('Illegitimate response from gateway');
         }
     }
     return $response;
 }
示例#5
0
 /**
  * Process the transaction.
  *
  * @author Joe Stump <*****@*****.**> 
  * @access public
  * @return mixed Payment_Process_Result on success, PEAR_Error on failure
  */
 function &process()
 {
     if (!strlen($this->_options['keyfile']) || !file_exists($this->_options['keyfile'])) {
         return PEAR::raiseError('Invalid key file');
     }
     // Sanity check
     $result = $this->validate();
     if (PEAR::isError($result)) {
         return $result;
     }
     // Prepare the data
     $result = $this->_prepare();
     if (PEAR::isError($result)) {
         return $result;
     }
     // Don't die partway through
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $xml = $this->_prepareQueryString();
     if (PEAR::isError($xml)) {
         return $xml;
     }
     $url = 'https://' . $this->_options['host'] . ':' . $this->_options['port'] . '/LSGSXML';
     $curl =& new Net_Curl($url);
     $result = $curl->create();
     if (PEAR::isError($result)) {
         return $result;
     }
     $curl->type = 'POST';
     $curl->fields = $xml;
     $curl->sslCert = $this->_options['keyfile'];
     // LinkPoint's staging server has a boned certificate. If they are
     // testing against staging we need to turn off SSL host verification.
     if ($this->_options['host'] == 'staging.linkpt.net') {
         $curl->verifyPeer = false;
         $curl->verifyHost = 0;
     }
     $curl->userAgent = 'PEAR Payment_Process_LinkPoint 0.1';
     $result =& $curl->execute();
     if (PEAR::isError($result)) {
         return PEAR::raiseError('cURL error: ' . $result->getMessage());
     } else {
         $curl->close();
     }
     $this->_responseBody = trim($result);
     $this->_processed = true;
     // Restore error handling
     PEAR::popErrorHandling();
     $response =& Payment_Process_Result::factory($this->_driver, $this->_responseBody, &$this);
     if (!PEAR::isError($response)) {
         $response->parse();
     }
     return $response;
 }
示例#6
0
 /**
  * Process the transaction.
  *
  * @return mixed Payment_Process_Result on success, PEAR_Error on failure
  */
 function &process()
 {
     // Sanity check
     $result = $this->validate();
     if (PEAR::isError($result)) {
         return $result;
     }
     // Prepare the data
     $result = $this->_prepare();
     if (PEAR::isError($result)) {
         return $result;
     }
     // Don't die partway through
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $fields = $this->_prepareQueryString();
     if (function_exists('tclink_send')) {
         /** USE TCLINK **/
         $result = tclink_send($fields);
         $r_keys = array_keys($result);
         for ($i = 0; $i < sizeof($r_keys); $i++) {
             $key = $r_keys[$i];
             $value = $result[$key];
             $result_string .= $key . '=' . $value . "\n";
         }
         if (PEAR::isError($result_string)) {
             PEAR::popErrorHandling();
             return $result_string;
         } else {
             $result = $result_string;
         }
     } else {
         /** USE CURL **/
         $curl = new Net_Curl('https://vault.trustcommerce.com/trans/');
         if (PEAR::isError($curl)) {
             PEAR::popErrorHandling();
             return $curl;
         }
         $curl->type = 'PUT';
         $curl->fields = $fields;
         $curl->userAgent = 'PEAR Payment_Process_TrustCommerce 0.1a';
         $result =& $curl->execute();
         if (PEAR::isError($result)) {
             PEAR::popErrorHandling();
             return $result;
         } else {
             $curl->close();
         }
     }
     /** END TCLINK/CURL CASE STATEMENT **/
     $this->_responseBody = trim($result);
     $this->_processed = true;
     // Restore error handling
     PEAR::popErrorHandling();
     $response = Payment_Process_Result::factory($this->_driver, $this->_responseBody, $this);
     if (!PEAR::isError($response)) {
         $response->parse();
     }
     return $response;
 }
示例#7
0
 /**
  * Process the transaction.
  *
  * @return mixed Payment_Process_Result on success, PEAR_Error on failure
  */
 function &process()
 {
     // Sanity check
     $result = $this->validate();
     if (PEAR::isError($result)) {
         return $result;
     }
     // Prepare the data
     $result = $this->_prepare();
     if (PEAR::isError($result)) {
         return $result;
     }
     // Don't die partway through
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $fields = $this->_prepareQueryString();
     $curl = new Net_Curl(isset($this->_options['live']) ? $this->_options['authorizeUri'] : $this->_options['authorizeTestUri']);
     if (PEAR::isError($curl)) {
         PEAR::popErrorHandling();
         return $curl;
     }
     $curl->type = 'PUT';
     $curl->fields = $fields;
     $curl->userAgent = 'PEAR Payment_Process_Bibit 0.1';
     $curl->username = $this->_data['x_login'];
     $curl->password = $this->_data['x_password'];
     $result =& $curl->execute();
     if (PEAR::isError($result)) {
         PEAR::popErrorHandling();
         return $result;
     } else {
         $curl->close();
     }
     $this->_responseBody = trim($result);
     $this->_processed = true;
     // Restore error handling
     PEAR::popErrorHandling();
     $response =& Payment_Process_Result::factory($this->_driver, $this->_responseBody, $this);
     if (!PEAR::isError($response)) {
         $response->parse();
     }
     return $response;
 }