Ejemplo n.º 1
0
 /**
  * Caller Magic Method
  */
 public function __call($method, $params)
 {
     $this->_lib_method = $method;
     $args = $params[0];
     $request_string = $this->_build_request($params);
     $raw_response = Payment_Request::curl_request($this->_api_endpoint, $request_string, 'application/x-www-form-urlencoded');
     return $this->_parse_response($raw_response);
 }
 /**
  * Caller Magic Method
  */
 public function __call($method, $params)
 {
     $this->_lib_method = $method;
     $args = $params[0];
     $request = $this->_build_request($args);
     $endpoint = $this->_mode == 'production' ? $this->_api_endpoint : $this->_api_endpoint_test;
     $request_string = $endpoint . '?' . $request;
     $raw_response = Payment_Request::curl_request($request_string);
     return $this->_parse_response($raw_response);
 }
 /**
  * Builds the Request
  */
 protected function _build_request($params)
 {
     $nodes = array();
     $nodes['merchantAuthentication'] = array('name' => $this->_settings['api_username'], 'transactionKey' => $this->_settings['api_password']);
     if ($this->_api == 'createTransactionRequest') {
         $nodes['transactionRequest'] = $this->_transaction_fields($params);
         $nodes['transactionRequest']['transactionSettings'] = $this->_transaction_settings();
     }
     if ($this->_api == 'getTransactionDetailsRequest') {
         $nodes['transId'] = $params['identifier'];
     }
     if ($this->_api == 'ARBGetSubscriptionStatusRequest' or $this->_api == 'ARBUpdateSubscriptionRequest' or $this->_api == 'ARBCancelSubscriptionRequest') {
         $nodes['subscriptionId'] = $params['identifier'];
     }
     if ($this->_api == 'ARBCreateSubscriptionRequest' or $this->_api == 'ARBUpdateSubscriptionRequest') {
         $nodes['subscription'] = $this->_transaction_fields($params);
     }
     $request_string = Payment_Request::build_xml_request($this->_settings['xml_version'], $this->_settings['encoding'], $nodes, $this->_api, $this->_settings['xml_schema']);
     return $request_string;
 }
 /**
  * Get the Session Ticket So We Can Create Transactions
  *
  * @return	object	$session->time, $session->ticket
  */
 private function _get_session_ticket()
 {
     $nodes = array();
     $nodes['SignonMsgsRq'] = array('SignonDesktopRq' => array('ClientDateTime' => gmdate('c'), 'ApplicationLogin' => $this->_api_settings['login'], 'ConnectionTicket' => $this->_api_settings['connection_ticket']));
     $request = Payment_Request::build_xml_request($this->_api_settings['xml_version'], $this->_api_settings['encoding'], $nodes, 'QBMSXML', null, $this->_api_settings['xml_extra']);
     $response_raw = Payment_Request::curl_request($this->_api_endpoint, $request, "application/x-qbmsxml");
     if (isset($response_raw->SignonMsgsRs->SignonDesktopRs)) {
         $r = $response_raw->SignonMsgsRs->SignonDesktopRs;
         $session = (object) array('time' => $r->ServerDateTime, 'ticket' => $r->SessionTicket);
         return $session;
     } else {
         throw new Exception('authentication_failure');
     }
 }
Ejemplo n.º 5
0
 /**
  * Build the query for the response and call the request function
  *
  * @param	array
  * @param	array
  * @return	array
  */
 private function _handle_query($method, $request)
 {
     $settings = array_merge($this->_api_settings, $this->_api_method);
     $merged = array_merge($settings, $request);
     $request = http_build_query($merged);
     $this->_http_query = $this->_api_endpoint . $request;
     $request = Payment_Request::curl_request($this->_http_query);
     $response = $this->_parse_response($request);
     return $response;
 }
Ejemplo n.º 6
0
 /**
  * Builds a request
  * @param	array	array of params
  * @param	string	the type of transaction
  * @return	array	Array of transaction settings
  */
 protected function _build_request($params)
 {
     $map = $this->method_map();
     $l = $this->_lib_method;
     $nodes = array();
     $nodes[$map[$l]['api']] = array();
     $root =& $nodes[$map[$l]['api']];
     $root['test'] = 'haha';
     $root['StoreId'] = $this->_api_settings['store_id'];
     $root['Passphrase'] = $this->_api_settings['pass_phrase'];
     foreach ($params as $k => $v) {
         if (isset($map[$l]['keymatch'][$k])) {
             $key = $map[$l]['keymatch'][$k];
             if (strpos($key, ',') !== false) {
                 $ex = explode(',', $key);
                 if ($k == 'cc_exp') {
                     $k1 = $ex[0];
                     $k2 = $ex[1];
                     $root[$k1] = substr($v, 0, 2);
                     //Sets the month
                     $root[$k2] = substr($v, -2, 2);
                     //Sets the year
                 }
             } else {
                 if (isset($nodes[$key])) {
                     $root[$key] .= $v;
                 } else {
                     $root[$key] = $v;
                 }
             }
         } else {
             error_log("{$k} is not a valid param for the {$l} method in the Psigate class");
         }
     }
     foreach ($map[$l]['static'] as $k => $v) {
         $root[$k] = $v;
     }
     $request = Payment_Request::build_xml_request($this->_api_settings['xml_version'], $this->_api_settings['encoding'], $nodes);
     return $request;
 }