function __construct($p)
 {
     Helper::assign($this, $p);
     $this->type = $this->transaction_type;
     $this->error = Errors\errorFromResponseHash($p);
     unset($this->code);
     unset($this->message);
     unset($this->technical_message);
 }
Example #2
0
 function __construct($p)
 {
     Helper::assign($this, $p);
     // alias for convinience
     if ($this->type == 'MobilePayment') {
         $this->submit_url = @$p['redirect_url'];
     }
     $this->error = Errors\errorFromResponseHash($p);
     unset($this->code);
     unset($this->message);
     unset($this->technical_message);
     // payment_transaction might be an array, as there might be multiple payment_transaction sibling-nodes in xml :-|
     if (isset($p['payment_transaction'])) {
         $this->transactions = array();
         if (array_key_exists(0, $p['payment_transaction'])) {
             foreach ($p['payment_transaction'] as $data) {
                 $this->transactions[] = new Transaction($data);
             }
         } else {
             $this->transactions[] = new Transaction($p['payment_transaction']);
         }
     }
 }
Example #3
0
 /**
  * private
  * @throws Hypercharge\Errors\Error
  */
 function handleError($url, $status, $response, $curlError, $curlInfo)
 {
     // redirects are considered errors as hypercharge api doesn't do redirects
     if (200 <= $status && $status < 300) {
         return;
     }
     if (empty($curlError)) {
         $curlError = "The requested URL returned error: " . $status;
     }
     $this->logError($curlError . "\n" . print_r($curlInfo, true));
     if ($status == 400 && !empty($response)) {
         $data = json_decode($response);
         if ($data && @$data->error) {
             throw Errors\errorFromResponseHash($data->error);
         }
     }
     throw new Errors\NetworkError($url, $status, $curlError . (!empty($response) ? "\n" . $response : ''), print_r($curlInfo, true));
 }