mdpirangi 0 Denunciar post Postado Novembro 17, 2015 Estou recebendo esse retorno do pagseguro mas apanhando para ler...Podem e dar uma mão..... preciso ler o valor do status---- Grato.... object(PagSeguroTransactionSearchResult)#22 (5) { ["date":"PagSeguroTransactionSearchResult":private]=> string(29) "2015-11-17T12:46:28.000-02:00" ["resultsInThisPage":"PagSeguroTransactionSearchResult":private]=> string(1) "1" ["totalPages":"PagSeguroTransactionSearchResult":private]=> string(1) "1" ["currentPage":"PagSeguroTransactionSearchResult":private]=> string(1) "1" ["transactions":"PagSeguroTransactionSearchResult":private]=> array(1) { [0]=> object(PagSeguroTransactionSummary)#21 (14) { ["date":"PagSeguroTransactionSummary":private]=> string(29) "2015-11-17T01:37:46.000-02:00" ["lastEventDate":"PagSeguroTransactionSummary":private]=> string(29) "2015-11-17T01:40:24.000-02:00" ["code":"PagSeguroTransactionSummary":private]=> string(36) "02AFD1A8-9D99-44D3-A06D-85764D9B587B" ["reference":"PagSeguroTransactionSummary":private]=> string(2) "36" ["grossAmount":"PagSeguroTransactionSummary":private]=> string(4) "5.00" ["type":"PagSeguroTransactionSummary":private]=> object(PagSeguroTransactionType)#24 (1) { ["value":"PagSeguroTransactionType":private]=> string(1) "1" } ["status":"PagSeguroTransactionSummary":private]=> object(PagSeguroTransactionStatus)#28 (1) { ["value":"PagSeguroTransactionStatus":private]=> string(1) "3" } ["netAmount":"PagSeguroTransactionSummary":private]=> string(4) "4.40" ["discountAmount":"PagSeguroTransactionSummary":private]=> string(4) "0.00" ["feeAmount":"PagSeguroTransactionSummary":private]=> string(4) "0.60" ["extraAmount":"PagSeguroTransactionSummary":private]=> string(4) "0.00" ["cancellationSource":"PagSeguroTransactionSummary":private]=> NULL ["paymentMethod":"PagSeguroTransactionSummary":private]=> object(PagSeguroPaymentMethod)#25 (2) { ["type":"PagSeguroPaymentMethod":private]=> object(PagSeguroPaymentMethodType) #23 (1) { ["value":"PagSeguroPaymentMethodType":private]=> string(1) "1" } ["code":"PagSeguroPaymentMethod":private]=> NULL } ["recoveryCode":"PagSeguroTransactionSummary":private]=> NULL } } } Compartilhar este post Link para o post Compartilhar em outros sites
Beraldo 864 Denunciar post Postado Novembro 17, 2015 Essa estrutura do var_dump te mostra exatamente o caminho até as propriedades do objeto. Veja a estrutura pelo código-fonte no navegador ou use a tag <pre>, para que fique formatado em árvore. echo "<pre>"; var_dump($objeto); Assim você acha o caminho até o "status" Compartilhar este post Link para o post Compartilhar em outros sites
mdpirangi 0 Denunciar post Postado Novembro 17, 2015 Essa estrutura do var_dump te mostra exatamente o caminho até as propriedades do objeto. Veja a estrutura pelo código-fonte no navegador ou use a tag <pre>, para que fique formatado em árvore. echo "<pre>"; var_dump($objeto); Assim você acha o caminho até o "status" Grato pela dica...essa é a duvida... esse resultado que postei foi com var_dump.....é pegar o valor dentro dele que estou apanhando.... Compartilhar este post Link para o post Compartilhar em outros sites
Gabriel Heming 766 Denunciar post Postado Novembro 17, 2015 A própria biblioteca do PagSeguro fornece todo o manual e exemplos de implementação: Eu tenho a biblioteca instalada via composer, o meu caminho fica o seguinte: vendor/pagseguro/php/source/examples/ O exmeplo abaixo é: vendor/pagseguro/php/source/examples/checkout/search/searchTransactionByCode.php <?php /* ************************************************************************ Copyright [2014] [PagSeguro Internet Ltda.] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ************************************************************************ */ require_once "../../../PagSeguroLibrary/PagSeguroLibrary.php"; class SearchTransactionByCode { public static function main() { $transaction_code = 'FC138A0E-C734-44A8-A9B7-6A79E1E33292'; try { /* * #### Credentials ##### * Replace the parameters below with your credentials * You can also get your credentials from a config file. See an example: * $credentials = PagSeguroConfig::getAccountCredentials(); */ // seller authentication $credentials = new PagSeguroAccountCredentials("vendedor@lojamodelo.com.br", "E231B2C9BCC8474DA2E260B6C8CF60D3"); $credentials = PagSeguroConfig::getAccountCredentials(); // application authentication //$credentials = PagSeguroConfig::getApplicationCredentials(); //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); $transaction = PagSeguroTransactionSearchService::searchByCode($credentials, $transaction_code); self::printTransaction($transaction); } catch (PagSeguroServiceException $e) { die($e->getMessage()); } } public static function printTransaction(PagSeguroTransaction $transaction) { echo "<h2>Transaction search by code result"; echo "<h3>Code: " . $transaction->getCode() . '</h3>'; echo "<h3>Status: " . $transaction->getStatus()->getTypeFromValue() . '</h3>'; echo "<h4>Reference: " . $transaction->getReference() . "</h4>"; echo "grossAmount: " . $transaction->getGrossAmount() . '<br>'; echo "discountAmount: " . $transaction->getDiscountAmount() . '<br>'; echo "installmentCount: " . $transaction->getInstallmentCount() . '<br>'; if ($transaction->getCreditorFees()) { echo "<h4>CreditorFees:</h4>"; echo "intermediationRateAmount: " . $transaction->getCreditorFees()->getIntermediationRateAmount() . '<br>'; echo "intermediationFeeAmount: " . $transaction->getCreditorFees()->getIntermediationFeeAmount() . '<br>'; } if ($transaction->getItems()) { echo "<h4>Items:</h4>"; if (is_array($transaction->getItems())) { foreach ($transaction->getItems() as $key => $item) { echo "Id: " . $item->getId() . '<br>'; // prints the item id, e.g. I39 echo "Description: " . $item->getDescription() . '<br>'; // prints the item description, e.g. Notebook prata echo "Quantidade: " . $item->getQuantity() . '<br>'; // prints the item quantity, e.g. 1 echo "Amount: " . $item->getAmount() . '<br>'; // prints the item unit value, e.g. 3050.68 echo "<hr>"; } } } if ($transaction->getSender()) { echo "<h4>Sender data:</h4>"; echo "Name: " . $transaction->getSender()->getName() . '<br>'; echo "Email: " . $transaction->getSender()->getEmail() . '<br>'; if ($transaction->getSender()->getPhone()) { echo "Phone: " . $transaction->getSender()->getPhone()->getAreaCode() . " - " . $transaction->getSender()->getPhone()->getNumber(); } } if ($transaction->getShipping()) { echo "<h4>Shipping information:</h4>"; if ($transaction->getShipping()->getAddress()) { echo "Postal code: " . $transaction->getShipping()->getAddress()->getPostalCode() . '<br>'; echo "Street: " . $transaction->getShipping()->getAddress()->getStreet() . '<br>'; echo "Number: " . $transaction->getShipping()->getAddress()->getNumber() . '<br>'; echo "Complement: " . $transaction->getShipping()->getAddress()->getComplement() . '<br>'; echo "District: " . $transaction->getShipping()->getAddress()->getDistrict() . '<br>'; echo "City: " . $transaction->getShipping()->getAddress()->getCity() . '<br>'; echo "State: " . $transaction->getShipping()->getAddress()->getState() . '<br>'; echo "Country: " . $transaction->getShipping()->getAddress()->getCountry() . '<br>'; } echo "Shipping type: " . $transaction->getShipping()->getType()->getTypeFromValue() . '<br>'; echo "Shipping cost: " . $transaction->getShipping()->getCost() . '<br>'; } } } SearchTransactionByCode::main(); Existe exemplos para cada função da biblioteca; Mais exemplos: https://github.com/pagseguro/php/tree/master/source/examples Classe base: PagSeguroSearchResult Classe retornada no seu exemplo PagSeguroTransactionSearchResult Compartilhar este post Link para o post Compartilhar em outros sites