diff --git a/app/code/community/UOL/PagSeguro/Helper/Data.php b/app/code/community/UOL/PagSeguro/Helper/Data.php index 9af137c..445d122 100644 --- a/app/code/community/UOL/PagSeguro/Helper/Data.php +++ b/app/code/community/UOL/PagSeguro/Helper/Data.php @@ -602,4 +602,213 @@ public function formatDocument($document) break; } } + + /** + * @param $type + * + * @return bool|string + */ + public function getTitleTypePaymentMethod($type) + { + if (!is_null($type)) { + switch ($type) { + case 1: + return $this->__('Cartão de crédito'); + break; + case 2: + return $this->__('Boleto'); + break; + case 3: + return $this->__('Débito online(TEF)'); + break; + case 4: + return $this->__('Saldo PagSeguro'); + break; + case 7: + return $this->__('Depósito em conta'); + break; + default: + return $type; + break; + } + } + + return false; + } + + /** + * @param $code + * + * @return bool|string + */ + public function getTitleCodePaymentMethod($code) + { + if (!is_null($code)) { + switch ($code) { + case 101: + return $this->__('Cartão de crédito Visa'); + break; + case 102: + return $this->__('Cartão de crédito MasterCard'); + break; + case 103: + return $this->__('Cartão de crédito American Express'); + break; + case 104: + return $this->__('Cartão de crédito Diners'); + break; + case 105: + return $this->__('Cartão de crédito Hipercard'); + break; + case 106: + return $this->__('Cartão de crédito Aura'); + break; + case 107: + return $this->__('Cartão de crédito Elo'); + break; + case 109: + return $this->__('Cartão de crédito PersonalCard'); + break; + case 112: + return $this->__('Cartão de crédito BrasilCard'); + break; + case 113: + return $this->__('Cartão de crédito FORTBRASIL'); + break; + case 115: + return $this->__('Cartão de crédito VALECARD'); + break; + case 116: + return $this->__('Cartão de crédito Cabal'); + break; + case 117: + return $this->__('Cartão de crédito Mais!'); + break; + case 119: + return $this->__('Cartão de crédito GRANDCARD'); + break; + case 120: + return $this->__('Cartão de crédito Sorocred'); + break; + case 122: + return $this->__('Cartão de crédito Up Policard'); + break; + case 123: + return $this->__('Cartão de crédito Banese Card'); + break; + case 201: + return $this->__('Boleto Bradesco'); + break; + case 202: + return $this->__('Boleto Santander'); + break; + case 301: + return $this->__('Débito online Bradesco'); + break; + case 302: + return $this->__('Débito online Itaú'); + break; + case 304: + return $this->__('Débito online Banco do Brasil'); + break; + case 306: + return $this->__('Débito online Banrisul'); + break; + case 401: + return $this->__('Saldo PagSeguro'); + break; + case 701: + return $this->__('Depósito em conta - Banco do Brasil'); + break; + default: + return $code; + break; + } + } + + return false; + } + + /** + * @param $type + * + * @return bool|string + */ + public function getTitleCancellationSourceTransaction($cancellationSource) + { + if (!is_null($cancellationSource)) { + switch ($cancellationSource) { + case "INTERNAL": + return $this->__('PagSeguro'); + break; + case "EXTERNAL": + return $this->__('Instituições Financeiras'); + break; + default: + return $cancellationSource; + break; + } + } + + return false; + } + + /** + * Translates the transation type code to his respective name, according with the api + * + * @param int $transactionTypeCode + * @return mixed string | int + */ + public function getTransactionTypeName($transactionTypeCode) + { + if ($transactionTypeCode) { + switch ($transactionTypeCode) { + case 1: + return $this->__('Venda'); + break; + case 2: + return $this->__('Transferência'); + break; + case 3: + return $this->__('Adição de fundos'); + break; + case 4: + return $this->__('Saque'); + break; + case 5: + return $this->__('Cobrança'); + break; + case 6: + return $this->__('Doação'); + break; + case 7: + return $this->__('Bônus'); + break; + case 8: + return $this->__('Repasse de bônus'); + break; + case 9: + return $this->__('Operacional'); + break; + case 10: + return $this->__('Doação pública'); + break; + case 11: + return $this->__('Pagamento pré aprovado'); + break; + case 12: + return $this->__('Campanha bônus'); + break; + case 13: + return $this->__('Secundária'); + break; + case 14: + return $this->__('Validador'); + break; + default: + return $transactionTypeCode; + break; + } + } + } } diff --git a/app/code/community/UOL/PagSeguro/Helper/Log.php b/app/code/community/UOL/PagSeguro/Helper/Log.php index 7f284bd..43d3c44 100644 --- a/app/code/community/UOL/PagSeguro/Helper/Log.php +++ b/app/code/community/UOL/PagSeguro/Helper/Log.php @@ -93,4 +93,42 @@ public function setUpdateOrderLog($class, $orderId, $transactionCode, $orderStat $phrase .= "'orderStatus' => '".$orderStatus."'\n ) )"; $this->setLog($phrase, $this->setModule($class)); } + + /** + * @param $class + * @param $parametros + */ + public function setSearchListTransactionLog($class, $params) + { + $phrase = "Search("; + + $filters = array(); + if(isset($params['idMagento'])){ + $filters[] = "idMagento = ".$params['idMagento']; + } + + if(isset($params['idPagSeguro'])){ + $filters[] = "idPagSeguro = '".$params['idPagSeguro']."'"; + } + + if(isset($params['environment'])){ + $filters[] = "environment = '".$params['environment']."'"; + } + + if(isset($params['startDate']) && isset($params['endDate'])){ + $filters[] = "range of dates = '".$params['startDate']." until ".$params['endDate']."'"; + } + + if(isset($params['status'])){ + $filters[] = "status = '".$params['status']."'"; + } + + if(count($filters) > 0){ + $phrase .= implode(' | ', $filters); + } + + $phrase .= ")"; + $this->setLog($phrase, $this->setModule($class)); + } + } diff --git a/app/code/community/UOL/PagSeguro/Helper/Transactions.php b/app/code/community/UOL/PagSeguro/Helper/Transactions.php new file mode 100644 index 0000000..cd3d5e0 --- /dev/null +++ b/app/code/community/UOL/PagSeguro/Helper/Transactions.php @@ -0,0 +1,288 @@ +getPagSeguroTransactions($paramsFilter); + } + + public function getPagSeguroOrdersArray() + { + return $this->arrayPagSeguroOrders; + } + + public function getTransactionsArray() + { + return $this->arrayTransaction; + } + + public function checkNeedConciliate() + { + return $this->needConciliate; + } + + public function getPagSeguroTransactions($paramsFilter) + { + $this->buildArrayPagSeguroOrders($this->getTransactionsDatabase($paramsFilter)); + } + + /** + * Get all PagSeguro transactions in DB with an transaction_id associated from + * pagseguro_orders table joined with orders table + * + * @param array $paramsFilter + * @return array + */ + private function getTransactionsDatabase($paramsFilter) + { + $resource = Mage::getSingleton('core/resource'); + $read = $resource->getConnection('core_read'); + $ordersTable = $resource->getTableName('sales/order'); + $pagseguroTable = Mage::getConfig()->getTablePrefix().'pagseguro_orders'; + + $select = $read->select() + ->from(array('order' => $ordersTable), array('status', 'created_at', 'increment_id', 'store_id')) + ->join(array('ps' => $pagseguroTable), 'order.entity_id = ps.order_id') + ->where('ps.transaction_code != ?', '') + ->order('created_at DESC') + ; + + if (!is_null(Mage::getSingleton('core/session')->getData("store_id"))) { + $select = $select->where('store_id = ?', Mage::getSingleton('core/session')->getData("store_id")); + } + + if (Mage::getStoreConfig('payment/pagseguro/environment')) { + $select = $select->where('environment = ?', Mage::getStoreConfig('payment/pagseguro/environment')); + } + + if (isset($paramsFilter['idMagento'])) { + $select = $select->where('order.increment_id = ?', $paramsFilter['idMagento']); + } + + if (isset($paramsFilter['idPagSeguro'])) { + $select = $select->where('ps.transaction_code = ?', $paramsFilter['idPagSeguro']); + } + + if (isset($paramsFilter['status'])) { + $select = $select->where('order.status = ?', $this->getPaymentStatusFromKey($paramsFilter['status'])); + } + + if (isset($paramsFilter['startDate']) && isset($paramsFilter['endDate'])) { + $startDate = date('Y-m-d H:i:s', strtotime(str_replace("/", "-", $paramsFilter['startDate']))); + $endDate = date('Y-m-d'.' 23:59:59', strtotime(str_replace("/", "-", $paramsFilter['endDate']))); + $select = $select->where('order.created_at >= ?', $startDate)->where('order.created_at <= ?', $endDate); + } + + $read->prepare($select); + return $read->fetchAll($select); + } + + public function getTransactionByCode($transactionCode) + { + $this->pagSeguroTransaction = $this->webserviceHelper()->getTransactionsByCode($transactionCode); + + if(!empty($this->pagSeguroTransaction)){ + $orderId = $this->getReferenceDecryptOrderID($this->pagSeguroTransaction->getReference()); + $order = Mage::getModel('sales/order')->load($orderId); + + if ($this->getStoreReference() == $this->getReferenceDecrypt($this->pagSeguroTransaction->getReference())) { + if ($order->getStatus() == $this->getPaymentStatusFromKey($this->pagSeguroTransaction->getStatus())) { + $this->arrayTransaction = $this->buildTransaction(); + }else{ + $this->needConciliate = true; + } + } + } + } + + public function buildTransaction() + { + return array( + 'date' => $this->getOrderMagetoDateConvert($this->pagSeguroTransaction->getDate()), + 'code' => $this->pagSeguroTransaction->getCode(), + 'reference' => $this->pagSeguroTransaction->getReference(), + 'type' => $this->getTransactionTypeName($this->pagSeguroTransaction->getType()), + 'status' => $this->getPaymentStatusToString($this->pagSeguroTransaction->getStatus()), + 'lastEventDate' => $this->getOrderMagetoDateConvert($this->pagSeguroTransaction->getLastEventDate()), + 'installmentCount' => $this->pagSeguroTransaction->getInstallmentCount(), + 'cancelationSource' => $this->getTitleCancellationSourceTransaction($this->pagSeguroTransaction->getCancelationSource()), + 'discountAmount' => $this->pagSeguroTransaction->getDiscountAmount(), + 'escrowEndDate' => $this->getOrderMagetoDateConvert($this->pagSeguroTransaction->getEscrowEndDate()), + 'extraAmount' => $this->pagSeguroTransaction->getExtraAmount(), + 'feeAmount' => $this->pagSeguroTransaction->getFeeAmount(), + 'grossAmount' => $this->pagSeguroTransaction->getGrossAmount(), + 'netAmount' => $this->pagSeguroTransaction->getNetAmount(), + 'creditorFees' => $this->prepareCreditorFees(), + 'itemCount' => $this->pagSeguroTransaction->getItemCount(), + 'items' => $this->prepareItems(), + 'paymentMethod' => $this->preparePaymentMethod(), + 'sender' => $this->prepareSender(), + 'shipping' => $this->prepareShipping(), + 'paymentLink' => $this->pagSeguroTransaction->getPaymentLink(), + 'promoCode' => $this->pagSeguroTransaction->getPromoCode() + ); + } + + private function prepareCreditorFees() + { + $creditorFees = ""; + if(!empty($this->pagSeguroTransaction->getCreditorFees())) + { + $creditorFees = array( + 'intermediationRateAmount' => $this->pagSeguroTransaction->getCreditorFees()->getIntermediationRateAmount(), + 'intermediationFeeAmount' => $this->pagSeguroTransaction->getCreditorFees()->getIntermediationFeeAmount(), + 'installmentFeeAmount' => $this->pagSeguroTransaction->getCreditorFees()->getInstallmentFeeAmount(), + 'operationalFeeAmount' => $this->pagSeguroTransaction->getCreditorFees()->getOperationalFeeAmount(), + 'commissionFeeAmount' => $this->pagSeguroTransaction->getCreditorFees()->getCommissionFeeAmount() + ); + } + return $creditorFees; + } + + private function prepareItems() + { + $itens = array(); + + if($this->pagSeguroTransaction->getItemCount() > 0) { + foreach ($this->pagSeguroTransaction->getItems() as $item) + { + $itens[] = array( + 'id' => $item->getId(), + 'description' => $item->getDescription(), + 'quantity' => $item->getQuantity(), + 'amount' => $item->getAmount(), + 'weight' => $item->getWeight(), + 'shippingCost' => $item->getShippingCost() + ); + } + } + return $itens; + } + + private function preparePaymentMethod() + { + $paymentMethod = ""; + if(!empty($this->pagSeguroTransaction->getPaymentMethod())) + { + $paymentMethod = array( + 'code' => $this->pagSeguroTransaction->getPaymentMethod()->getCode(), + 'type' => $this->pagSeguroTransaction->getPaymentMethod()->getType(), + 'titleType' => $this->getTitleTypePaymentMethod($this->pagSeguroTransaction->getPaymentMethod()->getType()), + 'titleCode' => $this->getTitleCodePaymentMethod($this->pagSeguroTransaction->getPaymentMethod()->getCode()) + ); + } + return $paymentMethod; + } + + private function prepareSender() + { + $documents = array(); + if(count($this->pagSeguroTransaction->getSender()->getDocuments()) > 0) { + foreach ($this->pagSeguroTransaction->getSender()->getDocuments() as $doc) + { + $documents[] = array( + 'type' => $doc->getType(), + 'identifier' => $doc->getIdentifier() + ); + } + } + + $sender = array(); + if(!empty($this->pagSeguroTransaction->getSender())){ + $sender = array( + 'name' => $this->pagSeguroTransaction->getSender()->getName(), + 'email' => $this->pagSeguroTransaction->getSender()->getEmail(), + 'phone' => array( + 'areaCode' => $this->pagSeguroTransaction->getSender()->getPhone()->getAreaCode(), + 'number' => $this->pagSeguroTransaction->getSender()->getPhone()->getNumber() + ), + 'documents' => $documents + ); + } + return $sender; + } + + private function prepareShipping() + { + $shipping = array(); + if(!empty($this->pagSeguroTransaction->getShipping())){ + $shipping = array( + 'addres' => array( + 'street' => $this->pagSeguroTransaction->getShipping()->getAddress()->getStreet(), + 'number' => $this->pagSeguroTransaction->getShipping()->getAddress()->getNumber(), + 'complement' => $this->pagSeguroTransaction->getShipping()->getAddress()->getComplement(), + 'district' => $this->pagSeguroTransaction->getShipping()->getAddress()->getDistrict(), + 'postalCode' => $this->pagSeguroTransaction->getShipping()->getAddress()->getPostalCode(), + 'city' => $this->pagSeguroTransaction->getShipping()->getAddress()->getCity(), + 'state' => $this->pagSeguroTransaction->getShipping()->getAddress()->getState(), + 'country' => $this->pagSeguroTransaction->getShipping()->getAddress()->getCountry() + ), + 'type' => $this->pagSeguroTransaction->getShipping()->getType()->getType(), + 'cost' => $this->pagSeguroTransaction->getShipping()->getCost()->getCost() + ); + } + return $shipping; + } + + private function getOrderEnvironment($orderPagSeguro) + { + if ($orderPagSeguro['environment'] == 'Produção') { + return "production"; + } else { + return $orderPagSeguro['environment']; + } + } + + /** + * Build an array and set it in the attribute arrayPagSeguroOrders. This array is used to show + * the PagSeguro transactions table + * + * @param array $pagSeguroOrders + * @return void + */ + private function buildArrayPagSeguroOrders($pagSeguroOrders) + { + $action = "%s
%s"; + foreach ($pagSeguroOrders as $pagSeguroOrder) { + $this->arrayPagSeguroOrders[] = array( + 'date' => $this->getOrderMagetoDateConvert($pagSeguroOrder['created_at']), + 'id_magento' => $pagSeguroOrder['increment_id'], + 'id_pagseguro' => $pagSeguroOrder['transaction_code'], + 'environment' => $pagSeguroOrder['environment'], + 'status_magento' => $this->getPaymentStatusToString($this->getPaymentStatusFromValue($pagSeguroOrder['status'])), + 'action' => sprintf( + $action, + $this->getEditOrderUrl($pagSeguroOrder['order_id']), + $this->__('Ver detalhes pedido'), + $pagSeguroOrder['transaction_code'], + $this->__('Ver detalhes transação') + ) + ); + } + } +} \ No newline at end of file diff --git a/app/code/community/UOL/PagSeguro/Helper/Webservice.php b/app/code/community/UOL/PagSeguro/Helper/Webservice.php index d6761eb..5ce789e 100644 --- a/app/code/community/UOL/PagSeguro/Helper/Webservice.php +++ b/app/code/community/UOL/PagSeguro/Helper/Webservice.php @@ -159,4 +159,26 @@ public function requestPagSeguroService($class, $transactionCode) throw new Exception($e->getMessage()); } } + + /** + * @param $code + * + * @return null|string + * @throws Exception + */ + public function getTransactionsByCode($code) + { + $response = null; + try { + $response = \PagSeguro\Services\Transactions\Search\Code::search( + $this->library->getAccountCredentials(), + $code + ); + } catch (Exception $e) { + throw new Exception($e->getMessage()); + } + + return $response; + } + } diff --git a/app/code/community/UOL/PagSeguro/Model/PaymentMethod.php b/app/code/community/UOL/PagSeguro/Model/PaymentMethod.php index 7e440b9..ec4eb25 100644 --- a/app/code/community/UOL/PagSeguro/Model/PaymentMethod.php +++ b/app/code/community/UOL/PagSeguro/Model/PaymentMethod.php @@ -145,7 +145,7 @@ private function setItems($payment) $this->setShippingIsRequired($payment, $product->getData()['product_type']); $payment->addItems()->withParameters( - $product->getId(), + $product->getProduct()->getId(), substr($product->getName(), 0, 254), (float)$product->getQtyOrdered(), number_format((float)$product->getPrice(), 2, '.', ''), diff --git a/app/code/community/UOL/PagSeguro/controllers/Adminhtml/TransactionsController.php b/app/code/community/UOL/PagSeguro/controllers/Adminhtml/TransactionsController.php new file mode 100644 index 0000000..8b2d954 --- /dev/null +++ b/app/code/community/UOL/PagSeguro/controllers/Adminhtml/TransactionsController.php @@ -0,0 +1,152 @@ +log = new UOL_PagSeguro_Helper_Log(); + } + + public function indexAction() + { + Mage::getSingleton('core/session')->setData( + 'store_id', + Mage::app()->getRequest()->getParam('store') + ); + + $this->loadLayout(); + $this->_setActiveMenu('pagseguro_menu')->renderLayout(); + } + + /** + * Call a helper to request all transactions of a PagSeguro. + */ + public function doPostAction() + { + $this->builder(); + $this->log->setSearchListTransactionLog(get_class($this->transaction), $this->paramsFilter); + try{ + $this->transaction->initialize($this->paramsFilter); + + if (!$this->transaction->getPagSeguroOrdersArray()) { + print json_encode(array("status" => false)); + exit(); + } + + print $this->transaction->getTransactionGrid($this->transaction->getPagSeguroOrdersArray()); + + }catch (Exception $e) { + print json_encode(array( + "status" => false, + "err" => trim($e->getMessage()) + ) + ); + } + } + + public function builder() + { + $this->transaction = Mage::helper('pagseguro/transactions'); + $this->log = Mage::helper('pagseguro/log'); + + $this->paramsFilter = array(); + + if($this->getRequest()->getPost('date_begin')) + { + $this->paramsFilter['startDate'] = $this->getRequest()->getPost('date_begin'); + } + + if($this->getRequest()->getPost('date_end')) + { + $this->paramsFilter['endDate'] = $this->getRequest()->getPost('date_end'); + } + + if($this->getRequest()->getPost('id_magento')) + { + $this->paramsFilter['idMagento'] = $this->getRequest()->getPost('id_magento'); + } + + if($this->getRequest()->getPost('id_pagseguro')) + { + $this->paramsFilter['idPagSeguro'] = $this->getRequest()->getPost('id_pagseguro'); + } + + if($this->getRequest()->getPost('status')) + { + $this->paramsFilter['status'] = $this->getRequest()->getPost('status'); + } + } + + /** + * Call a helper to request a transaction of a PagSeguro by transaction code + */ + public function getTransactionAction() + { + $this->builder(); + + if ($this->getRequest()->getParam('transaction_code')) { + $transactionCode = str_replace('-', '', $this->getRequest()->getParam('transaction_code')); + + try { + $this->transaction->getTransactionByCode($transactionCode); + + if(!$this->transaction->getTransactionsArray() && $this->transaction->checkNeedConciliate()) { + print json_encode(array("status" => false, "err" => "conciliate")); + exit(); + } + + if (!$this->transaction->getTransactionsArray()) { + print json_encode(array("status" => false)); + exit(); + } + + print json_encode($this->transaction->getTransactionsArray()); + } catch (Exception $e) { + print json_encode(array( + "status" => false, + "err" => trim($e->getMessage()), + ) + ); + exit(); + } + }else{ + print json_encode(array("status" => false)); + exit(); + } + } +} \ No newline at end of file diff --git a/app/code/community/UOL/PagSeguro/etc/config.xml b/app/code/community/UOL/PagSeguro/etc/config.xml index 6665ee1..75dc26f 100644 --- a/app/code/community/UOL/PagSeguro/etc/config.xml +++ b/app/code/community/UOL/PagSeguro/etc/config.xml @@ -138,6 +138,11 @@ limitations under the License. pagseguro/adminhtml_refund 2140 + + Listar transações + pagseguro/adminhtml_transactions + 2150 + diff --git a/app/design/adminhtml/default/default/layout/uol/pagseguro.xml b/app/design/adminhtml/default/default/layout/uol/pagseguro.xml index c63406a..d047585 100644 --- a/app/design/adminhtml/default/default/layout/uol/pagseguro.xml +++ b/app/design/adminhtml/default/default/layout/uol/pagseguro.xml @@ -181,6 +181,20 @@ limitations under the License. + + + uol/pagseguro/css/pagseguro-module.css + uol/pagseguro/css/pagseguro-modal.css + skin_jsuol/pagseguro/js/jquery-1.11.1.js + skin_jsuol/pagseguro/js/pagseguro-module.js + skin_jsuol/pagseguro/js/jquery.colorbox-min.js + skin_jsuol/pagseguro/js/jquery.dataTables.js + + + + + + uol/pagseguro/css/pagseguro-module.css @@ -194,4 +208,4 @@ limitations under the License. - + \ No newline at end of file diff --git a/app/design/adminhtml/default/default/template/uol/pagseguro/transactions.phtml b/app/design/adminhtml/default/default/template/uol/pagseguro/transactions.phtml new file mode 100644 index 0000000..29f75fa --- /dev/null +++ b/app/design/adminhtml/default/default/template/uol/pagseguro/transactions.phtml @@ -0,0 +1,529 @@ + +getUrl('pagseguro/adminhtml_conciliation'); +?> + +
+ getHeader(); ?> +
+
+ getSideMenu(); ?> +
+

__('Lista de Transações'); ?>

+

+ conciliação de suas transações para obter os status mais atuais."; + echo $helper->__($string); + ?> +

+ + + + + + + + + + + + + + + + + + + + +
__('Data'); ?>__('ID Magento'); ?>__('ID PagSeguro'); ?>__('Ambiente'); ?>__('Status PagSeguro'); ?>__('Ação'); ?>
+ + + + +
+ + __("Transação cancelada com sucesso!"); + $canceledError = $helper->__("Não foi possível executar esta ação.
Utilize a conciliação de transações primeiro ou tente novamente mais tarde."); + ?> + +
+

__('Somente transações geradas a partir da versão 2.3 do módulo serão listadas.'); ?>

+
+ + +
+
+ + + \ No newline at end of file diff --git a/lib/PagseguroPhpSdk/source/Domains/CreditorFees.php b/lib/PagseguroPhpSdk/source/Domains/CreditorFees.php index 26cdcda..d34f516 100644 --- a/lib/PagseguroPhpSdk/source/Domains/CreditorFees.php +++ b/lib/PagseguroPhpSdk/source/Domains/CreditorFees.php @@ -38,6 +38,18 @@ class CreditorFees * @var */ private $intermediationFeeAmount; + /** + * @var + */ + private $installmentFeeAmount; + /** + * @var + */ + private $operationalFeeAmount; + /** + * @var + */ + private $commissionFeeAmount; /** * @return mixed @@ -74,4 +86,57 @@ public function setIntermediationRateAmount($intermediationRateAmount) $this->intermediationRateAmount = $intermediationRateAmount; return $this; } + + /** + * @return mixed + */ + public function getInstallmentFeeAmount() + { + return $this->installmentFeeAmount; + } + + /** + * @param mixed $installmentFeeAmount + * @return CreditorFees + */ + public function setInstallmentFeeAmount($installmentFeeAmount) + { + $this->installmentFeeAmount = $installmentFeeAmount; + return $this; + } + + /** + * @return mixed + */ + public function getOperationalFeeAmount() + { + return $this->operationalFeeAmount; + } + + /** + * @param mixed $operationalFeeAmount + * @return CreditorFees + */ + public function setOperationalFeeAmount($operationalFeeAmount) + { + $this->operationalFeeAmount = $operationalFeeAmount; + return $this; + } + + /** + * @return mixed + */ + public function getCommissionFeeAmount() + { + return $this->commissionFeeAmount; + } + /** + * @param mixed $commissionFeeAmount + * @return CreditorFees + */ + public function setCommissionFeeAmount($commissionFeeAmount) + { + $this->commissionFeeAmount = $commissionFeeAmount; + return $this; + } } diff --git a/lib/PagseguroPhpSdk/source/Parsers/Response/CreditorFees.php b/lib/PagseguroPhpSdk/source/Parsers/Response/CreditorFees.php index a3bfe39..0651bd1 100644 --- a/lib/PagseguroPhpSdk/source/Parsers/Response/CreditorFees.php +++ b/lib/PagseguroPhpSdk/source/Parsers/Response/CreditorFees.php @@ -61,6 +61,18 @@ public function setCreditorFees($creditorFees) $creditor->setIntermediationFeeAmount(current($creditorFees->intermediationFeeAmount)); } + if (!is_null($creditorFees->installmentFeeAmount)) { + $creditor->setInstallmentFeeAmount(current($creditorFees->installmentFeeAmount)); + } + + if (!is_null($creditorFees->operationalFeeAmount)) { + $creditor->setOperationalFeeAmount(current($creditorFees->operationalFeeAmount)); + } + + if (!is_null($creditorFees->commissionFeeAmount)) { + $creditor->setCommissionFeeAmount(current($creditorFees->commissionFeeAmount)); + } + $this->creditorFees = $creditor; return $this; } diff --git a/lib/PagseguroPhpSdk/source/Parsers/Transaction/Response.php b/lib/PagseguroPhpSdk/source/Parsers/Transaction/Response.php index d98fd67..ae3e977 100644 --- a/lib/PagseguroPhpSdk/source/Parsers/Transaction/Response.php +++ b/lib/PagseguroPhpSdk/source/Parsers/Transaction/Response.php @@ -79,6 +79,11 @@ class Response */ private $cancelationSource; + /** + * @var + */ + private $promoCode; + public function getCancelationSource() { return $this->cancelationSource; @@ -216,4 +221,22 @@ public function setType($type) $this->type = $type; return $this; } + + /** + * @return mixed + */ + public function getPromoCode() + { + return $this->promoCode; + } + + /** + * @param mixed $installmentCount + * @return Response + */ + public function setPromoCode($promoCode) + { + $this->promoCode = $promoCode; + return $this; + } } diff --git a/lib/PagseguroPhpSdk/source/Parsers/Transaction/Search/Code/Request.php b/lib/PagseguroPhpSdk/source/Parsers/Transaction/Search/Code/Request.php index 4cfd8ed..469b49f 100644 --- a/lib/PagseguroPhpSdk/source/Parsers/Transaction/Search/Code/Request.php +++ b/lib/PagseguroPhpSdk/source/Parsers/Transaction/Search/Code/Request.php @@ -78,7 +78,8 @@ public static function success(Http $http) ->setItemCount(current($xml->itemCount)) ->setItems($xml->items) ->setSender($xml->sender) - ->setShipping($xml->shipping); + ->setShipping($xml->shipping) + ->setPromoCode(current($xml->promoCode)); return $response; } diff --git a/skin/adminhtml/default/default/uol/pagseguro/css/pagseguro-module.css b/skin/adminhtml/default/default/uol/pagseguro/css/pagseguro-module.css index 5d708ee..61e4339 100644 --- a/skin/adminhtml/default/default/uol/pagseguro/css/pagseguro-module.css +++ b/skin/adminhtml/default/default/uol/pagseguro/css/pagseguro-module.css @@ -70,6 +70,8 @@ limitations under the License. #pagseguro-module label { color:inherit; margin:0; padding: 0.2em 0.5em 0 0; width: auto; font-weight: bold; float:none; line-height: 1em; font-size:1em; } #pagseguro-module .config-area label { text-align: left; text-transform: uppercase; clear: both; display: block; } #pagseguro-module .pagseguro-field { font-size: 1.2em; padding: 8px 4px; width: auto; border-radius: 3px; box-shadow: 0 2px 2px #DDDDDD inset; color: #4F4F4F; border: none; margin: 0; border: 1px solid #BCC6D0; background-color: #FFF; } +#pagseguro-module .pagseguro-field-error { border-color: #dc3545 !important; } +#pagseguro-module .pagseguro-field-error:focus {border-color: #843534; -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px #ce8483; box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px #ce8483; background-color: #FFF !important; } #pagseguro-module select.pagseguro-field { padding-right: 1em; } #pagseguro-module .pagseguro-field:focus { background-color: #F2F4F8; outline: none; border-color: #7E9DB9; } #pagseguro-module .pagseguro-field:disabled { background-color: #DDD; } @@ -81,6 +83,8 @@ limitations under the License. #pagseguro-module .config-area select.pagseguro-field option { padding: 0.3em; } #pagseguro-module .pagseguro-select-hint { float: left; margin: 0 1em 0 0; max-width: 20%; } #pagseguro-module .pagseguro-option-hint { margin: 2.5em 0 4em 0; max-width: 100%; } +#pagseguro-module .money { font-size: 16px; font-weight: 700; color: #333; display: inline-block; vertical-align: middle; +} /* Tables */ .pagseguro-table { border: 1px solid #e5e5e5; border-bottom-width: 3px; border-collapse: collapse; color: #444; width: 100%; } @@ -100,6 +104,9 @@ limitations under the License. .pagseguro-table tbody tr.unread td { color: #000; font-weight: bold; } .pagseguro-table tbody td .link { display:block; padding: 0.5em 0.5em 0 0.5em; } .pagseguro-table tbody td i { margin: 0 0.4em; font-size: 0.9em; } +.pagseguro-table thead .input-search { vertical-align: middle; } +.pagseguro-table thead tr th .input-date { margin-top: 5px !important; } +#transaction-table thead tr:nth-child(2) th:nth-child(3) input { width: 255px; } /* DataTable Sorting */ .dataTable .sorting { background-image: url("../images/dataTable/sort_both.png"); cursor:pointer; } @@ -140,6 +147,38 @@ limitations under the License. .pagseguro-button.theme-gray:hover, .pagseguro-button.gray-theme:hover { background-color: #F9F9F9; } .pagseguro-button[disabled] { background-color: #CCC !important; color: #FFF !important; } +.pagseguro-button.align-right { float: right; } + +/*List Details*/ +.list-datails .group { border-bottom: solid 1px #DEDEDE; margin: 0 40px; padding: 10px 0; overflow: hidden; } +.list-datails .group > div:not(:last-child) { display: flex; justify-content: flex-start; margin-bottom: 8px;} +.list-datails .group h4 { margin-bottom: 0; } +.list-datails > div:nth-child(3) { margin-top: 25px; } +.list-datails .group > div > dl:not(:last-child) { margin-right: 40px; } +.list-datails .group div dl:first-child { width: 112px; } +.list-datails .group dl dd{ font-weight: 700; } +.list-datails .table { background-color: #e9e9e9; padding: 10px 25px; margin-top: 5px; max-height: 92px; overflow: auto; } +.list-datails .group-title { font-weight: 700; display: flex; flex-direction: row; justify-content: flex-start; margin-top: 7px; } +.list-datails .group-title > div:not(:first-child), .itens-line > div:not(:first-child) { margin-right: 50px; } +.list-datails .itens-cell { width: 70px; } +.list-datails .description-cell { width: 200px; margin-right: 0 !important; } +.list-datails .itens-line { display:flex; flex-flow: row wrap; justify-content: flex-start; } +.list-datails .group .table .rate { display: flex; justify-content: flex-start; } +.list-datails .group .table .rate dl { width: 140px; margin-top: 7px; margin-right: 45px; } + +/*Modal Details*/ +.modal { display: none; position: fixed; z-index: 101; padding-top: 100px; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgb(0,0,0); background-color: rgba(0,0,0,0.4); } +.modal .modal-content { background-color: #fefefe; margin: auto; padding: 20px; border: 1px solid #888; width: 60%; border-radius: 10px; max-height: 500px; } +.modal .modal-content-refund { background-color: #fefefe; margin: auto; padding: 20px; padding-bottom: 50px; border: 1px solid #888; width: 20%; border-radius: 10px; } +.modal .modal-content-refund form div input{ width: 90px !important; } +.modal .modal-content-refund form div label{ font-size: 16px !important; font-weight: 700 !important; color: #333 !important; display: inline-block; vertical-align: middle; } +.modal .close { color: #aaaaaa; float: right; font-size: 28px; font-weight: bold; } +.modal .close:hover, .close:focus { color: #000; text-decoration: none; cursor: pointer; } +#modal-close { padding: 12px; cursor: pointer; border: 0; border-radius: 50%; z-index: 10; background: center no-repeat #FFF url(data:image/gif;base64,R0lGODlhCgAKALMAANXV1dTU1O/v7/Dw8Ovr6+zs7Lu7u8DAwPX19QAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAAKAAoAAAQqEKEhJZXgFFkOQMJhaN0oIIR4qESVGmNblePGqeo2sO9BBQdZKlC5WCQRADs=); box-shadow: -1px 1px 13px rgba(0, 0, 0, 0.4); float: right; margin-top: -30px; margin-right: -30px; } +.group-side { float: left; width: 48%; padding: 0 2% 0 0; } +.group-full { float: none; width: auto; clear: both; } +.hidden-groups { display: none; } +.hidden-itens { text-align: right; width: auto; float: right; margin-right: 90px; margin-inline-start: auto; margin-top: -18px; } /* Messages */ .pagseguro-msg h3 > a { color:#035EC7!important } @@ -215,6 +254,7 @@ i.icon-pagseguro-msg.large, #pagseguro-module-contents #refund-info { margin-top: 40px; } #pagseguro-module-contents #canceled-info { margin-top: 40px; } #pagseguro-module-contents #abandoned-info { margin-top: 40px; } +#pagseguro-module-contents #list-info { margin-top: 40px; } #pagseguro-loading-message { width: 65px; } #pagseguro-module-menu ul ul li { display: none; } #pagseguro-module-menu ul li.open ul li, diff --git a/skin/adminhtml/default/default/uol/pagseguro/js/pagseguro-module.js b/skin/adminhtml/default/default/uol/pagseguro/js/pagseguro-module.js index 8ff1dae..7467afa 100644 --- a/skin/adminhtml/default/default/uol/pagseguro/js/pagseguro-module.js +++ b/skin/adminhtml/default/default/uol/pagseguro/js/pagseguro-module.js @@ -448,3 +448,110 @@ jQuery(document).ready(function () { } }) }) + +/* ************************************* */ +/* *************** DATE **************** */ +/* ************************************* */ + +function dateMask (date, fieldName) { + var mydate = ''; + var field = document.getElementById(fieldName); + mydate = mydate + date; + if (mydate.length == 2 && event.keyCode != 8){ + mydate = mydate + '/'; + field.value = mydate; + } + if (mydate.length == 5 && event.keyCode != 8){ + mydate = mydate + '/'; + field.value = mydate; + } + if (mydate.length == 10){ + dateVerify(field); + } + + if (field.value == "") { + field.classList.remove('pagseguro-field-error'); + } +} + +function dateVerifyOnLosesFocus(fieldName){ + var mydate = ''; + mydate = mydate + fieldName.value; + + if(mydate.length > 0 && mydate.length < 10){ + fieldName.classList.add('pagseguro-field-error'); + }else{ + dateVerify(fieldName); + } +} + +function dateVerify (field) { + + day = (field.value.substring(0,2)); + month = (field.value.substring(3,5)); + year = (field.value.substring(6,10)); + + situacao = ""; + + if ( isNaN(day) || ((day < 01)||(day < 01 || day > 30) && ( month == 04 || month == 06 || month == 09 || month == 11 ) || day > 31)) { + situacao = "false"; + } + + if ( isNaN(month) || month < 01 || month > 12 ) { + situacao = "false"; + } + + if ( isNaN(year) || month == 2 && ( day < 01 || day > 29 || ( day > 28 && (parseInt(year / 4) != year / 4)))) { + situacao = "false"; + } + + if (situacao == "false") { + field.classList.add('pagseguro-field-error'); + }else{ + field.classList.remove('pagseguro-field-error'); + } + return; +} + +function validateSearchByDate() { + var fieldDateFromValue = document.getElementById('date_begin').value; + var fieldDateToValue = document.getElementById('date_end').value; + + if ((fieldDateFromValue.length > 0 && fieldDateToValue.length == 0) || (fieldDateFromValue.length == 0 && fieldDateToValue.length > 0)) { + Modal.message('alert', 'Data de início e fim devem ser informadas!'); + return false; + } + + dayFrom = (fieldDateFromValue.substring(0,2)); + monthFrom = (fieldDateFromValue.substring(3,5)); + yearFrom = (fieldDateFromValue.substring(6,10)); + + dayTo = (fieldDateToValue.substring(0,2)); + monthTo = (fieldDateToValue.substring(3,5)); + yearTo = (fieldDateToValue.substring(6,10)); + + var dateFrom = new Date(yearFrom, monthFrom, dayFrom); + var dateTo = new Date(yearTo, monthTo, dayTo); + + if (dateFrom > dateTo) { + Modal.message('alert', 'Data de início maior que a data de fim!'); + return false; + } + + return true; +} + +/* ************************************* */ +/* *************** MONEY *************** */ +/* ************************************* */ + +function formatReal( int ) +{ + var tmp = int+''; + tmp = tmp.replace(".", ""); + tmp = tmp.replace(/([0-9]{2})$/g, ",$1"); + if( tmp.length > 6 ) + tmp = tmp.replace(/([0-9]{3}),([0-9]{2}$)/g, ".$1,$2"); + + return tmp; +} \ No newline at end of file