Ejemplo n.º 1
0
 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>';
     }
 }