/** * 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)); } } }
/** * 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); } } }
/** * Fixes the array inconsistency in XML to PHP object parsing by {@link xml2Array} * method (in case of single values, it does not return a sequence array, but * an associative array instead). * * @param array $array * @return array a sequence array representation of the associative passed * (or does nothing if the array is already sequence). * * @author Braga, Bruno <*****@*****.**> * * @since 0.3 * */ protected function fixXmlPhpArray($array) { $arr = array(); if (Text2PayApi_Common::isAssocArray($array)) { $arr[] = $array; } else { $arr = $array; } return $arr; }