Esempio n. 1
0
 /**
  * Creates a new instance of this response object, but this should not be
  * directly handled by enternal code, as the wrapper uses it to return more
  * accessible values from the Text2Pay API.
  *
  * @param string $raw The raw value from the API call response.
  *
  * @author Braga, Bruno <*****@*****.**>
  *
  * @since 0.1
  *
  */
 public function __construct($raw)
 {
     parent::__construct($raw);
     // Map all response data into this object
     $this->transactionGroupId = $this->response['transaction_group_id']['@attributes']['id'];
     $this->transactionInfos = array();
     if (Text2PayApi_Common::isAssocArray($this->response['transaction_group_id']['transaction_id'])) {
         // it is a single transaction
         $trxid = $this->response['transaction_group_id']['transaction_id']['@attributes']['id'];
         $confirmation = $this->response['transaction_group_id']['transaction_id']['confirmation'];
         $this->transactionInfos[] = new Text2PayApi_verifyTransaction_TransactionInfo($trxid, $confirmation);
     } else {
         // it is a list of multiple transactions
         foreach ($this->response['transaction_group_id']['transaction_id'] as $t) {
             $trxid = $t['@attributes']['id'];
             $confirmation = $t['confirmation'];
             $this->transactionInfos[] = new Text2PayApi_verifyTransaction_TransactionInfo($trxid, $confirmation);
         }
     }
 }
Esempio n. 2
0
 /**
  * The actual CURL execution that communicates with Text2Pay API by HTTP
  * GET request. Here, the arguments prepared for the URL querystring will
  * be properly "stringfied" by the built-in {@link http_build_query()},
  * in addition to the signature that is created by
  * {@link Text2PayApi_RequestBase::createSignature()} method.
  *
  * @return array object with all raw values returned from API.
  *
  * @throws Text2PayException In case the argument action was not properly
  * defined, or due to internet connectivity issues (CURL or HTTP errors).
  *
  * @throws Text2PayApiException For API response issues.
  *
  * @see Text2PayApi_RequestBase::createSignature()
  *
  * @uses curl_init() and related CURL functionalities for HTTP requests.
  * @uses http_build_query() to stringfy the arguments array
  *
  * @author Braga, Bruno <*****@*****.**>
  * @author Martens, Scott <*****@*****.**>
  *
  * @since 0.1
  *
  */
 private function apiPost()
 {
     $result = array();
     $params = $this->args;
     // include the source if applicable
     $source = $this->apiConnection->getSource();
     if (!empty($source)) {
         $params['source'] = $source;
     }
     // create our signature hash value
     $params['sig'] = Text2PayApi_RequestBase::createSignature($this->apiConnection->getApiKey(), $params);
     // manually build URL for debugging purposes
     $this->executedUrl = Text2PayApi_RequestBase::$url . '?' . http_build_query($params);
     // execute the request
     $this->rawData = Text2PayApi_Common::httpGet(Text2PayApi_RequestBase::$url, $params, $this->apiConnection->getUsername(), $this->apiConnection->getPassword());
     return $this->rawData;
 }
Esempio n. 3
0
 /**
  * Creates a new instance of this response object, but this should not be
  * directly handled by enternal code, as the wrapper uses it to return more
  * accessible values from the Text2Pay API.
  *
  * @param string $raw The raw value from the API call response.
  *
  * @author Braga, Bruno <*****@*****.**>
  *
  * @since 0.2
  *
  */
 public function __construct($raw)
 {
     parent::__construct($raw);
     $this->transactionGroupId = $this->response['transaction_group_id']['@attributes']['id'];
     $this->totalPricePoint = $this->response['transaction_group_id']['@attributes']['total_price_point'];
     $this->totalCommodityAmount = $this->response['transaction_group_id']['@attributes']['total_commodity_amount'];
     $this->transactionStatusInfos = array();
     if (Text2PayApi_Common::isAssocArray($this->response['transaction_group_id']['transaction_id'])) {
         // it is a single transaction
         array_push($this->transactionStatusInfos, new Text2PayApi_checkTransactionStatus_TransactionStatusInfo($this->response['transaction_group_id']['transaction_id']));
     } else {
         // it is a list of multiple transactions
         foreach ($this->response['transaction_group_id']['transaction_id'] as $t) {
             array_push($this->transactionStatusInfos, new Text2PayApi_checkTransactionStatus_TransactionStatusInfo($t));
         }
     }
 }
Esempio n. 4
0
 /**
  * Recursively extracts properties from a {@link SimpleXMLElement} object
  * to an array format, for simplicity of usage.
  *
  * Note: depending on the XML formatting, the array might be dirty formed,
  * 		 with attributes and such placed as keys in the array list. This
  * 		 must be treated manually afterwards.
  *
  * @param SimpleXMLElement $xmlObject the XML object to be converted
  *
  * @return array object representation of the
  * 		   {@link SimpleXMLElement} object.
  *
  * @author Braga, Bruno <*****@*****.**>
  * @author Martens, Scott <*****@*****.**>
  *
  * @example Text2PayApi_Common::xml2Array(@new SimpleXMLElement("&lt;xml..."));
  *
  * @since 0.1
  *
  */
 public static function xml2Array($xmlObject)
 {
     $out = array();
     foreach ((array) $xmlObject as $index => $node) {
         if (is_object($node) || is_array($node)) {
             $out[$index] = Text2PayApi_Common::xml2Array($node);
         } else {
             $out[$index] = $node;
         }
     }
     return $out;
 }