Esempio n. 1
0
 /**
  * Set data
  *
  * Please note that it overwrites (extends with data) the URL in GET requests.
  *
  *
  * @param array $data
  * @return void
  */
 public function setData($data)
 {
     // convert $pData to string if it is array or object, that step takes care of urlencode()-ing, too
     if ($data === null) {
         $data = '';
     }
     // IMPORTANT!
     if (is_object($data)) {
         $pData = OSS_Array::objectToArray($data);
     }
     if (is_array($data)) {
         $data = self::httpBuildQuery($data);
     }
     //OSS_Debug::prr( $pData ); die();
     if ($this->getMethod() == self::HTTP_POST) {
         // we need that even if there is no data to make cURL to create the "Content-Type: application/x-www-form-urlencoded" header for us
         if (is_string($data)) {
             curl_setopt($this->_curlHandler, CURLOPT_POSTFIELDS, $data);
         }
     } elseif ($this->getMethod() == self::HTTP_GET) {
         if (is_string($data)) {
             curl_setopt($this->_curlHandler, CURLOPT_URL, $this->getUrl() . '?' . $data);
         }
     }
 }
Esempio n. 2
0
 /**
  * Parse the XML response from Realex and update the transaction object
  *
  * This function:
  *
  *  - transforms the XML response to an array
  *  - validates the response hash
  *  - updates the authcode, pasref, state and response fields of the \Entities\RealexTransaction object
  *
  * @param string $xml The XML response from Realex for processing
  * @param \Entities\RealexTransaction $rtrans An instance of the \Entities\RealexTransaciton object
  * @return \Entities\ReleaxTransaction The updated $rtrans object for fluent interface
  * @throws OSS_PaymentProcessor_Realex_Receipt_Exception
  */
 private function _parseResponse($xml, $rtrans)
 {
     $resp = OSS_Array::objectToArray(OSS_Utils::parseXML($xml));
     $rtrans->setResult($this->_checkResponse($resp));
     if (isset($resp['authcode'])) {
         $rtrans->setAuthcode($resp['authcode']);
     }
     //if( isset( $resp['pasref'] ) )
     // $rtrans['pasref'] = $resp['pasref'];
     $rtrans->setState(\Entities\RealexTransaction::STATE_COMPLETE);
     $this->_log("[RTRANS: {$rtrans->getId()}] Realex::_parseResponse() - Realex result: {$rtrans->getResult()}");
     //FIXME: Barry
     if ($rtrans->isSuccessful() && !$this->_keep_request_data) {
         $rtrans->setRequest('');
     }
     $rtrans->setUpdated(new \DateTime());
     $this->getD2EM()->flush();
     //FIXME Transaction stats.
     //if( !CreditcardTransactionStatsTable::update( $cctrans['request_type'], $cctrans['result'], $cctrans['amount'] ) )
     //$this->_log( "CreditcardTrasactionStatTable::update() failed for [CCTRANS: {$cctrans['id']}].", OSS_Log::ALERT );
     if (in_array($rtrans->getRequestType(), array('receipt-in', 'payment-out')) && !$rtrans->isSuccessful()) {
         throw new OSS_PaymentProcessor_Realex_Receipt_Exception($rtrans, $resp['message']);
     }
     return $rtrans;
 }