IPG_PagSeguro_Transparente - Version 1.1.3

Version Notes

- Pequenas correções;

Download this release

Release Info

Developer iPAGARE
Extension IPG_PagSeguro_Transparente
Version 1.1.3
Comparing to
See all releases


Version 1.1.3

Files changed (504) hide show
  1. app/code/local/Ipagare/IpgBase/Block/Adminhtml/Sales/Order/Invoice/Totals.php +44 -0
  2. app/code/local/Ipagare/IpgBase/Block/Adminhtml/Sales/Order/Totals.php +44 -0
  3. app/code/local/Ipagare/IpgBase/Block/Adminhtml/System/Config/Fieldset/Licenca.php +34 -0
  4. app/code/local/Ipagare/IpgBase/Block/Adminhtml/System/Config/Form/Field/Date.php +26 -0
  5. app/code/local/Ipagare/IpgBase/Block/Adminhtml/System/Config/Form/Field/NeedHelp.php +28 -0
  6. app/code/local/Ipagare/IpgBase/Block/Checkout/Onepage/Success.php +47 -0
  7. app/code/local/Ipagare/IpgBase/Block/Sales/Order/Invoice/Totals.php +44 -0
  8. app/code/local/Ipagare/IpgBase/Block/Sales/Order/Totals.php +44 -0
  9. app/code/local/Ipagare/IpgBase/Config.php +37 -0
  10. app/code/local/Ipagare/IpgBase/ConfiguracoesSystem.php +38 -0
  11. app/code/local/Ipagare/IpgBase/Date.php +103 -0
  12. app/code/local/Ipagare/IpgBase/Helper/Boleto.php +109 -0
  13. app/code/local/Ipagare/IpgBase/Helper/Data.php +89 -0
  14. app/code/local/Ipagare/IpgBase/Helper/Date.php +154 -0
  15. app/code/local/Ipagare/IpgBase/Helper/LogUtils.php +49 -0
  16. app/code/local/Ipagare/IpgBase/Helper/Math.php +63 -0
  17. app/code/local/Ipagare/IpgBase/Helper/Module.php +394 -0
  18. app/code/local/Ipagare/IpgBase/Helper/OneStepCheckout.php +51 -0
  19. app/code/local/Ipagare/IpgBase/Helper/Session.php +49 -0
  20. app/code/local/Ipagare/IpgBase/Helper/StringUtils.php +41 -0
  21. app/code/local/Ipagare/IpgBase/Helper/TokenProcessor.php +104 -0
  22. app/code/local/Ipagare/IpgBase/Helper/Url.php +85 -0
  23. app/code/local/Ipagare/IpgBase/Logger.php +73 -0
  24. app/code/local/Ipagare/IpgBase/Model/EmailService.php +41 -0
  25. app/code/local/Ipagare/IpgBase/Model/ExpiraPedido.php +191 -0
  26. app/code/local/Ipagare/IpgBase/Model/HttpResponse.php +65 -0
  27. app/code/local/Ipagare/IpgBase/Model/Observer.php +166 -0
  28. app/code/local/Ipagare/IpgBase/Model/Session.php +21 -0
  29. app/code/local/Ipagare/IpgBase/Model/System/Config/Source/Dias.php +26 -0
  30. app/code/local/Ipagare/IpgBase/Model/System/Config/Source/Horas.php +26 -0
  31. app/code/local/Ipagare/IpgBase/Model/System/Config/Source/Minutos.php +26 -0
  32. app/code/local/Ipagare/IpgBase/PaymentDiscount.php +90 -0
  33. app/code/local/Ipagare/IpgBase/controllers/Adminhtml/ConfigController.php +41 -0
  34. app/code/local/Ipagare/IpgBase/controllers/BoletoController.php +48 -0
  35. app/code/local/Ipagare/IpgBase/controllers/CronController.php +44 -0
  36. app/code/local/Ipagare/IpgBase/etc/adminhtml.xml +28 -0
  37. app/code/local/Ipagare/IpgBase/etc/config.xml +188 -0
  38. app/code/local/Ipagare/IpgBase/etc/system.xml +285 -0
  39. app/code/local/Ipagare/IpgBase/sql/ipgbase_setup/mysql4-install-1.0.0.php +29 -0
  40. app/code/local/Ipagare/IpgBase/sql/ipgbase_setup/mysql4-upgrade-1.6.0-1.6.2.php +29 -0
  41. app/code/local/Ipagare/IpgBase/sql/ipgbase_setup/mysql4-upgrade-1.6.1-1.6.2.php +29 -0
  42. app/code/local/Ipagare/IpgBase/sql/ipgbase_setup/oldinstall.php +119 -0
  43. app/code/local/Ipagare/IpgPagSeguroDireto/Block/Checkout/Onepage/Success.php +37 -0
  44. app/code/local/Ipagare/IpgPagSeguroDireto/Block/Payment/Info.php +197 -0
  45. app/code/local/Ipagare/IpgPagSeguroDireto/Block/Payment/Transferencia.php +34 -0
  46. app/code/local/Ipagare/IpgPagSeguroDireto/Block/Standard/Form.php +95 -0
  47. app/code/local/Ipagare/IpgPagSeguroDireto/Config.php +98 -0
  48. app/code/local/Ipagare/IpgPagSeguroDireto/ConfiguracoesSystem.php +45 -0
  49. app/code/local/Ipagare/IpgPagSeguroDireto/ErrorMessages.php +164 -0
  50. app/code/local/Ipagare/IpgPagSeguroDireto/Helper/Data.php +133 -0
  51. app/code/local/Ipagare/IpgPagSeguroDireto/Helper/Math.php +101 -0
  52. app/code/local/Ipagare/IpgPagSeguroDireto/Helper/Module.php +17 -0
  53. app/code/local/Ipagare/IpgPagSeguroDireto/Helper/Session.php +40 -0
  54. app/code/local/Ipagare/IpgPagSeguroDireto/Helper/Validator.php +41 -0
  55. app/code/local/Ipagare/IpgPagSeguroDireto/Instituicao.php +43 -0
  56. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Credential.php +55 -0
  57. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Discount.php +91 -0
  58. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Entity/Erro.php +34 -0
  59. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Entity/Payment.php +26 -0
  60. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Entity/Sonda.php +26 -0
  61. app/code/local/Ipagare/IpgPagSeguroDireto/Model/ExpiraPedido.php +39 -0
  62. app/code/local/Ipagare/IpgPagSeguroDireto/Model/IpgPagSeguroDireto.php +215 -0
  63. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Mysql4/Entity/Erro.php +21 -0
  64. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Mysql4/Entity/Erro/Collection.php +21 -0
  65. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Mysql4/Entity/Payment.php +21 -0
  66. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Mysql4/Entity/Payment/Collection.php +21 -0
  67. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Mysql4/Entity/Sonda.php +21 -0
  68. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Mysql4/Entity/Sonda/Collection.php +21 -0
  69. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Notification.php +244 -0
  70. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Observer.php +96 -0
  71. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Payment.php +372 -0
  72. app/code/local/Ipagare/IpgPagSeguroDireto/Model/PaymentMath.php +39 -0
  73. app/code/local/Ipagare/IpgPagSeguroDireto/Model/PaymentType.php +222 -0
  74. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Sales/Order/Invoice/Total/Discount.php +34 -0
  75. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Sales/Quote/Address/Total/Discount.php +58 -0
  76. app/code/local/Ipagare/IpgPagSeguroDireto/Model/ShopPayment.php +106 -0
  77. app/code/local/Ipagare/IpgPagSeguroDireto/Model/Sonda.php +250 -0
  78. app/code/local/Ipagare/IpgPagSeguroDireto/Model/System/Config/Source/AllBoletoMethods.php +23 -0
  79. app/code/local/Ipagare/IpgPagSeguroDireto/Model/System/Config/Source/AllCardMethods.php +41 -0
  80. app/code/local/Ipagare/IpgPagSeguroDireto/Model/System/Config/Source/AllDebitMethods.php +27 -0
  81. app/code/local/Ipagare/IpgPagSeguroDireto/PaymentMode.php +315 -0
  82. app/code/local/Ipagare/IpgPagSeguroDireto/PaymentModeOption.php +93 -0
  83. app/code/local/Ipagare/IpgPagSeguroDireto/PaymentTypeOption.php +50 -0
  84. app/code/local/Ipagare/IpgPagSeguroDireto/PaymentTypeOptions.php +46 -0
  85. app/code/local/Ipagare/IpgPagSeguroDireto/RuntimeException.php +17 -0
  86. app/code/local/Ipagare/IpgPagSeguroDireto/ShopPayment.php +55 -0
  87. app/code/local/Ipagare/IpgPagSeguroDireto/TypePaymentType.php +21 -0
  88. app/code/local/Ipagare/IpgPagSeguroDireto/controllers/NotificationController.php +158 -0
  89. app/code/local/Ipagare/IpgPagSeguroDireto/controllers/PaymentController.php +138 -0
  90. app/code/local/Ipagare/IpgPagSeguroDireto/etc/adminhtml.xml +20 -0
  91. app/code/local/Ipagare/IpgPagSeguroDireto/etc/config.xml +238 -0
  92. app/code/local/Ipagare/IpgPagSeguroDireto/etc/system.xml +402 -0
  93. app/code/local/Ipagare/IpgPagSeguroDireto/sql/ipgpagsegurodireto_setup/mysql4-install-1.0.0.php +78 -0
  94. app/design/adminhtml/default/default/layout/ipagare/ipgbase.xml +17 -0
  95. app/design/adminhtml/default/default/layout/ipagare/ipgpagsegurodireto.xml +0 -0
  96. app/etc/modules/Ipagare_IpgBase.xml +10 -0
  97. app/etc/modules/Ipagare_IpgPagSeguroDireto.xml +13 -0
  98. app/locale/pt_BR/Ipagare_IpgBase.csv +1 -0
  99. app/locale/pt_BR/Ipagare_IpgPagSeguroDireto.csv +60 -0
  100. js/ipagare/ipgbase/adminhtml/index.js +1 -0
  101. js/ipagare/ipgbase/frontend/front.js +0 -0
  102. js/ipagare/ipgpagsegurodireto/adminhtml/index.js +0 -0
  103. js/ipagare/ipgpagsegurodireto/adminhtml/sales/order/view.js +8 -0
  104. js/ipagare/ipgpagsegurodireto/frontend/payment/pagseguro.directpayment.js +1 -0
  105. js/ipagare/ipgpagsegurodireto/frontend/payment/transferencia/index.js +29 -0
  106. js/ipagare/lib/checkout.js +1 -0
  107. js/ipagare/lib/ipagare.js +1 -0
  108. js/ipagare/lib/json2.js +326 -0
  109. js/ipagare/lib/prototype/maskedinput.js +295 -0
  110. lib/Ipagare/Log4php/Appenders/LoggerAppenderAdodb.php +263 -0
  111. lib/Ipagare/Log4php/Appenders/LoggerAppenderConsole.php +105 -0
  112. lib/Ipagare/Log4php/Appenders/LoggerAppenderDailyFile.php +92 -0
  113. lib/Ipagare/Log4php/Appenders/LoggerAppenderEcho.php +98 -0
  114. lib/Ipagare/Log4php/Appenders/LoggerAppenderFile.php +164 -0
  115. lib/Ipagare/Log4php/Appenders/LoggerAppenderMail.php +130 -0
  116. lib/Ipagare/Log4php/Appenders/LoggerAppenderMailEvent.php +167 -0
  117. lib/Ipagare/Log4php/Appenders/LoggerAppenderMongoDB.php +302 -0
  118. lib/Ipagare/Log4php/Appenders/LoggerAppenderNull.php +60 -0
  119. lib/Ipagare/Log4php/Appenders/LoggerAppenderPDO.php +323 -0
  120. lib/Ipagare/Log4php/Appenders/LoggerAppenderPhp.php +71 -0
  121. lib/Ipagare/Log4php/Appenders/LoggerAppenderRollingFile.php +254 -0
  122. lib/Ipagare/Log4php/Appenders/LoggerAppenderSocket.php +263 -0
  123. lib/Ipagare/Log4php/Appenders/LoggerAppenderSyslog.php +214 -0
  124. lib/Ipagare/Log4php/Configurators/LoggerConfiguratorBasic.php +47 -0
  125. lib/Ipagare/Log4php/Configurators/LoggerConfiguratorIni.php +463 -0
  126. lib/Ipagare/Log4php/Configurators/LoggerConfiguratorPhp.php +159 -0
  127. lib/Ipagare/Log4php/Configurators/LoggerConfiguratorXml.php +441 -0
  128. lib/Ipagare/Log4php/Filters/LoggerFilterDenyAll.php +56 -0
  129. lib/Ipagare/Log4php/Filters/LoggerFilterLevelMatch.php +104 -0
  130. lib/Ipagare/Log4php/Filters/LoggerFilterLevelRange.php +146 -0
  131. lib/Ipagare/Log4php/Filters/LoggerFilterStringMatch.php +89 -0
  132. lib/Ipagare/Log4php/Helpers/LoggerBasicPatternConverter.php +71 -0
  133. lib/Ipagare/Log4php/Helpers/LoggerCategoryPatternConverter.php +44 -0
  134. lib/Ipagare/Log4php/Helpers/LoggerClassNamePatternConverter.php +45 -0
  135. lib/Ipagare/Log4php/Helpers/LoggerDatePatternConverter.php +53 -0
  136. lib/Ipagare/Log4php/Helpers/LoggerFormattingInfo.php +50 -0
  137. lib/Ipagare/Log4php/Helpers/LoggerLiteralPatternConverter.php +57 -0
  138. lib/Ipagare/Log4php/Helpers/LoggerLocationPatternConverter.php +65 -0
  139. lib/Ipagare/Log4php/Helpers/LoggerMDCPatternConverter.php +50 -0
  140. lib/Ipagare/Log4php/Helpers/LoggerNamedPatternConverter.php +77 -0
  141. lib/Ipagare/Log4php/Helpers/LoggerOptionConverter.php +319 -0
  142. lib/Ipagare/Log4php/Helpers/LoggerPatternConverter.php +135 -0
  143. lib/Ipagare/Log4php/Helpers/LoggerPatternParser.php +341 -0
  144. lib/Ipagare/Log4php/Layouts/LoggerLayoutHtml.php +225 -0
  145. lib/Ipagare/Log4php/Layouts/LoggerLayoutPattern.php +219 -0
  146. lib/Ipagare/Log4php/Layouts/LoggerLayoutSimple.php +62 -0
  147. lib/Ipagare/Log4php/Layouts/LoggerLayoutTTCC.php +201 -0
  148. lib/Ipagare/Log4php/Layouts/LoggerLayoutXml.php +222 -0
  149. lib/Ipagare/Log4php/Logger.php +555 -0
  150. lib/Ipagare/Log4php/LoggerAppender.php +261 -0
  151. lib/Ipagare/Log4php/LoggerAppenderPool.php +60 -0
  152. lib/Ipagare/Log4php/LoggerConfigurator.php +53 -0
  153. lib/Ipagare/Log4php/LoggerException.php +28 -0
  154. lib/Ipagare/Log4php/LoggerFilter.php +126 -0
  155. lib/Ipagare/Log4php/LoggerHierarchy.php +246 -0
  156. lib/Ipagare/Log4php/LoggerLayout.php +70 -0
  157. lib/Ipagare/Log4php/LoggerLevel.php +278 -0
  158. lib/Ipagare/Log4php/LoggerLocationInfo.php +110 -0
  159. lib/Ipagare/Log4php/LoggerLoggingEvent.php +378 -0
  160. lib/Ipagare/Log4php/LoggerMDC.php +117 -0
  161. lib/Ipagare/Log4php/LoggerNDC.php +212 -0
  162. lib/Ipagare/Log4php/LoggerReflectionUtils.php +155 -0
  163. lib/Ipagare/Log4php/LoggerRoot.php +70 -0
  164. lib/Ipagare/Log4php/LoggerThrowableInformation.php +76 -0
  165. lib/Ipagare/Log4php/Renderers/LoggerRendererDefault.php +51 -0
  166. lib/Ipagare/Log4php/Renderers/LoggerRendererException.php +41 -0
  167. lib/Ipagare/Log4php/Renderers/LoggerRendererMap.php +150 -0
  168. lib/Ipagare/Log4php/Renderers/LoggerRendererObject.php +46 -0
  169. lib/Ipagare/Log4php/Xml/log4php.dtd +148 -0
  170. lib/Ipagare/PagSeguroDireto/Config/Config.php +134 -0
  171. lib/Ipagare/PagSeguroDireto/Config/ConfigFile.php +9 -0
  172. lib/Ipagare/PagSeguroDireto/Domain/AccountCredentials.php +102 -0
  173. lib/Ipagare/PagSeguroDireto/Domain/Address.php +307 -0
  174. lib/Ipagare/PagSeguroDireto/Domain/Bank.php +14 -0
  175. lib/Ipagare/PagSeguroDireto/Domain/Billing.php +31 -0
  176. lib/Ipagare/PagSeguroDireto/Domain/Credentials.php +35 -0
  177. lib/Ipagare/PagSeguroDireto/Domain/CreditCardHolder.php +97 -0
  178. lib/Ipagare/PagSeguroDireto/Domain/Currencies.php +92 -0
  179. lib/Ipagare/PagSeguroDireto/Domain/Document.php +92 -0
  180. lib/Ipagare/PagSeguroDireto/Domain/Documents.php +75 -0
  181. lib/Ipagare/PagSeguroDireto/Domain/Error.php +78 -0
  182. lib/Ipagare/PagSeguroDireto/Domain/HttpStatus.php +85 -0
  183. lib/Ipagare/PagSeguroDireto/Domain/Installment.php +52 -0
  184. lib/Ipagare/PagSeguroDireto/Domain/Item.php +174 -0
  185. lib/Ipagare/PagSeguroDireto/Domain/MetaData.php +64 -0
  186. lib/Ipagare/PagSeguroDireto/Domain/MetaDataItem.php +135 -0
  187. lib/Ipagare/PagSeguroDireto/Domain/MetaDataItemKeys.php +81 -0
  188. lib/Ipagare/PagSeguroDireto/Domain/NotificationType.php +64 -0
  189. lib/Ipagare/PagSeguroDireto/Domain/Parameter.php +58 -0
  190. lib/Ipagare/PagSeguroDireto/Domain/ParameterItem.php +117 -0
  191. lib/Ipagare/PagSeguroDireto/Domain/PaymentMethod.php +90 -0
  192. lib/Ipagare/PagSeguroDireto/Domain/PaymentMethodCode.php +374 -0
  193. lib/Ipagare/PagSeguroDireto/Domain/PaymentMethodType.php +100 -0
  194. lib/Ipagare/PagSeguroDireto/Domain/PaymentRequest.php +613 -0
  195. lib/Ipagare/PagSeguroDireto/Domain/PaymentResponse.php +67 -0
  196. lib/Ipagare/PagSeguroDireto/Domain/Phone.php +102 -0
  197. lib/Ipagare/PagSeguroDireto/Domain/Sender.php +175 -0
  198. lib/Ipagare/PagSeguroDireto/Domain/SenderDocument.php +75 -0
  199. lib/Ipagare/PagSeguroDireto/Domain/Session.php +33 -0
  200. lib/Ipagare/PagSeguroDireto/Domain/SessionResponse.php +53 -0
  201. lib/Ipagare/PagSeguroDireto/Domain/Shipping.php +109 -0
  202. lib/Ipagare/PagSeguroDireto/Domain/ShippingType.php +109 -0
  203. lib/Ipagare/PagSeguroDireto/Domain/Transaction.php +415 -0
  204. lib/Ipagare/PagSeguroDireto/Domain/TransactionCancellationSource.php +42 -0
  205. lib/Ipagare/PagSeguroDireto/Domain/TransactionSearchResponse.php +44 -0
  206. lib/Ipagare/PagSeguroDireto/Domain/TransactionSearchResult.php +144 -0
  207. lib/Ipagare/PagSeguroDireto/Domain/TransactionStatus.php +166 -0
  208. lib/Ipagare/PagSeguroDireto/Domain/TransactionSummary.php +303 -0
  209. lib/Ipagare/PagSeguroDireto/Domain/TransactionType.php +73 -0
  210. lib/Ipagare/PagSeguroDireto/Exception/ServiceException.php +143 -0
  211. lib/Ipagare/PagSeguroDireto/Helper/Helper.php +169 -0
  212. lib/Ipagare/PagSeguroDireto/Library.php +98 -0
  213. lib/Ipagare/PagSeguroDireto/Loader/AutoLoader.php +66 -0
  214. lib/Ipagare/PagSeguroDireto/Parser/PaymentParser.php +287 -0
  215. lib/Ipagare/PagSeguroDireto/Parser/PaymentParserData.php +307 -0
  216. lib/Ipagare/PagSeguroDireto/Parser/ServiceParser.php +49 -0
  217. lib/Ipagare/PagSeguroDireto/Parser/SessionParser.php +19 -0
  218. lib/Ipagare/PagSeguroDireto/Parser/TransactionParser.php +378 -0
  219. lib/Ipagare/PagSeguroDireto/Resources/Resources.php +92 -0
  220. lib/Ipagare/PagSeguroDireto/Resources/ResourcesFile.php +29 -0
  221. lib/Ipagare/PagSeguroDireto/Service/ConnectionData.php +186 -0
  222. lib/Ipagare/PagSeguroDireto/Service/NotificationService.php +98 -0
  223. lib/Ipagare/PagSeguroDireto/Service/PaymentService.php +96 -0
  224. lib/Ipagare/PagSeguroDireto/Service/SessionService.php +68 -0
  225. lib/Ipagare/PagSeguroDireto/Service/TransactionSearchService.php +235 -0
  226. lib/Ipagare/PagSeguroDireto/Utils/HttpConnection.php +114 -0
  227. lib/Ipagare/PagSeguroDireto/Utils/XmlParser.php +105 -0
  228. media/ipagare/ipgbase/images/imprimir_boleto.png +0 -0
  229. media/ipagare/ipgpagsegurodireto/bandeiras/101/10x.gif +0 -0
  230. media/ipagare/ipgpagsegurodireto/bandeiras/101/11x.gif +0 -0
  231. media/ipagare/ipgpagsegurodireto/bandeiras/101/12x.gif +0 -0
  232. media/ipagare/ipgpagsegurodireto/bandeiras/101/1x.gif +0 -0
  233. media/ipagare/ipgpagsegurodireto/bandeiras/101/2x.gif +0 -0
  234. media/ipagare/ipgpagsegurodireto/bandeiras/101/3x.gif +0 -0
  235. media/ipagare/ipgpagsegurodireto/bandeiras/101/4x.gif +0 -0
  236. media/ipagare/ipgpagsegurodireto/bandeiras/101/5x.gif +0 -0
  237. media/ipagare/ipgpagsegurodireto/bandeiras/101/6x.gif +0 -0
  238. media/ipagare/ipgpagsegurodireto/bandeiras/101/7x.gif +0 -0
  239. media/ipagare/ipgpagsegurodireto/bandeiras/101/8x.gif +0 -0
  240. media/ipagare/ipgpagsegurodireto/bandeiras/101/9x.gif +0 -0
  241. media/ipagare/ipgpagsegurodireto/bandeiras/102/10x.gif +0 -0
  242. media/ipagare/ipgpagsegurodireto/bandeiras/102/11x.gif +0 -0
  243. media/ipagare/ipgpagsegurodireto/bandeiras/102/12x.gif +0 -0
  244. media/ipagare/ipgpagsegurodireto/bandeiras/102/1x.gif +0 -0
  245. media/ipagare/ipgpagsegurodireto/bandeiras/102/2x.gif +0 -0
  246. media/ipagare/ipgpagsegurodireto/bandeiras/102/3x.gif +0 -0
  247. media/ipagare/ipgpagsegurodireto/bandeiras/102/4x.gif +0 -0
  248. media/ipagare/ipgpagsegurodireto/bandeiras/102/5x.gif +0 -0
  249. media/ipagare/ipgpagsegurodireto/bandeiras/102/6x.gif +0 -0
  250. media/ipagare/ipgpagsegurodireto/bandeiras/102/7x.gif +0 -0
  251. media/ipagare/ipgpagsegurodireto/bandeiras/102/8x.gif +0 -0
  252. media/ipagare/ipgpagsegurodireto/bandeiras/102/9x.gif +0 -0
  253. media/ipagare/ipgpagsegurodireto/bandeiras/103/10x.gif +0 -0
  254. media/ipagare/ipgpagsegurodireto/bandeiras/103/11x.gif +0 -0
  255. media/ipagare/ipgpagsegurodireto/bandeiras/103/12x.gif +0 -0
  256. media/ipagare/ipgpagsegurodireto/bandeiras/103/13x.gif +0 -0
  257. media/ipagare/ipgpagsegurodireto/bandeiras/103/14x.gif +0 -0
  258. media/ipagare/ipgpagsegurodireto/bandeiras/103/15x.gif +0 -0
  259. media/ipagare/ipgpagsegurodireto/bandeiras/103/1x.gif +0 -0
  260. media/ipagare/ipgpagsegurodireto/bandeiras/103/2x.gif +0 -0
  261. media/ipagare/ipgpagsegurodireto/bandeiras/103/3x.gif +0 -0
  262. media/ipagare/ipgpagsegurodireto/bandeiras/103/4x.gif +0 -0
  263. media/ipagare/ipgpagsegurodireto/bandeiras/103/5x.gif +0 -0
  264. media/ipagare/ipgpagsegurodireto/bandeiras/103/6x.gif +0 -0
  265. media/ipagare/ipgpagsegurodireto/bandeiras/103/7x.gif +0 -0
  266. media/ipagare/ipgpagsegurodireto/bandeiras/103/8x.gif +0 -0
  267. media/ipagare/ipgpagsegurodireto/bandeiras/103/9x.gif +0 -0
  268. media/ipagare/ipgpagsegurodireto/bandeiras/104/10x.gif +0 -0
  269. media/ipagare/ipgpagsegurodireto/bandeiras/104/11x.gif +0 -0
  270. media/ipagare/ipgpagsegurodireto/bandeiras/104/12x.gif +0 -0
  271. media/ipagare/ipgpagsegurodireto/bandeiras/104/1x.gif +0 -0
  272. media/ipagare/ipgpagsegurodireto/bandeiras/104/2x.gif +0 -0
  273. media/ipagare/ipgpagsegurodireto/bandeiras/104/3x.gif +0 -0
  274. media/ipagare/ipgpagsegurodireto/bandeiras/104/4x.gif +0 -0
  275. media/ipagare/ipgpagsegurodireto/bandeiras/104/5x.gif +0 -0
  276. media/ipagare/ipgpagsegurodireto/bandeiras/104/6x.gif +0 -0
  277. media/ipagare/ipgpagsegurodireto/bandeiras/104/7x.gif +0 -0
  278. media/ipagare/ipgpagsegurodireto/bandeiras/104/8x.gif +0 -0
  279. media/ipagare/ipgpagsegurodireto/bandeiras/104/9x.gif +0 -0
  280. media/ipagare/ipgpagsegurodireto/bandeiras/105/10x.gif +0 -0
  281. media/ipagare/ipgpagsegurodireto/bandeiras/105/11x.gif +0 -0
  282. media/ipagare/ipgpagsegurodireto/bandeiras/105/12x.gif +0 -0
  283. media/ipagare/ipgpagsegurodireto/bandeiras/105/1x.gif +0 -0
  284. media/ipagare/ipgpagsegurodireto/bandeiras/105/2x.gif +0 -0
  285. media/ipagare/ipgpagsegurodireto/bandeiras/105/3x.gif +0 -0
  286. media/ipagare/ipgpagsegurodireto/bandeiras/105/4x.gif +0 -0
  287. media/ipagare/ipgpagsegurodireto/bandeiras/105/5x.gif +0 -0
  288. media/ipagare/ipgpagsegurodireto/bandeiras/105/6x.gif +0 -0
  289. media/ipagare/ipgpagsegurodireto/bandeiras/105/7x.gif +0 -0
  290. media/ipagare/ipgpagsegurodireto/bandeiras/105/8x.gif +0 -0
  291. media/ipagare/ipgpagsegurodireto/bandeiras/105/9x.gif +0 -0
  292. media/ipagare/ipgpagsegurodireto/bandeiras/106/10x.gif +0 -0
  293. media/ipagare/ipgpagsegurodireto/bandeiras/106/11x.gif +0 -0
  294. media/ipagare/ipgpagsegurodireto/bandeiras/106/12x.gif +0 -0
  295. media/ipagare/ipgpagsegurodireto/bandeiras/106/13x.gif +0 -0
  296. media/ipagare/ipgpagsegurodireto/bandeiras/106/14x.gif +0 -0
  297. media/ipagare/ipgpagsegurodireto/bandeiras/106/15x.gif +0 -0
  298. media/ipagare/ipgpagsegurodireto/bandeiras/106/16x.gif +0 -0
  299. media/ipagare/ipgpagsegurodireto/bandeiras/106/17x.gif +0 -0
  300. media/ipagare/ipgpagsegurodireto/bandeiras/106/18x.gif +0 -0
  301. media/ipagare/ipgpagsegurodireto/bandeiras/106/1x.gif +0 -0
  302. media/ipagare/ipgpagsegurodireto/bandeiras/106/2x.gif +0 -0
  303. media/ipagare/ipgpagsegurodireto/bandeiras/106/3x.gif +0 -0
  304. media/ipagare/ipgpagsegurodireto/bandeiras/106/4x.gif +0 -0
  305. media/ipagare/ipgpagsegurodireto/bandeiras/106/5x.gif +0 -0
  306. media/ipagare/ipgpagsegurodireto/bandeiras/106/6x.gif +0 -0
  307. media/ipagare/ipgpagsegurodireto/bandeiras/106/7x.gif +0 -0
  308. media/ipagare/ipgpagsegurodireto/bandeiras/106/8x.gif +0 -0
  309. media/ipagare/ipgpagsegurodireto/bandeiras/106/9x.gif +0 -0
  310. media/ipagare/ipgpagsegurodireto/bandeiras/107/10x.gif +0 -0
  311. media/ipagare/ipgpagsegurodireto/bandeiras/107/11x.gif +0 -0
  312. media/ipagare/ipgpagsegurodireto/bandeiras/107/12x.gif +0 -0
  313. media/ipagare/ipgpagsegurodireto/bandeiras/107/1x.gif +0 -0
  314. media/ipagare/ipgpagsegurodireto/bandeiras/107/2x.gif +0 -0
  315. media/ipagare/ipgpagsegurodireto/bandeiras/107/3x.gif +0 -0
  316. media/ipagare/ipgpagsegurodireto/bandeiras/107/4x.gif +0 -0
  317. media/ipagare/ipgpagsegurodireto/bandeiras/107/5x.gif +0 -0
  318. media/ipagare/ipgpagsegurodireto/bandeiras/107/6x.gif +0 -0
  319. media/ipagare/ipgpagsegurodireto/bandeiras/107/7x.gif +0 -0
  320. media/ipagare/ipgpagsegurodireto/bandeiras/107/8x.gif +0 -0
  321. media/ipagare/ipgpagsegurodireto/bandeiras/107/9x.gif +0 -0
  322. media/ipagare/ipgpagsegurodireto/bandeiras/108/10x.gif +0 -0
  323. media/ipagare/ipgpagsegurodireto/bandeiras/108/11x.gif +0 -0
  324. media/ipagare/ipgpagsegurodireto/bandeiras/108/12x.gif +0 -0
  325. media/ipagare/ipgpagsegurodireto/bandeiras/108/1x.gif +0 -0
  326. media/ipagare/ipgpagsegurodireto/bandeiras/108/2x.gif +0 -0
  327. media/ipagare/ipgpagsegurodireto/bandeiras/108/3x.gif +0 -0
  328. media/ipagare/ipgpagsegurodireto/bandeiras/108/4x.gif +0 -0
  329. media/ipagare/ipgpagsegurodireto/bandeiras/108/5x.gif +0 -0
  330. media/ipagare/ipgpagsegurodireto/bandeiras/108/6x.gif +0 -0
  331. media/ipagare/ipgpagsegurodireto/bandeiras/108/7x.gif +0 -0
  332. media/ipagare/ipgpagsegurodireto/bandeiras/108/8x.gif +0 -0
  333. media/ipagare/ipgpagsegurodireto/bandeiras/108/9x.gif +0 -0
  334. media/ipagare/ipgpagsegurodireto/bandeiras/109/10x.gif +0 -0
  335. media/ipagare/ipgpagsegurodireto/bandeiras/109/11x.gif +0 -0
  336. media/ipagare/ipgpagsegurodireto/bandeiras/109/12x.gif +0 -0
  337. media/ipagare/ipgpagsegurodireto/bandeiras/109/1x.gif +0 -0
  338. media/ipagare/ipgpagsegurodireto/bandeiras/109/2x.gif +0 -0
  339. media/ipagare/ipgpagsegurodireto/bandeiras/109/3x.gif +0 -0
  340. media/ipagare/ipgpagsegurodireto/bandeiras/109/4x.gif +0 -0
  341. media/ipagare/ipgpagsegurodireto/bandeiras/109/5x.gif +0 -0
  342. media/ipagare/ipgpagsegurodireto/bandeiras/109/6x.gif +0 -0
  343. media/ipagare/ipgpagsegurodireto/bandeiras/109/7x.gif +0 -0
  344. media/ipagare/ipgpagsegurodireto/bandeiras/109/8x.gif +0 -0
  345. media/ipagare/ipgpagsegurodireto/bandeiras/109/9x.gif +0 -0
  346. media/ipagare/ipgpagsegurodireto/bandeiras/110/10x.gif +0 -0
  347. media/ipagare/ipgpagsegurodireto/bandeiras/110/11x.gif +0 -0
  348. media/ipagare/ipgpagsegurodireto/bandeiras/110/12x.gif +0 -0
  349. media/ipagare/ipgpagsegurodireto/bandeiras/110/1x.gif +0 -0
  350. media/ipagare/ipgpagsegurodireto/bandeiras/110/2x.gif +0 -0
  351. media/ipagare/ipgpagsegurodireto/bandeiras/110/3x.gif +0 -0
  352. media/ipagare/ipgpagsegurodireto/bandeiras/110/4x.gif +0 -0
  353. media/ipagare/ipgpagsegurodireto/bandeiras/110/5x.gif +0 -0
  354. media/ipagare/ipgpagsegurodireto/bandeiras/110/6x.gif +0 -0
  355. media/ipagare/ipgpagsegurodireto/bandeiras/110/7x.gif +0 -0
  356. media/ipagare/ipgpagsegurodireto/bandeiras/110/8x.gif +0 -0
  357. media/ipagare/ipgpagsegurodireto/bandeiras/110/9x.gif +0 -0
  358. media/ipagare/ipgpagsegurodireto/bandeiras/111/10x.gif +0 -0
  359. media/ipagare/ipgpagsegurodireto/bandeiras/111/11x.gif +0 -0
  360. media/ipagare/ipgpagsegurodireto/bandeiras/111/12x.gif +0 -0
  361. media/ipagare/ipgpagsegurodireto/bandeiras/111/1x.gif +0 -0
  362. media/ipagare/ipgpagsegurodireto/bandeiras/111/2x.gif +0 -0
  363. media/ipagare/ipgpagsegurodireto/bandeiras/111/3x.gif +0 -0
  364. media/ipagare/ipgpagsegurodireto/bandeiras/111/4x.gif +0 -0
  365. media/ipagare/ipgpagsegurodireto/bandeiras/111/5x.gif +0 -0
  366. media/ipagare/ipgpagsegurodireto/bandeiras/111/6x.gif +0 -0
  367. media/ipagare/ipgpagsegurodireto/bandeiras/111/7x.gif +0 -0
  368. media/ipagare/ipgpagsegurodireto/bandeiras/111/8x.gif +0 -0
  369. media/ipagare/ipgpagsegurodireto/bandeiras/111/9x.gif +0 -0
  370. media/ipagare/ipgpagsegurodireto/bandeiras/112/10x.gif +0 -0
  371. media/ipagare/ipgpagsegurodireto/bandeiras/112/11x.gif +0 -0
  372. media/ipagare/ipgpagsegurodireto/bandeiras/112/12x.gif +0 -0
  373. media/ipagare/ipgpagsegurodireto/bandeiras/112/1x.gif +0 -0
  374. media/ipagare/ipgpagsegurodireto/bandeiras/112/2x.gif +0 -0
  375. media/ipagare/ipgpagsegurodireto/bandeiras/112/3x.gif +0 -0
  376. media/ipagare/ipgpagsegurodireto/bandeiras/112/4x.gif +0 -0
  377. media/ipagare/ipgpagsegurodireto/bandeiras/112/5x.gif +0 -0
  378. media/ipagare/ipgpagsegurodireto/bandeiras/112/6x.gif +0 -0
  379. media/ipagare/ipgpagsegurodireto/bandeiras/112/7x.gif +0 -0
  380. media/ipagare/ipgpagsegurodireto/bandeiras/112/8x.gif +0 -0
  381. media/ipagare/ipgpagsegurodireto/bandeiras/112/9x.gif +0 -0
  382. media/ipagare/ipgpagsegurodireto/bandeiras/113/10x.gif +0 -0
  383. media/ipagare/ipgpagsegurodireto/bandeiras/113/11x.gif +0 -0
  384. media/ipagare/ipgpagsegurodireto/bandeiras/113/12x.gif +0 -0
  385. media/ipagare/ipgpagsegurodireto/bandeiras/113/1x.gif +0 -0
  386. media/ipagare/ipgpagsegurodireto/bandeiras/113/2x.gif +0 -0
  387. media/ipagare/ipgpagsegurodireto/bandeiras/113/3x.gif +0 -0
  388. media/ipagare/ipgpagsegurodireto/bandeiras/113/4x.gif +0 -0
  389. media/ipagare/ipgpagsegurodireto/bandeiras/113/5x.gif +0 -0
  390. media/ipagare/ipgpagsegurodireto/bandeiras/113/6x.gif +0 -0
  391. media/ipagare/ipgpagsegurodireto/bandeiras/113/7x.gif +0 -0
  392. media/ipagare/ipgpagsegurodireto/bandeiras/113/8x.gif +0 -0
  393. media/ipagare/ipgpagsegurodireto/bandeiras/113/9x.gif +0 -0
  394. media/ipagare/ipgpagsegurodireto/bandeiras/114/10x.gif +0 -0
  395. media/ipagare/ipgpagsegurodireto/bandeiras/114/11x.gif +0 -0
  396. media/ipagare/ipgpagsegurodireto/bandeiras/114/12x.gif +0 -0
  397. media/ipagare/ipgpagsegurodireto/bandeiras/114/1x.gif +0 -0
  398. media/ipagare/ipgpagsegurodireto/bandeiras/114/2x.gif +0 -0
  399. media/ipagare/ipgpagsegurodireto/bandeiras/114/3x.gif +0 -0
  400. media/ipagare/ipgpagsegurodireto/bandeiras/114/4x.gif +0 -0
  401. media/ipagare/ipgpagsegurodireto/bandeiras/114/5x.gif +0 -0
  402. media/ipagare/ipgpagsegurodireto/bandeiras/114/6x.gif +0 -0
  403. media/ipagare/ipgpagsegurodireto/bandeiras/114/7x.gif +0 -0
  404. media/ipagare/ipgpagsegurodireto/bandeiras/114/8x.gif +0 -0
  405. media/ipagare/ipgpagsegurodireto/bandeiras/114/9x.gif +0 -0
  406. media/ipagare/ipgpagsegurodireto/bandeiras/115/1x.gif +0 -0
  407. media/ipagare/ipgpagsegurodireto/bandeiras/115/2x.gif +0 -0
  408. media/ipagare/ipgpagsegurodireto/bandeiras/115/3x.gif +0 -0
  409. media/ipagare/ipgpagsegurodireto/bandeiras/116/10x.gif +0 -0
  410. media/ipagare/ipgpagsegurodireto/bandeiras/116/11x.gif +0 -0
  411. media/ipagare/ipgpagsegurodireto/bandeiras/116/12x.gif +0 -0
  412. media/ipagare/ipgpagsegurodireto/bandeiras/116/1x.gif +0 -0
  413. media/ipagare/ipgpagsegurodireto/bandeiras/116/2x.gif +0 -0
  414. media/ipagare/ipgpagsegurodireto/bandeiras/116/3x.gif +0 -0
  415. media/ipagare/ipgpagsegurodireto/bandeiras/116/4x.gif +0 -0
  416. media/ipagare/ipgpagsegurodireto/bandeiras/116/5x.gif +0 -0
  417. media/ipagare/ipgpagsegurodireto/bandeiras/116/6x.gif +0 -0
  418. media/ipagare/ipgpagsegurodireto/bandeiras/116/7x.gif +0 -0
  419. media/ipagare/ipgpagsegurodireto/bandeiras/116/8x.gif +0 -0
  420. media/ipagare/ipgpagsegurodireto/bandeiras/116/9x.gif +0 -0
  421. media/ipagare/ipgpagsegurodireto/bandeiras/117/10x.gif +0 -0
  422. media/ipagare/ipgpagsegurodireto/bandeiras/117/11x.gif +0 -0
  423. media/ipagare/ipgpagsegurodireto/bandeiras/117/12x.gif +0 -0
  424. media/ipagare/ipgpagsegurodireto/bandeiras/117/1x.gif +0 -0
  425. media/ipagare/ipgpagsegurodireto/bandeiras/117/2x.gif +0 -0
  426. media/ipagare/ipgpagsegurodireto/bandeiras/117/3x.gif +0 -0
  427. media/ipagare/ipgpagsegurodireto/bandeiras/117/4x.gif +0 -0
  428. media/ipagare/ipgpagsegurodireto/bandeiras/117/5x.gif +0 -0
  429. media/ipagare/ipgpagsegurodireto/bandeiras/117/6x.gif +0 -0
  430. media/ipagare/ipgpagsegurodireto/bandeiras/117/7x.gif +0 -0
  431. media/ipagare/ipgpagsegurodireto/bandeiras/117/8x.gif +0 -0
  432. media/ipagare/ipgpagsegurodireto/bandeiras/117/9x.gif +0 -0
  433. media/ipagare/ipgpagsegurodireto/bandeiras/118/1x.gif +0 -0
  434. media/ipagare/ipgpagsegurodireto/bandeiras/118/2x.gif +0 -0
  435. media/ipagare/ipgpagsegurodireto/bandeiras/118/3x.gif +0 -0
  436. media/ipagare/ipgpagsegurodireto/bandeiras/118/4x.gif +0 -0
  437. media/ipagare/ipgpagsegurodireto/bandeiras/118/5x.gif +0 -0
  438. media/ipagare/ipgpagsegurodireto/bandeiras/118/6x.gif +0 -0
  439. media/ipagare/ipgpagsegurodireto/bandeiras/119/10x.gif +0 -0
  440. media/ipagare/ipgpagsegurodireto/bandeiras/119/11x.gif +0 -0
  441. media/ipagare/ipgpagsegurodireto/bandeiras/119/12x.gif +0 -0
  442. media/ipagare/ipgpagsegurodireto/bandeiras/119/1x.gif +0 -0
  443. media/ipagare/ipgpagsegurodireto/bandeiras/119/2x.gif +0 -0
  444. media/ipagare/ipgpagsegurodireto/bandeiras/119/3x.gif +0 -0
  445. media/ipagare/ipgpagsegurodireto/bandeiras/119/4x.gif +0 -0
  446. media/ipagare/ipgpagsegurodireto/bandeiras/119/5x.gif +0 -0
  447. media/ipagare/ipgpagsegurodireto/bandeiras/119/6x.gif +0 -0
  448. media/ipagare/ipgpagsegurodireto/bandeiras/119/7x.gif +0 -0
  449. media/ipagare/ipgpagsegurodireto/bandeiras/119/8x.gif +0 -0
  450. media/ipagare/ipgpagsegurodireto/bandeiras/119/9x.gif +0 -0
  451. media/ipagare/ipgpagsegurodireto/bandeiras/202/1x.gif +0 -0
  452. media/ipagare/ipgpagsegurodireto/bandeiras/301/1x.gif +0 -0
  453. media/ipagare/ipgpagsegurodireto/bandeiras/302/1x.gif +0 -0
  454. media/ipagare/ipgpagsegurodireto/bandeiras/304/1x.gif +0 -0
  455. media/ipagare/ipgpagsegurodireto/bandeiras/306/1x.gif +0 -0
  456. media/ipagare/ipgpagsegurodireto/bandeiras/307/1x.gif +0 -0
  457. media/ipagare/ipgpagsegurodireto/images/logo_pagseguro.png +0 -0
  458. media/ipagare/ipgpagsegurodireto/images/logo_pagseguro_.png +0 -0
  459. package.xml +18 -0
  460. skin/adminhtml/default/default/ipgbase/css/images/francybox/blank.gif +0 -0
  461. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_close.png +0 -0
  462. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_loading.png +0 -0
  463. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_nav_left.png +0 -0
  464. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_nav_right.png +0 -0
  465. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_e.png +0 -0
  466. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_n.png +0 -0
  467. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_ne.png +0 -0
  468. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_nw.png +0 -0
  469. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_s.png +0 -0
  470. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_se.png +0 -0
  471. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_sw.png +0 -0
  472. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_w.png +0 -0
  473. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_title_left.png +0 -0
  474. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_title_main.png +0 -0
  475. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_title_over.png +0 -0
  476. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_title_right.png +0 -0
  477. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancybox-x.png +0 -0
  478. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancybox-y.png +0 -0
  479. skin/adminhtml/default/default/ipgbase/css/images/francybox/fancybox.png +0 -0
  480. skin/adminhtml/default/default/ipgbase/css/styles.css +1 -0
  481. skin/adminhtml/default/default/ipgbase/images/help.png +0 -0
  482. skin/adminhtml/default/default/ipgbase/images/logo-ipagare-menu.png +0 -0
  483. skin/adminhtml/default/default/ipgbase/images/logo-ipagare.png +0 -0
  484. skin/adminhtml/default/default/ipgpagsegurodireto/css/styles.css +0 -0
  485. skin/frontend/base/default/ipgbase/css/checkout/osc.css +1 -0
  486. skin/frontend/base/default/ipgbase/css/styles.css +1 -0
  487. skin/frontend/base/default/ipgbase/images/ajax-loader-tr.gif +0 -0
  488. skin/frontend/base/default/ipgbase/images/bkg_btn-close.gif +0 -0
  489. skin/frontend/base/default/ipgbase/images/bkg_btn-close2.gif +0 -0
  490. skin/frontend/base/default/ipgbase/images/boleto.png +0 -0
  491. skin/frontend/base/default/ipgpagsegurodireto/css/cvm.css +0 -0
  492. skin/frontend/base/default/ipgpagsegurodireto/css/opc.css +0 -0
  493. skin/frontend/base/default/ipgpagsegurodireto/css/styles-ie7.css +0 -0
  494. skin/frontend/base/default/ipgpagsegurodireto/css/styles.css +231 -0
  495. skin/frontend/base/default/ipgpagsegurodireto/images/boleto.png +0 -0
  496. skin/frontend/base/default/ipgpagsegurodireto/images/bubble.png +0 -0
  497. skin/frontend/base/default/ipgpagsegurodireto/images/codigo_bin_1.png +0 -0
  498. skin/frontend/base/default/ipgpagsegurodireto/images/codigo_bin_2.png +0 -0
  499. skin/frontend/base/default/ipgpagsegurodireto/images/cvv.gif +0 -0
  500. skin/frontend/base/default/ipgpagsegurodireto/images/padlock_clean.png +0 -0
  501. skin/frontend/base/default/ipgpagsegurodireto/images/padlock_closed.png +0 -0
  502. skin/frontend/base/default/ipgpagsegurodireto/images/pagseguro.png +0 -0
  503. skin/frontend/base/default/ipgpagsegurodireto/images/pagseguro.pxm +0 -0
  504. skin/frontend/base/default/ipgpagsegurodireto/images/pagseguro.pxm.sb-cd4c37b0-h3WR13 +0 -0
app/code/local/Ipagare/IpgBase/Block/Adminhtml/Sales/Order/Invoice/Totals.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Block_Adminhtml_Sales_Order_Invoice_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals {
16
+
17
+ /**
18
+ * Initialize order totals array
19
+ *
20
+ * @return Mage_Sales_Block_Order_Totals
21
+ */
22
+ protected function _initTotals() {
23
+ parent::_initTotals();
24
+ $order = $this->getOrder();
25
+ $payment = $order->getPayment();
26
+ $paymentMethodCode = $payment->getMethodInstance()->getCode();
27
+
28
+ if (Mage::helper('ipgbase')->isIpagarePaymentMethod($paymentMethodCode)) {
29
+ $amount = Mage::getModel($paymentMethodCode . '/discount')->getIpgDiscount($order);
30
+ if (abs($amount) > 0) {
31
+ $baseAmount = Mage::getModel($paymentMethodCode . '/discount')->getIpgBaseDiscount($order);
32
+ $code = Mage::getModel($paymentMethodCode . '/discount')->getIpgDiscountCode();
33
+ $this->addTotal(new Varien_Object(array(
34
+ 'code' => $code,
35
+ 'value' => $amount,
36
+ 'base_value' => $baseAmount,
37
+ 'label' => Mage::helper($paymentMethodCode)->__('Payment Discount'),
38
+ )));
39
+ }
40
+ }
41
+ return $this;
42
+ }
43
+
44
+ }
app/code/local/Ipagare/IpgBase/Block/Adminhtml/Sales/Order/Totals.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Block_Adminhtml_Sales_Order_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals {
16
+
17
+ /**
18
+ * Initialize order totals array
19
+ *
20
+ * @return Mage_Sales_Block_Order_Totals
21
+ */
22
+ protected function _initTotals() {
23
+ parent::_initTotals();
24
+ $order = $this->getOrder();
25
+ $payment = $order->getPayment();
26
+ $paymentMethodCode = $payment->getMethodInstance()->getCode();
27
+
28
+ if (Mage::helper('ipgbase')->isIpagarePaymentMethod($paymentMethodCode)) {
29
+ $amount = Mage::getModel($paymentMethodCode . '/discount')->getIpgDiscount($order);
30
+ if (abs($amount) > 0) {
31
+ $baseAmount = Mage::getModel($paymentMethodCode . '/discount')->getIpgBaseDiscount($order);
32
+ $code = Mage::getModel($paymentMethodCode . '/discount')->getIpgDiscountCode();
33
+ $this->addTotal(new Varien_Object(array(
34
+ 'code' => $code,
35
+ 'value' => $amount,
36
+ 'base_value' => $baseAmount,
37
+ 'label' => Mage::helper($paymentMethodCode)->__('Payment Discount'),
38
+ )));
39
+ }
40
+ }
41
+ return $this;
42
+ }
43
+
44
+ }
app/code/local/Ipagare/IpgBase/Block/Adminhtml/System/Config/Fieldset/Licenca.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Block_Adminhtml_System_Config_Fieldset_Licenca extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface {
16
+
17
+ /**
18
+ * Render element html
19
+ *
20
+ * @param Varien_Data_Form_Element_Abstract $element
21
+ * @return string
22
+ */
23
+ public function render(Varien_Data_Form_Element_Abstract $element) {
24
+ $stringExp = '';
25
+ if (extension_loaded('ionCube Loader')) {
26
+ $ioncubeInfo = ioncube_file_info();
27
+ if (isset($ioncubeInfo['FILE_EXPIRY'])) {
28
+ $dataExpiracao = date('d/m/Y', $ioncubeInfo['FILE_EXPIRY']);
29
+ $stringExp = '<h6>Sua licença expira em ' . $dataExpiracao . '. Para renovar sua licença, entre em contato com nosso <a href="http://ajuda.ipagare.com.br/" target="_blank">suporte.</a></h6><br/>';
30
+ }
31
+ }
32
+ return sprintf($stringExp);
33
+ }
34
+ }
app/code/local/Ipagare/IpgBase/Block/Adminhtml/System/Config/Form/Field/Date.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Block_Adminhtml_System_Config_Form_Field_Date extends Mage_Adminhtml_Block_System_Config_Form_Field {
16
+
17
+ public function render(Varien_Data_Form_Element_Abstract $element) {
18
+ //$element->setFormat(Varien_Date::DATE_INTERNAL_FORMAT); //or other format
19
+ $element->setFormat('dd/MM/yyyy'); //or other format
20
+ $element->setImage($this->getSkinUrl('images/grid-cal.gif'));
21
+ return parent::render($element);
22
+ }
23
+
24
+ }
25
+
26
+ ?>
app/code/local/Ipagare/IpgBase/Block/Adminhtml/System/Config/Form/Field/NeedHelp.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Block_Adminhtml_System_Config_Form_Field_NeedHelp extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface {
16
+
17
+ /**
18
+ * Render element html
19
+ *
20
+ * @param Varien_Data_Form_Element_Abstract $element
21
+ * @return string
22
+ */
23
+ public function render(Varien_Data_Form_Element_Abstract $element) {
24
+ $imgHelp = $this->getSkinUrl('ipgbase/images/help.png');
25
+ return sprintf('<tr class="system-fieldset-sub-head" id="row_%s"><td colspan="5"><h6 style="background-color: #FFF8E9;padding: 5px" id="%s"><img src=' . $imgHelp . '></img>%s</h6></td></tr>', $element->getHtmlId(), $element->getHtmlId(), $element->getLabel()
26
+ );
27
+ }
28
+ }
app/code/local/Ipagare/IpgBase/Block/Checkout/Onepage/Success.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Block_Checkout_Onepage_Success extends Mage_Checkout_Block_Onepage_Success {
16
+
17
+ private $paymentMethod;
18
+ private $isIpagareMethod;
19
+
20
+ protected function _construct() {
21
+ parent::_construct();
22
+ $this->setPaymentMethod();
23
+
24
+ $this->isIpagareMethod = Mage::helper('ipgbase')->isIpagarePaymentMethod($this->paymentMethod);
25
+ if ($this->isIpagareMethod) {
26
+ $this->setTemplate('ipagare/' . $this->paymentMethod . '/checkout/success-details.phtml');
27
+ }
28
+ }
29
+
30
+ public function getBlock() {
31
+ if ($this->isIpagareMethod) {
32
+ $block = $this->getLayout()->getBlockSingleton($this->paymentMethod . '/checkout_onepage_success');
33
+ if ($block) {
34
+ return $block;
35
+ }
36
+ }
37
+ return null;
38
+ }
39
+
40
+ private function setPaymentMethod() {
41
+ $order = Mage::helper('ipgbase/session')->getCurrentOrder();
42
+ $payment = $order->getPayment();
43
+ $method = $payment->getMethodInstance();
44
+ $this->paymentMethod = $payment->getMethodInstance()->getCode();
45
+ }
46
+
47
+ }
app/code/local/Ipagare/IpgBase/Block/Sales/Order/Invoice/Totals.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Block_Sales_Order_Invoice_Totals extends Mage_Sales_Block_Order_Invoice_Totals {
16
+
17
+ /**
18
+ * Initialize order totals array
19
+ *
20
+ * @return Mage_Sales_Block_Order_Totals
21
+ */
22
+ protected function _initTotals() {
23
+ parent::_initTotals();
24
+ $order = $this->getOrder();
25
+ $payment = $order->getPayment();
26
+ $paymentMethodCode = $payment->getMethodInstance()->getCode();
27
+
28
+ if (Mage::helper('ipgbase')->isIpagarePaymentMethod($paymentMethodCode)) {
29
+ $amount = Mage::getModel($paymentMethodCode . '/discount')->getIpgDiscount($order);
30
+ if (abs($amount) > 0) {
31
+ $baseAmount = Mage::getModel($paymentMethodCode . '/discount')->getIpgBaseDiscount($order);
32
+ $code = Mage::getModel($paymentMethodCode . '/discount')->getIpgDiscountCode();
33
+ $this->addTotal(new Varien_Object(array(
34
+ 'code' => $code,
35
+ 'value' => $amount,
36
+ 'base_value' => $baseAmount,
37
+ 'label' => Mage::helper($paymentMethodCode)->__('Payment Discount'),
38
+ )));
39
+ }
40
+ }
41
+ return $this;
42
+ }
43
+
44
+ }
app/code/local/Ipagare/IpgBase/Block/Sales/Order/Totals.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Block_Sales_Order_Totals extends Mage_Sales_Block_Order_Totals {
16
+
17
+ /**
18
+ * Initialize order totals array
19
+ *
20
+ * @return Mage_Sales_Block_Order_Totals
21
+ */
22
+ protected function _initTotals() {
23
+ parent::_initTotals();
24
+ $order = $this->getOrder();
25
+ $payment = $order->getPayment();
26
+ $paymentMethodCode = $payment->getMethodInstance()->getCode();
27
+
28
+ if (Mage::helper('ipgbase')->isIpagarePaymentMethod($paymentMethodCode)) {
29
+ $amount = Mage::getModel($paymentMethodCode . '/discount')->getIpgDiscount($order);
30
+ if (abs($amount) > 0) {
31
+ $baseAmount = Mage::getModel($paymentMethodCode . '/discount')->getIpgBaseDiscount($order);
32
+ $code = Mage::getModel($paymentMethodCode . '/discount')->getIpgDiscountCode();
33
+ $this->addTotal(new Varien_Object(array(
34
+ 'code' => $code,
35
+ 'value' => $amount,
36
+ 'base_value' => $baseAmount,
37
+ 'label' => Mage::helper($paymentMethodCode)->__('Payment Discount'),
38
+ )));
39
+ }
40
+ }
41
+ return $this;
42
+ }
43
+
44
+ }
app/code/local/Ipagare/IpgBase/Config.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ final class Ipagare_IpgBase_Config {
16
+
17
+ /**
18
+ * Códigos dos meios de pagamento implementados pelo iPAGARE.
19
+ *
20
+ */
21
+ protected static $_paymentMethods = array('ipgcore', 'ipgmoip', 'ipgpagamentodigital', 'ipgpagseguro', 'ipgcobrebemaprovafacil', 'ipgpagsegurolightbox', 'ipgpagsegurodireto');
22
+
23
+ /**
24
+ * Identifica que a origem do pedido, tabela "sales_flat_order", campo "ipagare_order_orig" é "televendas".
25
+ */
26
+ const ORDER_ORIG_TELEVENDAS = 'televendas';
27
+
28
+ /**
29
+ * Retorna a lista com os métodos de pagamentos
30
+ *
31
+ * @return type array
32
+ */
33
+ public static function listPaymentMethods() {
34
+ return self::$_paymentMethods;
35
+ }
36
+
37
+ }
app/code/local/Ipagare/IpgBase/ConfiguracoesSystem.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_ConfiguracoesSystem {
16
+
17
+ // Página de sucesso
18
+ const PAGINA_SUCESSO_MOSTRAR_CONTEUDO = 'ipgbase/pagina_sucesso/mostrar_conteudo';
19
+
20
+ // Expiração pedidos
21
+ const EXPIRACAO_PEDIDO_ACTIVE = 'ipgbase/expiracao_pedido/ativa';
22
+ const EXPIRACAO_PEDIDO_DATA_INICIAL = 'ipgbase/expiracao_pedido/data_inicial';
23
+ const EXPIRACAO_PEDIDO_PERIODO_DIAS = 'ipgbase/expiracao_pedido/periodo_dias';
24
+ const EXPIRACAO_PEDIDO_PERIODO_HORAS = 'ipgbase/expiracao_pedido/periodo_horas';
25
+ const EXPIRACAO_PEDIDO_PERIODO_MINUTOS = 'ipgbase/expiracao_pedido/periodo_minutos';
26
+
27
+ // Página de estilo OSC
28
+ const OSC_CSS_ACTIVE = 'ipgbase/osc/css_active';
29
+
30
+ const REENVIO_BOLETO_ATIVO = 'ipgbase/reenvio_boleto/ativa';
31
+ const REENVIO_BOLETO_NUMERO_DIAS = 'ipgbase/reenvio_boleto/numero_dias';
32
+
33
+ //Controle do envio de e-mails
34
+ const CONTROLE_ENVIO_EMAIL_NOVO = 'ipgbase/controle_envio_email/novo';
35
+ const CONTROLE_ENVIO_EMAIL_CANCELADO = 'ipgbase/controle_envio_email/cancelado';
36
+ const CONTROLE_ENVIO_EMAIL_FATURA_GERADA = 'ipgbase/controle_envio_email/fatura_gerada';
37
+
38
+ }
app/code/local/Ipagare/IpgBase/Date.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Date {
16
+
17
+ protected $day;
18
+ protected $month;
19
+ protected $year;
20
+ protected $hour;
21
+ protected $minute;
22
+ protected $second;
23
+
24
+ public function __construct($day, $month, $year, $hour, $minute, $second) {
25
+ $this->day = $day;
26
+ $this->month = $month;
27
+ $this->year = $year;
28
+ $this->hour = $hour;
29
+ $this->minute = $minute;
30
+ $this->second = $second;
31
+ }
32
+
33
+ public static function getInstanceFormatoAmericano($date){
34
+ $ano = substr($date, 0, 4);
35
+ $mes = substr($date, 5, 2);
36
+ $dia = substr($date, 8, 2);
37
+ $hora = substr($date, 11, 2);
38
+ $minuto = substr($date, 14, 2);
39
+ $segundo = substr($date, 17, 2);
40
+
41
+ if(Ipagare_IpgBase_Helper_StringUtils::isEmpty($hora)){
42
+ $hora = 0;
43
+ }
44
+ if(Ipagare_IpgBase_Helper_StringUtils::isEmpty($minuto)){
45
+ $minuto = 0;
46
+ }
47
+ if(Ipagare_IpgBase_Helper_StringUtils::isEmpty($segundo)){
48
+ $segundo = 0;
49
+ }
50
+
51
+ return new Ipagare_IpgBase_Date($dia, $mes, $ano, $hora, $minuto, $segundo);
52
+ }
53
+
54
+ public function setDay($day) {
55
+ $this->day = $day;
56
+ }
57
+
58
+ public function getDay() {
59
+ return $this->day;
60
+ }
61
+
62
+ public function setMonth($month) {
63
+ $this->month = $month;
64
+ }
65
+
66
+ public function getMonth() {
67
+ return $this->month;
68
+ }
69
+
70
+ public function setYear($year) {
71
+ $this->year = $year;
72
+ }
73
+
74
+ public function getYear() {
75
+ return $this->year;
76
+ }
77
+
78
+ public function setHour($hour) {
79
+ $this->hour = $hour;
80
+ }
81
+
82
+ public function getHour() {
83
+ return $this->hour;
84
+ }
85
+
86
+ public function setMinute($minute) {
87
+ $this->minute = $minute;
88
+ }
89
+
90
+ public function getMinute() {
91
+ return $this->minute;
92
+ }
93
+
94
+ public function setSecond($second) {
95
+ $this->second = $second;
96
+ }
97
+
98
+ public function getSecond() {
99
+ return $this->second;
100
+ }
101
+ }
102
+
103
+ ?>
app/code/local/Ipagare/IpgBase/Helper/Boleto.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Helper_Boleto extends Mage_Core_Helper_Abstract {
16
+
17
+ function feriados($ano, $posicao) {
18
+ $dia = 86400;
19
+ $datas = array();
20
+ $datas['pascoa'] = easter_date($ano);
21
+ $datas['sexta_santa'] = $datas['pascoa'] - (2 * $dia);
22
+ $datas['carnaval'] = $datas['pascoa'] - (47 * $dia);
23
+ $datas['corpus_christi'] = $datas['pascoa'] + (60 * $dia);
24
+ $feriados = array(
25
+ '01/01',
26
+ date('d/m', $datas['carnaval']),
27
+ date('d/m', $datas['sexta_santa']),
28
+ date('d/m', $datas['pascoa']),
29
+ '21/04',
30
+ '01/05',
31
+ date('d/m', $datas['corpus_christi']),
32
+ '12/10',
33
+ '02/11',
34
+ '15/11',
35
+ '25/12'
36
+ );
37
+ return $feriados[$posicao] . "/" . $ano;
38
+ }
39
+
40
+ //FORMATA COMO TIMESTAMP
41
+ function dataToTimestamp($data) {
42
+ $ano = substr($data, 6, 4);
43
+ $mes = substr($data, 3, 2);
44
+ $dia = substr($data, 0, 2);
45
+ return mktime(0, 0, 0, $mes, $dia, $ano);
46
+ }
47
+
48
+ function soma1dia($data) {
49
+ $ano = substr($data, 6, 4);
50
+ $mes = substr($data, 3, 2);
51
+ $dia = substr($data, 0, 2);
52
+ return date("d/m/Y", mktime(0, 0, 0, $mes, $dia + 1, $ano));
53
+ }
54
+
55
+ function somaDiasUteis($xDataInicial, $xSomarDias, $xUsaDiasUteis) {
56
+ if ($xUsaDiasUteis) {
57
+ for ($ii = 1; $ii <= $xSomarDias; $ii++) {
58
+ $xDataInicial = $this->soma1dia($xDataInicial); //SOMA DIA NORMAL
59
+ //VERIFICANDO SE EH DIA DE TRABALHO
60
+ if (date("w", $this->dataToTimestamp($xDataInicial)) == "0") {
61
+ //SE DIA FOR DOMINGO OU FERIADO, SOMA +1
62
+ $xDataInicial = $this->soma1dia($xDataInicial);
63
+ } else if (date("w", $this->dataToTimestamp($xDataInicial)) == "6") {
64
+ //SE DIA FOR SABADO, SOMA +2
65
+ $xDataInicial = $this->soma1dia($xDataInicial);
66
+ $xDataInicial = $this->soma1dia($xDataInicial);
67
+ } else {
68
+ //senao vemos se este dia eh FERIADO
69
+ for ($i = 0; $i < 11; $i++) {
70
+ if ($xDataInicial == $this->feriados(date("Y"), $i)) {
71
+ $xDataInicial = $this->soma1dia($xDataInicial);
72
+ }
73
+ }
74
+ }
75
+ }
76
+ } else {
77
+ for ($ii = 1; $ii <= $xSomarDias; $ii++) {
78
+ $xDataInicial = $this->soma1dia($xDataInicial); //SOMA DIA NORMAL
79
+ }
80
+ }
81
+ return $xDataInicial;
82
+ }
83
+
84
+ /*
85
+ * Metodo que calcula a data de expiração de um boleto
86
+ *
87
+ * @param date $validadeBoleto
88
+ * @param int $diasExpiracao
89
+ * @return date
90
+ *
91
+ */
92
+ public function calculaExpiracao($vencimentoBoleto, $diasExpiracao) {
93
+ //$dataTeste = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
94
+ //$dataAtual = Mage::getModel('core/date')->date('Y-m-d H:i:s');
95
+
96
+ $dataHoraVencimentoBoleto = new Zend_Date($vencimentoBoleto);
97
+ $dataHoraVencimentoBoleto->setHour(23);
98
+ $dataHoraVencimentoBoleto->setMinute(59);
99
+ $dataHoraVencimentoBoleto->setSecond(59);
100
+ $dataHoraVencimentoBoleto = $dataHoraVencimentoBoleto->get('yyyy-MM-dd HH:mm:ss');
101
+
102
+ //Ipagare_IpgBase_Helper_LogUtils::varDump($dataAtual);
103
+ //$soma = ($validade + $diasUteis);
104
+ //$dataVencimentoBoleto = Mage::helper('ipgbase/date')->addDaysToUs($soma, $dataAtual);
105
+
106
+ return Mage::helper('ipgbase/date')->addDaysToUs($diasExpiracao, $dataHoraVencimentoBoleto);
107
+ }
108
+
109
+ }
app/code/local/Ipagare/IpgBase/Helper/Data.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Helper_Data extends Mage_Core_Helper_Abstract {
16
+
17
+ /**
18
+ * Verifica se o método de pagamento consta na lista de Payment Methods desenvolvidos pelo iPAGARE.
19
+ *
20
+ * @return type boolean
21
+ */
22
+ public function isIpagarePaymentMethod($paymentMethodCode) {
23
+ return in_array($paymentMethodCode, Ipagare_IpgBase_Config::listPaymentMethods());
24
+ }
25
+
26
+ /**
27
+ * Retorna a lista com os métodos de pagamentos
28
+ *
29
+ * @return type array
30
+ */
31
+ public function listPaymentMethods() {
32
+ return Ipagare_IpgBase_Config::listPaymentMethods();
33
+ }
34
+
35
+ public function isOscCssEnabled() {
36
+ return Mage::getStoreConfig(Ipagare_IpgBase_ConfiguracoesSystem::OSC_CSS_ACTIVE);
37
+ }
38
+
39
+ public function canSendEmail(Mage_Sales_Model_Order $order) {
40
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_CANCELED) {
41
+ if (Mage::getStoreConfig(Ipagare_IpgBase_ConfiguracoesSystem::CONTROLE_ENVIO_EMAIL_CANCELADO)) {
42
+ return true;
43
+ }
44
+ }
45
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
46
+ if (Mage::getStoreConfig(Ipagare_IpgBase_ConfiguracoesSystem::CONTROLE_ENVIO_EMAIL_NOVO)) {
47
+ return true;
48
+ }
49
+ }
50
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING || $order->getState() == Mage_Sales_Model_Order::STATE_COMPLETE) {
51
+ if (Mage::getStoreConfig(Ipagare_IpgBase_ConfiguracoesSystem::CONTROLE_ENVIO_EMAIL_FATURA_GERADA)) {
52
+ return true;
53
+ }
54
+ }
55
+ return false;
56
+ }
57
+
58
+ public function isUrlTelevendas() {
59
+ $currentUrl = Mage::helper('core/url')->getCurrentUrl();
60
+ if (preg_match('/ipgtelevendas/', $currentUrl)) {
61
+ return true;
62
+ }
63
+ return false;
64
+ }
65
+
66
+ public function addStatusHistoryComment($order, $message, $notified = false) {
67
+ $order->addStatusHistoryComment($message, false)->setIsCustomerNotified($notified);
68
+ $order->save();
69
+ }
70
+
71
+ public function getStoreConfig($value, $store = null) {
72
+ return trim(Mage::getStoreConfig($value, $store));
73
+ }
74
+
75
+ public function getPaymentMethodCode() {
76
+ $order = Mage::helper('ipgbase/session')->getCurrentOrder();
77
+ $payment = $order->getPayment();
78
+ return $payment->getMethodInstance()->getCode();
79
+ }
80
+
81
+ /**
82
+ * Retorna apenas os números.
83
+ *
84
+ */
85
+ public function getOnlyNumbers($entry) {
86
+ return preg_replace('/\D/', '', $entry);
87
+ }
88
+
89
+ }
app/code/local/Ipagare/IpgBase/Helper/Date.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Helper_Date extends Mage_Core_Helper_Abstract {
16
+
17
+ private $logger;
18
+
19
+ /**
20
+ * Initialize resource model
21
+ */
22
+ protected function _construct() {
23
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
24
+ }
25
+
26
+ public function addMinutes($minutesToAdd) {
27
+ return gmdate("Y-m-d H:i:s", mktime(date("H"), date("i") + $minutesToAdd, date("s"), date("m"), date("d"), date("Y")));
28
+ }
29
+
30
+ public function addMinutesToUs($minutesToAdd, $dataInicial = null) {
31
+ if ($dataInicial == null) {
32
+ $dataInicial = Mage::getModel('core/date')->date('Y-m-d H:i:s');
33
+ }
34
+ $data = Ipagare_IpgBase_Date::getInstanceFormatoAmericano($dataInicial);
35
+
36
+ return gmdate("Y-m-d H:i:s", mktime($data->getHour(), $data->getMinute() + $minutesToAdd, $data->getSecond(), $data->getMonth(), $data->getDay(), $data->getYear()));
37
+ }
38
+
39
+ public function addHours($hoursToAdd) {
40
+ return gmdate("Y-m-d H:i:s", mktime(date("H") + $hoursToAdd, date("i"), date("s"), date("m"), date("d"), date("Y")));
41
+ }
42
+
43
+ public function addHoursToUs($hoursToAdd, $dataInicial) {
44
+ if ($dataInicial == null) {
45
+ $dataInicial = Mage::getModel('core/date')->date('Y-m-d H:i:s');
46
+ }
47
+
48
+ $data = Ipagare_IpgBase_Date::getInstanceFormatoAmericano($dataInicial);
49
+
50
+ return gmdate("Y-m-d H:i:s", mktime($data->getHour() + $hoursToAdd, $data->getMinute(), $data->getSecond(), $data->getMonth(), $data->getDay(), $data->getYear()));
51
+ }
52
+
53
+ public function addDays($daysToAdd, $dataInicial) {
54
+ if ($dataInicial == null) {
55
+ // FIXME: o formato da data deve ser Y-m-d H:i:s
56
+ $dataInicial = Mage::getModel('core/date')->date('d/m/Y H:i:s');
57
+ }
58
+ $ano = substr($dataInicial, 6, 4);
59
+ $mes = substr($dataInicial, 3, 2);
60
+ $dia = substr($dataInicial, 0, 2);
61
+ $hora = substr($dataInicial, 11, 2);
62
+ $minuto = substr($dataInicial, 14, 2);
63
+ $segundo = substr($dataInicial, 17, 2);
64
+
65
+ return gmdate("Y-m-d H:i:s", mktime($hora, $minuto, $segundo, $mes, $dia + $daysToAdd, $ano));
66
+ }
67
+
68
+ /**
69
+ * Adiciona dias em uma data para formato Americano.
70
+ *
71
+ * @param type $daysToAdd
72
+ * @param type $dataInicial
73
+ * @return type
74
+ */
75
+ public function addDaysToUs($daysToAdd, $dataInicial) {
76
+ if ($dataInicial == null) {
77
+ $dataInicial = Mage::getModel('core/date')->date('Y-m-d H:i:s');
78
+ }
79
+ $data = Ipagare_IpgBase_Date::getInstanceFormatoAmericano($dataInicial);
80
+
81
+ return gmdate("Y-m-d H:i:s", mktime($data->getHour(), $data->getMinute(), $data->getSecond(), $data->getMonth(), $data->getDay() + $daysToAdd, $data->getYear()));
82
+ }
83
+
84
+ public function isUsDateBeforeToday($date) {
85
+ if ($date == null) {
86
+ return false;
87
+ }
88
+
89
+ $ano = substr($date, 0, 4);
90
+ $mes = substr($date, 5, 2);
91
+ $dia = substr($date, 8, 2);
92
+ $hora = substr($date, 11, 2);
93
+ $minuto = substr($date, 14, 2);
94
+ $segundo = substr($date, 17, 2);
95
+
96
+ $date = mktime($hora, $minuto, $segundo, $mes, $dia, $ano);
97
+ $agora = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
98
+
99
+ if ($date < $agora) {
100
+ return true;
101
+ }
102
+ return false;
103
+ }
104
+
105
+ public function isDateBeforeAnother($date, $anotherDate) {
106
+ if ($date == null || $anotherDate == null) {
107
+ return false;
108
+ }
109
+
110
+ $ano = substr($date, 0, 4);
111
+ $mes = substr($date, 5, 2);
112
+ $dia = substr($date, 8, 2);
113
+ $hora = substr($date, 11, 2);
114
+ $minuto = substr($date, 14, 2);
115
+ $segundo = substr($date, 17, 2);
116
+ $date = mktime($hora, $minuto, $segundo, $mes, $dia, $ano);
117
+
118
+ $ano = substr($anotherDate, 0, 4);
119
+ $mes = substr($anotherDate, 5, 2);
120
+ $dia = substr($anotherDate, 8, 2);
121
+ $hora = substr($anotherDate, 11, 2);
122
+ $minuto = substr($anotherDate, 14, 2);
123
+ $segundo = substr($anotherDate, 17, 2);
124
+ $anotherDate = mktime($hora, $minuto, $segundo, $mes, $dia, $ano);
125
+
126
+ if ($date < $anotherDate) {
127
+ return true;
128
+ }
129
+
130
+ return false;
131
+ }
132
+
133
+ /**
134
+ * Converte data no formato 00/00/0000 00:00:00 (dd/mm/yyyy HH:MM:SS)
135
+ *
136
+ * @param type $data
137
+ * @return type
138
+ */
139
+ public function convertDateToBr($data) {
140
+ return implode(!strstr($data, '/') ? "/" : "-", array_reverse(explode(!strstr($data, '/') ? "-" : "/", $data)));
141
+ }
142
+
143
+ public function isBrValidDate($data) {
144
+ $data = split("[-,/]", $data);
145
+ if (!checkdate($data[1], $data[0], $data[2]) and !checkdate($data[1], $data[2], $data[0])) {
146
+ return false;
147
+ }
148
+
149
+ return true;
150
+ }
151
+
152
+ }
153
+
154
+ ?>
app/code/local/Ipagare/IpgBase/Helper/LogUtils.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Helper_LogUtils {
16
+
17
+ public static function varDump($variable) {
18
+ $logFile = Mage::getBaseDir('var') . DS . 'log' . DS . Mage::getStoreConfig('dev/log/file');
19
+ ob_start();
20
+ // write content
21
+ if (is_object($variable)) {
22
+ //new Ipagare_Print($variable);
23
+ var_dump($variable);
24
+ } else {
25
+ var_dump($variable);
26
+ }
27
+ $content = ob_get_contents();
28
+ ob_end_clean();
29
+ file_put_contents($logFile, $content, FILE_APPEND);
30
+ }
31
+
32
+ }
33
+
34
+ class Ipagare_Print {
35
+
36
+ public function __construct($class) {
37
+ $api = new ReflectionClass($class);
38
+
39
+ foreach ($api->getProperties() as $propertie) {
40
+ print $propertie->getName() . "\n";
41
+ print $propertie->getValue($class);
42
+ }
43
+
44
+
45
+ }
46
+
47
+
48
+
49
+ }
app/code/local/Ipagare/IpgBase/Helper/Math.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Helper_Math extends Mage_Core_Helper_Abstract {
16
+
17
+ /**
18
+ * Returns the first found number from an string
19
+ * Parsing depends on given locale (grouping and decimal)
20
+ *
21
+ * Examples for input:
22
+ * ' 2345.4356,1234' = 23455456.1234
23
+ * '+23,3452.123' = 233452.123
24
+ * ' 12343 ' = 12343
25
+ * '-9456km' = -9456
26
+ * '0' = 0
27
+ * '2 054,10' = 2054.1
28
+ * '2'054.52' = 2054.52
29
+ * '2,46 GB' = 2.46
30
+ *
31
+ * @param string|int $value
32
+ * @return float
33
+ */
34
+ public static function formatPriceToUS($value) {
35
+ if (is_null($value)) {
36
+ return null;
37
+ }
38
+ if (!is_string($value)) {
39
+ return floatval($value);
40
+ }
41
+
42
+ //trim space and apos
43
+ $value = str_replace('\'', '', $value);
44
+ $value = str_replace(' ', '', $value);
45
+
46
+ $separatorComa = strpos($value, ',');
47
+ $separatorDot = strpos($value, '.');
48
+
49
+ if ($separatorComa !== false && $separatorDot !== false) {
50
+ if ($separatorComa > $separatorDot) {
51
+ $value = str_replace('.', '', $value);
52
+ $value = str_replace(',', '.', $value);
53
+ } else {
54
+ $value = str_replace(',', '', $value);
55
+ }
56
+ } elseif ($separatorComa !== false) {
57
+ $value = str_replace(',', '.', $value);
58
+ }
59
+
60
+ return floatval($value);
61
+ }
62
+
63
+ }
app/code/local/Ipagare/IpgBase/Helper/Module.php ADDED
@@ -0,0 +1,394 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ final class Ipagare_IpgBase_Helper_Module extends Mage_Core_Helper_Abstract {
16
+
17
+ /**
18
+ * Verifica se o módulo Core existe.
19
+ *
20
+ * @return type
21
+ */
22
+ public static function isCoreExists() {
23
+ error_reporting(0);
24
+ $exists = class_exists('Ipagare_IpgCore_Helper_Module');
25
+ error_reporting(1);
26
+
27
+ return $exists;
28
+ }
29
+
30
+ /**
31
+ * Verifica se o módulo Cielo existe.
32
+ *
33
+ * @return type
34
+ */
35
+ public static function isCieloExists() {
36
+ error_reporting(0);
37
+ $exists = class_exists('Ipagare_IpgCielo_Helper_Module');
38
+ error_reporting(1);
39
+
40
+ return $exists;
41
+ }
42
+
43
+ /**
44
+ * Verifica se o módulo Boleto existe.
45
+ *
46
+ * @return type
47
+ */
48
+ public static function isBoletoExists() {
49
+ error_reporting(0);
50
+ $exists = class_exists('Ipagare_IpgBoleto_Helper_Module');
51
+ error_reporting(1);
52
+
53
+ return $exists;
54
+ }
55
+
56
+ /**
57
+ * Verifica se o módulo ClearSale existe.
58
+ *
59
+ * @return type
60
+ */
61
+ public static function isClearSaleExists() {
62
+ error_reporting(0);
63
+ $exists = class_exists('Ipagare_IpgClearSale_Helper_Module');
64
+ error_reporting(1);
65
+
66
+ return $exists;
67
+ }
68
+
69
+ /**
70
+ * Verifica se o módulo Redecard existe.
71
+ *
72
+ * @return type
73
+ */
74
+ public static function isRedecardExists() {
75
+ error_reporting(0);
76
+ $exists = class_exists('Ipagare_IpgRedecard_Helper_Module');
77
+ error_reporting(1);
78
+
79
+ return $exists;
80
+ }
81
+
82
+ /**
83
+ * Verifica se o módulo Amex existe.
84
+ *
85
+ * @return type
86
+ */
87
+ public static function isAmexExists() {
88
+ error_reporting(0);
89
+ $exists = class_exists('Ipagare_IpgAmex_Helper_Module');
90
+ error_reporting(1);
91
+
92
+ return $exists;
93
+ }
94
+
95
+ /**
96
+ * Verifica se o módulo Itau ShoLine existe.
97
+ *
98
+ * @return type
99
+ */
100
+ public static function isItauShoplineExists() {
101
+ error_reporting(0);
102
+ $exists = class_exists('Ipagare_IpgItauShopline_Helper_Module');
103
+ error_reporting(1);
104
+
105
+ return $exists;
106
+ }
107
+
108
+ /**
109
+ * Verifica se o módulo Bradesco existe.
110
+ *
111
+ * @return type
112
+ */
113
+ public static function isBradescoExists() {
114
+ error_reporting(0);
115
+ $exists = class_exists('Ipagare_IpgBradesco_Helper_Module');
116
+ error_reporting(1);
117
+
118
+ return $exists;
119
+ }
120
+
121
+ /**
122
+ * Verifica se o módulo Branco Brasil existe.
123
+ *
124
+ * @return type
125
+ */
126
+ public static function isBancoBrasilExists() {
127
+ error_reporting(0);
128
+ $exists = class_exists('Ipagare_IpgBancoBrasil_Helper_Module');
129
+ error_reporting(1);
130
+
131
+ return $exists;
132
+ }
133
+
134
+ /**
135
+ * Verifica se o módulo ClearSale existe.
136
+ *
137
+ * @return type
138
+ */
139
+ public static function isClearSaleWebServiceExists() {
140
+ error_reporting(0);
141
+ $exists = class_exists('Ipagare_IpgClearSaleWebService_Helper_Module');
142
+ error_reporting(1);
143
+
144
+ return $exists;
145
+ }
146
+
147
+ /**
148
+ * Verifica se o módulo Televendas existe.
149
+ *
150
+ * @return type
151
+ */
152
+ public static function isTeleVendasExists() {
153
+ error_reporting(0);
154
+ $exists = class_exists('Ipagare_IpgTeleVendas_Helper_Module');
155
+ error_reporting(1);
156
+
157
+ return $exists;
158
+ }
159
+
160
+ /**
161
+ * Verifica se o módulo Moip existe.
162
+ *
163
+ * @return type
164
+ */
165
+ public static function isMoipExists() {
166
+ error_reporting(0);
167
+ $exists = class_exists('Ipagare_IpgMoip_Helper_Module');
168
+ error_reporting(1);
169
+
170
+ return $exists;
171
+ }
172
+
173
+ /**
174
+ * Verifica se o módulo Pagamento Digital existe.
175
+ *
176
+ * @return type
177
+ */
178
+ public static function isPagamentoDigitalExists() {
179
+ error_reporting(0);
180
+ $exists = class_exists('Ipagare_IpgPagamentoDigital_Helper_Module');
181
+ error_reporting(1);
182
+
183
+ return $exists;
184
+ }
185
+
186
+ /**
187
+ * Verifica se o módulo PagSeguro existe.
188
+ *
189
+ * @return type
190
+ */
191
+ public static function isPagSeguroExists() {
192
+ error_reporting(0);
193
+ $exists = class_exists('Ipagare_IpgPagSeguro_Helper_Module');
194
+ error_reporting(1);
195
+
196
+ return $exists;
197
+ }
198
+ /**
199
+ * Verifica se o módulo PagSeguro Lightbox existe.
200
+ *
201
+ * @return type
202
+ */
203
+ public static function isPagSeguroLightboxExists() {
204
+ error_reporting(0);
205
+ $exists = class_exists('Ipagare_IpgPagSeguroLightbox_Helper_Module');
206
+ error_reporting(1);
207
+
208
+ return $exists;
209
+ }
210
+
211
+ /**
212
+ * Verifica se o módulo PagSeguro Direto existe.
213
+ *
214
+ * @return type
215
+ */
216
+ public static function isPagSeguroDiretoExists() {
217
+ error_reporting(0);
218
+ $exists = class_exists('Ipagare_IpgPagSeguroDireto_Helper_Module');
219
+ error_reporting(1);
220
+
221
+ return $exists;
222
+ }
223
+
224
+ /**
225
+ * Verifica se o módulo CobreBemAprovaFacil existe.
226
+ *
227
+ * @return type
228
+ */
229
+ public static function isCobreBemAprovaFacilExists() {
230
+ error_reporting(0);
231
+ $exists = class_exists('Ipagare_IpgCobreBemAprovaFacil_Helper_Module');
232
+ error_reporting(1);
233
+
234
+ return $exists;
235
+ }
236
+
237
+ /**
238
+ * Verifica se o módulo ClearSale existe.
239
+ *
240
+ * @return type
241
+ */
242
+ public static function isClearSaleStartExists() {
243
+ error_reporting(0);
244
+ $exists = class_exists('Ipagare_IpgClearSaleStart_Helper_Module');
245
+ error_reporting(1);
246
+
247
+ return $exists;
248
+ }
249
+
250
+ /**
251
+ * Verifica se o módulo Boleto existe e está ativo.
252
+ *
253
+ * @return type
254
+ */
255
+ public function isBoletoExistsAndActive() {
256
+ return $this->isBoletoExists() && Mage::helper('ipgboleto')->isModuleActive();
257
+ }
258
+
259
+ /**
260
+ * Verifica se o módulo Cielo existe e está ativo.
261
+ *
262
+ * @return type
263
+ */
264
+ public function isCieloExistsAndActive() {
265
+ return $this->isCieloExists() && Mage::helper('ipgcielo')->isModuleActive();
266
+ }
267
+
268
+ /**
269
+ * Verifica se o módulo ClearSale existe e está ativo.
270
+ *
271
+ * @return type
272
+ */
273
+ public function isClearSaleExistsAndActive() {
274
+ return $this->isClearSaleExists() && Mage::helper('ipgclearsale')->isModuleActive();
275
+ }
276
+
277
+ /**
278
+ * Verifica se o módulo Redecard existe e está ativo.
279
+ *
280
+ * @return type
281
+ */
282
+ public function isRedecardExistsAndActive() {
283
+ return $this->isRedecardExists() && Mage::helper('ipgredecard')->isModuleActive();
284
+ }
285
+
286
+ /**
287
+ * Verifica se o módulo Amex existe e está ativo.
288
+ *
289
+ * @return type
290
+ */
291
+ public function isAmexExistsAndActive() {
292
+ return $this->isAmexExists() && Mage::helper('ipgamex')->isModuleActive();
293
+ }
294
+
295
+ /**
296
+ * Verifica se o módulo Itau ShoLine existe e está ativo.
297
+ *
298
+ * @return type
299
+ */
300
+ public function isItauShoplineExistsAndActive() {
301
+ return $this->isItauShoplineExists() && Mage::helper('ipgitaushopline')->isModuleActive();
302
+ }
303
+
304
+ /**
305
+ * Verifica se o módulo Bradesco existe e está ativo.
306
+ *
307
+ * @return type
308
+ */
309
+ public function isBradescoExistsAndActive() {
310
+ return $this->isBradescoExists() && Mage::helper('ipgbradesco')->isModuleActive();
311
+ }
312
+
313
+ /**
314
+ * Verifica se o módulo Branco Brasil existe e está ativo.
315
+ *
316
+ * @return type
317
+ */
318
+ public function isBancoBrasilExistsAndActive() {
319
+ return $this->isBancoBrasilExists() && Mage::helper('ipgbancobrasil')->isModuleActive();
320
+ }
321
+
322
+ /**
323
+ * Verifica se o módulo ClearSaleWebService existe e está ativo.
324
+ *
325
+ * @return type
326
+ */
327
+ public function isClearSaleWebServiceExistsAndActive() {
328
+ return $this->isClearSaleWebServiceExists() && Mage::helper('ipgclearsalewebservice')->isModuleActive();
329
+ }
330
+
331
+ /**
332
+ * Verifica se o módulo Moip existe e está ativo.
333
+ *
334
+ * @return type
335
+ */
336
+ public function isMoipExistsAndActive() {
337
+ return $this->isMoipExists() && Mage::helper('ipgmoip')->isModuleActive();
338
+ }
339
+
340
+ /**
341
+ * Verifica se o módulo Pagamento Digital existe e está ativo.
342
+ *
343
+ * @return type
344
+ */
345
+ public function isPagamentoDigitalExistsAndActive() {
346
+ return $this->isPagamentoDigitalExists() && Mage::helper('ipgpagamentodigital')->isModuleActive();
347
+ }
348
+
349
+ /**
350
+ * Verifica se o módulo PagSeguro existe e está ativo.
351
+ *
352
+ * @return type
353
+ */
354
+ public function isPagSeguroExistsAndActive() {
355
+ return $this->isPagSeguroExists() && Mage::helper('ipgpagseguro')->isModuleActive();
356
+ }
357
+ /**
358
+ * Verifica se o módulo PagSeguro Lightbox existe e está ativo.
359
+ *
360
+ * @return type
361
+ */
362
+ public function isPagSeguroLightboxExistsAndActive() {
363
+ return $this->isPagSeguroLightboxExists() && Mage::helper('ipgpagsegurolightbox')->isModuleActive();
364
+ }
365
+
366
+ /**
367
+ * Verifica se o módulo PagSeguro Direto existe e está ativo.
368
+ *
369
+ * @return type
370
+ */
371
+ public function isPagSeguroDiretoExistsAndActive() {
372
+ return $this->isPagSeguroDiretoExists() && Mage::helper('ipgpagsegurodireto')->isModuleActive();
373
+ }
374
+
375
+
376
+ /**
377
+ * Verifica se o módulo Pagamento Digital existe e está ativo.
378
+ *
379
+ * @return type
380
+ */
381
+ public function isCobreBemAprovaFacilExistsAndActive() {
382
+ return $this->isCobreBemAprovaFacilExists() && Mage::helper('ipgcobrebemaprovafacil')->isModuleActive();
383
+ }
384
+
385
+
386
+ /**
387
+ * Verifica se o módulo ClearSale Start existe e está ativo.
388
+ *
389
+ * @return type
390
+ */
391
+ public function isClearSaleStartExistsAndActive() {
392
+ return $this->isClearSaleStartExists() && Mage::helper('ipgclearsalestart')->isModuleActive();
393
+ }
394
+ }
app/code/local/Ipagare/IpgBase/Helper/OneStepCheckout.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Helper_OneStepCheckout extends Mage_Core_Helper_Abstract {
16
+
17
+ private $logger;
18
+
19
+ /**
20
+ * Initialize resource model
21
+ */
22
+ protected function _construct() {
23
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
24
+ }
25
+
26
+ public function getVersion() {
27
+ $version = $this->getCompleteVersion();
28
+ if (!Mage::helper('ipgbase/stringUtils')->isEmpty($version)) {
29
+ return substr($version, 0, 1);
30
+ }
31
+ return '';
32
+ }
33
+
34
+ public function getCompleteVersion() {
35
+ $resource = Mage::getSingleton('core/resource');
36
+ $conn = $resource->getConnection('core_read');
37
+ $sql = "SELECT version FROM {$resource->getTableName('core_resource')} WHERE code='onestepcheckout_setup'";
38
+ $version = $conn->fetchAll($sql);
39
+ if (!Mage::helper('ipgbase/stringUtils')->isEmpty($version[0]['version'])) {
40
+ return $version[0]['version'];
41
+ }
42
+ return null;
43
+ }
44
+
45
+ public function isActive() {
46
+ return Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links');
47
+ }
48
+
49
+ }
50
+
51
+ ?>
app/code/local/Ipagare/IpgBase/Helper/Session.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Helper_Session extends Mage_Core_Helper_Abstract {
16
+
17
+ private $logger;
18
+
19
+ /**
20
+ * Initialize resource model
21
+ */
22
+ protected function _construct() {
23
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
24
+ }
25
+
26
+ public function getCurrentOrder() {
27
+ $session = Mage::getSingleton('checkout/session');
28
+ $order = Mage::getModel('sales/order');
29
+
30
+ $sessionQuote = $session->getQuote();
31
+ $orderId = null;
32
+ if ($orderId == null || $orderId == "") {
33
+ $orderId = $sessionQuote->getReservedOrderId();
34
+ $lastRealOrderId = $session->getLastRealOrderId();
35
+ if ($lastRealOrderId != null && $lastRealOrderId != "") {
36
+ $orderId = $lastRealOrderId;
37
+ }
38
+ }
39
+
40
+ if ($orderId == null || $orderId == "") {
41
+ $order->loadByIncrementId($session->getLastRealOrderId());
42
+ } else {
43
+ $order->loadByAttribute('increment_id', $orderId);
44
+ }
45
+
46
+ return $order;
47
+ }
48
+
49
+ }
app/code/local/Ipagare/IpgBase/Helper/StringUtils.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Helper_StringUtils extends Mage_Core_Helper_Abstract {
16
+
17
+ /**
18
+ * Verifica se determinada valor é <strong>null</strong> ou <strong>vazio</strong>.
19
+ *
20
+ * @param type $str
21
+ * @return type
22
+ */
23
+ public static function isEmpty($str) {
24
+ if ($str == null) {
25
+ return true;
26
+ }
27
+ if (trim($str) == '') {
28
+ return true;
29
+ }
30
+ return false;
31
+ }
32
+
33
+ public static function removeParentheses($str) {
34
+ if (self::isEmpty($str)) {
35
+ return $str;
36
+ }
37
+ $str = str_ireplace('(', '', $str);
38
+ $str = str_ireplace(')', '', $str);
39
+ return $str;
40
+ }
41
+ }
app/code/local/Ipagare/IpgBase/Helper/TokenProcessor.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Helper_TokenProcessor extends Mage_Core_Helper_Abstract {
16
+
17
+ /**
18
+ * The timestamp used most recently to generate a token value.
19
+ */
20
+ private $previous;
21
+
22
+ public function isTokenValid($request, $reset = false) {
23
+ // Retrieve the current session for this request
24
+ $saved = (string) Mage::getSingleton('ipgbase/session')->getIpagareTimestamp();
25
+
26
+ if ($saved == null || $saved == '') {
27
+ return false;
28
+ }
29
+
30
+ if ($reset) {
31
+ $this->resetToken();
32
+ }
33
+
34
+ // Retrieve the transaction token included in this request
35
+ $token = $request['ipagare_timestamp'];
36
+
37
+ if (Mage::helper('ipgbase/stringUtils')->isEmpty($token)) {
38
+ return false;
39
+ }
40
+
41
+ return ($saved == $token);
42
+ }
43
+
44
+ /**
45
+ * Reset the saved transaction token in the user's session. This
46
+ * indicates that transactional token checking will not be needed on the
47
+ * next request that is submitted.
48
+ *
49
+ * @param request The servlet request we are processing
50
+ */
51
+ public function resetToken() {
52
+ Mage::getSingleton('ipgbase/session')->unsIpagareTimestamp();
53
+ }
54
+
55
+ /**
56
+ * Save a new transaction token in the user's current session, creating a
57
+ * new session if necessary.
58
+ *
59
+ * @param request The servlet request we are processing
60
+ */
61
+ public function saveToken() {
62
+ $token = $this->generateToken();
63
+ if ($token != null) {
64
+ Mage::getSingleton('ipgbase/session')->setIpagareTimestamp($token);
65
+ }
66
+ return $token;
67
+ }
68
+
69
+ /**
70
+ * Generate a new transaction token, to be used for enforcing a single
71
+ * request for a particular transaction.
72
+ *
73
+ * @param id a unique Identifier for the session or other context in which
74
+ * this token is to be used.
75
+ */
76
+ public function generateToken() {
77
+ $current = time();
78
+
79
+ if ($current == $this->previous) {
80
+ $current++;
81
+ }
82
+
83
+ $this->previous = $current;
84
+
85
+ $now = md5($current);
86
+ return $now;
87
+ }
88
+
89
+ /**
90
+ * Convert a byte array to a String of hexadecimal digits and return it.
91
+ *
92
+ * @param buffer The byte array to be converted
93
+ */
94
+ // private String toHex(byte[] buffer) {
95
+ // StringBuffer sb = new StringBuffer(buffer.length * 2);
96
+ //
97
+ // for (int i = 0; i < buffer.length; i++) {
98
+ // sb.append(Character.forDigit((buffer[i] & 0xf0) >> 4, 16));
99
+ // sb.append(Character.forDigit(buffer[i] & 0x0f, 16));
100
+ // }
101
+ //
102
+ // return sb.toString();
103
+ // }
104
+ }
app/code/local/Ipagare/IpgBase/Helper/Url.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Helper_Url extends Mage_Core_Helper_Abstract {
16
+
17
+ /**
18
+ *
19
+ */
20
+ const ONE_STEP_CHECKOUT = '/onestepcheckout/';
21
+
22
+ const OPC_CHECKOUT = '/checkout/onepage/';
23
+
24
+ /**
25
+ * Checkout Venda Mais
26
+ */
27
+
28
+ const CHECKOUT_VM = '/idecheckoutvm/';
29
+
30
+ /**
31
+ *
32
+ */
33
+ const TELEVENDAS = '/ipgtelevendas/pagamento/index/';
34
+
35
+ /**
36
+ *
37
+ * @var type
38
+ */
39
+ private static $logger;
40
+
41
+ /**
42
+ * Initialize resource model
43
+ */
44
+ protected function _construct() {
45
+ }
46
+
47
+ public function isInTelevendasPayment() {
48
+ $currentUrl = Mage::helper('core/url')->getCurrentUrl();
49
+ if (strpos($currentUrl, self::TELEVENDAS)) {
50
+ return true;
51
+ }
52
+ return false;
53
+ }
54
+
55
+ public function isInOscPayment() {
56
+ $currentUrl = Mage::helper('core/url')->getCurrentUrl();
57
+ if (strpos($currentUrl, self::ONE_STEP_CHECKOUT)) {
58
+ return true;
59
+ }
60
+ return false;
61
+ }
62
+
63
+ public function isInOpcPayment() {
64
+ $currentUrl = Mage::helper('core/url')->getCurrentUrl();
65
+ if (strpos($currentUrl, self::OPC_CHECKOUT)) {
66
+ return true;
67
+ }
68
+ return false;
69
+ }
70
+
71
+ public function isInCvmPayment() {
72
+ $currentUrl = Mage::helper('core/url')->getCurrentUrl();
73
+ if (strpos($currentUrl, self::CHECKOUT_VM)) {
74
+ return true;
75
+ }
76
+ return false;
77
+ }
78
+
79
+ public function printHeaders(){
80
+ self::$logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
81
+ $sessionCore = $_SESSION['core'];
82
+ $visitorData = $sessionCore['visitor_data'];
83
+ self::$logger->info("Informacoes do cliente: \n http_user_agent= {$visitorData['http_user_agent']} \n http_accept_language = {$visitorData['http_accept_language']} \n request_uri = {$visitorData['request_uri']} \n http_referer = {$visitorData['http_referer']} \n");
84
+ }
85
+ }
app/code/local/Ipagare/IpgBase/Logger.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ define('IPG_LOGGER_LEVEL', (isset($_SERVER['MAGE_IS_DEVELOPER_MODE']) ? 'DEBUG' : 'INFO'));
16
+ define('IPG_LOGGER_FILE', Mage::getBaseDir('var') . DS . 'log' . DS . 'ipagare-%s.log');
17
+ define('IPG_LOGGER_DEFAULT_APPENDER', 'Ipagare_Log4php_Appenders_LoggerAppenderDailyFile');
18
+
19
+ class Ipagare_IpgBase_Logger extends Ipagare_Log4php_Logger {
20
+
21
+ private static $configurationFile;
22
+
23
+ private static $configured = false;
24
+
25
+ private static $appenders = array('file' => array('log4php.appender.default.Threshold' => IPG_LOGGER_LEVEL,
26
+ 'log4php.appender.default' => IPG_LOGGER_DEFAULT_APPENDER,
27
+ 'log4php.appender.default.file' => IPG_LOGGER_FILE,
28
+ 'log4php.appender.default.datePattern' => 'Ymd',
29
+ 'log4php.appender.default.layout' => 'Ipagare_Log4php_Layouts_LoggerLayoutPattern',
30
+ 'log4php.appender.default.layout.conversionPattern' => '"%d{Y-m-d H:i:s.u} %c:%L %-5p %m%n"'));
31
+
32
+ public static function getLogger($name) {
33
+ if (!self::$configured) {
34
+ self::configureLog4php();
35
+ self::$configured = true;
36
+ }
37
+ return parent::getLogger($name);
38
+ }
39
+
40
+ private static function configureLog4php() {
41
+ if (self::$configured == false) {
42
+ self::$configured = true;
43
+ self::$configurationFile = dirname(__FILE__) . DS . 'log4php-ipagare.properties';
44
+
45
+ $configutations = self::fillAllAppenders();
46
+ self::generateConfigFile($configutations);
47
+ Ipagare_Log4php_Logger::configure(self::$configurationFile);
48
+ }
49
+ }
50
+
51
+ private static function generateConfigFile($content) {
52
+ if (!file_exists(self::$configurationFile)) {
53
+ if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
54
+ chmod(self::$configurationFile, 0777);
55
+ }
56
+ $fh = fopen(self::$configurationFile, 'a', false) or die("Impossível abrir arquivo " . self::$configurationFile);
57
+ foreach ($content as $key => $value) {
58
+ fwrite($fh, $key . '=' . $value . "\n");
59
+ }
60
+ fclose($fh);
61
+ }
62
+ }
63
+
64
+ private static function fillAllAppenders() {
65
+ $configutations = array('log4php.rootLogger' => IPG_LOGGER_LEVEL . ', default');
66
+ foreach (self::$appenders as $key => $value) {
67
+ foreach ($value as $key2 => $value2) {
68
+ $configutations[$key2] = $value2;
69
+ }
70
+ }
71
+ return $configutations;
72
+ }
73
+ }
app/code/local/Ipagare/IpgBase/Model/EmailService.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Model_EmailService extends Mage_Core_Model_Abstract {
16
+
17
+ private $logger;
18
+
19
+ const IPG_BOLETO_POR_VENCER = 'IpgBoletoPorVencer';
20
+
21
+ /**
22
+ * Initialize resource model
23
+ */
24
+ protected function _construct() {
25
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
26
+ }
27
+
28
+ public function getIdTemplateEmail() {
29
+
30
+ $resource = Mage::getSingleton('core/resource');
31
+
32
+ $sql = "SELECT template_id FROM {$resource->getTableName('core_email_template')} WHERE
33
+ template_code = " . "'". self::IPG_BOLETO_POR_VENCER ."'";
34
+
35
+ $readConnection = $resource->getConnection('core_read');
36
+ $idTemplate = $readConnection->fetchOne($sql);
37
+
38
+ return $idTemplate;
39
+ }
40
+
41
+ }
app/code/local/Ipagare/IpgBase/Model/ExpiraPedido.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Model_ExpiraPedido extends Mage_Core_Model_Abstract {
16
+
17
+ private $logger;
18
+
19
+ /**
20
+ * Initialize resource model
21
+ */
22
+ protected function _construct() {
23
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
24
+ }
25
+
26
+ public function buscaPedidosParaExpirar() {
27
+ $dataInicialBuscaPedidos = $this->getDataInicial();
28
+ $dataCriacaoMaxima = $this->getDataExpiracao();
29
+ $metodosPagamento = $this->buildPaymentMethods();
30
+ $orderIds = array();
31
+ $resource = Mage::getSingleton('core/resource');
32
+
33
+ $sql = "SELECT increment_id FROM {$resource->getTableName('sales_flat_order')} o
34
+ INNER JOIN {$resource->getTableName('sales_flat_order_payment')} p ON p.parent_id=o.entity_id";
35
+ $sql .= ' WHERE o.state=\'' . Mage_Sales_Model_Order::STATE_NEW . '\'';
36
+ $sql .= ' and o.created_at BETWEEN \'' . $dataInicialBuscaPedidos . '\' and \'' . $dataCriacaoMaxima . '\'';
37
+ $sql .= ' AND (p.method = \'\' OR p.method IS NULL)';
38
+
39
+ $readConnection = $resource->getConnection('core_read');
40
+ $tmp = $readConnection->fetchAll($sql);
41
+ if (is_array($tmp)) {
42
+ $orderIds = array_merge($orderIds, $tmp);
43
+ }
44
+
45
+ // módulo Core integração direta de pagamento
46
+ if (Mage::helper('ipgbase/module')->isCoreExists()) {
47
+ $tmp = Mage::getModel('ipgcore/expiraPedido')->buscaPedidosParaExpirar($sql, $dataInicialBuscaPedidos, $dataCriacaoMaxima, $metodosPagamento);
48
+ if (is_array($tmp)) {
49
+ $orderIds = array_merge($orderIds, $tmp);
50
+ }
51
+ }
52
+
53
+ // módulo Moip
54
+ if (Mage::helper('ipgbase/module')->isMoipExistsAndActive()) {
55
+ $tmp = Mage::getModel('ipgmoip/expiraPedido')->buscaPedidosParaExpirar($sql, $dataInicialBuscaPedidos, $dataCriacaoMaxima);
56
+
57
+ if (is_array($tmp)) {
58
+ $orderIds = array_merge($orderIds, $tmp);
59
+ }
60
+ }
61
+
62
+ // módulo Pagamento Digital
63
+ if (Mage::helper('ipgbase/module')->isPagamentoDigitalExistsAndActive()) {
64
+ $tmp = Mage::getModel('ipgpagamentodigital/expiraPedido')->buscaPedidosParaExpirar($sql, $dataInicialBuscaPedidos, $dataCriacaoMaxima);
65
+
66
+ if (is_array($tmp)) {
67
+ $orderIds = array_merge($orderIds, $tmp);
68
+ }
69
+ }
70
+
71
+ // módulo PagSeguro
72
+ if (Mage::helper('ipgbase/module')->isPagSeguroExistsAndActive()) {
73
+ $tmp = Mage::getModel('ipgpagseguro/expiraPedido')->buscaPedidosParaExpirar($sql, $dataInicialBuscaPedidos, $dataCriacaoMaxima);
74
+ if (is_array($tmp)) {
75
+ $orderIds = array_merge($orderIds, $tmp);
76
+ }
77
+ }
78
+
79
+ // módulo IpgCobreBemAprovaFacil
80
+ if (Mage::helper('ipgbase/module')->isCobreBemAprovaFacilExistsAndActive()) {
81
+ $tmp = Mage::getModel('ipgcobrebemaprovafacil/expiraPedido')->buscaPedidosParaExpirar($sql, $dataInicialBuscaPedidos, $dataCriacaoMaxima);
82
+ if (is_array($tmp)) {
83
+ $orderIds = array_merge($orderIds, $tmp);
84
+ }
85
+ }
86
+
87
+ // módulo IpgPagSeguroLightbox
88
+ if (Mage::helper('ipgbase/module')->isPagSeguroLightboxExistsAndActive()) {
89
+ $tmp = Mage::getModel('ipgpagsegurolightbox/expiraPedido')->buscaPedidosParaExpirar($sql, $dataInicialBuscaPedidos, $dataCriacaoMaxima);
90
+ if (is_array($tmp)) {
91
+ $orderIds = array_merge($orderIds, $tmp);
92
+ }
93
+ }
94
+
95
+ // módulo IpgPagSeguroDireto
96
+ if (Mage::helper('ipgbase/module')->isPagSeguroDiretoExistsAndActive()) {
97
+ $tmp = Mage::getModel('ipgpagsegurodireto/expiraPedido')->buscaPedidosParaExpirar($dataInicialBuscaPedidos, $dataCriacaoMaxima);
98
+ if (is_array($tmp)) {
99
+ $orderIds = array_merge($orderIds, $tmp);
100
+ }
101
+ }
102
+
103
+ return $orderIds;
104
+ }
105
+
106
+ public function cancelaPedido(Mage_Sales_Model_Order $order) {
107
+ $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
108
+ $listPaymentMethodsIpagare = Mage::helper('ipgbase')->listPaymentMethods();
109
+ $this->logger->info('Processando cancelamento do pedido ' . $order->getRealOrderId() . ', do modulo: ' . $paymentMethod);
110
+
111
+ try {
112
+ if ($order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) {
113
+ $order->cancel();
114
+
115
+ //força o cancelamento
116
+ if ($order->getStatus() != Mage_Sales_Model_Order::STATE_CANCELED) {
117
+ $order->setState(
118
+ Mage_Sales_Model_Order::STATE_CANCELED, true, Mage::helper('ipgbase')->__('Pedido cancelado'), $notified = false
119
+ );
120
+ } else {
121
+ $order->addStatusToHistory($order->getStatus(), Mage::helper('ipgbase')->__('Pedido cancelado.'));
122
+ }
123
+
124
+ if ($order->hasInvoices() != '') {
125
+ $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, Mage::helper('ipgbase')->__('O pagamento e o pedido foram cancelados, mas não foi possível retornar os produtos ao estoque pois já havia uma fatura gerada para este pedido.'), $notified = false);
126
+ }
127
+ $order->save();
128
+ }
129
+
130
+ if (Mage::helper('ipgbase')->isIpagarePaymentMethod($paymentMethod) && Mage::helper('ipgbase/module')->isCoreExists() && $paymentMethod == $listPaymentMethodsIpagare[0]) {
131
+ Mage::getModel('ipgcore/notification')->sendEmail($order);
132
+ } else if (Mage::helper('ipgbase')->isIpagarePaymentMethod($paymentMethod) && Mage::helper('ipgbase/module')->isMoipExistsAndActive() && $paymentMethod == $listPaymentMethodsIpagare[1]) {
133
+ Mage::getModel('ipgmoip/notification')->sendEmail($order);
134
+ } else if (Mage::helper('ipgbase')->isIpagarePaymentMethod($paymentMethod) && Mage::helper('ipgbase/module')->isPagamentoDigitalExistsAndActive() && $paymentMethod == $listPaymentMethodsIpagare[2]) {
135
+ Mage::getModel('ipgpagamentodigital/notification')->sendEmail($order);
136
+ } else if (Mage::helper('ipgbase')->isIpagarePaymentMethod($paymentMethod) && Mage::helper('ipgbase/module')->isPagSeguroExistsAndActive() && $paymentMethod == $listPaymentMethodsIpagare[3]) {
137
+ Mage::getModel('ipgpagseguro/notification')->sendEmail($order);
138
+ } else if (Mage::helper('ipgbase')->isIpagarePaymentMethod($paymentMethod) && Mage::helper('ipgbase/module')->isCobreBemAprovaFacilExistsAndActive() && $paymentMethod == $listPaymentMethodsIpagare[4]) {
139
+ Mage::getModel('ipgcobrebemaprovafacil/notification')->sendEmail($order);
140
+ } else if (Mage::helper('ipgbase')->isIpagarePaymentMethod($paymentMethod) && Mage::helper('ipgbase/module')->isPagSeguroLightboxExistsAndActive() && $paymentMethod == $listPaymentMethodsIpagare[5]) {
141
+ Mage::getModel('ipgpagsegurolightbox/notification')->sendEmail($order);
142
+ } else if (Mage::helper('ipgbase')->isIpagarePaymentMethod($paymentMethod) && Mage::helper('ipgbase/module')->isPagSeguroDiretoExistsAndActive() && $paymentMethod == $listPaymentMethodsIpagare[6]) {
143
+ Mage::getModel('ipgpagsegurodireto/notification')->sendEmail($order);
144
+ }
145
+ } catch (Exception $e) {
146
+ $this->logger->error("Erro ao cancelar pedido $orderId \n $e->__toString()");
147
+ }
148
+
149
+ $this->logger->info('Cancelamento do pedido foi concluido ' . $order->getRealOrderId() . ', do modulo: ' . $paymentMethod);
150
+
151
+ return;
152
+ }
153
+
154
+ public function isExpiracaoAtiva() {
155
+ return Mage::getStoreConfig(Ipagare_IpgBase_ConfiguracoesSystem::EXPIRACAO_PEDIDO_ACTIVE);
156
+ }
157
+
158
+ private function getDataInicial() {
159
+ return Mage::helper('ipgbase/date')->convertDateToBr(Mage::getStoreConfig(Ipagare_IpgBase_ConfiguracoesSystem::EXPIRACAO_PEDIDO_DATA_INICIAL));
160
+ }
161
+
162
+ public function getDataExpiracao() {
163
+ $dias = Mage::getStoreConfig(Ipagare_IpgBase_ConfiguracoesSystem::EXPIRACAO_PEDIDO_PERIODO_DIAS);
164
+ $horas = Mage::getStoreConfig(Ipagare_IpgBase_ConfiguracoesSystem::EXPIRACAO_PEDIDO_PERIODO_HORAS);
165
+ $minutos = Mage::getStoreConfig(Ipagare_IpgBase_ConfiguracoesSystem::EXPIRACAO_PEDIDO_PERIODO_MINUTOS);
166
+
167
+ $order = Mage::getModel('sales/order');
168
+ $data = $order->getResource()->formatDate(mktime());
169
+
170
+ $data = Mage::helper('ipgbase/date')->addMinutesToUs(-$minutos, $data);
171
+ $data = Mage::helper('ipgbase/date')->addHoursToUs(-$horas, $data);
172
+ $data = Mage::helper('ipgbase/date ')->addDaysToUs(-$dias, $data);
173
+
174
+ return $data;
175
+ }
176
+
177
+ private function buildPaymentMethods() {
178
+ $paymentMethods = Mage::helper('ipgbase')->listPaymentMethods();
179
+ $methods = '';
180
+ if ($paymentMethods != null) {
181
+ for ($i = 0; $i < sizeof($paymentMethods); $i++) {
182
+ $methods .= '\'' . $paymentMethods[$i] . '\'';
183
+ if (($i + 1) < sizeof($paymentMethods)) {
184
+ $methods .= ',';
185
+ }
186
+ }
187
+ }
188
+ return $methods;
189
+ }
190
+
191
+ }
app/code/local/Ipagare/IpgBase/Model/HttpResponse.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Model_HttpResponse extends Mage_Core_Model_Abstract {
16
+ const ERROR = 'error';
17
+
18
+ const SUCCESS = 'success';
19
+
20
+ private static $_httpErrors = array('400', '401', '402', '403', '404', '405', '406', '407', '408', '409', '410', '411', '412', '413', '414', '415', '416', '417');
21
+
22
+ private $status = 'success';
23
+
24
+ private $message;
25
+
26
+ private $httpCode;
27
+
28
+ public function __construct($data=array()) {
29
+ if (in_array($data['httpCode'], self::$_httpErrors)) {
30
+ $this->status = self::ERROR;
31
+ $this->httpCode = $data['httpCode'];
32
+ }
33
+ $this->message = $data['message'];
34
+ }
35
+
36
+ public function isError() {
37
+ return $this->status == self::ERROR;
38
+ }
39
+
40
+ public function isSuccess() {
41
+ return $this->status == self::SUCCESS;
42
+ }
43
+
44
+ public function getHttpCode() {
45
+ return $this->httpCode;
46
+ }
47
+
48
+ public function getStatus() {
49
+ return $this->status;
50
+ }
51
+
52
+ public function getMessage() {
53
+ return $this->message;
54
+ }
55
+
56
+ public function __toString() {
57
+ $buffer = __CLASS__ . '[';
58
+ $buffer = $buffer . 'status = ' . $this->status;
59
+ $buffer = $buffer . ', message = ' . $this->message;
60
+ $buffer = $buffer . ']';
61
+
62
+ return $buffer;
63
+ }
64
+
65
+ }
app/code/local/Ipagare/IpgBase/Model/Observer.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Model_Observer {
16
+
17
+ private $logger;
18
+
19
+ const ACTION_MARCAR = 'marcar';
20
+ const ACTION_CAPTURAR = 'capturar';
21
+ const ACTION_CANCELAR = 'cancelar';
22
+
23
+ /**
24
+ * Initialize resource model
25
+ */
26
+ public function __construct() {
27
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
28
+ }
29
+
30
+ public function expirapedido() {
31
+ $this->logger->info('Executando expiração automática de pedidos - início');
32
+
33
+ if (Mage::getModel('ipgbase/expiraPedido')->isExpiracaoAtiva()) {
34
+ $orderIds = Mage::getModel('ipgbase/expiraPedido')->buscaPedidosParaExpirar();
35
+ foreach ($orderIds as $key => $value) {
36
+ $order = Mage::getModel('sales/order');
37
+ $order = $order->loadByAttribute('increment_id', $value['increment_id']);
38
+ // verifica se pedido não está cancelado
39
+ if ($order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) {
40
+ $this->logger->info('Vai expirar pedido ' . $value['increment_id']);
41
+ Mage::getModel('ipgbase/expiraPedido')->cancelaPedido($order);
42
+ }
43
+ }
44
+ } else {
45
+ $this->logger->info('Expiração automática não está ativa, não irá expirar nenhum pedido.');
46
+ }
47
+
48
+ $this->logger->info('Executando expiração automática de pedidos - fim');
49
+ }
50
+
51
+ public function expiraBoletos() {
52
+ $this->logger->info('Executando expiração automática de boletos - início');
53
+
54
+ //core
55
+
56
+ if (Mage::helper('ipgbase/module')->isCoreExists()) {
57
+ $orderIds = Mage::getModel('ipgcore/expiraBoletos')->expiraBoletos();
58
+ foreach ($orderIds as $key => $value) {
59
+ $this->expirarOrder($value['order_id']);
60
+ }
61
+ }
62
+
63
+ //moip
64
+
65
+ if (Mage::helper('ipgbase/module')->isMoipExistsAndActive()) {
66
+ $realOrderIds = Mage::getModel('ipgmoip/expiraBoletos')->expiraBoletos();
67
+ foreach ($realOrderIds as $key => $value) {
68
+ $this->expirarOrder($value['real_order_id']);
69
+ }
70
+ }
71
+
72
+ //CobreBem
73
+ if (Mage::helper('ipgbase/module')->isCobreBemAprovaFacilExistsAndActive()) {
74
+ $realOrderIds = Mage::getModel('ipgcobrebemaprovafacil/expiraBoletos')->expiraBoletos();
75
+ foreach ($realOrderIds as $key => $value) {
76
+ $this->expirarOrder($value['order_increment_id']);
77
+ }
78
+ }
79
+
80
+ $this->logger->info('Executando expiração automática de boletos - fim');
81
+ }
82
+
83
+ public function expirarOrder($orderId) {
84
+ $this->logger->info('Vai expirar boleto ' . $orderId);
85
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
86
+ if ($order) {
87
+ Mage::getModel('ipgbase/expiraPedido')->cancelaPedido($order);
88
+ }
89
+ }
90
+
91
+ public function enviaEmailBoletosAvencer() {
92
+ //core
93
+ if (Mage::helper('ipgbase/module')->isCoreExists()) {
94
+ $realOrderIds = Mage::getModel('ipgcore/observer')->enviaEmailPedidoBoleto();
95
+ }
96
+
97
+ //moip
98
+ if (Mage::helper('ipgbase/module')->isMoipExistsAndActive()) {
99
+ $realOrderIds = Mage::getModel('ipgmoip/observer')->enviaEmailPedidoBoleto();
100
+ }
101
+
102
+ //cobrebem
103
+ if (Mage::helper('ipgbase/module')->isCobreBemAprovaFacilExistsAndActive()) {
104
+ $realOrderIds = Mage::getModel('ipgcobrebemaprovafacil/observer')->enviaEmailPedidoBoleto();
105
+ }
106
+ }
107
+
108
+ public function logUserAction($observer) {
109
+ $orderId = $observer->getEvent()->getOrderId();
110
+ $action = $observer->getEvent()->getAction();
111
+ $comment = '';
112
+ if (Mage::app()->getStore()->isAdmin() && Mage::getSingleton('admin/session')->getUser() != null) {
113
+ $user = Mage::getSingleton('admin/session')->getUser()->getName();
114
+ if ($action == self::ACTION_MARCAR) {
115
+ $comment = "Usuário $user marcou boleto do pedido $orderId como pago";
116
+ } elseif ($action == self::ACTION_CAPTURAR) {
117
+ $comment = "Usuário $user capturou pagamento do pedido $orderId";
118
+ } elseif ($action == self::ACTION_CANCELAR) {
119
+ $comment = "Usuário $user cancelou pagamento do pedido $orderId";
120
+ }
121
+ } else {
122
+ $comment = 'Pedido atualizado automaticamente';
123
+ }
124
+
125
+ $this->logger->info($comment);
126
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
127
+ Mage::helper('ipgbase')->addStatusHistoryComment($order, $comment);
128
+ }
129
+
130
+ public function licenseExpCheck() {
131
+ $this->logger->info('Executando verificação da licença iPAGARE - início');
132
+ if (extension_loaded('ionCube Loader')) {
133
+ $ioncubeInfo = ioncube_file_info();
134
+ if (isset($ioncubeInfo['FILE_EXPIRY'])) {
135
+ $licenseExpDay = $ioncubeInfo['FILE_EXPIRY'];
136
+ $remainingDays = abs(floor((time() - $licenseExpDay) / 86400));
137
+ if ($remainingDays == 14 || $remainingDays == 7 || $remainingDays == 1) {
138
+ if ($remainingDays == 14) {
139
+ $title = 'ATENÇÃO: A licença iPAGARE vai expirar em duas semanas! Contate nosso suporte para renovar.';
140
+ $description = 'A licença iPAGARE da sua loja vai expirar em duas semanas. Contate nosso <a href="http://ajuda.ipagare.com.br" target="_blank">suporte</a> para renovar.';
141
+ $severity = Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR;
142
+ $this->logger->info('Faltam duas semanas para a expiração da licença iPAGARE');
143
+ }
144
+ if ($remainingDays == 7) {
145
+ $title = 'ATENÇÃO: A licença iPAGARE vai expirar em uma semana! Contate nosso suporte para renovar.';
146
+ $description = 'A licença iPAGARE da sua loja vai expirar em uma semana. Contate nosso <a href="http://ajuda.ipagare.com.br" target="_blank">suporte</a> para renovar.';
147
+ $severity = Mage_AdminNotification_Model_Inbox::SEVERITY_MAJOR;
148
+ $this->logger->info('Falta uma semana para a expiração da licença iPAGARE');
149
+ }
150
+ if ($remainingDays == 1) {
151
+ $title = 'ATENÇÃO: A licença iPAGARE vai expirar amanhã! Contate nosso suporte para renovar.';
152
+ $description = 'A licença iPAGARE da sua loja vai expirar amanhã. Contate nosso <a href="http://ajuda.ipagare.com.br" target="_blank">suporte</a> para renovar.';
153
+ $severity = Mage_AdminNotification_Model_Inbox::SEVERITY_CRITICAL;
154
+ $this->logger->info('Falta 1 dia para a expiração da licença iPAGARE');
155
+ }
156
+ $inbox = Mage::getModel('adminnotification/inbox');
157
+ $url = 'http://ajuda.ipagare.com.br';
158
+ $isInternal = false;
159
+ $inbox->add($severity, $title, $description, $url, $isInternal);
160
+ }
161
+ }
162
+ }
163
+ $this->logger->info('Executando verificação da licença iPAGARE - fim');
164
+ }
165
+
166
+ }
app/code/local/Ipagare/IpgBase/Model/Session.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Model_Session extends Mage_Core_Model_Session_Abstract {
16
+
17
+ public function __construct() {
18
+ $this->init('ipgbase');
19
+ }
20
+
21
+ }
app/code/local/Ipagare/IpgBase/Model/System/Config/Source/Dias.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Model_System_Config_Source_Dias {
16
+
17
+ public function toOptionArray() {
18
+ $opcoes = array();
19
+ for ($i = 0; $i <= 99; $i++) {
20
+ $dia = str_pad($i, 2, '0', STR_PAD_LEFT);
21
+ $opcoes[$dia] = $dia;
22
+ }
23
+ return $opcoes;
24
+ }
25
+
26
+ }
app/code/local/Ipagare/IpgBase/Model/System/Config/Source/Horas.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Model_System_Config_Source_Horas {
16
+
17
+ public function toOptionArray() {
18
+ $opcoes = array();
19
+ for ($i = 0; $i <= 23; $i++) {
20
+ $hora = str_pad($i, 2, '0', STR_PAD_LEFT);
21
+ $opcoes[$hora] = $hora;
22
+ }
23
+ return $opcoes;
24
+ }
25
+
26
+ }
app/code/local/Ipagare/IpgBase/Model/System/Config/Source/Minutos.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_Model_System_Config_Source_Minutos {
16
+
17
+ public function toOptionArray() {
18
+ $opcoes = array();
19
+ for ($i = 0; $i <= 59; $i++) {
20
+ $minuto = str_pad($i, 2, '0', STR_PAD_LEFT);
21
+ $opcoes[$minuto] = $minuto;
22
+ }
23
+ return $opcoes;
24
+ }
25
+
26
+ }
app/code/local/Ipagare/IpgBase/PaymentDiscount.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_PaymentDiscount extends stdClass {
16
+
17
+ /**
18
+ *
19
+ * @var type
20
+ */
21
+ public $baseCurrencyCode;
22
+
23
+ /**
24
+ *
25
+ * @var type
26
+ */
27
+ public $totalPercent;
28
+
29
+ /**
30
+ *
31
+ * @var type
32
+ */
33
+ public $baseSubtotalWithDiscount;
34
+
35
+ /**
36
+ *
37
+ * @var type
38
+ */
39
+ public $baseTax;
40
+
41
+ public function __construct() {
42
+ $this->baseCurrencyCode = 0;
43
+ $this->totalPercent = 0;
44
+ $this->baseSubtotalWithDiscount = 0;
45
+ $this->baseTax = 0;
46
+ }
47
+
48
+ public static function getInstance($baseCurrencyCode, $totalPercent, $baseSubtotalWithDiscount, $baseTax) {
49
+ $paymentDiscount = new Ipagare_IpgBase_PaymentDiscount();
50
+ $paymentDiscount->setBaseCurrencyCode($baseCurrencyCode);
51
+ $paymentDiscount->setTotalPercent($totalPercent);
52
+ $paymentDiscount->setBaseSubtotalWithDiscount($baseSubtotalWithDiscount);
53
+ $paymentDiscount->setBaseTax($baseTax);
54
+
55
+ return $paymentDiscount;
56
+ }
57
+
58
+ public function getTotalPercent() {
59
+ return $this->totalPercent;
60
+ }
61
+
62
+ public function setTotalPercent($totalPercent) {
63
+ $this->totalPercent = $totalPercent;
64
+ }
65
+
66
+ public function getBaseCurrencyCode() {
67
+ return $this->baseCurrencyCode;
68
+ }
69
+
70
+ public function setBaseCurrencyCode($baseCurrencyCode) {
71
+ $this->baseCurrencyCode = $baseCurrencyCode;
72
+ }
73
+
74
+ public function getBaseSubtotalWithDiscount() {
75
+ return $this->baseSubtotalWithDiscount;
76
+ }
77
+
78
+ public function setBaseSubtotalWithDiscount($baseSubtotalWithDiscount) {
79
+ $this->baseSubtotalWithDiscount = $baseSubtotalWithDiscount;
80
+ }
81
+
82
+ public function getBaseTax() {
83
+ return $this->baseTax;
84
+ }
85
+
86
+ public function setBaseTax($baseTax) {
87
+ $this->baseTax = $baseTax;
88
+ }
89
+
90
+ }
app/code/local/Ipagare/IpgBase/controllers/Adminhtml/ConfigController.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once Mage::getModuleDir('controllers', 'Mage_Adminhtml') . DS . 'System' . DS . 'ConfigController.php';
3
+
4
+ class Ipagare_IpgBase_Adminhtml_ConfigController extends Mage_Adminhtml_System_ConfigController {
5
+
6
+ public function editAction() {
7
+ $this->_title($this->__('Configurações iPAGARE'));
8
+
9
+ $current = $this->getRequest()->getParam('section');
10
+ $website = $this->getRequest()->getParam('website');
11
+ $store = $this->getRequest()->getParam('store');
12
+
13
+ $configFields = Mage::getSingleton('adminhtml/config');
14
+
15
+ $sections = $configFields->getSections($current);
16
+ $section = $sections->$current;
17
+ $hasChildren = $configFields->hasChildren($section, $website, $store);
18
+ if (!$hasChildren && $current) {
19
+ $this->_redirect('*/*/', array('website' => $website, 'store' => $store));
20
+ }
21
+
22
+ $this->loadLayout();
23
+
24
+ $this->_setActiveMenu('ipagare/ipgbase');
25
+ $this->getLayout()->getBlock('menu')->setAdditionalCacheKeyInfo(array($current));
26
+
27
+ //$this->_addBreadcrumb(Mage::helper('adminhtml')->__('System'), Mage::helper('adminhtml')->__('System'), $this->getUrl('*/system'));
28
+
29
+ //$this->getLayout()->getBlock('left')->append($this->getLayout()->createBlock('adminhtml/system_config_tabs')->initTabs());
30
+
31
+ if ($this->_isSectionAllowedFlag) {
32
+ $this->_addContent($this->getLayout()->createBlock('adminhtml/system_config_edit')->initForm());
33
+
34
+ //$this->_addJs($this->getLayout()->createBlock('adminhtml/template')->setTemplate('system/shipping/ups.phtml'));
35
+ $this->_addJs($this->getLayout()->createBlock('adminhtml/template')->setTemplate('system/config/js.phtml'));
36
+ //$this->_addJs($this->getLayout()->createBlock('adminhtml/template')->setTemplate('system/shipping/applicable_country.phtml'));
37
+
38
+ $this->renderLayout();
39
+ }
40
+ }
41
+ }
app/code/local/Ipagare/IpgBase/controllers/BoletoController.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_BoletoController extends Mage_Core_Controller_Front_Action {
16
+
17
+ /**
18
+ * Instantiate config
19
+ */
20
+ protected function _construct() {
21
+ parent::_construct();
22
+ }
23
+
24
+ public function viewAction() {
25
+
26
+ $orderId = $this->getRequest()->getParam('order_id');
27
+
28
+ if (null === $orderId) {
29
+ $this->_redirect('/index');
30
+ }
31
+
32
+ $order = Mage::getSingleton('sales/order')->load(base64_decode($orderId));
33
+
34
+ if (is_null($order->getId())) {
35
+ $this->_redirect('/index');
36
+ }
37
+ $boleto = Mage::getModel('ipgcore/boleto')->view($order->getRealOrderId());
38
+ $pagamento = Mage::getModel('ipgcore/pagamento_pagamento');
39
+ $pagamento->loadByAttribute('order_id', $order->getRealOrderId());
40
+ $meioPagamento = Ipagare_IpgCore_PaymentType::valueOf($pagamento->getMeioPagamento());
41
+ if ($meioPagamento->isBradescoBoletoOnline() || $meioPagamento->isBbBoletoOnline()) {
42
+ $boleto = html_entity_decode($boleto);
43
+ }
44
+
45
+ $this->getResponse()->setBody($boleto);
46
+ }
47
+
48
+ }
app/code/local/Ipagare/IpgBase/controllers/CronController.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgBase_CronController extends Mage_Core_Controller_Front_Action {
16
+
17
+ private $logger;
18
+
19
+ /**
20
+ * Instantiate config
21
+ */
22
+ protected function _construct() {
23
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
24
+ parent::_construct();
25
+ }
26
+
27
+ public function indexAction() {
28
+ $status = 'OK';
29
+ $this->logger->info('Cron - Início');
30
+ try {
31
+ Mage::app('admin')->setUseSessionInUrl(false);
32
+ Mage::getConfig()->init()->loadEventObservers('crontab');
33
+ Mage::app()->addEventArea('crontab');
34
+ Mage::dispatchEvent('default');
35
+ } catch (Exception $e) {
36
+ $status = $e->getMessage();
37
+ $this->logger->error($e->getMessage() . "\n\n" . $e->getTraceAsString());
38
+ }
39
+ $this->logger->info('Cron - Fim');
40
+
41
+ $this->getResponse()->setBody($status);
42
+ }
43
+
44
+ }
app/code/local/Ipagare/IpgBase/etc/adminhtml.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <!--
4
+ <menu>
5
+ <ipagare translate="title">
6
+ <title>iPAGARE</title>
7
+ <sort_order>100</sort_order>
8
+ </ipagare>
9
+ </menu>
10
+ -->
11
+ <acl>
12
+ <resources>
13
+ <admin>
14
+ <children>
15
+ <system>
16
+ <children>
17
+ <config>
18
+ <children>
19
+ <ipgbase translate="title" />
20
+ </children>
21
+ </config>
22
+ </children>
23
+ </system>
24
+ </children>
25
+ </admin>
26
+ </resources>
27
+ </acl>
28
+ </config>
app/code/local/Ipagare/IpgBase/etc/config.xml ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ipagare_IpgBase>
5
+ <version>1.16.4</version>
6
+ </Ipagare_IpgBase>
7
+ </modules>
8
+
9
+ <global>
10
+ <models>
11
+ <ipgbase>
12
+ <class>Ipagare_IpgBase_Model</class>
13
+ </ipgbase>
14
+ </models>
15
+
16
+ <blocks>
17
+ <ipgbase>
18
+ <class>Ipagare_IpgBase_Block</class>
19
+ </ipgbase>
20
+ <adminhtml>
21
+ <rewrite>
22
+ <sales_order_totals>Ipagare_IpgBase_Block_Adminhtml_Sales_Order_Totals</sales_order_totals>
23
+ <sales_order_invoice_totals>Ipagare_IpgBase_Block_Adminhtml_Sales_Order_Invoice_Totals</sales_order_invoice_totals>
24
+ </rewrite>
25
+ </adminhtml>
26
+ <sales>
27
+ <rewrite>
28
+ <order_totals>Ipagare_IpgBase_Block_Sales_Order_Totals</order_totals>
29
+ <order_invoice_totals>Ipagare_IpgBase_Block_Sales_Order_Invoice_Totals</order_invoice_totals>
30
+ </rewrite>
31
+ </sales>
32
+ </blocks>
33
+
34
+ <helpers>
35
+ <ipgbase>
36
+ <class>Ipagare_IpgBase_Helper</class>
37
+ </ipgbase>
38
+ </helpers>
39
+
40
+ <resources>
41
+ <ipgbase_setup>
42
+ <setup>
43
+ <module>Ipagare_IpgBase</module>
44
+ <class>Mage_Sales_Model_Mysql4_Setup</class>
45
+ </setup>
46
+ <connection>
47
+ <use>core_setup</use>
48
+ </connection>
49
+ </ipgbase_setup>
50
+ </resources>
51
+
52
+ <events>
53
+ <ipgbase_log_user_action>
54
+ <observers>
55
+ <ipgbase_log_user_action>
56
+ <class>ipgbase/observer</class>
57
+ <method>logUserAction</method>
58
+ </ipgbase_log_user_action>
59
+ </observers>
60
+ </ipgbase_log_user_action>
61
+ </events>
62
+
63
+ <template>
64
+ <email>
65
+ <ipg_boleto_sales_email_order_template translate="label" module="sales">
66
+ <label>Boleto a vencer</label>
67
+ <file>sales/ipg_boleto.html</file>
68
+ <type>html</type>
69
+ </ipg_boleto_sales_email_order_template>
70
+ </email>
71
+ </template>
72
+ </global>
73
+
74
+ <admin>
75
+ <!--
76
+ <secure_url>
77
+ <Ipagare_IpgBase>/ipgbase</Ipagare_IpgBase>
78
+ </secure_url>
79
+ -->
80
+ <routers>
81
+ <ipgbase>
82
+ <use>admin</use>
83
+ <args>
84
+ <module>Ipagare_IpgBase</module>
85
+ <frontName>ipgbase</frontName>
86
+ </args>
87
+ </ipgbase>
88
+ </routers>
89
+ </admin>
90
+
91
+ <adminhtml>
92
+ <layout>
93
+ <updates>
94
+ <ipgbase module='ipgbase'>
95
+ <file>ipagare/ipgbase.xml</file>
96
+ </ipgbase>
97
+ </updates>
98
+ </layout>
99
+ </adminhtml>
100
+
101
+ <frontend>
102
+ <secure_url>
103
+ <idecheckoutvm>/ipgbase/</idecheckoutvm>
104
+ </secure_url>
105
+ <routers>
106
+ <idecheckoutvm>
107
+ <use>standard</use>
108
+ <args>
109
+ <module>Ipagare_IpgBase</module>
110
+ <frontName>ipgbase</frontName>
111
+ </args>
112
+ </idecheckoutvm>
113
+ </routers>
114
+ <layout>
115
+ <updates>
116
+ <ipgbase module='ipgbase'>
117
+ <file>ipagare/ipgbase.xml</file>
118
+ </ipgbase>
119
+ </updates>
120
+ </layout>
121
+ <translate>
122
+ <modules>
123
+ <Ipagare_IpgBase>
124
+ <files>
125
+ <default>Ipagare_IpgBase.csv</default>
126
+ </files>
127
+ </Ipagare_IpgBase>
128
+ </modules>
129
+ </translate>
130
+ </frontend>
131
+
132
+ <crontab>
133
+ <jobs>
134
+ <ipagare_ipgbase_expirapedido>
135
+ <schedule>
136
+ <cron_expr>*/30 * * * *</cron_expr>
137
+ </schedule>
138
+ <run>
139
+ <model>ipgbase/observer::expirapedido</model>
140
+ </run>
141
+ </ipagare_ipgbase_expirapedido>
142
+ <ipagare_ipgbase_expiraboleto>
143
+ <schedule>
144
+ <cron_expr>10 1 * * *</cron_expr>
145
+ </schedule>
146
+ <run>
147
+ <model>ipgbase/observer::expiraBoletos</model>
148
+ </run>
149
+ </ipagare_ipgbase_expiraboleto>
150
+ <ipagare_ipgbase_reenvioemail>
151
+ <schedule>
152
+ <cron_expr>10 2 * * *</cron_expr>
153
+ </schedule>
154
+ <run>
155
+ <model>ipgbase/observer::enviaEmailBoletosAvencer</model>
156
+ </run>
157
+ </ipagare_ipgbase_reenvioemail>
158
+ <ipagare_ipgbase_licenseexpcheck>
159
+ <schedule>
160
+ <cron_expr>10 3 * * *</cron_expr>
161
+ </schedule>
162
+ <run>
163
+ <model>ipgbase/observer::licenseExpCheck</model>
164
+ </run>
165
+ </ipagare_ipgbase_licenseexpcheck>
166
+ </jobs>
167
+ </crontab>
168
+
169
+ <default>
170
+ <ipgbase>
171
+ <pagina_sucesso>
172
+ <mostrar_conteudo>1</mostrar_conteudo>
173
+ </pagina_sucesso>
174
+ <osc>
175
+ <css_active>1</css_active>
176
+ </osc>
177
+ <reenvio_boleto>
178
+ <numero_dias>2</numero_dias>
179
+ </reenvio_boleto>
180
+ <controle_envio_email>
181
+ <novo>1</novo>
182
+ <cancelado>1</cancelado>
183
+ <fatura_gerada>1</fatura_gerada>
184
+ <texto_email_cancelado>Caso deseje realizar a compra novamente, acesse nosso site ##URL_LOJA##</texto_email_cancelado>
185
+ </controle_envio_email>
186
+ </ipgbase>
187
+ </default>
188
+ </config>
app/code/local/Ipagare/IpgBase/etc/system.xml ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <ipagare translate="label" module="ipgbase">
5
+ <label>Pagamento</label>
6
+ <sort_order>1000</sort_order>
7
+ </ipagare>
8
+ </tabs>
9
+
10
+ <sections>
11
+ <ipgbase>
12
+ <label><![CDATA[Configurações Gerais]]></label>
13
+ <sort_order>0</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <tab>ipagare</tab>
18
+ <groups>
19
+ <pagina_sucesso translate="label comment">
20
+ <label><![CDATA[Página de sucesso]]> (1.16.4)</label>
21
+ <comment>
22
+ <![CDATA[
23
+ <p>Na página de sucesso, algumas informações não são visualizadas quando um pedido é realizado com usuário não autenticado.</p>
24
+ <p>Caso queira exibir as informações do pagamento na tela sucesso ative essa configuração.</p>
25
+ ]]>
26
+ </comment>
27
+ <frontend_type>text</frontend_type>
28
+ <sort_order>1</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>1</show_in_store>
32
+ <expanded>1</expanded>
33
+ <fields>
34
+ <mostrar_conteudo translate="label">
35
+ <label><![CDATA[Mostrar conteúdo na página de sucesso]]></label>
36
+ <frontend_type>select</frontend_type>
37
+ <source_model>adminhtml/system_config_source_yesno</source_model>
38
+ <sort_order>0</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </mostrar_conteudo>
43
+ </fields>
44
+ </pagina_sucesso>
45
+
46
+ <expiracao_pedido translate="label comment">
47
+ <label><![CDATA[Expiração de pedido]]> (1.16.4)</label>
48
+ <comment>
49
+ <![CDATA[
50
+ <p>
51
+ Após decorrido o período configurado da criação do pedido, o pedido em status "Pendente" será cancelado automaticamente e todos os produtos deste pedido voltarão ao estoque.<br/>
52
+ </p>
53
+ ]]>
54
+ </comment>
55
+ <frontend_type>text</frontend_type>
56
+ <sort_order>5</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ <expanded>1</expanded>
61
+ <fields>
62
+ <ativa translate="label">
63
+ <label><![CDATA[Ativar expiração automática]]></label>
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>adminhtml/system_config_source_yesno</source_model>
66
+ <sort_order>0</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ <comment><![CDATA[Pedidos expirados serão cancelados e seus produtos voltarão ao estoque.]]></comment>
71
+ </ativa>
72
+
73
+ <!--
74
+ <periodo translate="label">
75
+ <label><![CDATA[Período para expiração]]></label>
76
+ <frontend_type>time</frontend_type>
77
+ <sort_order>1</sort_order>
78
+ <validate>required-entry</validate>
79
+ <depends><active>1</active></depends>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ <comment><![CDATA[Tempo decorrido desde a criação do pedido para expiração.]]></comment>
84
+ </periodo>
85
+ -->
86
+
87
+ <data_inicial translate="label">
88
+ <label><![CDATA[Expirar pedidos criados após]]></label>
89
+ <frontend_type>date</frontend_type>
90
+ <frontend_model>ipgbase/adminhtml_system_config_form_field_date</frontend_model>
91
+ <sort_order>3</sort_order>
92
+ <validate>required-entry</validate>
93
+ <depends><ativa>1</ativa></depends>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ <comment><![CDATA[Serão expirados apenas pedidos criados após esta data.]]></comment>
98
+ </data_inicial>
99
+
100
+ <controle translate="label">
101
+ <label><![CDATA[<strong>Período para expiração</strong>]]>
102
+ </label>
103
+ <frontend_type>hidden</frontend_type>
104
+ <depends><ativa>1</ativa></depends>
105
+ <sort_order>5</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ <comment><![CDATA[Tempo decorrido desde a criação do pedido para expiração.]]></comment>
110
+ </controle>
111
+
112
+ <periodo_dias translate="label">
113
+ <label><![CDATA[Dias para expiração]]></label>
114
+ <frontend_type>select</frontend_type>
115
+ <source_model>ipgbase/system_config_source_dias</source_model>
116
+ <validate>required-entry</validate>
117
+ <depends><ativa>1</ativa></depends>
118
+ <sort_order>6</sort_order>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>1</show_in_store>
122
+ </periodo_dias>
123
+ <periodo_horas translate="label">
124
+ <label><![CDATA[Horas para expiração]]></label>
125
+ <frontend_type>select</frontend_type>
126
+ <source_model>ipgbase/system_config_source_horas</source_model>
127
+ <validate>required-entry</validate>
128
+ <depends><ativa>1</ativa></depends>
129
+ <sort_order>7</sort_order>
130
+ <show_in_default>1</show_in_default>
131
+ <show_in_website>1</show_in_website>
132
+ <show_in_store>1</show_in_store>
133
+ </periodo_horas>
134
+ <periodo_minutos translate="label">
135
+ <label><![CDATA[Minutos para expiração]]></label>
136
+ <frontend_type>select</frontend_type>
137
+ <source_model>ipgbase/system_config_source_minutos</source_model>
138
+ <validate>required-entry</validate>
139
+ <depends><ativa>1</ativa></depends>
140
+ <sort_order>8</sort_order>
141
+ <show_in_default>1</show_in_default>
142
+ <show_in_website>1</show_in_website>
143
+ <show_in_store>1</show_in_store>
144
+ </periodo_minutos>
145
+ </fields>
146
+ </expiracao_pedido>
147
+
148
+ <osc translate="label comment">
149
+ <label><![CDATA[OneStepCheckout]]> (1.16.4)</label>
150
+ <comment>
151
+ <![CDATA[<p>Essa opção possibilita aplicar um estilo mais legível aos campos do Onestepcheckout.</p>
152
+ <p>* Válido apenas para clientes que possuem o Onestepcheckout contratado.</p>
153
+ ]]>
154
+ </comment>
155
+ <frontend_type>text</frontend_type>
156
+ <sort_order>10</sort_order>
157
+ <show_in_default>1</show_in_default>
158
+ <show_in_website>1</show_in_website>
159
+ <show_in_store>1</show_in_store>
160
+ <expanded>1</expanded>
161
+ <fields>
162
+ <css_active translate="label">
163
+ <label><![CDATA[Habilitar estilo no checkout]]></label>
164
+ <frontend_type>select</frontend_type>
165
+ <source_model>adminhtml/system_config_source_yesno</source_model>
166
+ <sort_order>0</sort_order>
167
+ <show_in_default>1</show_in_default>
168
+ <show_in_website>1</show_in_website>
169
+ <show_in_store>1</show_in_store>
170
+ </css_active>
171
+ </fields>
172
+ </osc>
173
+
174
+
175
+ <reenvio_boleto translate="label comment">
176
+ <label><![CDATA[Aviso automático de boleto por vencer]]> (1.16.4)</label>
177
+ <comment>
178
+ <![CDATA[
179
+ <p>
180
+ Permite que seja enviado um e-mail avisando o cliente que um boleto emitido na loja e que ainda não tenha sido pago está próximo da data de vencimento. <span style="color: red">*</span><br/>
181
+ </p>
182
+ <p>
183
+ <span style="color: red">*</span> Configuração não disponível para o módulo Bcash.
184
+ </p>
185
+ ]]>
186
+ </comment>
187
+ <frontend_type>text</frontend_type>
188
+ <sort_order>5</sort_order>
189
+ <show_in_default>1</show_in_default>
190
+ <show_in_website>1</show_in_website>
191
+ <show_in_store>1</show_in_store>
192
+ <expanded>1</expanded>
193
+ <fields>
194
+ <ativa translate="label">
195
+ <label><![CDATA[Ativar envio de e-mail para boletos que estão vencendo]]></label>
196
+ <frontend_type>select</frontend_type>
197
+ <source_model>adminhtml/system_config_source_yesno</source_model>
198
+ <sort_order>0</sort_order>
199
+ <show_in_default>1</show_in_default>
200
+ <show_in_website>1</show_in_website>
201
+ <show_in_store>1</show_in_store>
202
+ </ativa>
203
+
204
+ <numero_dias translate="label">
205
+ <label><![CDATA[Número de dias antes do vencimento que deve ser enviado e-mail]]></label>
206
+ <frontend_type>text</frontend_type>
207
+ <frontend_model>ipgbase/adminhtml_system_config_form_field_date</frontend_model>
208
+ <sort_order>3</sort_order>
209
+ <validate>required-entry validate-digits</validate>
210
+ <depends><ativa>1</ativa></depends>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>1</show_in_website>
213
+ <show_in_store>1</show_in_store>
214
+ </numero_dias>
215
+
216
+ </fields>
217
+ </reenvio_boleto>
218
+
219
+
220
+ <controle_envio_email translate="label comment">
221
+ <label><![CDATA[Controle de envio de e-mails]]> (1.16.4)</label>
222
+ <comment>
223
+ <![CDATA[
224
+ <p>
225
+ Opções para controlar o fluxo dos e-mails enviados pela loja<br/>
226
+ </p>
227
+ ]]>
228
+ </comment>
229
+ <frontend_type>text</frontend_type>
230
+ <sort_order>5</sort_order>
231
+ <show_in_default>1</show_in_default>
232
+ <show_in_website>1</show_in_website>
233
+ <show_in_store>1</show_in_store>
234
+ <expanded>1</expanded>
235
+ <fields>
236
+
237
+ <novo translate="label">
238
+ <label><![CDATA[Ativar envio de e-mail para novos pedidos]]></label>
239
+ <frontend_type>select</frontend_type>
240
+ <source_model>adminhtml/system_config_source_yesno</source_model>
241
+ <sort_order>0</sort_order>
242
+ <show_in_default>1</show_in_default>
243
+ <show_in_website>1</show_in_website>
244
+ <show_in_store>1</show_in_store>
245
+ </novo>
246
+
247
+ <cancelado translate="label">
248
+ <label><![CDATA[Ativar envio de e-mail para pedidos com status cancelado]]></label>
249
+ <frontend_type>select</frontend_type>
250
+ <source_model>adminhtml/system_config_source_yesno</source_model>
251
+ <sort_order>10</sort_order>
252
+ <show_in_default>1</show_in_default>
253
+ <show_in_website>1</show_in_website>
254
+ <show_in_store>1</show_in_store>
255
+ </cancelado>
256
+
257
+ <fatura_gerada translate="label">
258
+ <label><![CDATA[Ativar envio de e-mail para pedido com fatura gerada.]]></label>
259
+ <frontend_type>select</frontend_type>
260
+ <source_model>adminhtml/system_config_source_yesno</source_model>
261
+ <sort_order>20</sort_order>
262
+ <show_in_default>1</show_in_default>
263
+ <show_in_website>1</show_in_website>
264
+ <show_in_store>1</show_in_store>
265
+ </fatura_gerada>
266
+
267
+ <!--
268
+ <texto_email_cancelado translate="label">
269
+ <frontend_type>hidden</frontend_type>
270
+ <depends><ativa>1</ativa></depends>
271
+ <sort_order>30</sort_order>
272
+ <show_in_default>1</show_in_default>
273
+ <show_in_website>1</show_in_website>
274
+ <show_in_store>1</show_in_store>
275
+ </texto_email_cancelado>
276
+ -->
277
+
278
+ </fields>
279
+ </controle_envio_email>
280
+
281
+
282
+ </groups>
283
+ </ipgbase>
284
+ </sections>
285
+ </config>
app/code/local/Ipagare/IpgBase/sql/ipgbase_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ $installer = $this;
16
+
17
+ $installer->startSetup();
18
+
19
+ $conn = $installer->getConnection();
20
+ $table = $installer->getTable('sales_flat_order');
21
+
22
+ if(!$conn->tableColumnExists($table, 'ipagare_order_orig')) {
23
+ $conn->addColumn($table, 'ipagare_order_orig', 'VARCHAR(10) NULL');
24
+ }
25
+ if(!$conn->tableColumnExists($table, 'ipagare_use_risk_management')) {
26
+ $conn->addColumn($table, 'ipagare_use_risk_management', 'VARCHAR(5) NULL');
27
+ }
28
+
29
+ $installer->endSetup();
app/code/local/Ipagare/IpgBase/sql/ipgbase_setup/mysql4-upgrade-1.6.0-1.6.2.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ $installer = $this;
16
+
17
+ $installer->startSetup();
18
+
19
+ $conn = $installer->getConnection();
20
+ $table = $installer->getTable('sales_flat_order');
21
+
22
+ if(!$conn->tableColumnExists($table, 'ipagare_order_orig')) {
23
+ $conn->addColumn($table, 'ipagare_order_orig', 'VARCHAR(10) NULL');
24
+ }
25
+ if(!$conn->tableColumnExists($table, 'ipagare_use_risk_management')) {
26
+ $conn->addColumn($table, 'ipagare_use_risk_management', 'VARCHAR(5) NULL');
27
+ }
28
+
29
+ $installer->endSetup();
app/code/local/Ipagare/IpgBase/sql/ipgbase_setup/mysql4-upgrade-1.6.1-1.6.2.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ $installer = $this;
16
+
17
+ $installer->startSetup();
18
+
19
+ $conn = $installer->getConnection();
20
+ $table = $installer->getTable('sales_flat_order');
21
+
22
+ if(!$conn->tableColumnExists($table, 'ipagare_order_orig')) {
23
+ $conn->addColumn($table, 'ipagare_order_orig', 'VARCHAR(10) NULL');
24
+ }
25
+ if(!$conn->tableColumnExists($table, 'ipagare_use_risk_management')) {
26
+ $conn->addColumn($table, 'ipagare_use_risk_management', 'VARCHAR(5) NULL');
27
+ }
28
+
29
+ $installer->endSetup();
app/code/local/Ipagare/IpgBase/sql/ipgbase_setup/oldinstall.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgBase
9
+ * @copyright Copyright (c) 2012 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.16.4
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ $installer = $this;
16
+ $installer->startSetup();
17
+
18
+ $conn = $installer->getConnection();
19
+ $table_core_email_template = $installer->getTable('core_email_template');
20
+ $templateName = 'IpgBoletoPorVencer';
21
+ $templateId = Mage::getModel('ipgbase/emailService')->getIdTemplateEmail();
22
+ $order = '$order';
23
+
24
+ $varTeste= '{"store url=\\\"\\\"":"Store Url",';
25
+ $varTeste.= '"skin url=\\\"images/logo_email.gif\\\" _area=\'\'frontend\'\'":"Email Logo Image",';
26
+ $varTeste.= '"htmlescape var=$order.getCustomerName()":"Customer Name",';
27
+ $varTeste.= '"var order.increment_id":"Order Id",';
28
+ $varTeste.= '"var order.getStatusLabel()":"Order Status",';
29
+ $varTeste.= '"store url=\\\"customer/account/\\\"":"Customer Account Url",';
30
+ $varTeste.= '"var comment":"Order Comment",';
31
+ $varTeste.= '"var store.getFrontendName()":"Store Name"}';
32
+
33
+
34
+ $installer->run("INSERT INTO `$table_core_email_template`
35
+ (`template_code`,
36
+ `template_text`,
37
+ `template_styles`,
38
+ `template_type`,
39
+ `template_subject`,
40
+ `template_sender_name`,
41
+ `template_sender_email`,
42
+ `added_at`,
43
+ `modified_at`,
44
+ `orig_template_code`,
45
+ `orig_template_variables`)
46
+ SELECT '$templateName',
47
+ '<body style=\"background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;\">
48
+ \r\n<div style=\"background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;\">
49
+ \r\n<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" height=\"100%\" width=\"100%\">
50
+ \r\n <tr>
51
+ \r\n <td align=\"center\" valign=\"top\" style=\"padding:20px 0 20px 0\">
52
+ \r\n <!-- [ header starts here] -->
53
+ \r\n <table bgcolor=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\" width=\"650\" style=\"border:1px solid #E0E0E0;\">
54
+ \r\n <tr>
55
+ \r\n <td valign=\"top\">
56
+ <a href=\"{{store url=\"\"}}\">
57
+ <img src=\"{{skin url=\"images/logo_email.gif\" _area=\'frontend\'}}\" alt=\"{{var store.getFrontendName()}}\" style=\"margin-bottom:10px;\" border=\"0\"/>
58
+ </a>
59
+ </td>
60
+ \r\n
61
+ </tr>
62
+ \r\n <!-- [ middle starts here] -->
63
+ \r\n <tr>
64
+ \r\n <td valign=\"top\">
65
+ \r\n <h1 style=\"font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;\">Prezado(a) {{htmlescape var=$order.getCustomerName()}},</h1>
66
+ \r\n <p style=\"font-size:12px; line-height:16px; margin:0 0 10px 0;\">
67
+ \r\n Seu Pedido # {{var order.increment_id}} está <br/>
68
+ \r\n <strong>{{var order.getStatusLabel()}}</strong>.
69
+ \r\n </p>
70
+ \r\n <p style=\"font-size:12px; line-height:16px; margin:0 0 10px 0;\">Você pode checar o status do pedido
71
+ <a href=\"{{store url=\"customer/account/\"}}\" style=\"color:#1E7EC8;\">Logando em sua conta</a>.
72
+ </p>
73
+ \r\n <p style=\"font-size:12px; line-height:16px; margin:0 0 10px 0;\">Caso queira pagar o boleto diretamente: {{var comment}}</p>
74
+ \r\n <p style=\"font-size:12px; line-height:16px; margin:0;\">
75
+ \r\n Para qualquer outra dúvida, entre em contato através do e-mail:
76
+ \r\n <a href=\"mailto:{{config path=\'trans_email/ident_support/email\'}}\" style=\"color:#1E7EC8;\">{{config path=\'trans_email/ident_support/email\'}}</a>.
77
+ \r\n </p>
78
+ \r\n </td>
79
+ \r\n </tr>
80
+ \r\n <tr>
81
+ \r\n <td bgcolor=\"#EAEAEA\" align=\"center\" style=\"background:#EAEAEA; text-align:center;\">
82
+ <center>
83
+ <p style=\"font-size:12px; margin:0;\">Muito obrigado, <strong>{{var store.getFrontendName()}}</strong>
84
+ </p></center></td>
85
+ \r\n </tr>
86
+ \r\n </table>
87
+ \r\n </td>
88
+ \r\n </tr>
89
+ \r\n </table>
90
+ \r\n </div>
91
+ \r\n </body>' ,
92
+
93
+ 'body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }' ,
94
+
95
+ '2' ,
96
+
97
+ '{{var store.getFrontendName()}}: Boleto vencendo para pedido {{var order.increment_id}}',
98
+
99
+ NULL ,
100
+
101
+ NULL ,
102
+
103
+ '2012-07-31 14:18:21' ,
104
+
105
+ '2012-08-07 13:12:42' ,
106
+
107
+ 'sales_email_order_comment_template' ,
108
+
109
+ '$varTeste'
110
+
111
+
112
+ FROM DUAL WHERE NOT EXISTS
113
+ (SELECT `template_code` FROM $table_core_email_template c
114
+ WHERE c.template_code = '$templateName') ;");
115
+
116
+
117
+
118
+
119
+ $installer->endSetup();
app/code/local/Ipagare/IpgPagSeguroDireto/Block/Checkout/Onepage/Success.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Block_Checkout_Onepage_Success extends Mage_Checkout_Block_Onepage_Success {
16
+
17
+ public function getViewOrder() {
18
+ return (bool) Mage::getStoreConfig(Ipagare_IpgBase_ConfiguracoesSystem::PAGINA_SUCESSO_MOSTRAR_CONTEUDO) || (bool) $this->_getData('can_view_order');
19
+ }
20
+
21
+ public function getCanViewOrder() {
22
+ return (bool) Mage::getStoreConfig(Ipagare_IpgBase_ConfiguracoesSystem::PAGINA_SUCESSO_MOSTRAR_CONTEUDO) || (bool) $this->_getData('can_view_order');
23
+ }
24
+
25
+ public function getCanPrintOrder() {
26
+ return (bool) Mage::getStoreConfig(Ipagare_IpgBase_ConfiguracoesSystem::PAGINA_SUCESSO_MOSTRAR_CONTEUDO) || (bool) $this->_getData('can_print_order');
27
+ }
28
+
29
+ public function getLastOrder() {
30
+ return Mage::helper('ipgpagsegurodireto/session')->getCurrentOrder();
31
+ }
32
+
33
+ public function getPaymentData() {
34
+ return Mage::getSingleton('ipgbase/session')->getPaymentData();
35
+ }
36
+
37
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Block/Payment/Info.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Block_Payment_Info extends Mage_Payment_Block_Info {
16
+
17
+ private $logger;
18
+
19
+ protected function _construct() {
20
+ parent::_construct();
21
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
22
+ if (!Mage::helper('ipgbase/url')->isInOpcPayment()) {
23
+ $this->setTemplate('ipagare/ipgpagsegurodireto/payment/info/default.phtml');
24
+ }
25
+ }
26
+
27
+ protected function _prepareSpecificInformation($transport = null) {
28
+ if (null !== $this->_paymentSpecificInformation) {
29
+ return $this->_paymentSpecificInformation;
30
+ }
31
+ $transport = parent::_prepareSpecificInformation($transport);
32
+ $dadosPagamento = array();
33
+ $data = array();
34
+ $orderId = '';
35
+
36
+ if (!Mage::helper('ipgbase/url')->isInOpcPayment()) {
37
+ $order = $this->getOrder();
38
+ $realOrderId = $order->getRealOrderId();
39
+ $orderId = $this->getPayment()->getOrderId();
40
+ if (!Mage::helper('ipgbase/stringUtils')->isEmpty($realOrderId)) {
41
+ $dadosPagamento = $this->getDadosPagamento();
42
+ if (Mage::helper('ipgpagsegurodireto')->notNull($dadosPagamento)) {
43
+ foreach ($dadosPagamento as $key => $value) {
44
+ if (!Mage::helper('ipgbase/stringUtils')->isEmpty($value['valor'])) {
45
+ $data[$value['titulo']] = $value['valor'];
46
+ }
47
+ }
48
+ } else if ($order->getData('ipagare_order_orig') == Ipagare_IpgBase_Config::ORDER_ORIG_TELEVENDAS) {
49
+ $param1 = strtr(trim(Mage::helper('core')->encrypt($realOrderId)), '+/=', '-_~');
50
+ $param2 = strtr(trim(Mage::helper('core')->encrypt($order->getCustomerEmail())), '+/=', '-_~');
51
+
52
+ $urlPayment = Mage::getModel('core/store')->load($order->getStoreId())->getUrl('ipgtelevendas/index/index/', array('param1' => $param1, 'param2' => $param2));
53
+ $linkImage = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA, false) . "ipagare/ipgtelevendas/images/pagar.png";
54
+
55
+ $bloco = "<p><a href=\"$urlPayment\" target=\"_blank\"><img alt=\"Clique aqui para pagar\" title=\"Clique aqui para pagar\" border=\"0\" src=\"$linkImage\"></img></a></p>";
56
+ $bloco = $bloco . "<p>Ao clicar no botão acima você será redirecionado ao ambiente seguro da loja para realizar o pagamento.</p>";
57
+ $data['link-televendas'] = $bloco;
58
+
59
+ $this->logger->info('Link de pagamento. Pedido ' . $realOrderId . ': ' . $urlPayment);
60
+ }
61
+ }
62
+ }
63
+ return $transport->setData(array_merge($data, $transport->getData()));
64
+ }
65
+
66
+ public function getDadosPagamento() {
67
+ $order = $this->getOrder();
68
+ $payment = $this->getPayment();
69
+ $bandeiraPagSeguro = "<img src=\" " . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . "ipagare/ipgpagsegurodireto/images/logo_pagseguro.png \" />";
70
+
71
+ $meioPagamento = $payment->getMeioPagamento();
72
+ $formaPagamento = $payment->getFormaPagamento();
73
+ $hasCode = !Mage::helper('ipgbase/stringUtils')->isEmpty($payment->getCodeCheckout());
74
+ if (is_null($payment->getIdIpagarePagseguroDiretoPagamento())) {
75
+ if ($order->getData('ipagare_order_orig') == Ipagare_IpgBase_Config::ORDER_ORIG_TELEVENDAS) {
76
+ return null;
77
+ }
78
+ }
79
+
80
+ $dadosPagamento = array();
81
+
82
+ if (!isset($meioPagamento) || empty($meioPagamento)) {
83
+ if ($hasCode) {
84
+ $dadosPagamento[] = array('titulo' => $bandeiraPagSeguro, 'valor' => '<br/>');
85
+ return $dadosPagamento;
86
+ } else {
87
+ $dadosPagamento[] = array('titulo' => $bandeiraPagSeguro, 'valor' => '<br/>');
88
+ // erros
89
+ $erros = $this->getErros();
90
+ $list = '';
91
+ foreach ($erros as $key => $erro) {
92
+ $e = new Ipagare_IpgPagSeguroDireto_ErrorMessages($erro['code']);
93
+
94
+ $list .= 'Erro(' . $e->getCode() . ') - ' . $e->getMessage() . '<br />';
95
+ }
96
+
97
+ $dadosPagamento[] = array('titulo' => 'Motivo', 'valor' => $list);
98
+
99
+ return $dadosPagamento;
100
+ }
101
+ }
102
+ $status = new Ipagare_PagSeguroDireto_Domain_TransactionStatus($payment->getStatus());
103
+
104
+ $paymentType = new Ipagare_PagSeguroDireto_Domain_PaymentMethodCode($meioPagamento);
105
+ $paymentMode = Ipagare_IpgPagSeguroDireto_PaymentMode::valueOf($formaPagamento);
106
+
107
+ $pathImage = "ipagare/ipgpagsegurodireto/bandeiras/" . $paymentType->getValue() . '/' . $paymentMode->getParcelas() . "x.gif";
108
+ $bandeiraMeioPagamento = "<img src=\" " . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . "$pathImage \" />";
109
+ $dadosPagamento[] = array('titulo' => $bandeiraPagSeguro, 'valor' => $bandeiraMeioPagamento);
110
+ $dadosPagamento[] = array('titulo' => 'Forma de pagamento', 'valor' => $paymentMode->getCompleteName());
111
+ $dadosPagamento[] = array('titulo' => 'Total pago', 'valor' => Mage::helper('core')->currency($payment->getValorTotal(), true, false));
112
+ if ($payment->getTransactionCode() != null) {
113
+ $dadosPagamento[] = array('titulo' => 'Código da transação', 'valor' => str_replace('-', '', $payment->getTransactionCode()));
114
+ }
115
+
116
+ if ($status->isCancelada()) {
117
+ if (!Mage::helper('ipgbase/stringUtils')->isEmpty($payment->getMensagemCancelamento())) {
118
+ $dadosPagamento[] = array('titulo' => 'Mensagem', 'valor' => $payment->getMensagemCancelamento());
119
+ } else {
120
+ $dadosPagamento[] = array('titulo' => 'Mensagem', 'valor' => $status->getMessage());
121
+ }
122
+ } else {
123
+ $dadosPagamento[] = array('titulo' => 'Mensagem', 'valor' => $status->getMessage());
124
+ }
125
+
126
+ return $dadosPagamento;
127
+ }
128
+
129
+ public function isUrlEmail() {
130
+ $currentUrl = $this->helper('core/url')->getCurrentUrl();
131
+ if (preg_match('/email/', $currentUrl)) {
132
+ return true;
133
+ }
134
+ return false;
135
+ }
136
+
137
+ public function getPaymentType() {
138
+ $meioPagamento = $this->getPayment()->getMeioPagamento();
139
+
140
+ if (!isset($meioPagamento)) {
141
+ return false;
142
+ }
143
+
144
+ return new Ipagare_PagSeguroDireto_Domain_PaymentMethodCode($meioPagamento);
145
+ }
146
+
147
+ public function hasPaymentType() {
148
+ $payment = $this->getPayment();
149
+ $meioPagamento = $payment->getMeioPagamento();
150
+ if (!isset($meioPagamento)) {
151
+ return false;
152
+ }
153
+ return true;
154
+ }
155
+
156
+ public function getPayment() {
157
+ $orderId = $this->getOrder()->getRealOrderId();
158
+ $payment = Mage::getModel('ipgpagsegurodireto/entity_payment');
159
+ $payment->loadByAttribute('order_id', $orderId);
160
+
161
+ return $payment;
162
+ }
163
+
164
+ public function getErros() {
165
+ $orderId = $this->getOrder()->getRealOrderId();
166
+ return Mage::getModel('ipgpagsegurodireto/entity_erro')->getErrorCodes($orderId);
167
+ }
168
+
169
+ public function getPaymentLink() {
170
+ $payment = $this->getPayment();
171
+ $paymentLink = $payment->getPaymentLink();
172
+
173
+ if (!isset($paymentLink)) {
174
+ return false;
175
+ }
176
+
177
+ return $paymentLink;
178
+ }
179
+
180
+ public function isPaymentPending() {
181
+ $order = $this->getOrder();
182
+ if ($order->isCanceled() || $order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING || $order->getState() == Mage_Sales_Model_Order::STATE_COMPLETE || $order->getState() == Mage_Sales_Model_Order::STATE_CLOSED || $order->getState() == Mage_Sales_Model_Order::STATE_HOLDED) {
183
+ return false;
184
+ }
185
+ return true;
186
+ }
187
+
188
+ protected function getOrder() {
189
+ $order = '';
190
+ $currentOrder = $this->getInfo()->getOrder();
191
+ if (isset($currentOrder)) {
192
+ return $currentOrder;
193
+ }
194
+ return $order;
195
+ }
196
+
197
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Block/Payment/Transferencia.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Block_Payment_Transferencia extends Mage_Payment_Block_Form {
16
+
17
+ private $parameters;
18
+
19
+ protected function _construct() {
20
+ parent::_construct();
21
+ }
22
+
23
+ public function getParameters() {
24
+ if ($this->parameters == null) {
25
+ $this->parameters = Mage::getSingleton('ipgbase/session')->getPaymentData();
26
+ }
27
+ return $this->parameters;
28
+ }
29
+
30
+ public function getLastOrder() {
31
+ return Mage::helper('ipgpagsegurodireto/session')->getCurrentOrder();
32
+ }
33
+
34
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Block/Standard/Form.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Block_Standard_Form extends Mage_Payment_Block_Form {
16
+
17
+ private $paymentTypeOptions;
18
+
19
+ protected function _construct() {
20
+ $this->setTemplate('ipagare/ipgpagsegurodireto/payment/form.phtml');
21
+ parent::_construct();
22
+ }
23
+
24
+ protected function _prepareLayout() {
25
+ return parent::_prepareLayout();
26
+ }
27
+
28
+ public function hasCreditCard() {
29
+ if (count($this->paymentTypeOptions->getOptions()) < 1) {
30
+ return false;
31
+ }
32
+ foreach ($this->paymentTypeOptions->getOptions() as $paymentTypeOption) {
33
+ $paymentType = $paymentTypeOption->getPaymentType();
34
+ if ($paymentType->isCreditCard()) {
35
+ return true;
36
+ }
37
+ }
38
+ return false;
39
+ }
40
+
41
+ public function hasErrors() {
42
+ return $this->paymentTypeOptions->hasErrors();
43
+ }
44
+
45
+ public function hasBoleto() {
46
+ if (count($this->paymentTypeOptions->getOptions()) < 1) {
47
+ return false;
48
+ }
49
+ foreach ($this->paymentTypeOptions->getOptions() as $paymentTypeOption) {
50
+ $paymentType = $paymentTypeOption->getPaymentType();
51
+ if ($paymentType->isBoleto()) {
52
+ return true;
53
+ }
54
+ }
55
+ return false;
56
+ }
57
+
58
+ public function hasTransferencia() {
59
+ if (count($this->paymentTypeOptions->getOptions()) < 1) {
60
+ return false;
61
+ }
62
+ foreach ($this->paymentTypeOptions->getOptions() as $paymentTypeOption) {
63
+ $paymentType = $paymentTypeOption->getPaymentType();
64
+ if ($paymentType->isDebitoBancario()) {
65
+ return true;
66
+ }
67
+ }
68
+ return false;
69
+ }
70
+
71
+ public function mountPaymentTypeOptions() {
72
+ $valorTotal = Mage::getSingleton('checkout/session')->getQuote()->getBaseGrandTotal();
73
+ $this->paymentTypeOptions = Mage::getModel('ipgpagsegurodireto/paymentType')->getPaymentTypeOptions($valorTotal);
74
+ }
75
+
76
+ public function getPaymentTypeOptions() {
77
+ return $this->paymentTypeOptions;
78
+ }
79
+
80
+ public function isTeleVendasActive() {
81
+ if (Mage::helper('ipgbase/module')->isTeleVendasExists()) {
82
+ return true;
83
+ }
84
+ return false;
85
+ }
86
+
87
+ public function getSessionId() {
88
+ return Mage::getModel('ipgpagsegurodireto/credential')->getSessionId();
89
+ }
90
+
91
+ public function isCustomCssEnabled() {
92
+ return Mage::getStoreConfigFlag(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::CUSTOM_CSS);
93
+ }
94
+
95
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Config.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ final class Ipagare_IpgPagSeguroDireto_Config {
16
+
17
+ const ERROR_001 = '001';
18
+ const ERROR_002 = '002';
19
+
20
+ protected static $_paymentModes = array('A01' => array('parcelas' => 1, 'codigo' => 'A01', 'juros' => false),
21
+ 'A02' => array('parcelas' => 2, 'codigo' => 'A02', 'juros' => false),
22
+ 'A03' => array('parcelas' => 3, 'codigo' => 'A03', 'juros' => false),
23
+ 'A04' => array('parcelas' => 4, 'codigo' => 'A04', 'juros' => false),
24
+ 'A05' => array('parcelas' => 5, 'codigo' => 'A05', 'juros' => false),
25
+ 'A06' => array('parcelas' => 6, 'codigo' => 'A06', 'juros' => false),
26
+ 'A07' => array('parcelas' => 7, 'codigo' => 'A07', 'juros' => false),
27
+ 'A08' => array('parcelas' => 8, 'codigo' => 'A08', 'juros' => false),
28
+ 'A09' => array('parcelas' => 9, 'codigo' => 'A09', 'juros' => false),
29
+ 'A10' => array('parcelas' => 10, 'codigo' => 'A10', 'juros' => false),
30
+ 'A11' => array('parcelas' => 11, 'codigo' => 'A11', 'juros' => false),
31
+ 'A12' => array('parcelas' => 12, 'codigo' => 'A12', 'juros' => false),
32
+ 'A13' => array('parcelas' => 13, 'codigo' => 'A13', 'juros' => false),
33
+ 'A14' => array('parcelas' => 14, 'codigo' => 'A14', 'juros' => false),
34
+ 'A15' => array('parcelas' => 15, 'codigo' => 'A15', 'juros' => false),
35
+ 'A16' => array('parcelas' => 16, 'codigo' => 'A16', 'juros' => false),
36
+ 'A17' => array('parcelas' => 17, 'codigo' => 'A17', 'juros' => false),
37
+ 'A18' => array('parcelas' => 18, 'codigo' => 'A18', 'juros' => false),
38
+ 'A19' => array('parcelas' => 19, 'codigo' => 'A19', 'juros' => false),
39
+ 'A20' => array('parcelas' => 20, 'codigo' => 'A20', 'juros' => false),
40
+ 'A21' => array('parcelas' => 21, 'codigo' => 'A21', 'juros' => false),
41
+ 'A22' => array('parcelas' => 22, 'codigo' => 'A22', 'juros' => false),
42
+ 'A23' => array('parcelas' => 23, 'codigo' => 'A23', 'juros' => false),
43
+ 'A24' => array('parcelas' => 24, 'codigo' => 'A24', 'juros' => false),
44
+ 'B02' => array('parcelas' => 2, 'codigo' => 'B02', 'juros' => true),
45
+ 'B03' => array('parcelas' => 3, 'codigo' => 'B03', 'juros' => true),
46
+ 'B04' => array('parcelas' => 4, 'codigo' => 'B04', 'juros' => true),
47
+ 'B05' => array('parcelas' => 5, 'codigo' => 'B05', 'juros' => true),
48
+ 'B06' => array('parcelas' => 6, 'codigo' => 'B06', 'juros' => true),
49
+ 'B07' => array('parcelas' => 7, 'codigo' => 'B07', 'juros' => true),
50
+ 'B08' => array('parcelas' => 8, 'codigo' => 'B08', 'juros' => true),
51
+ 'B09' => array('parcelas' => 9, 'codigo' => 'B09', 'juros' => true),
52
+ 'B10' => array('parcelas' => 10, 'codigo' => 'B10', 'juros' => true),
53
+ 'B11' => array('parcelas' => 11, 'codigo' => 'B11', 'juros' => true),
54
+ 'B12' => array('parcelas' => 12, 'codigo' => 'B12', 'juros' => true),
55
+ 'B13' => array('parcelas' => 13, 'codigo' => 'B13', 'juros' => true),
56
+ 'B14' => array('parcelas' => 14, 'codigo' => 'B14', 'juros' => true),
57
+ 'B15' => array('parcelas' => 15, 'codigo' => 'B15', 'juros' => true),
58
+ 'B16' => array('parcelas' => 16, 'codigo' => 'B16', 'juros' => true),
59
+ 'B17' => array('parcelas' => 17, 'codigo' => 'B17', 'juros' => true),
60
+ 'B18' => array('parcelas' => 18, 'codigo' => 'B18', 'juros' => true),
61
+ 'B19' => array('parcelas' => 19, 'codigo' => 'B19', 'juros' => true),
62
+ 'B20' => array('parcelas' => 20, 'codigo' => 'B20', 'juros' => true),
63
+ 'B21' => array('parcelas' => 21, 'codigo' => 'B21', 'juros' => true),
64
+ 'B22' => array('parcelas' => 22, 'codigo' => 'B22', 'juros' => true),
65
+ 'B23' => array('parcelas' => 23, 'codigo' => 'B23', 'juros' => true),
66
+ 'B24' => array('parcelas' => 24, 'codigo' => 'B24', 'juros' => true),
67
+ );
68
+
69
+ protected static $_errors = array('001' => array('mensagem' => 'Não existe meio de pagamento para o seu pedido.'),
70
+ '002' => array('mensagem' => 'Não existe opção de pagamento para o seu pedido.'),
71
+ );
72
+
73
+ /**
74
+ * @param type $paymentMode
75
+ * @return type
76
+ */
77
+ public static function getPaymentMode($paymentMode) {
78
+ if (array_key_exists($paymentMode, self::$_paymentModes)) {
79
+ return self::$_paymentModes[$paymentMode];
80
+ } else {
81
+ throw new Ipagare_IpgPagSeguroDireto_RuntimeException("Chave não encontrada para opção de pagamento informado. Chave = " . $paymentMode);
82
+ }
83
+ }
84
+
85
+ /**
86
+ *
87
+ *
88
+ * @param type $error
89
+ * @return
90
+ */
91
+ public static function getError($error) {
92
+ if (array_key_exists($error, self::$_errors)) {
93
+ return self::$_errors[$error];
94
+ } else {
95
+ throw new Ipagare_IpgPagSeguroDireto_RuntimeException("Chave não encontrada o código de erro $error");
96
+ }
97
+ }
98
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/ConfiguracoesSystem.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem {
16
+
17
+ // payment method
18
+ const ACTIVE = 'payment/ipgpagsegurodireto/active';
19
+ const INVOICE = 'ipgpagsegurodireto/geral/invoice';
20
+ const CANCEL_ORDER = 'ipgpagsegurodireto/geral/cancel_order';
21
+ const EMAIL = 'ipgpagsegurodireto/geral/email';
22
+ const TOKEN = 'ipgpagsegurodireto/geral/token';
23
+ const CUSTOM_CSS = 'ipgpagsegurodireto/geral/custom_css';
24
+ // cartao
25
+ const CARTAO_ACTIVE = 'ipgpagsegurodireto/cartao/active';
26
+ const CARTAO_CODIGOS = 'ipgpagsegurodireto/cartao/codigos';
27
+ const CARTAO_VALOR_MINIMO = 'ipgpagsegurodireto/cartao/valor_minimo';
28
+ const CARTAO_VALOR_MAXIMO = 'ipgpagsegurodireto/cartao/valor_maximo';
29
+ const CARTAO_DESCONTO_AVISTA = 'ipgpagsegurodireto/cartao/desconto_avista';
30
+ // debito
31
+ const DEBITO_ACTIVE = 'ipgpagsegurodireto/debito/active';
32
+ const DEBITO_CODIGOS = 'ipgpagsegurodireto/debito/codigos';
33
+ const DEBITO_VALOR_MINIMO = 'ipgpagsegurodireto/debito/valor_minimo';
34
+ const DEBITO_VALOR_MAXIMO = 'ipgpagsegurodireto/debito/valor_maximo';
35
+ const DEBITO_DESCONTO_AVISTA = 'ipgpagsegurodireto/debito/desconto_avista';
36
+ // boleto
37
+ const BOLETO_ACTIVE = 'ipgpagsegurodireto/boleto/active';
38
+ const BOLETO_CODIGOS = 'ipgpagsegurodireto/boleto/codigos';
39
+ const BOLETO_VALOR_MINIMO = 'ipgpagsegurodireto/boleto/valor_minimo';
40
+ const BOLETO_VALOR_MAXIMO = 'ipgpagsegurodireto/boleto/valor_maximo';
41
+ const BOLETO_DESCONTO_AVISTA = 'ipgpagsegurodireto/boleto/desconto_avista';
42
+ // sender_email
43
+ const SENDER_EMAIL = 'ipgpagsegurodireto/environment/sender_email';
44
+
45
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/ErrorMessages.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_ErrorMessages {
16
+
17
+ private static $list = array(
18
+ 'UNAUTHORIZED' => array('message' => 'Não foi possível conectar com o PagSeguro. Por favor, verifique se seu convênio está correto.'),
19
+ '53004' => array('message' => 'quantidade de itens é inválido.'),
20
+ '53005' => array('message' => 'Moeda é obrigatório.'),
21
+ '53006' => array('message' => 'Moeda contém valor inválido.'),
22
+ '53007' => array('message' => 'Código de referência contém tamanho inválido.'),
23
+ '53008' => array('message' => 'URL de notificação contém tamanho inválido.'),
24
+ '53009' => array('message' => 'URL de notificação contém valor inválido.'),
25
+ '53010' => array('message' => 'E-mail do remetente é obrigatório.'),
26
+ '53011' => array('message' => 'E-mail do remetente contém tamanho inválido.'),
27
+ '53012' => array('message' => 'E-mail do remetente contém valor inválido.'),
28
+ '53013' => array('message' => 'E-mail do remetente é obrigatório.'),
29
+ '53014' => array('message' => 'E-mail do remetente contém tamanho inválido.'),
30
+ '53015' => array('message' => 'CPF do remetente contém valor inválido.'),
31
+ '53017' => array('message' => 'CPF do remetente contém valor inválido.'),
32
+ '53018' => array('message' => 'Código de área do telefone é obrigatório.'),
33
+ '53019' => array('message' => 'Código de área do telefone é inválido.'),
34
+ '53020' => array('message' => 'Telefone do remetente é é obrigatório.'),
35
+ '53021' => array('message' => 'Telefone do remetente é inválido.'),
36
+ '53022' => array('message' => 'CEP do endereço de entrega é obrigatório.'),
37
+ '53023' => array('message' => 'CEP do endereço de entrega contém valor inválido.'),
38
+ '53024' => array('message' => 'Endereço de entrega é obrigatório.'),
39
+ '53025' => array('message' => 'Endereço do endereço de entrega contém tamanho inválido.'),
40
+ '53026' => array('message' => 'Número do endereço de entrega é obrigatório.'),
41
+ '53027' => array('message' => 'Número do endereço de entrega contém tamanho inválido.'),
42
+ '53028' => array('message' => 'Campo "complemento" do endereço de entrega contém tamanho inválido.'),
43
+ '53029' => array('message' => 'Campo "bairro" do endereço de entrega é obrigatório.'),
44
+ '53030' => array('message' => 'Campo "bairro" do endereço de entrega contém tamanho inválido.'),
45
+ '53031' => array('message' => 'Cidade do endereço de entrega é obrigatório.'),
46
+ '53032' => array('message' => 'Cidade do endereço de entrega contém tamanho inválido.'),
47
+ '53033' => array('message' => 'Estado do endereço de entrega é obrigatório.'),
48
+ '53034' => array('message' => 'Estado do endereço de entrega contém valor inválido.'),
49
+ '53035' => array('message' => 'País do endereço de entrega é obrigatório.'),
50
+ '53036' => array('message' => 'País do endereço de entrega contém tamanho inválido.'),
51
+ '53037' => array('message' => 'Número do Cartão de Crédito é inválido.'),
52
+ '53038' => array('message' => 'Quantidade de parcelas é obrigatório.'),
53
+ '53039' => array('message' => 'Quantidade de parcelas contém valor inválido.'),
54
+ '53040' => array('message' => 'Valor da parcela é obrigatório.'),
55
+ '53041' => array('message' => 'Valor da parcela contém valor inválido.'),
56
+ '53042' => array('message' => 'Nome do portador do cartão de crédito é obrigatório.'),
57
+ '53043' => array('message' => 'Nome do portador do cartão de crédito contém tamanho inválido.'),
58
+ '53044' => array('message' => 'Nome do portador do cartão de crédito contém valor inválido.'),
59
+ '53045' => array('message' => 'CPF do portador do cartão de crédito é obrigatório.'),
60
+ '53046' => array('message' => 'CPF do portador do cartão de crédito contém valor inválido.'),
61
+ '53047' => array('message' => 'Data de nascimento do portador do cartão de crédito é obrigatório.'),
62
+ '53048' => array('message' => 'Data de nascimento do portador do cartão de crédito contém valor inválido.'),
63
+ '53049' => array('message' => 'Código de área do telefone do portador do cartão de crédito é obrigatório.'),
64
+ '53050' => array('message' => 'Código de área do telefone do portador do cartão de crédito contém valor inválido.'),
65
+ '53051' => array('message' => 'Telefone do portador do cartão de crédito é obrigatório.'),
66
+ '53052' => array('message' => 'Telefone do portador do cartão de crédito contém valor inválido.'),
67
+ '53053' => array('message' => 'CEP do endereço de cobrança é obrigatório.'),
68
+ '53054' => array('message' => 'CEP do endereço de cobrança contém valor inválido.'),
69
+ '53055' => array('message' => 'Endereço de cobrança é obrigatório.'),
70
+ '53056' => array('message' => 'Endereço de cobrança contém tamanho inválido.'),
71
+ '53057' => array('message' => 'Número do endereço de cobrança é obrigatório.'),
72
+ '53058' => array('message' => 'Número do endereço de cobrança contém tamanho inválido.'),
73
+ '53059' => array('message' => 'Campo "complemento" do endereço de cobrança contém tamanho inválido.'),
74
+ '53060' => array('message' => 'Campo "bairro" do endereço de cobrança é obrigatório.'),
75
+ '53061' => array('message' => 'Campo "bairro" do endereço de cobrança contém tamanho inválido.'),
76
+ '53062' => array('message' => 'Campo "cidade" do endereço de cobrança é obrigatório.'),
77
+ '53063' => array('message' => 'Campo "cidade" do endereço de cobrança contém tamanho inválido.'),
78
+ '53064' => array('message' => 'Campo "estado" do endereço de cobrança é obrigatório.'),
79
+ '53065' => array('message' => 'Campo "estado" do endereço de cobrança contém valor inválido.'),
80
+ '53066' => array('message' => 'Campo "país" do endereço de cobrança é obrigatório.'),
81
+ '53067' => array('message' => 'Campo "país" do endereço de cobrança contém tamanho inválido.'),
82
+ '53068' => array('message' => 'E-mail do recebedor contém tamanho inválido.'),
83
+ '53069' => array('message' => 'E-mail do recebedor contém valor inválido.'),
84
+ '53070' => array('message' => 'ID do item é obrigatório.'),
85
+ '53071' => array('message' => 'ID do item contém tamanho inválido.'),
86
+ '53072' => array('message' => 'Descrição do item é obrigatório.'),
87
+ '53073' => array('message' => 'Descrição do item contém tamanho inválido.'),
88
+ '53074' => array('message' => 'Quantidade do item é obrigatório.'),
89
+ '53075' => array('message' => 'Quantidade do item está fora do intervalo permitido.'),
90
+ '53076' => array('message' => 'Quantidade do item contém valor inválido.'),
91
+ '53077' => array('message' => 'Valor do item é obrigatório.'),
92
+ '53078' => array('message' => 'Valor do item está formatado de maneira errada.'),
93
+ '53079' => array('message' => 'Valor do item está fora do intervalo permitido.'),
94
+ '53081' => array('message' => 'O remetente está relacionado com o Recebedor.'),
95
+ '53084' => array('message' => 'Recebedor inválido: verifique o status da conta do recebedor e se a conta é do tipo conta de vendedor.'),
96
+ '53085' => array('message' => 'Método de pagamento indisponível. Por favor, tente novamente mais tarde ou escolha outra opção de pagamento.'),
97
+ '53086' => array('message' => 'Total do pedido está fora do intervalo permitido.'),
98
+ '53087' => array('message' => 'Informações do cartão de crédito são inválidas.'),
99
+ '53091' => array('message' => 'Hash do remetente é inválida.'),
100
+ '53092' => array('message' => 'Bandeira do cartão de crédito não é aceita.'),
101
+ '53095' => array('message' => 'Tipo de frete contém valor inválido.'),
102
+ '53096' => array('message' => 'Custo do frete contém valor inválido.'),
103
+ '53097' => array('message' => 'Custo do frete está fora do intervalo permitido.'),
104
+ '53098' => array('message' => 'Total do pedido contém valor negativo.'),
105
+ '53099' => array('message' => 'Valor extra está fora do intervalo permitido.'),
106
+ '53101' => array('message' => 'Modo de pagamento contém valor inválido. Os valores aceitos são "default" e "gateway".'),
107
+ '53102' => array('message' => 'Método de pagamento contém valor inválido. Os valores aceitos são "creditCard", "boleto" e "eft".'),
108
+ '53104' => array('message' => 'Custo de transporte foi informado, endereço de entrega deve ser completo.'),
109
+ '53105' => array('message' => 'E-mail do remetente também deve ser informado.'),
110
+ '53106' => array('message' => 'Informações do portador do cartão de crédito estão incompletas.'),
111
+ '53109' => array('message' => 'E-mail do remetente também deve ser informado.'),
112
+ '53110' => array('message' => 'Banco é obrigatório.'),
113
+ '53111' => array('message' => 'Banco não aceito.'),
114
+ '53115' => array('message' => 'Data de nascimento do remetente contém valor inválido.'),
115
+ '53118' => array('message' => 'CPF/CNPJ do comprador é obrigatório.'),
116
+ '53121' => array('message' => 'Pagamento com cartão de crédito empresarial não é permitido para este vendedor.'),
117
+ '53122' => array('message' => 'Domínio do e-mail do remetente deve conter @sandbox.pagseguro.com.br.'),
118
+ '53140' => array('message' => 'Quantidade de parcelas está fora do intervalo permitido.'),
119
+ '53141' => array('message' => 'O PagSeguro identificou problemas em sua conta.'),
120
+ '53142' => array('message' => 'Número do Cartão de Crédito é inválido.'),
121
+ '53150' => array('message' => 'Por favor, tente realizar o pagamento novamente (verifique se o número de seu cartão está correto).')
122
+ );
123
+
124
+ /**
125
+ *
126
+ * @var string
127
+ */
128
+ private $code;
129
+
130
+ /**
131
+ *
132
+ * @var string
133
+ */
134
+ private $message;
135
+
136
+ public function __construct($code) {
137
+ if (array_key_exists($code, self::$list)) {
138
+ $v = self::$list[$code];
139
+
140
+ $this->code = $code;
141
+ $this->message = $v['message'];
142
+ } else {
143
+ $this->code = $code;
144
+ $this->message = 'Não foi possível processar o pagamento.';
145
+ }
146
+ }
147
+
148
+ public function getCode() {
149
+ return $this->code;
150
+ }
151
+
152
+ public function getMessage() {
153
+ return $this->message;
154
+ }
155
+
156
+ public function setCode($code) {
157
+ $this->code = $code;
158
+ }
159
+
160
+ public function setMessage($message) {
161
+ $this->message = $message;
162
+ }
163
+
164
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Helper/Data.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Helper_Data extends Mage_Core_Helper_Abstract {
16
+
17
+ private $logger;
18
+
19
+ /**
20
+ * Initialize resource model
21
+ */
22
+ protected function _construct() {
23
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
24
+ }
25
+
26
+ /**
27
+ * Verifica se o módulo está ativo.
28
+ * @return type boolean
29
+ */
30
+ public function isModuleActive() {
31
+ return Mage::getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::ACTIVE);
32
+ }
33
+
34
+ public static function buildParametersForLog($parameters) {
35
+ $paramsLog = '';
36
+ foreach ($parameters as $key => $value) {
37
+ $paramsLog .= $key . ' = ' . $value . "\n";
38
+ }
39
+ return $paramsLog;
40
+ }
41
+
42
+ public static function formatPriceToUS($value) {
43
+ if (is_null($value)) {
44
+ return null;
45
+ }
46
+ if (!is_string($value)) {
47
+ return floatval($value);
48
+ }
49
+
50
+ //trim space and apos
51
+ $value = str_replace('\'', '', $value);
52
+ $value = str_replace(' ', '', $value);
53
+
54
+ $separatorComa = strpos($value, ',');
55
+ $separatorDot = strpos($value, '.');
56
+
57
+ if ($separatorComa !== false && $separatorDot !== false) {
58
+ if ($separatorComa > $separatorDot) {
59
+ $value = str_replace('.', '', $value);
60
+ $value = str_replace(',', '.', $value);
61
+ } else {
62
+ $value = str_replace(',', '', $value);
63
+ }
64
+ } elseif ($separatorComa !== false) {
65
+ $value = str_replace(',', '.', $value);
66
+ }
67
+
68
+ return floatval($value);
69
+ }
70
+
71
+ /*
72
+ * Converte o valor do formato enviado em centavos para o formato numérico.
73
+ * Exemplo: 49999 para 499.99
74
+ */
75
+
76
+ public static function convertStringCentsToDouble($cents) {
77
+ $value = self::formatPriceToUS($cents);
78
+ $value = str_ireplace(".", "", $value);
79
+ return $value / 100;
80
+ }
81
+
82
+ public function formatCpf($cpf) {
83
+ $formatCpf = preg_replace("/[^0-9]/", '', $cpf);
84
+ $formatCpf = str_pad($formatCpf, 11, '0', STR_PAD_LEFT);
85
+
86
+ return substr($formatCpf, -11);
87
+ }
88
+
89
+ public function formatCep($cep) {
90
+ $formatCep = preg_replace("/[^0-9]/", '', $cep);
91
+ $formatCep = str_pad($formatCep, 8, '0', STR_PAD_RIGHT);
92
+
93
+ return substr($formatCep, -8);
94
+ }
95
+
96
+ public static function notNull($value) {
97
+ if (is_array($value)) {
98
+ if (sizeof($value) > 0) {
99
+ return true;
100
+ }
101
+ return false;
102
+ }
103
+ if (($value != '') && (strtolower($value) != 'null') && (strlen(trim($value)) > 0)) {
104
+ return true;
105
+ }
106
+ return false;
107
+ }
108
+
109
+ public static function clearSession() {
110
+ Mage::getSingleton('checkout/session')->clear();
111
+ foreach (Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item) {
112
+ Mage::getSingleton('checkout/cart')->removeItem($item->getId())->save();
113
+ }
114
+ }
115
+
116
+ public static function formataValorPagSeguro($valor) {
117
+ $valor = Mage::helper('ipgbase/math')->formatPriceToUS($valor);
118
+ $a1 = explode('.', $valor);
119
+ if (sizeof($a1) == 1) {
120
+ $valor = $a1[0] . '.00';
121
+ } else if (strlen($a1[1]) == 1) {
122
+ $valor = $a1[0] . '.' . $a1[1] . '0';
123
+ }
124
+ return $valor;
125
+ }
126
+
127
+ public function getPagSeguroLibrary() {
128
+ $ds = DIRECTORY_SEPARATOR;
129
+ $basePath = Mage::getBaseDir('lib');
130
+ require_once $basePath . $ds . 'Ipagare' . $ds . 'PagSeguroDireto' . $ds . 'Library.php';
131
+ }
132
+
133
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Helper/Math.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Helper_Math extends Mage_Core_Helper_Abstract {
16
+
17
+ /**
18
+ * Calcula valor da parcela para financiamento em parcelas fixas.
19
+ *
20
+ * @param total
21
+ * Valor total financiado
22
+ * @param interestRate
23
+ * Taxa de juros
24
+ * @param numberOfPayments
25
+ * Número de parcelas
26
+ * @return valor da parcela
27
+ */
28
+ public static function calculatePayment($total, $interestRate, $numberOfPayments) {
29
+ $payment = 0;
30
+ if ($interestRate != 0) {
31
+ if (self::isJuroComposto()) {
32
+ // Calculo do valor da parcela - Juros Composto { M = (C. (1 + i)t) / t }
33
+ $total_parcela = round(($total * pow((1 + $interestRate), $numberOfPayments)) / $numberOfPayments, 2);
34
+ $payment = round($total_parcela, 2);
35
+ } else {
36
+ // Calculo do valor da parcela - Tabela Price { R = P x [ i (1 + i)n ] ÷ [ (1 + i )n -1] }
37
+ $payment = round($total * (($interestRate * pow((1 + $interestRate), $numberOfPayments)) / (pow((1 + $interestRate), $numberOfPayments) - 1)), 2);
38
+ }
39
+ } else {
40
+ $payment = $total / $numberOfPayments;
41
+ }
42
+
43
+ return $payment;
44
+ }
45
+
46
+ /*
47
+ * Converte o valor do formato enviado em centavos para o formato numérico.
48
+ * Exemplo: 49999 para 499.99
49
+ */
50
+
51
+ public static function convertStringCentsToDouble($cents) {
52
+ $value = Mage::helper('ipgbase/math')->formatPriceToUS($cents);
53
+ $value = str_ireplace(".", "", $value);
54
+ return $value / 100;
55
+ }
56
+
57
+ /**
58
+ * Formata um valor para ter no máximo dois dígitos após a vírgula.
59
+ */
60
+ public static function formatAmount($amount) {
61
+ return round($amount, 2);
62
+ }
63
+
64
+ /**
65
+ * Recebe um numérico e retorna o mesmo valor em centavos.
66
+ * Entrada: 12,34, saída 1234
67
+ */
68
+ public static function formatPaymentAmountToCents($amount) {
69
+ $amountInt = (int) $amount;
70
+ if ($amountInt == $amount) {
71
+ $amount = (int) $amount;
72
+ //transforma em string
73
+ $amountStr = $amount;
74
+ $amountStr = str_ireplace(",", "", $amountStr);
75
+ $amountStr = str_ireplace(".", "", $amountStr);
76
+ //adiciona os zeros dos centavos.
77
+ $amountStr = $amountStr . '00';
78
+ } else {
79
+ $amount = self::formatAmount($amount);
80
+ $amountStr = $amount;
81
+
82
+ $pos = strpos($amountStr, '.');
83
+ $decimais = substr($amountStr, $pos + 1);
84
+ $tamDecimais = strlen($decimais);
85
+
86
+ while ($tamDecimais < 2) {
87
+ $amountStr = $amountStr . '0';
88
+
89
+ $pos = strpos($amountStr, '.');
90
+ $decimais = substr($amountStr, $pos + 1);
91
+ $tamDecimais = strlen($decimais);
92
+ }
93
+
94
+ $amountStr = str_ireplace(",", "", $amountStr);
95
+ $amountStr = str_ireplace(".", "", $amountStr);
96
+ }
97
+
98
+ return $amountStr;
99
+ }
100
+
101
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Helper/Module.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Helper_Module extends Mage_Core_Helper_Abstract {
16
+
17
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Helper/Session.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Helper_Session extends Mage_Core_Helper_Abstract {
16
+
17
+ private $logger;
18
+
19
+ /**
20
+ * Initialize resource model
21
+ */
22
+ protected function _construct() {
23
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
24
+ }
25
+
26
+ public function getCurrentOrder() {
27
+ $order = Mage::getModel('sales/order');
28
+ $realOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
29
+ if (isset($realOrderId) && $realOrderId != null) {
30
+ return $order->loadByAttribute('increment_id', $realOrderId);
31
+ }
32
+
33
+ $sessionQuote = Mage::getSingleton('checkout/session')->getQuote();
34
+ $realOrderId = $sessionQuote->getReservedOrderId();
35
+ $order->loadByAttribute('increment_id', $realOrderId);
36
+
37
+ return $order;
38
+ }
39
+
40
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Helper/Validator.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Helper_Validator extends Mage_Core_Helper_Abstract {
16
+
17
+ private $logger;
18
+
19
+ /**
20
+ * Initialize resource model
21
+ */
22
+ protected function _construct() {
23
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
24
+ }
25
+
26
+ /** Formata o telefone; opcional: bool para validador
27
+ *
28
+ * @param type $telephone
29
+ * @param type $returnbool
30
+ * @return type
31
+ */
32
+ public function formatTelephone($telephone) {
33
+ $formatTelephone = preg_replace("/[^0-9]/", "", $telephone);
34
+ $formatTelephone = ltrim($formatTelephone, '0');
35
+ if (strlen($formatTelephone) <= 11 && strlen($formatTelephone) >= 10) {
36
+ return $formatTelephone;
37
+ }
38
+ return false;
39
+ }
40
+
41
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Instituicao.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Instituicao {
16
+
17
+ const VISA = 'VISA';
18
+ const MASTERCARD = 'MASTERCARD';
19
+ const AMERICAN_EXPRESS = "AMEX";
20
+ const AURA = 'AURA';
21
+ const DINERS = "DINERS";
22
+ const HIPERCARD = "HIPERCARD";
23
+ const ELO = "ELO";
24
+ const PLENOCARD = "PLENOCARD";
25
+ const PERSONALCARD = "PERSONALCARD";
26
+ const JCB = "JCB";
27
+ const DISCOVER = "DISCOVER";
28
+ const BRASILCARD = "BRASILCARD";
29
+ const FORTBRASIL = "FORTBRASIL";
30
+ const BOLETO = "BOLETO";
31
+ const BRADESCO = "BRADESCO";
32
+ const SANTANDER = "SANTANDER";
33
+ const ITAU = "ITAU";
34
+ const BANCO_BRASIL = "BANCODOBRASIL";
35
+ const BANRISUL = "BANRISUL";
36
+ const HSBC = "HSBC";
37
+ const GRANDCARD = 'GRANDCARD';
38
+ const CARDBAN = 'CARDBAN';
39
+ const VALECARD = 'VALECARD';
40
+ const CABAL = 'CABAL';
41
+ const MAIS = 'MAIS';
42
+ const AVISTA = 'AVISTA';
43
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Credential.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Credential extends Mage_Core_Model_Abstract {
16
+
17
+ private $logger;
18
+
19
+ /**
20
+ * Initialize resource model
21
+ */
22
+ protected function _construct() {
23
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
24
+ }
25
+
26
+ /**
27
+ *
28
+ *
29
+ * @return String
30
+ */
31
+ public function getAccountCredentials() {
32
+ $email = Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::EMAIL);
33
+ $token = Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::TOKEN);
34
+
35
+ return new Ipagare_PagSeguroDireto_Domain_AccountCredentials($email, $token);
36
+ }
37
+
38
+ /**
39
+ * Autentica no PagSeguro e retorna o ID da Sessão.
40
+ *
41
+ * @return String
42
+ */
43
+ public function getSessionId() {
44
+ $credentials = $this->getAccountCredentials();
45
+ $sessionResponse = Ipagare_PagSeguroDireto_Service_SessionService::createSession($credentials);
46
+ if ($sessionResponse->hasErrors()) {
47
+ foreach ($sessionResponse->getErrors() as $error) {
48
+ $this->logger->error('(' . $error->getCode() . ') ' . $error->getMessage());
49
+ }
50
+ }
51
+
52
+ return $sessionResponse;
53
+ }
54
+
55
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Discount.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Discount extends Mage_Core_Model_Abstract {
16
+
17
+ public function canApply($address) {
18
+ $data = Mage::app()->getRequest()->getPost('payment', array());
19
+ if (!count($data) || !isset($data['type'])) {
20
+ return false;
21
+ }
22
+
23
+ $currentPaymentMethod = null;
24
+ $paymentType = null;
25
+ $paymentMode = null;
26
+
27
+ if (isset($data['type'])) {
28
+ $arrayex = explode('_', $data['type']);
29
+ if (isset($arrayex[0]) && isset($arrayex[1])) {
30
+ $paymentType = $arrayex[0];
31
+ $paymentMode = $arrayex[1];
32
+ }
33
+ }
34
+
35
+ $sessionQuote = Mage::getSingleton('checkout/session')->getQuote();
36
+ if ($sessionQuote->getPayment() != null && $sessionQuote->getPayment()->hasMethodInstance()) {
37
+ $currentPaymentMethod = $sessionQuote->getPayment()->getMethodInstance()->getCode();
38
+ } elseif (isset($data['method'])) {
39
+ $currentPaymentMethod = $data['method'];
40
+ }
41
+
42
+ if ($currentPaymentMethod == 'ipgpagsegurodireto' && $paymentType != null && $paymentMode == Ipagare_IpgPagSeguroDireto_PaymentMode::A01) {
43
+ return true;
44
+ }
45
+
46
+ return false;
47
+ }
48
+
49
+ public function getDiscount() {
50
+ $data = Mage::app()->getRequest()->getPost('payment', array());
51
+
52
+ $paymentType = null;
53
+ if (isset($data['type'])) {
54
+ $arrayex = explode('_', $data['type']);
55
+ if (isset($arrayex[0]) && isset($arrayex[1])) {
56
+ $paymentType = new Ipagare_PagSeguroDireto_Domain_PaymentMethodCode($arrayex[0]);
57
+ }
58
+ }
59
+
60
+ $descontoAvista = str_replace(',', '.', Mage::getModel('ipgpagsegurodireto/paymentMath')->getDescontoAvista($paymentType));
61
+ $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
62
+ $baseSubtotalWithDiscount = 0;
63
+ $baseTax = 0;
64
+
65
+ $sessionQuote = Mage::getSingleton('checkout/session')->getQuote();
66
+ if ($sessionQuote->isVirtual()) {
67
+ $address = $sessionQuote->getBillingAddress();
68
+ } else {
69
+ $address = $sessionQuote->getShippingAddress();
70
+ }
71
+ if ($address) {
72
+ $baseSubtotalWithDiscount = $address->getBaseSubtotalWithDiscount();
73
+ $baseTax = $address->getBaseTaxAmount();
74
+ }
75
+
76
+ return Ipagare_IpgBase_PaymentDiscount::getInstance($baseCurrencyCode, $descontoAvista, $baseSubtotalWithDiscount, $baseTax);
77
+ }
78
+
79
+ public function getIpgDiscount($order) {
80
+ return $order->getIpgPagsegurodiretoDiscountAmount();
81
+ }
82
+
83
+ public function getIpgBaseDiscount($order) {
84
+ return $order->getIpgPagsegurodiretoBaseDiscountAmount();
85
+ }
86
+
87
+ public function getIpgDiscountCode() {
88
+ return 'discount-ipgpagsegurodireto';
89
+ }
90
+
91
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Entity/Erro.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Entity_Erro extends Mage_Core_Model_Abstract {
16
+
17
+ public function _construct() {
18
+ $this->_init('ipgpagsegurodireto/entity_erro');
19
+ }
20
+
21
+ public function loadByAttribute($attribute, $value) {
22
+ $this->load($value, $attribute);
23
+ return $this;
24
+ }
25
+
26
+ public function getErrorCodes($orderId) {
27
+ $resource = Mage::getSingleton('core/resource');
28
+ $readConnection = $resource->getConnection('core_read');
29
+
30
+ $sql = "SELECT `code` FROM `{$resource->getTableName('ipagare_pagsegurodireto_erro')}` WHERE `order_id` = {$orderId} ";
31
+ return $readConnection->fetchAll($sql);
32
+ }
33
+
34
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Entity/Payment.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Entity_Payment extends Mage_Core_Model_Abstract {
16
+
17
+ public function _construct() {
18
+ $this->_init('ipgpagsegurodireto/entity_payment');
19
+ }
20
+
21
+ public function loadByAttribute($attribute, $value) {
22
+ $this->load($value, $attribute);
23
+ return $this;
24
+ }
25
+
26
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Entity/Sonda.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Entity_Sonda extends Mage_Core_Model_Abstract {
16
+
17
+ public function _construct() {
18
+ $this->_init('ipgpagsegurodireto/entity_sonda');
19
+ }
20
+
21
+ public function loadByAttribute($attribute, $value) {
22
+ $this->load($value, $attribute);
23
+ return $this;
24
+ }
25
+
26
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/ExpiraPedido.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_ExpiraPedido extends Mage_Core_Model_Abstract {
16
+
17
+ private $logger;
18
+
19
+ /**
20
+ * Initialize resource model
21
+ */
22
+ protected function _construct() {
23
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
24
+ }
25
+
26
+ public function buscaPedidosParaExpirar($dataInicialBuscaPedidos, $dataCriacaoMaxima) {
27
+ $resource = Mage::getSingleton('core/resource');
28
+ $sql = "SELECT increment_id FROM {$resource->getTableName('sales_flat_order')} o
29
+ INNER JOIN {$resource->getTableName('ipagare_pagsegurodireto_pagamento')} ip ON ip.order_id = o.increment_id";
30
+ $sql .= ' WHERE o.state=\'' . Mage_Sales_Model_Order::STATE_NEW . '\'';
31
+ $sql .= ' and o.created_at BETWEEN \'' . $dataInicialBuscaPedidos . '\' and \'' . $dataCriacaoMaxima . '\'';
32
+
33
+ $readConnection = $resource->getConnection('core_read');
34
+ $orderIds = $readConnection->fetchAll($sql);
35
+
36
+ return $orderIds;
37
+ }
38
+
39
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/IpgPagSeguroDireto.php ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ Mage::helper('ipgpagsegurodireto')->getPagSeguroLibrary();
16
+
17
+ class Ipagare_IpgPagSeguroDireto_Model_IpgPagSeguroDireto extends Mage_Payment_Model_Method_Abstract {
18
+
19
+ private $logger;
20
+
21
+ /**
22
+ * rewrited for Mage_Payment_Model_Method_Abstract
23
+ */
24
+ protected $_code = 'ipgpagsegurodireto';
25
+ protected $_isGateway = true;
26
+ protected $_canAuthorize = true;
27
+ protected $_canCapture = true;
28
+ protected $_canCapturePartial = false;
29
+ protected $_canRefund = true;
30
+ protected $_canVoid = true;
31
+ protected $_canUseInternal = true;
32
+ protected $_canUseCheckout = true;
33
+ protected $_canUseForMultishipping = true;
34
+ protected $_isInitializeNeeded = true;
35
+ protected $_formBlockType = 'ipgpagsegurodireto/standard_form';
36
+ protected $_infoBlockType = 'ipgpagsegurodireto/payment_info';
37
+
38
+ public function __construct() {
39
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
40
+ }
41
+
42
+ protected function _construct() {
43
+ parent::_construct();
44
+ }
45
+
46
+ public function isAvailable($quote = null) {
47
+ $email = Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::EMAIL);
48
+ $token = Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::TOKEN);
49
+
50
+ if (Mage::helper('ipgbase/stringUtils')->isEmpty($email)) {
51
+ $this->logger->fatal('Email ausente na configuração do Módulo PagSeguro Direto.');
52
+ return false;
53
+ }
54
+ if (Mage::helper('ipgbase/stringUtils')->isEmpty($token)) {
55
+ $this->logger->fatal('Token ausente na configuração do Módulo PagSeguro Direto.');
56
+ return false;
57
+ }
58
+
59
+ return parent::isAvailable($quote);
60
+ }
61
+
62
+ public function getOrderPlaceRedirectUrl() {
63
+ $order = Mage::helper('ipgpagsegurodireto/session')->getCurrentOrder();
64
+ $paymentPost = $this->getPaymentPost();
65
+ $opc = explode("_", $paymentPost['type']);
66
+
67
+ $paymentType = new Ipagare_PagSeguroDireto_Domain_PaymentMethodCode($opc[0]);
68
+ $paymentMode = Ipagare_IpgPagSeguroDireto_PaymentMode::valueOf($opc[1]);
69
+
70
+ $this->_colocaParametrosNaSessao($paymentType, $paymentMode, $order);
71
+
72
+ return Mage::getUrl('ipgpagsegurodireto/payment/pay');
73
+ }
74
+
75
+ protected function _colocaParametrosNaSessao(Ipagare_PagSeguroDireto_Domain_PaymentMethodCode $paymentType, Ipagare_IpgPagSeguroDireto_PaymentMode $paymentMode, $order) {
76
+ $sessionCoreMage = Mage::getSingleton('ipgbase/session');
77
+ $sessionCoreMage->setMeioPagamento($paymentType->getValue());
78
+ $sessionCoreMage->setFormaPagamento($paymentMode->getCodigo());
79
+ $sessionCoreMage->setOrderId($order->getRealOrderId());
80
+ $sessionCoreMage->setRealOrderId($order->getRealOrderId());
81
+
82
+ $paymentPost = $this->getPaymentPost();
83
+
84
+ $sessionCoreMage->setSenderHash($this->getSenderHash($paymentPost));
85
+ $sessionCoreMage->setPagSeguroSessionId($this->getPagSeguroSessionId($paymentPost));
86
+ $sessionCoreMage->setPagSeguroSenderHash($this->getPagSeguroSenderHash($paymentPost));
87
+
88
+ $paymentMethod = null;
89
+
90
+ if ($paymentType->isCreditCard()) {
91
+ $paymentMethod = 'creditCard';
92
+ $codigoBinCartao = $this->getCodigoBinCartao($paymentPost);
93
+ $numeroCartao = trim($codigoBinCartao . $this->getNumeroCartao($paymentPost));
94
+ $mesValidadeCartao = $this->getMesValidadeCartao($paymentPost);
95
+ $anoValidadeCartao = $this->getAnoValidadeCartao($paymentPost);
96
+ $codigoSegurancaCartao = $this->getCodigoSegurancaCartao($paymentPost);
97
+
98
+ $encrypt = Mage::getModel('payment/info');
99
+ $numeroCartao = $encrypt->encrypt($numeroCartao);
100
+ $mesValidadeCartao = $encrypt->encrypt($mesValidadeCartao);
101
+ $anoValidadeCartao = $encrypt->encrypt($anoValidadeCartao);
102
+ $codigoSegurancaCartao = $encrypt->encrypt($codigoSegurancaCartao);
103
+
104
+ $sessionCoreMage->setCreditCardToken($this->getCreditCardToken($paymentPost));
105
+ $sessionCoreMage->setNumeroCartao($numeroCartao);
106
+ $sessionCoreMage->setMesValidadeCartao($mesValidadeCartao);
107
+ $sessionCoreMage->setAnoValidadeCartao($anoValidadeCartao);
108
+ $sessionCoreMage->setCodigoSegurancaCartao($codigoSegurancaCartao);
109
+ $sessionCoreMage->setNomePortador($this->getNomePortador($paymentPost));
110
+
111
+ $sessionCoreMage->setPagSeguroCreditCardToken($this->getPagSeguroCreditCardToken($paymentPost));
112
+ $sessionCoreMage->setPagSeguroInstallmentQuantity($this->getPagSeguroInstallmentQuantity($paymentPost));
113
+ $sessionCoreMage->setPagSeguroInstallmentValue($this->getPagSeguroInstallmentValue($paymentPost));
114
+
115
+ $sessionCoreMage->setCpfPortador($this->getCpfPortador($paymentPost));
116
+ $sessionCoreMage->setDataNascimentoPortador($this->getNascimentoPortador($paymentPost));
117
+ $sessionCoreMage->setAreaCodePortador($this->getAreaCodePortador($paymentPost));
118
+ $sessionCoreMage->setFoneNumberPortador($this->getPhonePortador($paymentPost));
119
+ } else if ($paymentType->isBoleto()) {
120
+ $paymentMethod = 'boleto';
121
+ } else if ($paymentType->isDebitoBancario()) {
122
+ $paymentMethod = 'eft';
123
+ }
124
+
125
+ $sessionCoreMage->setPagSeguroPaymentMethod($paymentMethod);
126
+ }
127
+
128
+ private function getPaymentPost() {
129
+ return Mage::app()->getRequest()->getPost('payment');
130
+ }
131
+
132
+ private function getNumeroCartao($paymentPost) {
133
+ return $paymentPost["ipgpagsegurodireto_numero_cartao"];
134
+ }
135
+
136
+ private function getMesValidadeCartao($paymentPost) {
137
+ return $paymentPost["ipgpagsegurodireto_mes_validade_cartao"];
138
+ }
139
+
140
+ private function getAnoValidadeCartao($paymentPost) {
141
+ return $paymentPost["ipgpagsegurodireto_ano_validade_cartao"];
142
+ }
143
+
144
+ private function getCodigoSegurancaCartao($paymentPost) {
145
+ return $paymentPost["ipgpagsegurodireto_codigo_seguranca_cartao"];
146
+ }
147
+
148
+ private function getCreditCardToken($paymentPost) {
149
+ if (isset($paymentPost["ipg_pagsegurodireto_credit_card_token"])) {
150
+ if (!Mage::helper('ipgbase/stringUtils')->isEmpty($paymentPost["ipg_pagsegurodireto_credit_card_token"])) {
151
+ return $paymentPost["ipg_pagsegurodireto_credit_card_token"];
152
+ }
153
+ }
154
+ return '';
155
+ }
156
+
157
+ private function getSenderHash($paymentPost) {
158
+ if (isset($paymentPost["ipg_pagsegurodireto_sender_hash"])) {
159
+ if (!Mage::helper('ipgbase/stringUtils')->isEmpty($paymentPost["ipg_pagsegurodireto_sender_hash"])) {
160
+ return $paymentPost["ipg_pagsegurodireto_sender_hash"];
161
+ }
162
+ }
163
+ return '';
164
+ }
165
+
166
+ private function getCodigoBinCartao($paymentPost) {
167
+ if (isset($paymentPost["ipgpagsegurodireto_codigo_bin_cartao"])) {
168
+ if (!Mage::helper('ipgbase/stringUtils')->isEmpty($paymentPost["ipgpagsegurodireto_codigo_bin_cartao"])) {
169
+ return $paymentPost["ipgpagsegurodireto_codigo_bin_cartao"];
170
+ }
171
+ }
172
+ return '';
173
+ }
174
+
175
+ private function getNomePortador($paymentPost) {
176
+ return $paymentPost["ipgpagsegurodireto_nome_titular_cartao"];
177
+ }
178
+
179
+ private function getCpfPortador($paymentPost) {
180
+ return $paymentPost["ipgpagsegurodireto_cpf_titular_cartao"];
181
+ }
182
+
183
+ private function getNascimentoPortador($paymentPost) {
184
+ return $paymentPost["ipgpagsegurodireto_nascimento_titular_cartao"];
185
+ }
186
+
187
+ private function getAreaCodePortador($paymentPost) {
188
+ return $paymentPost["ipgpagsegurodireto_areacode_titular_cartao"];
189
+ }
190
+
191
+ private function getPhonePortador($paymentPost) {
192
+ return $paymentPost["ipgpagsegurodireto_fonenumber_titular_cartao"];
193
+ }
194
+
195
+ private function getPagSeguroSessionId($paymentPost) {
196
+ return $paymentPost["ipg_pagsegurodireto_session_id"];
197
+ }
198
+
199
+ private function getPagSeguroCreditCardToken($paymentPost) {
200
+ return $paymentPost["ipg_pagsegurodireto_credit_card_token"];
201
+ }
202
+
203
+ private function getPagSeguroSenderHash($paymentPost) {
204
+ return $paymentPost["ipg_pagsegurodireto_sender_hash"];
205
+ }
206
+
207
+ private function getPagSeguroInstallmentQuantity($paymentPost) {
208
+ return $paymentPost["ipg_pagsegurodireto_installment_quantity"];
209
+ }
210
+
211
+ private function getPagSeguroInstallmentValue($paymentPost) {
212
+ return $paymentPost["ipg_pagsegurodireto_installment_value"];
213
+ }
214
+
215
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Mysql4/Entity/Erro.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Mysql4_Entity_Erro extends Mage_Core_Model_Mysql4_Abstract {
16
+
17
+ public function _construct() {
18
+ $this->_init('ipgpagsegurodireto/entity_erro', 'id_ipagare_pagsegurodireto_erro');
19
+ }
20
+
21
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Mysql4/Entity/Erro/Collection.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Mysql4_Entity_Erro_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
16
+
17
+ public function __construct() {
18
+ $this->_init('ipgpagsegurodireto/entity_erro');
19
+ }
20
+
21
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Mysql4/Entity/Payment.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Mysql4_Entity_Payment extends Mage_Core_Model_Mysql4_Abstract {
16
+
17
+ public function _construct() {
18
+ $this->_init('ipgpagsegurodireto/entity_payment', 'id_ipagare_pagsegurodireto_pagamento');
19
+ }
20
+
21
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Mysql4/Entity/Payment/Collection.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Mysql4_Entity_Payment_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
16
+
17
+ public function __construct() {
18
+ $this->_init('ipgpagsegurodireto/entity_payment');
19
+ }
20
+
21
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Mysql4/Entity/Sonda.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Mysql4_Entity_Sonda extends Mage_Core_Model_Mysql4_Abstract {
16
+
17
+ public function _construct() {
18
+ $this->_init('ipgpagsegurodireto/entity_sonda', 'id_ipagare_pagsegurodireto_sonda');
19
+ }
20
+
21
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Mysql4/Entity/Sonda/Collection.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Mysql4_Entity_Payment_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
16
+
17
+ public function __construct() {
18
+ $this->_init('ipgpagsegurodireto/entity_sonda');
19
+ }
20
+
21
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Notification.php ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Notification extends Mage_Core_Model_Abstract {
16
+
17
+ private $logger;
18
+
19
+ /**
20
+ * Initialize resource model
21
+ */
22
+ protected function _construct() {
23
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
24
+ }
25
+
26
+ public function sendEmail(Mage_Sales_Model_Order $order) {
27
+ if (!Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_ENABLED)) {
28
+ $this->logger->info('Envio de e-mail desativado.');
29
+ return;
30
+ }
31
+
32
+ try {
33
+ if (!Mage::helper('ipgbase')->canSendEmail($order)) {
34
+ return;
35
+ }
36
+
37
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
38
+ if (!$order->getData('ipagare_order_orig') == Ipagare_IpgBase_Config::ORDER_ORIG_TELEVENDAS) {
39
+ $order->sendNewOrderEmail();
40
+ }
41
+ }
42
+
43
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_CANCELED) {
44
+ $msgEmailConfig = Mage::getStoreConfig('ipgbase/controle_envio_email/texto_email_cancelado');
45
+ $nomeLoja = '{{var store.getFrontendName()}}';
46
+ $urlLoja = Mage::helper('core/url')->getHomeUrl();
47
+
48
+ $searchUrlMsg = '##URL_LOJA##';
49
+ $replaceUrlMsg = "<a href='$urlLoja'>$nomeLoja</a>";
50
+
51
+ $msgEmailFinal = str_replace($searchUrlMsg, $replaceUrlMsg, $msgEmailConfig);
52
+
53
+ $order->sendOrderUpdateEmail(true, $msgEmailFinal);
54
+ }
55
+
56
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING) {
57
+ if ($order->hasInvoices()) {
58
+ $this->sendInvoiceEmail($order);
59
+ } else {
60
+ if ($order->getEmailSent()) {
61
+ $msgEmailConfig = Mage::getStoreConfig('ipgbase/controle_envio_email/texto_email_confirmado');
62
+ $order->sendOrderUpdateEmail(true, $msgEmailConfig);
63
+ } else {
64
+ $order->sendNewOrderEmail();
65
+ }
66
+ }
67
+ }
68
+ } catch (Exception $e) {
69
+ $message = "Não foi possivel enviar email de confirmação para o pedido: " . $order->getRealOrderId();
70
+ $this->addStatusHistoryComment($order, $message);
71
+ $this->logger->error($message . "\n" . $e->__toString());
72
+ return;
73
+ }
74
+ // FIXME: Testar Todas as formas de erro que podem ocorrer.
75
+ $message = "Email de confirmação para o pedido " . $order->getRealOrderId() . " enviado com sucesso.";
76
+ $this->addStatusHistoryComment($order, $message, true);
77
+ $this->logger->info($message);
78
+
79
+ return true;
80
+ }
81
+
82
+ public function sendInvoiceEmail(Mage_Sales_Model_Order $order) {
83
+ $invoice = $this->_getOrderInvoice($order);
84
+ if ($invoice == null) {
85
+ return;
86
+ }
87
+ try {
88
+ if (Mage::helper('ipgbase')->canSendEmail($order)) {
89
+ $invoice->setEmailSent(true);
90
+ $invoice->save();
91
+ $invoice->sendEmail();
92
+ }
93
+ } catch (Exception $e) {
94
+ $message = "Não foi possivel enviar email de fatura para o pedido: " . $order->getRealOrderId();
95
+ $this->logger->error($message . "\n" . $e->__toString());
96
+ return;
97
+ }
98
+ $message = "Email de fatura para o pedido " . $order->getRealOrderId() . " enviado com sucesso.";
99
+ $this->addStatusHistoryComment($order, $message, true);
100
+ $this->logger->info($message);
101
+ }
102
+
103
+ public function addStatusHistoryComment($order, $message, $notified = false) {
104
+ $order->addStatusHistoryComment($message, false)->setIsCustomerNotified($notified);
105
+ $order->save();
106
+ }
107
+
108
+ public function processCancel($orderId, $message, $sendEmail = true) {
109
+ if (isset($orderId)) {
110
+ $this->_processCancel($orderId, $message, $sendEmail);
111
+ }
112
+ return true;
113
+ }
114
+
115
+ protected function _processCancel($orderId, $message, $sendEmail) {
116
+ $order = $this->_getRequestOrder($orderId);
117
+
118
+ try {
119
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_CANCELED) {
120
+ return true;
121
+ }
122
+ $order->cancel();
123
+
124
+ //$order->addStatusToHistory($order->getStatus(), $message);
125
+ $this->addStatusHistoryComment($order, $message);
126
+
127
+ if ($order->hasInvoices() != '') {
128
+ $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, Mage::helper('ipgpagsegurodireto')->__('O pagamento e o pedido foram cancelados, mas não foi possível retornar os produtos ao estoque pois já havia uma fatura gerada para este pedido.'), $notified = false);
129
+ }
130
+ $order->save();
131
+ if ($sendEmail) {
132
+ $this->sendEmail($order);
133
+ }
134
+ return true;
135
+ } catch (Exception $e) {
136
+ $this->logger->error("Erro ao cancelar pedido $orderId \n $e->__toString()");
137
+ }
138
+
139
+ $this->_errorViolationSequenceStates($order);
140
+
141
+ return false;
142
+ }
143
+
144
+ public function processSuccess($orderId, $valorPago, $message) {
145
+ if (isset($orderId)) {
146
+ $this->_processSuccess($orderId, $valorPago, $message);
147
+ }
148
+ return true;
149
+ }
150
+
151
+ protected function _processSuccess($orderId, $valorPago, $message) {
152
+ $order = $this->_getRequestOrder($orderId);
153
+ $store = $order->getStore();
154
+ $invoiceConfig = false;
155
+ if ($order->getState() != Mage_Sales_Model_Order::STATE_PROCESSING) {
156
+ $order->setState(
157
+ Mage_Sales_Model_Order::STATE_PROCESSING, true, $message, $notified = false
158
+ );
159
+
160
+ $msg = "";
161
+ $invoiceConfig = Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::INVOICE, $store);
162
+ if ($invoiceConfig) {
163
+ if (!$invoice = $this->_getOrderInvoice($order)) {
164
+ $invoice = $order->prepareInvoice();
165
+ //$invoice->register()->capture();
166
+ $invoice->register()->pay();
167
+ $invoice->addComment(Mage::helper('ipgpagsegurodireto')->__('O pagamento do pedido foi confirmado e a nota-fiscal foi gerada automaticamente.'));
168
+ $invoice->setTransactionId($orderId);
169
+
170
+ $transactionSave = Mage::getModel('core/resource_transaction')
171
+ ->addObject($invoice)
172
+ ->addObject($invoice->getOrder())
173
+ ->save();
174
+ }
175
+ }
176
+ if (isset($valorPago) && !empty($valorPago)) {
177
+ $order->setBaseTotalPaid($valorPago);
178
+ $order->setTotalPaid(Mage::app()->getStore()->convertPrice($valorPago));
179
+ }
180
+ $order->save();
181
+ if ($invoiceConfig) {
182
+ if (Mage::getStoreConfig(Ipagare_IpgBase_ConfiguracoesSystem::CONTROLE_ENVIO_EMAIL_FATURA_GERADA)) {
183
+ $this->sendInvoiceEmail($order);
184
+ }
185
+ } else {
186
+ $this->sendEmail($order);
187
+ }
188
+
189
+ return true;
190
+ }
191
+ return false;
192
+ }
193
+
194
+ /**
195
+ * @return Mage_Sales_Model_Order
196
+ */
197
+ private function _getRequestOrder($codigoPedido) {
198
+ $tam = strlen($codigoPedido);
199
+ if ($tam > 0) {
200
+ $order = Mage::getModel('sales/order')->loadByAttribute('increment_id', $codigoPedido);
201
+
202
+ if ($order->isEmpty()) {
203
+ $this->_error(Mage::helper('ipgpagsegurodireto')->__('Erro na confirmação: pedido não encontrado.'));
204
+ }
205
+
206
+ return $order;
207
+ }
208
+ return null;
209
+ }
210
+
211
+ /**
212
+ * @param Mage_Sales_Model_Order $order
213
+ */
214
+ protected function _errorViolationSequenceStates($order) {
215
+ $this->_error(Mage::helper('ipgpagsegurodireto')->__('Erro na confirmação do Pagamento: erro no fluxo dos status de pedido.'));
216
+ }
217
+
218
+ /**
219
+ * Processa erros genéricos.
220
+ *
221
+ * @param string $comment
222
+ * @param array $request
223
+ * @param Mage_Sales_Model_Order $order
224
+ */
225
+ protected function _error($comment, $order = null) {
226
+ $message = $comment . Mage::helper('ipgpagsegurodireto')->__('<br/>Parâmetros da requisição');
227
+
228
+ if (!is_null($order)) {
229
+ $order->addStatusToHistory($order->getStatus(), $message)->save();
230
+ }
231
+ Mage::throwException($comment);
232
+ }
233
+
234
+ protected function _getOrderInvoice($order) {
235
+ foreach ($order->getInvoiceCollection() as $orderInvoice) {
236
+ if ($orderInvoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_PAID ||
237
+ $orderInvoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_OPEN) {
238
+ return $orderInvoice;
239
+ }
240
+ }
241
+ return false;
242
+ }
243
+
244
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Observer.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Observer extends Mage_Core_Model_Abstract {
16
+
17
+ private $logger;
18
+ protected $_code = 'ipgpagsegurodireto';
19
+
20
+ /**
21
+ * Initialize resource model
22
+ */
23
+ protected function _construct() {
24
+ parent::_construct();
25
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
26
+ }
27
+
28
+ /**
29
+ * Envia e-mail com confirmação de criação de novo pedido.
30
+ *
31
+ * @param Varien_Object $observer
32
+ */
33
+ public function sendNewOrderEmail($observer) {
34
+ $order = $observer->getEvent()->getOrder();
35
+ $mensagem = $observer->getEvent()->getMensagem();
36
+ $this->logger->info('Enviando e-mail de novo pedido [' . $order->getRealOrderId() . ']');
37
+
38
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
39
+ $pagamento = Mage::getModel('ipgpagsegurodireto/entity_payment')->loadByAttribute('order_id', $order->getRealOrderId());
40
+ if ($pagamento != null && $pagamento->getOrderId()) {
41
+ Mage::getModel('ipgpagsegurodireto/notification')->sendEmail($order);
42
+ }
43
+ }
44
+ if (!Mage::helper('ipgbase/stringUtils')->isEmpty($mensagem)) {
45
+ Mage::getModel('ipgpagsegurodireto/notification')->addStatusHistoryComment($order, $mensagem);
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Confirma o pagamento e Envia e-mail com confirmação de pagamento.
51
+ *
52
+ * @param Varien_Object $observer
53
+ */
54
+ public function proccessSuccess($observer) {
55
+ $order = $observer->getEvent()->getOrder();
56
+ $valor = $observer->getEvent()->getValor();
57
+ $mensagem = $observer->getEvent()->getMensagem();
58
+
59
+ $this->logger->info('Processando confirmação de pagamento. Pedido ' . $order->getRealOrderId());
60
+
61
+ Mage::getModel('ipgpagsegurodireto/notification')->processSuccess($order->getRealOrderId(), $valor, $mensagem);
62
+
63
+ $this->logger->info('Confirmação de pagamento foi concluido . Pedido ' . $order->getRealOrderId());
64
+ }
65
+
66
+ /**
67
+ * Cancela o pedido e Envia e-mail com confirmação de cancerlamento.
68
+ *
69
+ * @param Varien_Object $observer
70
+ */
71
+ public function proccessCancel($observer) {
72
+ $order = $observer->getEvent()->getOrder();
73
+ $mensagem = $observer->getEvent()->getMensagem();
74
+
75
+ $this->logger->info('Processando cancelamento da transação ' . $order->getRealOrderId());
76
+ Mage::getModel('ipgpagsegurodireto/notification')->processCancel($order->getRealOrderId(), $mensagem, Mage::helper('ipgbase')->canSendEmail($order));
77
+ $this->logger->info('Cancelamento da transação foi concluida ' . $order->getRealOrderId());
78
+ }
79
+
80
+ public function paymentSonda() {
81
+ $this->logger->info('Executando sonda - início');
82
+
83
+ $listOrderIds = Mage::getModel('ipgpagsegurodireto/sonda')->getOrderIds();
84
+
85
+ foreach ($listOrderIds as $key => $orderIds) {
86
+ foreach ($orderIds as $k => $orderId) {
87
+ if ($orderId != null) {
88
+ $this->logger->info('Vai consultar pedido [' . $orderId . '] no PagSeguro.');
89
+ Mage::getModel('ipgpagsegurodireto/sonda')->run($orderId);
90
+ }
91
+ }
92
+ }
93
+ $this->logger->info('Executando sonda - fim');
94
+ }
95
+
96
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Payment.php ADDED
@@ -0,0 +1,372 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Payment extends Mage_Core_Model_Abstract {
16
+
17
+ private $logger;
18
+
19
+ protected function _construct() {
20
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
21
+ }
22
+
23
+ /**
24
+ *
25
+ * @param Mage_Sales_Model_Order $order
26
+ * @param Ipagare_PagSeguroDireto_Domain_PaymentMethodCode
27
+ * @return Ipagare_PagSeguroDireto_Domain_PaymentResponse
28
+ */
29
+ public function pay(Mage_Sales_Model_Order $order, Ipagare_PagSeguroDireto_Domain_PaymentMethodCode $paymentType) {
30
+ $this->logger->info('Início criação da transação do pedido ' . $order->getIncrementId());
31
+
32
+ $credentials = Mage::getSingleton('ipgpagsegurodireto/credential')->getAccountCredentials();
33
+ $paymentRequest = $this->generatePaymentRequest($order, $paymentType);
34
+ return $paymentRequest->register($credentials);
35
+ }
36
+
37
+ protected function generatePaymentRequest(Mage_Sales_Model_Order $order, Ipagare_PagSeguroDireto_Domain_PaymentMethodCode $paymentType) {
38
+ $paymentRequest = new Ipagare_PagSeguroDireto_Domain_PaymentRequest();
39
+
40
+ /* reference */
41
+ $paymentRequest->setReference($order->getIncrementId());
42
+
43
+ /* Currency */
44
+ $paymentRequest->setCurrency(Ipagare_PagSeguroDireto_Domain_Currencies::getIsoCodeByName('REAL'));
45
+
46
+ /* Extra amount */
47
+ $paymentRequest->setExtraAmount($this->getExtraAmountValues($order));
48
+
49
+ /* Products */
50
+ $paymentRequest->setItems($this->generateProductsData($order));
51
+
52
+ /* Sender */
53
+ $paymentRequest->setSender($this->generateSenderData($order));
54
+
55
+ /* Shipping */
56
+ $paymentRequest->setShipping($this->generateShippingData($order));
57
+
58
+ /* Billing */
59
+ $paymentRequest->setBilling($this->generateBillingData($order));
60
+
61
+ $sessionCoreMage = Mage::getSingleton('ipgbase/session');
62
+ $paymentMethod = $sessionCoreMage->getPagSeguroPaymentMethod();
63
+ if ($paymentMethod == 'creditCard') {
64
+ $creditCardToken = $sessionCoreMage->getPagSeguroCreditCardToken();
65
+ $installmentQuantity = $sessionCoreMage->getPagSeguroInstallmentQuantity();
66
+
67
+ $paymentRequest->setCreditCardToken($creditCardToken);
68
+ $paymentRequest->setCreditCardHolder($this->generateCreditCardHolder());
69
+
70
+ /**
71
+ * Installment
72
+ */
73
+ $installmentValue = $sessionCoreMage->getPagSeguroInstallmentValue();
74
+ $installmentValue = number_format(round($installmentValue, 2), 2, '.', '');
75
+ $installment = array('quantity' => $installmentQuantity, 'value' => $installmentValue);
76
+ $paymentRequest->setInstallment(new Ipagare_PagSeguroDireto_Domain_Installment($installment));
77
+ } else if ($paymentMethod == 'eft') {
78
+ $paymentRequest->setBank($this->generateBank($paymentType));
79
+ }
80
+ /* receiver email */
81
+ $receiverEmail = Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::EMAIL);
82
+ $paymentRequest->setReceiverEmail($receiverEmail);
83
+
84
+ /* payment method */
85
+ $paymentRequest->setPaymentMethod($paymentMethod);
86
+
87
+ /* payment mode */
88
+ $paymentRequest->setPaymentMode('default');
89
+
90
+ return $paymentRequest;
91
+ }
92
+
93
+ /**
94
+ * Gets extra amount values for order
95
+ *
96
+ * @return float
97
+ */
98
+ private function getExtraAmountValues(Mage_Sales_Model_Order $order) {
99
+ $addition = 0.00;
100
+ $discount = 0.00;
101
+ if ($order->getBaseDiscountAmount()) {
102
+ $discount += $order->getBaseDiscountAmount();
103
+ }
104
+ if ($order->getIpgPagsegurodiretoBaseDiscountAmount()) {
105
+ $discount += $order->getIpgPagsegurodiretoBaseDiscountAmount();
106
+ }
107
+ // Afiliates Mage Store (www.magestore.com/affiliateplus/)
108
+ if ($order->getBaseAffiliateplusDiscount()) {
109
+ $discount += $order->getBaseAffiliateplusDiscount();
110
+ }
111
+ if ($order->getBaseTaxAmount()) {
112
+ $addition = $order->getBaseTaxAmount();
113
+ }
114
+ $amount = $addition + $discount;
115
+
116
+ return round($amount, 2);
117
+ }
118
+
119
+ /**
120
+ * Generates products data to PagSeguro transaction
121
+ *
122
+ * @return Array PagSeguroItem
123
+ */
124
+ private function generateProductsData(Mage_Sales_Model_Order $order) {
125
+ $pagseguroItems = array();
126
+ $count = 0;
127
+
128
+ foreach ($order->getAllItems() as $itemId => $item) {
129
+ $qtd = $item->getQtyToInvoice();
130
+ $basePrice = round($item->getBasePrice(), 2);
131
+ if (!empty($qtd) && $basePrice > 0) {
132
+ $pagSeguroItem = new Ipagare_PagSeguroDireto_Domain_Item();
133
+ $pagSeguroItem->setId($item->getProductId());
134
+ $pagSeguroItem->setDescription(substr($item->getName(), 0, 100));
135
+ $pagSeguroItem->setQuantity($qtd);
136
+
137
+ $pagSeguroItem->setAmount($basePrice);
138
+ //$pagSeguroItem->setWeight();
139
+ //$pagSeguroItem->setShippingCost();
140
+
141
+ $pagseguroItems[$count++] = $pagSeguroItem;
142
+ }
143
+ }
144
+
145
+
146
+ /**
147
+ * Taxas
148
+ *
149
+ * Obs.: foi passado pro ExtraAmount
150
+ */
151
+ /*
152
+ if ($order->getBaseTaxAmount() > 0) {
153
+ $pagSeguroItem = new Ipagare_PagSeguroDireto_Domain_Item();
154
+ $pagSeguroItem->setId('TX-0001');
155
+ $pagSeguroItem->setDescription(substr('Taxas', 0, 255));
156
+ $pagSeguroItem->setQuantity(1);
157
+
158
+ $pagSeguroItem->setAmount(round($order->getBaseTaxAmount(), 2));
159
+
160
+ $pagseguroItems[$count++] = $pagSeguroItem;
161
+ }
162
+ */
163
+
164
+ // frete
165
+ if ($order->getBaseShippingAmount() > 0) {
166
+ $pagSeguroItem = new Ipagare_PagSeguroDireto_Domain_Item();
167
+ $pagSeguroItem->setId('FR-0003');
168
+ $pagSeguroItem->setDescription(substr('Frete', 0, 100));
169
+ $pagSeguroItem->setQuantity(1);
170
+
171
+ $pagSeguroItem->setAmount(round($order->getBaseShippingAmount(), 2));
172
+
173
+ $pagseguroItems[$count++] = $pagSeguroItem;
174
+ }
175
+ return $pagseguroItems;
176
+ }
177
+
178
+ /**
179
+ * Generates sender data to PagSeguro transaction
180
+ *
181
+ * @return PagSeguroSender
182
+ */
183
+ private function generateSenderData(Mage_Sales_Model_Order $order) {
184
+ $sender = new Ipagare_PagSeguroDireto_Domain_Sender();
185
+
186
+ $senderName = trim($order->getCustomerFirstname()) . ' ' . ($order->getCustomerMiddlename() != null ? trim($order->getCustomerMiddlename()) . ' ' : '') . trim($order->getCustomerLastname());
187
+ $sender->setName(substr($senderName, 0, 50));
188
+
189
+ $senderCPF = $order->getCustomerTaxvat();
190
+ $senderCPF = Mage::helper('ipgbase')->getOnlyNumbers($senderCPF);
191
+
192
+ if ($order->getCustomerTipoPessoa() != null && $order->getCustomerTipoPessoa() == 'J') {
193
+ $sender->addDocument('cnpj', $senderCPF);
194
+ } else {
195
+ $sender->addDocument('cpf', $senderCPF);
196
+ }
197
+ // telefone
198
+ $billingAddress = $order->getBillingAddress();
199
+ $telephone = Mage::helper('ipgbase')->getOnlyNumbers($billingAddress->getTelephone());
200
+ $areaCode = substr($telephone, 0, 2);
201
+ $phoneNumber = substr($telephone, 2);
202
+ $sender->setPhone($areaCode, $phoneNumber);
203
+
204
+ /**
205
+ * Se utilizar o SandBox é preciso informar o e-mail contendo "@sandbox.pagseguro.com.br"
206
+ */
207
+ $senderEmail = Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::SENDER_EMAIL);
208
+ if ($senderEmail != null) {
209
+ $sender->setEmail($senderEmail);
210
+ } else {
211
+ $sender->setEmail($order->getCustomerEmail());
212
+ }
213
+ // hash
214
+ $sessionCoreMage = Mage::getSingleton('ipgbase/session');
215
+ $hash = $sessionCoreMage->getSenderHash();
216
+ $sender->setHash($hash);
217
+
218
+ return $sender;
219
+ }
220
+
221
+ private function generateBank(Ipagare_PagSeguroDireto_Domain_PaymentMethodCode $paymentType) {
222
+ $bank = new Ipagare_PagSeguroDireto_Domain_Bank();
223
+ $bank->setName($paymentType->getBandeira());
224
+
225
+ return $bank;
226
+ }
227
+
228
+ private function generateCreditCardHolder() {
229
+ $sessionCoreMage = Mage::getSingleton('ipgbase/session');
230
+ $name = $sessionCoreMage->getNomePortador();
231
+ $cpf = $sessionCoreMage->getCpfPortador();
232
+ $cpf = Mage::helper('ipgbase')->getOnlyNumbers($cpf);
233
+ $birthday = $sessionCoreMage->getDataNascimentoPortador();
234
+ $areaCode = $sessionCoreMage->getAreaCodePortador();
235
+ $phoneNumber = $sessionCoreMage->getFoneNumberPortador();
236
+
237
+ $creadiCardHolder = new Ipagare_PagSeguroDireto_Domain_CreditCardHolder();
238
+ $creadiCardHolder->setName(substr($name, 0, 50));
239
+ $creadiCardHolder->setCpf($cpf);
240
+ $creadiCardHolder->setBirthDate($birthday);
241
+
242
+ $areaCode = Mage::helper('ipgbase')->getOnlyNumbers($areaCode);
243
+ $creadiCardHolder->setAreaCode($areaCode);
244
+ $phoneNumber = Mage::helper('ipgbase')->getOnlyNumbers($phoneNumber);
245
+ $creadiCardHolder->setPhone($phoneNumber);
246
+
247
+ return $creadiCardHolder;
248
+ }
249
+
250
+ private function generateBillingData(Mage_Sales_Model_Order $order) {
251
+ $billing = new Ipagare_PagSeguroDireto_Domain_Billing();
252
+ $billing->setAddress($this->generateBillingAddressData($order));
253
+
254
+ return $billing;
255
+ }
256
+
257
+ /**
258
+ * Generates billing address data to PagSeguro transaction
259
+ *
260
+ * @return Ipagare_PagSeguroDireto_Domain_Address
261
+ */
262
+ private function generateBillingAddressData(Mage_Sales_Model_Order $order) {
263
+ $billingAddress = $order->getBillingAddress();
264
+
265
+ $address = new Ipagare_PagSeguroDireto_Domain_Address();
266
+ $address->setCity($billingAddress->getCity());
267
+ $address->setPostalCode($billingAddress->getPostcode());
268
+
269
+ $street = substr($billingAddress->getStreet(1), 0, 80);
270
+ $address->setStreet($street);
271
+
272
+ $number = substr($billingAddress->getStreet(2), 0, 20);
273
+ $address->setNumber($number);
274
+
275
+ $complement = substr($billingAddress->getStreet(3), 0, 40);
276
+ $address->setComplement($complement);
277
+
278
+ $district = substr($billingAddress->getStreet(4), 0, 60);
279
+ $address->setDistrict($district);
280
+
281
+ $country = $billingAddress->getCountryModel();
282
+ $address->setCountry($country->getIso3Code());
283
+ $address->setState($billingAddress->getRegionCode());
284
+
285
+ return $address;
286
+ }
287
+
288
+ private function generateShippingData(Mage_Sales_Model_Order $order) {
289
+ $shipping = new Ipagare_PagSeguroDireto_Domain_Shipping();
290
+ $shipping->setAddress($this->generateShippingAddressData($order));
291
+
292
+ return $shipping;
293
+ }
294
+
295
+ /**
296
+ * Generates shipping address data to PagSeguro transaction
297
+ *
298
+ * @return Ipagare_PagSeguroDireto_Domain_Address
299
+ */
300
+ private function generateShippingAddressData(Mage_Sales_Model_Order $order) {
301
+ $shippingAddress = null;
302
+ if ($order->getIsVirtual()) {
303
+ $shippingAddress = $order->getBillingAddress();
304
+ } else {
305
+ $shippingAddress = $order->getShippingAddress();
306
+ }
307
+
308
+ $address = new Ipagare_PagSeguroDireto_Domain_Address();
309
+ $address->setCity($shippingAddress->getCity());
310
+ $address->setPostalCode($shippingAddress->getPostcode());
311
+
312
+ $street = substr($shippingAddress->getStreet(1), 0, 80);
313
+ $address->setStreet($street);
314
+
315
+ $number = substr($shippingAddress->getStreet(2), 0, 20);
316
+ $address->setNumber($number);
317
+
318
+ $complement = substr($shippingAddress->getStreet(3), 0, 40);
319
+ $address->setComplement($complement);
320
+
321
+ $district = substr($shippingAddress->getStreet(4), 0, 60);
322
+ $address->setDistrict($district);
323
+
324
+ $country = $shippingAddress->getCountryModel();
325
+ $address->setCountry($country->getIso3Code());
326
+ $address->setState($shippingAddress->getRegionCode());
327
+
328
+ return $address;
329
+ }
330
+
331
+ public function save(Ipagare_PagSeguroDireto_Parser_PaymentParserData $paymentParserData, Ipagare_IpgPagSeguroDireto_PaymentMode $paymentMode) {
332
+ $payment = Mage::getModel('ipgpagsegurodireto/entity_payment');
333
+ $payment->loadByAttribute('order_id', $paymentParserData->getReference());
334
+
335
+ if (Mage::helper('ipgbase/stringUtils')->isEmpty($payment->getOrderId())) {
336
+ $payment->setOrderId($paymentParserData->getReference());
337
+ $payment->setTransactionCode($paymentParserData->getCode());
338
+ $payment->setMeioPagamento($paymentParserData->getPaymentMethod()->getCode()->getValue());
339
+ $payment->setFormaPagamento($paymentMode->getCodigo());
340
+ $payment->setValorTotal($paymentParserData->getGrossAmount());
341
+
342
+ $payment->setStatus($paymentParserData->getStatus()->getCode());
343
+ $payment->setPaymentLink($paymentParserData->getPaymentLink());
344
+ $payment->setCreatedTime(date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())));
345
+
346
+ $payment->save();
347
+ }
348
+ }
349
+
350
+ public function saveError($errorCode, $orderId) {
351
+ $erro = Mage::getModel('ipgpagsegurodireto/entity_erro');
352
+ $erro->loadByAttribute('order_id', $orderId);
353
+
354
+ if (Mage::helper('ipgbase/stringUtils')->isEmpty($erro->getOrderId())) {
355
+ $erro->setOrderId($orderId);
356
+ $erro->setCode($errorCode);
357
+
358
+ $erro->save();
359
+ }
360
+ }
361
+
362
+ public function hasPayment($orderId) {
363
+ $pagamento = Mage::getModel('ipgpagsegurodireto/entity_payment');
364
+ $pagamento->loadByAttribute('order_id', $orderId);
365
+
366
+ if (Mage::helper('ipgbase/stringUtils')->isEmpty($pagamento->getOrderId())) {
367
+ return false;
368
+ }
369
+ return true;
370
+ }
371
+
372
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/PaymentMath.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_PaymentMath extends Mage_Core_Model_Abstract {
16
+
17
+ private $shopPaymentModel;
18
+
19
+ /**
20
+ * Initialize resource model
21
+ */
22
+ protected function _construct() {
23
+ $this->shopPaymentModel = Mage::getModel('ipgpagsegurodireto/shopPayment');
24
+ }
25
+
26
+ public function getDescontoAvista(Ipagare_PagSeguroDireto_Domain_PaymentMethodCode $paymentType) {
27
+ return $this->getParameterValue($paymentType, Ipagare_IpgPagSeguroDireto_Model_ShopPayment::DESCONTO_AVISTA);
28
+ }
29
+
30
+ public function getParameterValue(Ipagare_PagSeguroDireto_Domain_PaymentMethodCode $paymentType, $parameterName) {
31
+ $value = null;
32
+ $shopPayment = $this->shopPaymentModel->getShopPayment($paymentType->getValue());
33
+ if ($shopPayment != null) {
34
+ $value = $shopPayment->getSetting($parameterName);
35
+ }
36
+ return $value;
37
+ }
38
+
39
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/PaymentType.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_PaymentType extends Mage_Core_Model_Abstract {
16
+
17
+ private $paymentMathModel;
18
+ private $shopPaymentModel;
19
+
20
+ /**
21
+ * Initialize resource model
22
+ */
23
+ protected function _construct() {
24
+ $this->paymentMathModel = Mage::getModel('ipgpagsegurodireto/paymentMath');
25
+ $this->shopPaymentModel = Mage::getModel('ipgpagsegurodireto/shopPayment');
26
+ }
27
+
28
+ /**
29
+ * Retorna todas as opções de pagamento disponíveis para o pedido.
30
+ *
31
+ * @param type $total
32
+ */
33
+ public function getPaymentTypeOptions($total) {
34
+ $shopPayments = $this->shopPaymentModel->listActiveShopPayments();
35
+ return $this->buildPaymentTypeOptions($shopPayments, $total);
36
+ }
37
+
38
+ private function buildPaymentTypeOptions($shopPayments, $total) {
39
+ $paymentTypeOptions = new Ipagare_IpgPagSeguroDireto_PaymentTypeOptions();
40
+ if (!is_null($shopPayments) && count($shopPayments) > 0) {
41
+ foreach ($shopPayments as $key => $shopPayment) {
42
+ $paymentTypeOption = $this->buildPaymentTypeOption($shopPayment, $total);
43
+ if (!is_null($paymentTypeOption)) {
44
+ $paymentTypeOptions->addOption($paymentTypeOption);
45
+ }
46
+ }
47
+ if (!$paymentTypeOptions->hasOptions()) {
48
+ $paymentTypeOptions->addError(Ipagare_IpgPagSeguroDireto_Config::ERROR_002);
49
+ }
50
+ } else {
51
+ $paymentTypeOptions->addError(Ipagare_IpgPagSeguroDireto_Config::ERROR_001);
52
+ }
53
+
54
+ return $paymentTypeOptions;
55
+ }
56
+
57
+ private function buildPaymentTypeOption(Ipagare_IpgPagSeguroDireto_ShopPayment $shopPayment, $total) {
58
+ $paymentTypeOption = null;
59
+ $maximumOrderValue = $shopPayment->getSetting(Ipagare_IpgPagSeguroDireto_Model_ShopPayment::VALOR_MAXIMO_PEDIDO);
60
+
61
+ if ($this->isLessThanMaximumOrderValue($total, $maximumOrderValue)) {
62
+ $paymentModeOptions = $this->getPaymentModeOptions($total, $shopPayment);
63
+ if (!is_null($paymentModeOptions) && count($paymentModeOptions) > 0) {
64
+ $paymentType = $shopPayment->getPaymentType();
65
+
66
+ $paymentTypeOption = new Ipagare_IpgPagSeguroDireto_PaymentTypeOption();
67
+ $paymentTypeOption->setPaymentType($paymentType);
68
+ $paymentTypeOption->setPaymentModes($paymentModeOptions);
69
+ }
70
+ }
71
+
72
+ return $paymentTypeOption;
73
+ }
74
+
75
+ /**
76
+ *
77
+ * Verifica se o valor do pedido é menor ou igual que o valor máximo
78
+ *
79
+ * @param orderValue
80
+ * @param maximum
81
+ * @return
82
+ */
83
+ private function isLessThanMaximumOrderValue($orderValue, $maximumOrderValue) {
84
+ $less = true;
85
+ $maximum = 0;
86
+ if (!Mage::helper('ipgbase/stringUtils')->isEmpty($maximumOrderValue)) {
87
+ $maximum = $maximumOrderValue;
88
+ if ($orderValue > $maximum) {
89
+ $less = false;
90
+ }
91
+ }
92
+
93
+ return $less;
94
+ }
95
+
96
+ /**
97
+ *
98
+ * Verifica se o valor do pedido é maior ou igual que o valor minimo
99
+ *
100
+ * @param orderValue
101
+ * @param minimumOrderValue
102
+ * @return
103
+ */
104
+ private function isGreaterThanMinimumOrderValue($orderValue, $minimumOrderValue) {
105
+ $greater = true;
106
+ if ($orderValue < $minimumOrderValue) {
107
+ $greater = false;
108
+ }
109
+
110
+ return $greater;
111
+ }
112
+
113
+ private function getPaymentModeOptions($total, $shopPayment) {
114
+ if (is_null($shopPayment)) {
115
+ return null;
116
+ }
117
+ $paymentModeOptions = array();
118
+ $paymentType = $shopPayment->getPaymentType();
119
+
120
+ $taxaPagamento = null;
121
+ $taxaAbsolutoPercentagem = null;
122
+ $taxaDesconto = null;
123
+
124
+ $descontoAvista = str_replace(',', '.', $this->paymentMathModel->getDescontoAvista($paymentType));
125
+ $valorMinimoParcela = str_replace(',', '.', $this->paymentMathModel->getParameterValue($paymentType, Ipagare_IpgPagSeguroDireto_Model_ShopPayment::VALOR_MINIMO_PARCELA));
126
+ $juros = str_replace(',', '.', $this->paymentMathModel->getParameterValue($paymentType, Ipagare_IpgPagSeguroDireto_Model_ShopPayment::JUROS));
127
+
128
+ $newOrderTotal = $this->addTax($total, $taxaPagamento, $taxaAbsolutoPercentagem, $taxaDesconto);
129
+
130
+ $minimumOrderValue = $shopPayment->getSetting(Ipagare_IpgPagSeguroDireto_Model_ShopPayment::VALOR_MINIMO_PEDIDO);
131
+ if ($this->isGreaterThanMinimumOrderValue($newOrderTotal, $minimumOrderValue)) {
132
+ if ($paymentType->isCreditCard()) {
133
+ $parcelasTotal = 1;
134
+ $parcelasSemJuros = 1;
135
+ $parcelasTotal = 1;
136
+ $parcelasSemJuros = 1;
137
+ $paymentModes = null;
138
+ $acabou = false;
139
+ $j = 1;
140
+ while (!$acabou) {
141
+ $paymentMode = null;
142
+ $valorParcela = 0;
143
+ if ($j == 1 && !is_null($descontoAvista)) {
144
+ $paymentMode = Ipagare_IpgPagSeguroDireto_PaymentMode::valueOf(Ipagare_IpgPagSeguroDireto_PaymentMode::A01);
145
+ $valorParcela = $this->addTax($newOrderTotal, $descontoAvista, Ipagare_IpgPagSeguroDireto_Model_ShopPayment::TAXA_VALOR_PERCENTAGEM, Ipagare_IpgPagSeguroDireto_Model_ShopPayment::DESCONTO);
146
+ $paymentModeOptions[] = new Ipagare_IpgPagSeguroDireto_PaymentModeOption($paymentMode, $valorParcela, $juros, $descontoAvista, $total);
147
+ }
148
+ $acabou = true;
149
+ $j++;
150
+ }
151
+ } else {
152
+ $newOrderTotal = $this->addTax($newOrderTotal, $descontoAvista, Ipagare_IpgPagSeguroDireto_Model_ShopPayment::TAXA_VALOR_PERCENTAGEM, Ipagare_IpgPagSeguroDireto_Model_ShopPayment::DESCONTO);
153
+ $paymentModeOptions[] = new Ipagare_IpgPagSeguroDireto_PaymentModeOption(Ipagare_IpgPagSeguroDireto_PaymentMode::valueOf(Ipagare_IpgPagSeguroDireto_PaymentMode::A01), $newOrderTotal, 0, $descontoAvista, $total);
154
+ }
155
+ }
156
+
157
+ return $paymentModeOptions;
158
+ }
159
+
160
+ /**
161
+ *
162
+ * Adiciona ao valor do pagamento a taxa configurada pelo Estabelecimento
163
+ *
164
+ * @param paymentAmount
165
+ * @param taxaPagamento
166
+ * @param taxaAbsolutoPercentagem
167
+ * @return
168
+ */
169
+ private function addTax($paymentAmount, $taxaPagamento, $taxaAbsolutoPercentagem, $taxaDesconto) {
170
+ $sessionQuote = Mage::getSingleton('checkout/session')->getQuote();
171
+ $baseShippingAmount = $sessionQuote->getShippingAddress()->getBaseShippingAmount();
172
+ if (is_null($taxaAbsolutoPercentagem)) {
173
+ return $paymentAmount;
174
+ }
175
+ $tax = 0;
176
+ if (!is_null($taxaPagamento)) {
177
+ $tax = $taxaPagamento;
178
+ }
179
+ if (trim($taxaAbsolutoPercentagem) == Ipagare_IpgPagSeguroDireto_Model_ShopPayment::TAXA_VALOR_ABSOLUTO) {
180
+ if (Ipagare_IpgPagSeguroDireto_ShopPayment::DESCONTO == $taxaDesconto) {
181
+ $paymentAmount -= $tax;
182
+ } else {
183
+ $paymentAmount += $tax;
184
+ }
185
+ } else if (trim($taxaAbsolutoPercentagem) == Ipagare_IpgPagSeguroDireto_Model_ShopPayment::TAXA_VALOR_PERCENTAGEM) {
186
+ if (Ipagare_IpgPagSeguroDireto_Model_ShopPayment::DESCONTO == $taxaDesconto) {
187
+ $paymentAmount -= (($paymentAmount - $baseShippingAmount) * $tax) / 100;
188
+ } else {
189
+ $paymentAmount += ($paymentAmount * $tax) / 100;
190
+ }
191
+ }
192
+
193
+ return $paymentAmount;
194
+ }
195
+
196
+ public function getPaymentAmount($paymentAmount, $meioPagamento, $formaPagamento) {
197
+ $paymentType = new Ipagare_PagSeguroDireto_Domain_PaymentMethodCode($meioPagamento);
198
+ $paymentMode = Ipagare_IpgPagSeguroDireto_PaymentMode::valueOf($formaPagamento);
199
+
200
+ $taxaPagamento = null;
201
+ $taxaAbsolutoPercentagem = null;
202
+ $taxaDesconto = null;
203
+ $paymentAmount = $this->addTax($paymentAmount, $taxaPagamento, $taxaAbsolutoPercentagem, $taxaDesconto);
204
+
205
+ if ($paymentMode->hasJuros()) {
206
+ $juros = str_replace(',', '.', $this->paymentMathModel->getParameterValue($paymentType, Ipagare_IpgPagSeguroDireto_Model_ShopPayment::JUROS));
207
+ $paymentAmount = $this->calculateTotalValue($paymentAmount, $juros / 100, $paymentMode->getParcelas());
208
+ }
209
+ return Zend_Locale_Math::round($paymentAmount, 2);
210
+ }
211
+
212
+ private function calculateTotalValue($total, $interestRate, $numberOfPayments) {
213
+ $payment = 0;
214
+ $valor = $total;
215
+ if ($interestRate != 0) {
216
+ $payment = Mage::helper('ipgpagsegurodireto/math')->calculatePayment($total, $interestRate, $numberOfPayments);
217
+ $valor = $payment * $numberOfPayments;
218
+ }
219
+ return $valor;
220
+ }
221
+
222
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Sales/Order/Invoice/Total/Discount.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Sales_Order_Invoice_Total_Discount extends Mage_Sales_Model_Order_Invoice_Total_Abstract {
16
+
17
+ protected $_code = 'discount-ipgpagsegurodireto';
18
+
19
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice) {
20
+ parent::collect($invoice);
21
+ $order = $invoice->getOrder();
22
+ $baseTotalDiscountAmount = $order->getIpgPagsegurodiretoBaseDiscountAmount();
23
+ $totalDiscountAmount = Mage::app()->getStore()->convertPrice($baseTotalDiscountAmount);
24
+
25
+ $invoice->setIpgPagsegurodiretoDiscountAmount($totalDiscountAmount);
26
+ $invoice->setIpgPagsegurodiretoBaseDiscountAmount($baseTotalDiscountAmount);
27
+
28
+ $invoice->setGrandTotal($invoice->getGrandTotal() + $invoice->getIpgPagsegurodiretoDiscountAmount());
29
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $invoice->getIpgPagsegurodiretoBaseDiscountAmount());
30
+
31
+ return $this;
32
+ }
33
+
34
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Sales/Quote/Address/Total/Discount.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_Sales_Quote_Address_Total_Discount extends Mage_Sales_Model_Quote_Address_Total_Abstract {
16
+
17
+ protected $_code = 'discount-ipgpagsegurodireto';
18
+
19
+ public function collect(Mage_Sales_Model_Quote_Address $address) {
20
+ parent::collect($address);
21
+ $this->_setAmount(0);
22
+ $this->_setBaseAmount(0);
23
+ $address->setIpgPagsegurodiretoDiscountAmount(0);
24
+ $address->setIpgPagsegurodiretoBaseDiscountAmount(0);
25
+
26
+ $items = $this->_getAddressItems($address);
27
+ if (!count($items)) {
28
+ return $this;
29
+ }
30
+
31
+ $discount = Mage::getSingleton('ipgpagsegurodireto/discount');
32
+ if ($discount->canApply($address)) {
33
+ $paymentDiscount = $discount->getDiscount();
34
+
35
+ $baseTotalDiscountAmount = round((($paymentDiscount->baseSubtotalWithDiscount + $paymentDiscount->baseTax) * $paymentDiscount->totalPercent) / 100, 2);
36
+
37
+ $totalDiscountAmount = Mage::helper('directory')->currencyConvert($baseTotalDiscountAmount, $paymentDiscount->baseCurrencyCode);
38
+ $address->setIpgPagsegurodiretoDiscountAmount(-$totalDiscountAmount);
39
+ $address->setIpgPagsegurodiretoBaseDiscountAmount(-$baseTotalDiscountAmount);
40
+ $address->setGrandTotal($address->getGrandTotal() + $address->getIpgPagsegurodiretoDiscountAmount());
41
+ $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getIpgPagsegurodiretoBaseDiscountAmount());
42
+ }
43
+
44
+ return $this;
45
+ }
46
+
47
+ public function fetch(Mage_Sales_Model_Quote_Address $address) {
48
+ $amount = $address->getIpgPagsegurodiretoDiscountAmount();
49
+ if ($amount < 0) {
50
+ $address->addTotal(array('code' => $this->getCode(),
51
+ 'title' => Mage::helper('ipgbase')->__('Payment Discount'),
52
+ 'value' => $amount
53
+ ));
54
+ }
55
+ return $this;
56
+ }
57
+
58
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/ShopPayment.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_ShopPayment extends Mage_Core_Model_Abstract {
16
+
17
+ const TAXA_VALOR_ABSOLUTO = "0";
18
+ const TAXA_VALOR_PERCENTAGEM = "1";
19
+ const ACRESCIMO = "0";
20
+ const DESCONTO = "1";
21
+ // Geral
22
+ const ACTIVE = 'active';
23
+ const VALOR_MINIMO_PEDIDO = 'valor_minimo_pedido';
24
+ const VALOR_MAXIMO_PEDIDO = 'valor_maximo_pedido';
25
+ const VALOR_MINIMO_PARCELA = 'valor_minimo_parcela';
26
+ const JUROS = 'juros';
27
+ const DESCONTO_AVISTA = 'desconto_avista';
28
+
29
+ public function getShopPayment($codigoPaymentType) {
30
+ $store = Mage::getSingleton('checkout/session')->getQuote()->getStore();
31
+ $shopPayment = null;
32
+ $codigosCartao = explode(',', Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::CARTAO_CODIGOS, $store));
33
+ $codigosBoleto = explode(',', Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::BOLETO_CODIGOS, $store));
34
+ $codigosDebito = explode(',', Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::DEBITO_CODIGOS, $store));
35
+
36
+ $shopPayment = new Ipagare_IpgPagSeguroDireto_ShopPayment();
37
+
38
+ // CARTAO
39
+ if (in_array($codigoPaymentType, $codigosCartao)) {
40
+ $shopPayment->setPaymentType(new Ipagare_PagSeguroDireto_Domain_PaymentMethodCode($codigoPaymentType));
41
+ $shopPayment->addSetting(self::ACTIVE, Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::CARTAO_ACTIVE, $store));
42
+ $shopPayment->addSetting(self::VALOR_MINIMO_PEDIDO, Mage::helper('ipgbase/math')->formatPriceToUS(Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::CARTAO_VALOR_MINIMO, $store)));
43
+ $shopPayment->addSetting(self::VALOR_MAXIMO_PEDIDO, Mage::helper('ipgbase/math')->formatPriceToUS(Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::CARTAO_VALOR_MAXIMO, $store)));
44
+ $shopPayment->addSetting(self::DESCONTO_AVISTA, Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::CARTAO_DESCONTO_AVISTA, $store));
45
+ }
46
+ // BOLETO
47
+ if (in_array($codigoPaymentType, $codigosBoleto)) {
48
+ $shopPayment->setPaymentType(new Ipagare_PagSeguroDireto_Domain_PaymentMethodCode($codigoPaymentType));
49
+ $shopPayment->addSetting(self::ACTIVE, Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::BOLETO_ACTIVE, $store));
50
+ $shopPayment->addSetting(self::VALOR_MINIMO_PEDIDO, Mage::helper('ipgbase/math')->formatPriceToUS(Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::BOLETO_VALOR_MINIMO, $store)));
51
+ $shopPayment->addSetting(self::VALOR_MAXIMO_PEDIDO, Mage::helper('ipgbase/math')->formatPriceToUS(Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::BOLETO_VALOR_MAXIMO, $store)));
52
+ $shopPayment->addSetting(self::DESCONTO_AVISTA, Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::BOLETO_DESCONTO_AVISTA, $store));
53
+ }
54
+ // DEBITO
55
+ if (in_array($codigoPaymentType, $codigosDebito)) {
56
+ $shopPayment->setPaymentType(new Ipagare_PagSeguroDireto_Domain_PaymentMethodCode($codigoPaymentType));
57
+ $shopPayment->addSetting(self::ACTIVE, Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::DEBITO_ACTIVE, $store));
58
+ $shopPayment->addSetting(self::VALOR_MINIMO_PEDIDO, Mage::helper('ipgbase/math')->formatPriceToUS(Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::DEBITO_VALOR_MINIMO, $store)));
59
+ $shopPayment->addSetting(self::VALOR_MAXIMO_PEDIDO, Mage::helper('ipgbase/math')->formatPriceToUS(Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::DEBITO_VALOR_MAXIMO, $store)));
60
+ $shopPayment->addSetting(self::DESCONTO_AVISTA, Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::DEBITO_DESCONTO_AVISTA, $store));
61
+ }
62
+
63
+ return $shopPayment;
64
+ }
65
+
66
+ public function listActiveShopPayments() {
67
+ $store = Mage::getSingleton('checkout/session')->getQuote()->getStore();
68
+ if (!Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::ACTIVE, $store)) {
69
+ return null;
70
+ }
71
+ $codigosCartao = null;
72
+ $codigosBoleto = null;
73
+ $codigosDebito = null;
74
+
75
+ if (Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::CARTAO_ACTIVE, $store)) {
76
+ $codigosCartao = explode(',', Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::CARTAO_CODIGOS, $store));
77
+ }
78
+ if (Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::BOLETO_ACTIVE, $store)) {
79
+ $codigosBoleto = explode(',', Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::BOLETO_CODIGOS, $store));
80
+ }
81
+ if (Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::DEBITO_ACTIVE, $store)) {
82
+ $codigosDebito = explode(',', Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::DEBITO_CODIGOS, $store));
83
+ }
84
+
85
+ $codigos = array();
86
+ if (Mage::helper('ipgpagsegurodireto')->notNull($codigosCartao)) {
87
+ $codigos = array_merge($codigos, $codigosCartao);
88
+ }
89
+ if (Mage::helper('ipgpagsegurodireto')->notNull($codigosBoleto)) {
90
+ $codigos = array_merge($codigos, $codigosBoleto);
91
+ }
92
+ if (Mage::helper('ipgpagsegurodireto')->notNull($codigosDebito)) {
93
+ $codigos = array_merge($codigos, $codigosDebito);
94
+ }
95
+
96
+ if (Mage::helper('ipgpagsegurodireto')->notNull($codigos)) {
97
+ $shopPayments = array();
98
+ foreach ($codigos as $codigo) {
99
+ $shopPayments[$codigo] = $this->getShopPayment($codigo);
100
+ }
101
+ return $shopPayments;
102
+ }
103
+ return null;
104
+ }
105
+
106
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/Sonda.php ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ Mage::helper('ipgpagsegurodireto')->getPagSeguroLibrary();
16
+
17
+ class Ipagare_IpgPagSeguroDireto_Model_Sonda extends Mage_Core_Model_Abstract {
18
+
19
+ const MAX_SONDA_PERIOD_DAYS = 10;
20
+
21
+ private $logger;
22
+
23
+ /**
24
+ * Initialize resource model
25
+ */
26
+ protected function _construct() {
27
+ parent::_construct();
28
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
29
+ }
30
+
31
+ protected function getNotification() {
32
+ return Mage::getModel('ipgpagsegurodireto/notification');
33
+ }
34
+
35
+ public function criarSonda($orderId) {
36
+ if (empty($orderId)) {
37
+ $this->logger->info("Não foi possivel criar a sonda. Número do pedido não foi encontrado.");
38
+ return false;
39
+ }
40
+ $this->logger->info("Criacao de sonda para o pedido : $orderId");
41
+ try {
42
+ $payment = Mage::getModel('ipgpagsegurodireto/entity_sonda');
43
+ $payment->loadByAttribute('order_id', $orderId);
44
+
45
+ if ($payment->getOrderId() == '') {
46
+ $payment->setOrderId($orderId);
47
+ $payment->setDueDate(date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())));
48
+ $payment->setRegisterDate(date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())));
49
+ $payment->save();
50
+ }
51
+ } catch (Exception $e) {
52
+ $this->logger->error("Erro ao Criar a sonda do pedido $orderId \n Verificar a tabela ipagare_pagsegurodireto_sonda . \n" . $e->__toString());
53
+ }
54
+ }
55
+
56
+ public function removerSonda($orderId) {
57
+ $this->logger->info("Removendo sonda do pedido: $orderId");
58
+
59
+ $resource = Mage::getSingleton('core/resource');
60
+ try {
61
+ $installer = new Mage_Core_Model_Resource_Setup('core_setup');
62
+ $installer->startSetup();
63
+
64
+ $sql = "DELETE FROM `{$resource->getTableName('ipagare_pagsegurodireto_sonda')}` WHERE `order_id`=$orderId;";
65
+
66
+ $installer->run($sql);
67
+ $installer->endSetup();
68
+ } catch (exception $e) {
69
+ $this->logger->error("Erro ao excluir sonda do pedido: $orderId");
70
+ }
71
+ }
72
+
73
+ public function atualizarPagamento(Mage_Sales_Model_Order $order, Ipagare_PagSeguroDireto_Domain_Transaction $transaction) {
74
+ $transactionStatus = $transaction->getStatus();
75
+ $valorPago = $order->getBaseGrandTotal();
76
+
77
+ if (($transactionStatus->isPaga() || $transactionStatus->isDisponivel())) {
78
+ $this->atualizarTabelaIpagarePagSeguro($order, $transaction);
79
+
80
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
81
+ $this->getNotification()->processSuccess($order->getRealOrderId(), $valorPago, $transactionStatus->getMessage());
82
+ }
83
+ $this->removerSonda($order->getRealOrderId());
84
+ } else if ($transactionStatus->isAguardandoPagamento() || $transactionStatus->isEmAnalise()) {
85
+ $this->atualizarTabelaIpagarePagSeguro($order, $transaction);
86
+ if ($this->deveLogarResultadoSonda($order->getRealOrderId())) {
87
+ $this->getNotification()->addStatusHistoryComment($order, $transactionStatus->getMessage());
88
+ }
89
+ } else if (($transactionStatus->isCancelada() || $transactionStatus->isDevolvida())) {
90
+ $this->atualizarTabelaIpagarePagSeguro($order, $transaction);
91
+
92
+ if (!$order->isCanceled()) {
93
+ $msgSourceCancelamento = 'Pedido ' . $order->getRealOrderId() . ': ';
94
+
95
+ switch ($transaction->getCancellationSource()) {
96
+ case 'INTERNAL':
97
+ $msgSourceCancelamento .= 'A transação foi cancelada pelo PagSeguro sem ter sido finalizada.';
98
+ break;
99
+
100
+ case 'EXTERNAL':
101
+ $msgSourceCancelamento .= 'A transação foi cancelado pelo Banco Emissor ou Operadora do Cartão sem ter sido finalizada.';
102
+ break;
103
+
104
+ default:
105
+ $msgSourceCancelamento .= 'A transação foi cancelada sem ter sido finalizada.';
106
+ break;
107
+ }
108
+ $this->getNotification()->processCancel($order->getRealOrderId(), $msgSourceCancelamento);
109
+ }
110
+ $this->removerSonda($order->getRealOrderId());
111
+ } else {
112
+ $this->logger->info('Status de pagamento do pedido [' . $order->getRealOrderId() . '] nao foi alterado.');
113
+ return false;
114
+ }
115
+
116
+ $this->logger->info('Status de pagamento do pedido ' . $order->getRealOrderId() . ' foi alterado.');
117
+ return true;
118
+ }
119
+
120
+ private function deveLogarResultadoSonda($orderId) {
121
+ $paymentSonda = $this->getEntityPayment($orderId);
122
+ $diffHours = $this->diffDate($paymentSonda->getRegisterDate());
123
+ if ($diffHours >= 1) {
124
+ return false;
125
+ }
126
+ return true;
127
+ }
128
+
129
+ /*
130
+ * Calcula a diferença em horas entre uma data e outra.
131
+ */
132
+
133
+ private function diffDate($dataInicial) {
134
+ $ano = substr($dataInicial, 0, 4);
135
+ $mes = substr($dataInicial, 5, 2);
136
+ $dia = substr($dataInicial, 8, 2);
137
+ $hora = substr($dataInicial, 11, 2);
138
+ $minuto = substr($dataInicial, 14, 2);
139
+ $segundo = substr($dataInicial, 17, 2);
140
+
141
+ $data = mktime($hora, $minuto, $segundo, $mes, $dia, $ano);
142
+ $now = time();
143
+
144
+ $difMinutes = ($now - $data) / 60; // minutos
145
+ $difHours = $difMinutes / 60; // horas
146
+
147
+ return $difHours;
148
+ }
149
+
150
+ public function atualizarTabelaIpagarePagSeguro(Mage_Sales_Model_Order $order, Ipagare_PagSeguroDireto_Domain_Transaction $transaction) {
151
+ $payment = $this->getEntityPayment($order->getRealOrderId());
152
+ $payment->setOrderId($transaction->getReference());
153
+ $payment->setMeioPagamento($transaction->getPaymentMethod()->getCode()->getValue());
154
+ //$payment->setFormaPagamento($transaction->getPaymentMethod());
155
+ $payment->setValorTotal($transaction->getGrossAmount());
156
+ $payment->setTransactionCode($transaction->getCode());
157
+ $payment->setStatus($transaction->getStatus()->getCode());
158
+ $payment->setPaymentLink($payment->getPaymentLink());
159
+ //$payment->setCreatedTime($payment->getCreatedTime());
160
+ $payment->save();
161
+
162
+ return true;
163
+ }
164
+
165
+ public function getOrderIds() {
166
+ $resource = Mage::getSingleton('core/resource');
167
+ $readConnection = $resource->getConnection('core_read');
168
+
169
+ $sql = "SELECT `order_id` FROM `{$resource->getTableName('ipagare_pagsegurodireto_sonda')}` ";
170
+ $orderIds = $readConnection->fetchAll($sql);
171
+
172
+ return $orderIds;
173
+ }
174
+
175
+ public function run($orderId) {
176
+ $order = Mage::getModel('sales/order')->loadByAttribute('increment_id', $orderId);
177
+ $paymentSonda = $this->getEntityPayment($orderId);
178
+ $transactionSearchResponse = null;
179
+
180
+ if ($paymentSonda != null) {
181
+ // verifica se deve excluir sonda
182
+ if ($this->deveExcluirSonda($paymentSonda->getCreatedTime())) {
183
+ $this->logger->info('Removendo sonda para pedido: ' . $orderId);
184
+ $this->removerSonda($orderId);
185
+ return true;
186
+ }
187
+ $this->logger->info('Executando sonda para pedido: ' . $orderId);
188
+
189
+ $credentials = Mage::getSingleton('ipgpagsegurodireto/credential')->getAccountCredentials();
190
+ $transactionSearchService = new Ipagare_PagSeguroDireto_Service_TransactionSearchService();
191
+ $transactionSearchResponse = $transactionSearchService->searchByCode($credentials, $paymentSonda->getTransactionCode());
192
+
193
+ if ($transactionSearchResponse->hasErrors()) {
194
+ foreach ($transactionSearchResponse->getErrors() as $error) {
195
+ $this->logger->error('Erro ao executar sonda. Pedido [' . $orderId . ']. Erro [' . $error->getCode() . ' - ' . $error->getMessage() . ']');
196
+ }
197
+
198
+ return $transactionSearchResponse;
199
+ }
200
+
201
+ $transaction = $transactionSearchResponse->getTransaction();
202
+ if ($order->getRealOrderId()) {
203
+ $grossAmount = round($transaction->getGrossAmount(), 2);
204
+ $baseGrandTotal = round($order->getBaseGrandTotal(), 2);
205
+
206
+ if ($grossAmount != $baseGrandTotal) {
207
+ $msg = "Total pago ao PagSeguro ({$grossAmount}) é diferente do valor original ({$baseGrandTotal}). Pedido:" . $orderId;
208
+ $order->addStatusToHistory($order->getStatus(), Mage::helper('ipgpagsegurodireto')->__($msg), true);
209
+ $order->save();
210
+ $this->logger->info($msg);
211
+ }
212
+
213
+ $this->atualizarPagamento($order, $transaction);
214
+ } else {
215
+ $this->logger->info('Pedido [' . $orderId . '] não localizado na loja.');
216
+ $this->removerSonda($orderId);
217
+ }
218
+ } else {
219
+ $this->logger->info('Não foi possivel encontrar o pedido na base de dados de pagamento. Pedido: ' . $orderId);
220
+ $this->removerSonda($orderId);
221
+ }
222
+
223
+ return $transactionSearchResponse;
224
+ }
225
+
226
+ public function getEntityPayment($orderId) {
227
+ try {
228
+ $pagamento = Mage::getModel('ipgpagsegurodireto/entity_payment');
229
+ $pagamento->loadByAttribute('order_id', $orderId);
230
+ if ($pagamento->getOrderId() != '') {
231
+ return $pagamento;
232
+ }
233
+ } catch (Exception $e) {
234
+ $this->logger->error("Erro ao abrir a sonda do pedido $orderId \n Verificar a tabela ipagare_pagsegurodireto_sonda . \n $e->__toString()");
235
+ }
236
+
237
+ return false;
238
+ }
239
+
240
+ private function deveExcluirSonda($dataRegistro) {
241
+ $dataExpiracao = Mage::helper('ipgbase/date')->addDaysToUs(self::MAX_SONDA_PERIOD_DAYS, $dataRegistro);
242
+
243
+ if (Mage::helper('ipgbase/date')->isUsDateBeforeToday($dataExpiracao)) {
244
+ return true;
245
+ }
246
+
247
+ return false;
248
+ }
249
+
250
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/System/Config/Source/AllBoletoMethods.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_System_Config_Source_AllBoletoMethods {
16
+
17
+ public function toOptionArray() {
18
+ return array(
19
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::SANTANDER_BOLETO, 'label' => 'Boleto Santander')
20
+ );
21
+ }
22
+
23
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/System/Config/Source/AllCardMethods.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_System_Config_Source_AllCardMethods {
16
+
17
+ public function toOptionArray() {
18
+ return array(
19
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::VISA_CREDIT_CARD, 'label' => 'Visa'),
20
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::MASTERCARD_CREDIT_CARD, 'label' => 'MasterCard'),
21
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::AMEX_CREDIT_CARD, 'label' => 'American Express'),
22
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::DINERS_CREDIT_CARD, 'label' => 'Diners'),
23
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::HIPERCARD_CREDIT_CARD, 'label' => 'Hipercard'),
24
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::AURA_CREDIT_CARD, 'label' => 'Aura'),
25
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::ELO_CREDIT_CARD, 'label' => 'Elo'),
26
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::PLENOCARD, 'label' => 'PlenoCard'),
27
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::PERSONALCARD, 'label' => 'PersonalCard'),
28
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::JCB_CREDIT_CARD, 'label' => 'JCB'),
29
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::DISCOVER_CREDIT_CARD, 'label' => 'Discover'),
30
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::BRASILCARD, 'label' => 'BrasilCard'),
31
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::FORTBRASIL_CREDIT_CARD, 'label' => 'FortBrasil'),
32
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::CARDBAN_CARD, 'label' => 'Cardban'),
33
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::VALECARD_CARD, 'label' => 'ValeCard'),
34
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::CABAL_CARD, 'label' => 'Cabal'),
35
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::MAIS_CARD, 'label' => 'Mais!'),
36
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::AVISTA_CARD, 'label' => 'Avista'),
37
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::GRANDCARD_CARD, 'label' => 'GrandCard')
38
+ );
39
+ }
40
+
41
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/Model/System/Config/Source/AllDebitMethods.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_Model_System_Config_Source_AllDebitMethods {
16
+
17
+ public function toOptionArray() {
18
+ return array(
19
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::BRADESCO_ONLINE_TRANSFER, 'label' => 'Bradesco'),
20
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::ITAU_ONLINE_TRANSFER, 'label' => 'Itaú'),
21
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::BANCO_BRASIL_ONLINE_TRANSFER, 'label' => 'Banco do Brasil'),
22
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::BANRISUL_ONLINE_TRANSFER, 'label' => 'Banrisul'),
23
+ array('value' => Ipagare_PagSeguroDireto_Domain_PaymentMethodCode::HSBC_ONLINE_TRANSFER, 'label' => 'HSBC')
24
+ );
25
+ }
26
+
27
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/PaymentMode.php ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_PaymentMode {
16
+ /**
17
+ * à vista
18
+ */
19
+ const A01 = 'A01';
20
+
21
+ /**
22
+ * 2x sem juros
23
+ */
24
+ const A02 = 'A02';
25
+
26
+ /**
27
+ * 3x sem juros
28
+ */
29
+ const A03 = 'A03';
30
+
31
+ /**
32
+ * 4x sem juros
33
+ */
34
+ const A04 = 'A04';
35
+
36
+ /**
37
+ * 5x sem juros
38
+ */
39
+ const A05 = 'A05';
40
+
41
+ /**
42
+ * 6x sem juros
43
+ */
44
+ const A06 = 'A06';
45
+
46
+ /**
47
+ * 7x sem juros
48
+ */
49
+ const A07 = 'A07';
50
+
51
+ /**
52
+ * 8x sem juros
53
+ */
54
+ const A08 = 'A08';
55
+
56
+ /**
57
+ * 9x sem juros
58
+ */
59
+ const A09 = 'A09';
60
+
61
+ /**
62
+ * 10x sem juros
63
+ */
64
+ const A10 = 'A10';
65
+
66
+ /**
67
+ * 11x sem juros
68
+ */
69
+ const A11 = 'A11';
70
+
71
+ /**
72
+ * 12x sem juros
73
+ */
74
+ const A12 = 'A12';
75
+
76
+ /**
77
+ * 13x sem juros
78
+ */
79
+ const A13 = 'A13';
80
+
81
+ /**
82
+ * 14x sem juros
83
+ */
84
+ const A14 = 'A14';
85
+
86
+ /**
87
+ * 15x sem juros
88
+ */
89
+ const A15 = 'A15';
90
+
91
+ /**
92
+ * 16x sem juros
93
+ */
94
+ const A16 = 'A16';
95
+
96
+ /**
97
+ * 17x sem juros
98
+ */
99
+ const A17 = 'A17';
100
+
101
+ /**
102
+ * 18x sem juros
103
+ */
104
+ const A18 = 'A18';
105
+
106
+ /**
107
+ * 19x sem juros
108
+ */
109
+ const A19 = 'A19';
110
+
111
+ /**
112
+ * 20x sem juros
113
+ */
114
+ const A20 = 'A20';
115
+
116
+ /**
117
+ * 21x sem juros
118
+ */
119
+ const A21 = 'A21';
120
+
121
+ /**
122
+ * 22x sem juros
123
+ */
124
+ const A22 = 'A22';
125
+
126
+ /**
127
+ * 23x sem juros
128
+ */
129
+ const A23 = 'A23';
130
+
131
+ /**
132
+ * 24x sem juros
133
+ */
134
+ const A24 = 'A24';
135
+
136
+ /**
137
+ * 2x com juros
138
+ */
139
+ const B02 = 'B02';
140
+
141
+ /**
142
+ * 3x com juros
143
+ */
144
+ const B03 = 'B03';
145
+
146
+ /**
147
+ * 4x com juros
148
+ */
149
+ const B04 = 'B04';
150
+
151
+ /**
152
+ * 5x com juros
153
+ */
154
+ const B05 = 'B05';
155
+
156
+ /**
157
+ * 6x com juros
158
+ */
159
+ const B06 = 'B06';
160
+
161
+ /**
162
+ * 7x com juros
163
+ */
164
+ const B07 = 'B07';
165
+
166
+ /**
167
+ * 8x com juros
168
+ */
169
+ const B08 = 'B08';
170
+
171
+ /**
172
+ * 9x com juros
173
+ */
174
+ const B09 = 'B09';
175
+
176
+ /**
177
+ * 10x com juros
178
+ */
179
+ const B10 = 'B10';
180
+
181
+ /**
182
+ * 11x com juros
183
+ */
184
+ const B11 = 'B11';
185
+
186
+ /**
187
+ * 12x com juros
188
+ */
189
+ const B12 = 'B12';
190
+
191
+ /**
192
+ * 13x com juros
193
+ */
194
+ const B13 = 'B13';
195
+
196
+ /**
197
+ * 14x com juros
198
+ */
199
+ const B14 = 'B14';
200
+
201
+ /**
202
+ * 15x com juros
203
+ */
204
+ const B15 = 'B15';
205
+
206
+ /**
207
+ * 16x com juros
208
+ */
209
+ const B16 = 'B16';
210
+
211
+ /**
212
+ * 17x com juros
213
+ */
214
+ const B17 = 'B17';
215
+
216
+ /**
217
+ * 18x com juros
218
+ */
219
+ const B18 = 'B18';
220
+
221
+ /**
222
+ * 19x com juros
223
+ */
224
+ const B19 = 'B19';
225
+
226
+ /**
227
+ * 20x com juros
228
+ */
229
+ const B20 = 'B20';
230
+
231
+ /**
232
+ * 20x com juros
233
+ */
234
+ const B21 = 'B21';
235
+
236
+ /**
237
+ * 22x com juros
238
+ */
239
+ const B22 = 'B22';
240
+
241
+ /**
242
+ * 23x com juros
243
+ */
244
+ const B23 = 'B23';
245
+
246
+ /**
247
+ * 24x com juros
248
+ */
249
+ const B24 = 'B24';
250
+
251
+ const SEM_JUROS = "A";
252
+
253
+ const AVISTA = "A01";
254
+
255
+ private $codigo;
256
+ private $parcelas;
257
+ private $juros;
258
+
259
+ public static function getInstance($codigo, $parcelas) {
260
+ if (strlen($parcelas) == 1) {
261
+ $parcelas = '0' . $parcelas;
262
+ }
263
+ return self::valueOf($codigo . $parcelas);
264
+ }
265
+
266
+ public static function valueOf($codigo) {
267
+ if (is_null($codigo)) {
268
+ // FIXME: exception
269
+ }
270
+ $p = Ipagare_IpgPagSeguroDireto_Config::getPaymentMode($codigo);
271
+ if (!is_null($p)) {
272
+ $paymentMode = new Ipagare_IpgPagSeguroDireto_PaymentMode();
273
+ $paymentMode->setCodigo($p['codigo']);
274
+ $paymentMode->setParcelas($p['parcelas']);
275
+ $paymentMode->setJuros($p['juros']);
276
+
277
+ return $paymentMode;
278
+ }
279
+ }
280
+
281
+ public function setCodigo($codigo) {
282
+ $this->codigo = $codigo;
283
+ }
284
+
285
+ public function getCodigo() {
286
+ return $this->codigo;
287
+ }
288
+
289
+ public function setParcelas($parcelas) {
290
+ $this->parcelas = $parcelas;
291
+ }
292
+
293
+ public function getParcelas() {
294
+ return $this->parcelas;
295
+ }
296
+
297
+ public function setJuros($juros) {
298
+ $this->juros = $juros;
299
+ }
300
+
301
+ public function hasJuros() {
302
+ return $this->juros;
303
+ }
304
+
305
+ public function isAvista() {
306
+ return $this->codigo == self::A01;
307
+ }
308
+
309
+ public function getCompleteName() {
310
+ if ($this->isAvista()) {
311
+ return ' à vista';
312
+ }
313
+ return $this->parcelas . ($this->juros == true ? 'x com juros' : 'x sem juros');
314
+ }
315
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/PaymentModeOption.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_PaymentModeOption {
16
+
17
+ private $paymentMode;
18
+ private $parcelAmount;
19
+ private $interestRate;
20
+ private $descontoAvista;
21
+ private $baseGrandTotal;
22
+
23
+ /**
24
+ *
25
+ * @param type $paymentMode
26
+ * @param type $parcelAmount
27
+ * @param type $interestRate
28
+ * @param type $descontoAvista
29
+ * @param type $grandTotal
30
+ */
31
+ public function __construct($paymentMode, $parcelAmount, $interestRate, $descontoAvista, $grandTotal) {
32
+ $this->paymentMode = $paymentMode;
33
+ $this->parcelAmount = $parcelAmount;
34
+ $this->interestRate = $interestRate;
35
+ $this->descontoAvista = $descontoAvista;
36
+ $this->baseGrandTotal = $grandTotal;
37
+ }
38
+
39
+ public function setPaymentMode($paymentMode) {
40
+ $this->paymentMode = $paymentMode;
41
+ }
42
+
43
+ public function getPaymentMode() {
44
+ return $this->paymentMode;
45
+ }
46
+
47
+ public function setParcelAmount($parcelAmount) {
48
+ $this->parcelAmount = $parcelAmount;
49
+ }
50
+
51
+ public function getParcelAmount() {
52
+ return $this->parcelAmount;
53
+ }
54
+
55
+ public function setInterestRate($interestRate) {
56
+ $this->interestRate = $interestRate;
57
+ }
58
+
59
+ public function getInterestRate() {
60
+ return $this->interestRate;
61
+ }
62
+
63
+ public function setDescontoAvista($descontoAvista) {
64
+ $this->descontoAvista = $descontoAvista;
65
+ }
66
+
67
+ public function getDescontoAvista() {
68
+ return $this->descontoAvista;
69
+ }
70
+
71
+ public function hasDescontaAvista() {
72
+ if (!is_null($this->descontoAvista) && $this->descontoAvista > 0) {
73
+ return true;
74
+ }
75
+ return false;
76
+ }
77
+
78
+ public function setBaseGrandTotal($grandTotal) {
79
+ $this->baseGrandTotal = $grandTotal;
80
+ }
81
+
82
+ public function getBaseGrandTotal() {
83
+ return $this->baseGrandTotal;
84
+ }
85
+
86
+ public function getTotalDesconto() {
87
+ if ($this->hasDescontaAvista()) {
88
+ return $this->baseGrandTotal - $this->parcelAmount;
89
+ }
90
+ return $this->baseGrandTotal;
91
+ }
92
+
93
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/PaymentTypeOption.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_PaymentTypeOption {
16
+
17
+ private $paymentType;
18
+ private $paymentModeOptions = array();
19
+ private $maskedCreditCard;
20
+
21
+ public function getPaymentModeOptions() {
22
+ return $this->paymentModeOptions;
23
+ }
24
+
25
+ public function setPaymentModes($paymentModeOptions) {
26
+ $this->paymentModeOptions = $paymentModeOptions;
27
+ }
28
+
29
+ public function getPaymentType() {
30
+ return $this->paymentType;
31
+ }
32
+
33
+ public function setPaymentType($paymentType) {
34
+ $this->paymentType = $paymentType;
35
+ }
36
+
37
+ public function getMaskedCreditCard() {
38
+ return $this->maskedCreditCard;
39
+ }
40
+
41
+ public function setMaskedCreditCard($maskedCreditCard) {
42
+ $this->maskedCreditCard = $maskedCreditCard;
43
+ }
44
+
45
+ public function getMaxPaymentMode() {
46
+ $indice = count($this->paymentModeOptions) - 1;
47
+ return $this->paymentModeOptions[$indice];
48
+ }
49
+
50
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/PaymentTypeOptions.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_PaymentTypeOptions {
16
+
17
+ private $options = array();
18
+ private $errors = array();
19
+
20
+ public function getOptions() {
21
+ return $this->options;
22
+ }
23
+
24
+ public function addOption($option) {
25
+ $this->options[] = $option;
26
+ }
27
+
28
+ public function getErrors() {
29
+ return $this->errors;
30
+ }
31
+
32
+ public function addError($error) {
33
+ if (!array_key_exists($error, $this->errors)) {
34
+ $this->errors[$error] = Ipagare_IpgPagSeguroDireto_Config::getError($error);
35
+ }
36
+ }
37
+
38
+ public function hasErrors() {
39
+ return count($this->errors) > 0;
40
+ }
41
+
42
+ public function hasOptions() {
43
+ return count($this->options) > 0;
44
+ }
45
+
46
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/RuntimeException.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_RuntimeException extends Zend_Exception {
16
+
17
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/ShopPayment.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_ShopPayment {
16
+
17
+ private $settings = array();
18
+
19
+ /**
20
+ *
21
+ * @var Ipagare_PagSeguroDireto_Domain_PaymentMethodCode
22
+ */
23
+ private $paymentType;
24
+
25
+ /**
26
+ *
27
+ * @param type $key
28
+ * @return type
29
+ */
30
+ public function getSetting($key) {
31
+ if (array_key_exists($key, $this->settings)) {
32
+ return $this->settings[$key];
33
+ }
34
+ }
35
+
36
+ /**
37
+ *
38
+ * @param type $key
39
+ * @param type $value
40
+ */
41
+ public function addSetting($key, $value) {
42
+ if (!array_key_exists($key, $this->settings)) {
43
+ $this->settings[$key] = $value;
44
+ }
45
+ }
46
+
47
+ public function setPaymentType($paymentType) {
48
+ $this->paymentType = $paymentType;
49
+ }
50
+
51
+ public function getPaymentType() {
52
+ return $this->paymentType;
53
+ }
54
+
55
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/TypePaymentType.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ class Ipagare_IpgPagSeguroDireto_TypePaymentType {
16
+
17
+ const CREDIT_CARD = 1;
18
+ const BOLETO = 2;
19
+ const ONLINE_TRANSFER = 3;
20
+
21
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/controllers/NotificationController.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ Mage::helper('ipgpagsegurodireto')->getPagSeguroLibrary();
16
+
17
+ class Ipagare_IpgPagSeguroDireto_NotificationController extends Mage_Core_Controller_Front_Action {
18
+
19
+ protected function _construct() {
20
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
21
+ }
22
+
23
+ public function testAction() {
24
+
25
+ /*
26
+ $rules = Mage::getResourceModel('salesrule/rule_collection')->load();
27
+
28
+ foreach ($rules as $rule) {
29
+ if ($rule->getIsActive()) {
30
+ $rule = Mage::getModel('salesrule/rule')->load($rule->getId());
31
+ $conditions = $rule->getConditions();
32
+ $conditions = $rule->getConditions()->asArray();
33
+
34
+ foreach ($conditions['conditions'] as $_conditions):
35
+ foreach ($_conditions['conditions'] as $_condition):
36
+ $string = explode(',', $_condition['value']);
37
+ for ($i = 0; $i < count($string); $i++) {
38
+ $skus[] = trim($string[$i]);
39
+ }
40
+ endforeach;
41
+ endforeach;
42
+ }
43
+ }
44
+ */
45
+ }
46
+
47
+ public function avisoAction() {
48
+ $notificationCode = $this->getRequest()->getParam('notificationCode');
49
+ $this->logger->info('Iniciando Campainha para Notification Code: ' . $notificationCode . '. Parametros recebidos: ' . Mage::helper('ipgpagsegurodireto')->buildParametersForLog($this->getRequest()->getParams()));
50
+ $log = null;
51
+ if (!isset($notificationCode) || Mage::helper('ipgbase/stringUtils')->isEmpty($notificationCode)) {
52
+ $log = 'Codigo de notificacao nao existe ou esta nulo.';
53
+ $this->logger->error($log);
54
+ $this->getResponse()->setHttpResponseCode(304);
55
+ } else {
56
+ $credentials = Mage::getSingleton('ipgpagsegurodireto/credential')->getAccountCredentials();
57
+ $notificationService = new Ipagare_PagSeguroDireto_Service_NotificationService();
58
+ $transactionSearchResponse = $notificationService->checkTransaction($credentials, $notificationCode);
59
+
60
+ if ($transactionSearchResponse->hasErrors()) {
61
+ $this->getResponse()->setHttpResponseCode(304);
62
+ foreach ($transactionSearchResponse->getErrors() as $error) {
63
+ $l = 'Erro na notificacao de aviso(' . $error->getCode() . ') ' . $error->getMessage();
64
+ $log .= $l;
65
+ $this->logger->error($l);
66
+ }
67
+ } else {
68
+ $this->processUpdates($transactionSearchResponse->getTransaction());
69
+ $log = 'Finalizando notificacao de aviso para Pedido com Id: ' . $transactionSearchResponse->getTransaction()->getReference();
70
+ $this->getResponse()->setHttpResponseCode(200);
71
+ $this->logger->info($log);
72
+ }
73
+ echo $log;
74
+ exit(0);
75
+ }
76
+ }
77
+
78
+ private function processUpdates(Ipagare_PagSeguroDireto_Domain_Transaction $transaction) {
79
+ if (Mage::helper('ipgbase/stringUtils')->isEmpty($transaction->getReference())) {
80
+ $this->logger->error('Erro ao processar atualizacoes no pedido. Pedido sem referencia.');
81
+ }
82
+ $orderId = $transaction->getReference();
83
+ $order = Mage::getModel('sales/order')->loadByAttribute('increment_id', $orderId);
84
+
85
+ if ($order->getId() == null) {
86
+ $this->logger->error('Pedido nao encontrado com Id: ' . $orderId);
87
+ } else {
88
+ $payment = $this->_getRequestPayment($orderId);
89
+ $status = new Ipagare_PagSeguroDireto_Domain_TransactionStatus($transaction->getStatus()->getCode());
90
+ // Confere se status do do pagamento foi atualizado.
91
+ if ((!Mage::helper('ipgbase/stringUtils')->isEmpty($status->getCode()))) {
92
+ if ($status->getCode() != $payment->getStatus()) {
93
+ Mage::getModel('ipgpagsegurodireto/sonda')->atualizarPagamento($order, $transaction);
94
+ $this->logger->info('Pedido [' . $orderId . '] alterado para [' . $status->getMessage() . ']');
95
+ } else {
96
+ $this->logger->info('Pedido [' . $orderId . '] nao sofreu alteracao de status.');
97
+ }
98
+ if ($transaction->getPaymentMethod()->getCode()->getValue() != $payment->getMeioPagamento()) {
99
+ Mage::getModel('ipgpagsegurodireto/sonda')->atualizarTabelaIpagarePagSeguro($order, $transaction);
100
+ }
101
+ //$transaction->setHttpResponseCode(200);
102
+ }
103
+ if (Mage::helper('ipgbase/stringUtils')->isEmpty($payment->getOrderId())) {
104
+ $this->logger->info('Pedido com Id ' . $orderId . ' nao foi localizado na tabela de pagamento. ');
105
+ }
106
+ //$transaction->setHttpResponseCode(304);
107
+ }
108
+ return $transaction;
109
+ }
110
+
111
+ public function retornoAction() {
112
+ $params = $this->getRequest()->getParams();
113
+ $orderId = $params['order_id'];
114
+ $store = $this->_getCurrentStore($orderId);
115
+
116
+ $paramsForLog = Mage::helper('ipgpagsegurodireto')->buildParametersForLog($params);
117
+ $this->logger->info('Notificação PagSeguro Direto - Retorno: ' . $paramsForLog);
118
+
119
+ $sondaResult = Mage::getModel('ipgpagsegurodireto/sonda')->run($orderId);
120
+ $urlFailure = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true) . 'checkout/onepage/failure';
121
+ $urlSuccess = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true) . 'checkout/onepage/success';
122
+
123
+ if ($sondaResult->hasErrors()) {
124
+ $errors = array();
125
+ foreach ($sondaResult->getErrors() as $error) {
126
+ $errors[] = $error->getCode() . ' - ' . $error->getMessage();
127
+ }
128
+ Mage::getSingleton('checkout/session')->setErrorMessage("<ul><li>" . implode("</li><li>", $errors) . "</li></ul>");
129
+ return $this->getResponse()->setRedirect($urlFailure);
130
+ }
131
+
132
+ $transactionStatus = $sondaResult->getTransaction()->getStatus();
133
+ if ($transactionStatus->isCancelada() || $transactionStatus->isDevolvida() || $transactionStatus->isEmDisputa()) {
134
+ return $this->getResponse()->setRedirect($urlFailure);
135
+ } else {
136
+ Mage::helper('ipgpagsegurodireto')->clearSession();
137
+ Mage::getSingleton('checkout/type_onepage')->getCheckout()->setLastSuccessQuoteId(true);
138
+ return $this->getResponse()->setRedirect($urlSuccess);
139
+ }
140
+ }
141
+
142
+ private function _getRequestPayment($orderId) {
143
+ $payment = Mage::getModel('ipgpagsegurodireto/entity_payment');
144
+ $payment->loadByAttribute('order_id', $orderId);
145
+ return $payment;
146
+ }
147
+
148
+ private function _getCurrentStore($orderId) {
149
+ $order = Mage::getModel('sales/order');
150
+ if ($orderId == null || $orderId == "") {
151
+ $order = Mage::helper('ipgcore/session')->getCurrentOrder();
152
+ } else {
153
+ $order->loadByAttribute('increment_id', $orderId);
154
+ }
155
+ return $order->getStore();
156
+ }
157
+
158
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/controllers/PaymentController.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ Mage::helper('ipgpagsegurodireto')->getPagSeguroLibrary();
16
+
17
+ class Ipagare_IpgPagSeguroDireto_PaymentController extends Mage_Core_Controller_Front_Action {
18
+
19
+ private $logger;
20
+
21
+ /**
22
+ * Initialize resource model
23
+ */
24
+ protected function _construct() {
25
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
26
+ /**
27
+ * Não remover esse log.
28
+ */
29
+ Mage::log('Iniciando pagamento');
30
+ }
31
+
32
+ public function payAction() {
33
+ $order = Mage::helper('ipgbase/session')->getCurrentOrder();
34
+ $store = $order->getStore();
35
+ $urlLojaSucesso = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true) . 'checkout/onepage/success';
36
+ $urlLojaFalha = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true) . 'checkout/onepage/failure';
37
+ $urlLojaTransferencia = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true) . 'ipgpagsegurodireto/payment/transferencia/order_id/' . $order->getRealOrderId();
38
+
39
+ $sessionCoreMage = Mage::getSingleton('ipgbase/session');
40
+
41
+ $paymentType = new Ipagare_PagSeguroDireto_Domain_PaymentMethodCode($sessionCoreMage->getMeioPagamento());
42
+ $paymentMode = Ipagare_IpgPagSeguroDireto_PaymentMode::valueOf($sessionCoreMage->getFormaPagamento());
43
+
44
+ $this->logger->info('Início pagamento do pedido ' . $order->getIncrementId());
45
+ Mage::helper('ipgbase/url')->printHeaders();
46
+
47
+ /**
48
+ * Já tem pagamento
49
+ */
50
+ $paymentModel = Mage::getModel('ipgpagsegurodireto/payment');
51
+ if ($paymentModel->hasPayment($order->getIncrementId())) {
52
+ $this->logger->info('Já consta um pagamento para o pedido ' . $order->getIncrementId());
53
+
54
+ Mage::helper('ipgpagsegurodireto')->clearSession();
55
+ Mage::getSingleton('checkout/type_onepage')->getCheckout()->setLastSuccessQuoteId(true);
56
+
57
+ return $this->getResponse()->setRedirect($urlLojaSucesso);
58
+ }
59
+
60
+ $paymentResponse = $paymentModel->pay($order, $paymentType);
61
+
62
+ /**
63
+ * Erros
64
+ */
65
+ if ($paymentResponse->hasErrors()) {
66
+ $errors = array();
67
+ foreach ($paymentResponse->getErrors() as $error) {
68
+ $errors[] = $error->getCode() . ' - ' . $error->getMessage();
69
+
70
+ Mage::getSingleton('ipgpagsegurodireto/payment')->saveError($error->getCode(), $order->getRealOrderId());
71
+ }
72
+ Mage::getSingleton('checkout/session')->setErrorMessage("<ul><li>" . implode("</li><li>", $errors) . "</li></ul>");
73
+
74
+ Mage::getSingleton('ipgbase/session')->clear();
75
+
76
+ /**
77
+ * Verifica se cancela pedido
78
+ */
79
+ $cancelOrderConfig = Mage::helper('ipgbase')->getStoreConfig(Ipagare_IpgPagSeguroDireto_ConfiguracoesSystem::CANCEL_ORDER, $store);
80
+ if ($cancelOrderConfig) {
81
+ $this->logger->info('Cancelando pedido ' . $order->getIncrementId() . ' por falha no pagamento.');
82
+ Mage::getModel('ipgbase/expiraPedido')->cancelaPedido($order);
83
+ }
84
+
85
+ return $this->getResponse()->setRedirect($urlLojaFalha);
86
+ }
87
+
88
+ /**
89
+ * Sucesso
90
+ */
91
+ //if ($paymentResponse->isSuccess()) {
92
+ $paymentParserData = $paymentResponse->getPaymentParserData();
93
+ $paymentType = $paymentParserData->getPaymentMethod()->getCode();
94
+ $transactionStatus = $paymentParserData->getStatus();
95
+
96
+ Mage::getSingleton('ipgbase/session')->setPaymentData($paymentParserData);
97
+
98
+ /**
99
+ * Salva os dados de pagamento
100
+ */
101
+ Mage::getSingleton('ipgpagsegurodireto/payment')->save($paymentParserData, $paymentMode);
102
+
103
+ /**
104
+ * Cria a sonda
105
+ */
106
+ if (!$transactionStatus->isCancelada()) {
107
+ Mage::getModel('ipgpagsegurodireto/sonda')->criarSonda($order->getRealOrderId());
108
+
109
+ $order->getPayment()->setAdditionalInformation('ipgpagsegurodireto_use_status_sonda', '1')->save();
110
+ }
111
+
112
+ if ($transactionStatus->isPaga() || $transactionStatus->isDisponivel() || $transactionStatus->isDevolvida()) {
113
+ Mage::getModel('ipgpagsegurodireto/sonda')->removerSonda($order->getRealOrderId());
114
+ // captura pagamento, passa pedido para proccessing e envia e-mail de pagamento em caso de sucesso
115
+ Mage::dispatchEvent('ipgpagsegurodireto_proccess_success', array('order' => $order, 'valor' => $paymentParserData->getGrossAmount(), 'mensagem' => $transactionStatus->getMessage()));
116
+ } else {
117
+ // envia e-mail de pedido criado para status de transação em andamento
118
+ Mage::dispatchEvent('ipgpagsegurodireto_send_new_order_email', array('order' => $order, 'mensagem' => $transactionStatus->getMessage()));
119
+ }
120
+
121
+ Mage::helper('ipgpagsegurodireto')->clearSession();
122
+ $this->logger->info('Finalizando transação com sucesso do pedido ' . $order->getIncrementId());
123
+ Mage::getSingleton('checkout/type_onepage')->getCheckout()->setLastSuccessQuoteId(true);
124
+
125
+ if ($paymentType->isCreditCard() || $paymentType->isBoleto()) {
126
+ return $this->getResponse()->setRedirect($urlLojaSucesso);
127
+ } else if ($paymentType->isDebitoBancario()) {
128
+ return $this->getResponse()->setRedirect($urlLojaTransferencia);
129
+ }
130
+ }
131
+
132
+ public function transferenciaAction() {
133
+ $this->loadLayout();
134
+ $this->_initLayoutMessages('core/session');
135
+ $this->renderLayout();
136
+ }
137
+
138
+ }
app/code/local/Ipagare/IpgPagSeguroDireto/etc/adminhtml.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <ipgpagsegurodireto translate="title" />
12
+ </children>
13
+ </config>
14
+ </children>
15
+ </system>
16
+ </children>
17
+ </admin>
18
+ </resources>
19
+ </acl>
20
+ </config>
app/code/local/Ipagare/IpgPagSeguroDireto/etc/config.xml ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ipagare_IpgPagSeguroDireto>
5
+ <version>1.1.3</version>
6
+ </Ipagare_IpgPagSeguroDireto>
7
+ </modules>
8
+
9
+ <global>
10
+ <models>
11
+ <ipgpagsegurodireto>
12
+ <class>Ipagare_IpgPagSeguroDireto_Model</class>
13
+ <resourceModel>ipgpagsegurodireto_mysql4</resourceModel>
14
+ </ipgpagsegurodireto>
15
+ <ipgpagsegurodireto_mysql4>
16
+ <class>Ipagare_IpgPagSeguroDireto_Model_Mysql4</class>
17
+ <entities>
18
+ <entity_payment>
19
+ <table>ipagare_pagsegurodireto_pagamento</table>
20
+ </entity_payment>
21
+ <entity_sonda>
22
+ <table>ipagare_pagsegurodireto_sonda</table>
23
+ </entity_sonda>
24
+ <entity_erro>
25
+ <table>ipagare_pagsegurodireto_erro</table>
26
+ </entity_erro>
27
+ </entities>
28
+ </ipgpagsegurodireto_mysql4>
29
+ </models>
30
+
31
+ <helpers>
32
+ <ipgpagsegurodireto>
33
+ <class>Ipagare_IpgPagSeguroDireto_Helper</class>
34
+ </ipgpagsegurodireto>
35
+ </helpers>
36
+
37
+ <blocks>
38
+ <ipgpagsegurodireto>
39
+ <class>Ipagare_IpgPagSeguroDireto_Block</class>
40
+ </ipgpagsegurodireto>
41
+
42
+ <checkout>
43
+ <rewrite>
44
+ <onepage_success>Ipagare_IpgPagSeguroDireto_Block_Checkout_Onepage_Success</onepage_success>
45
+ </rewrite>
46
+ </checkout>
47
+ </blocks>
48
+
49
+ <sales>
50
+ <quote>
51
+ <totals>
52
+ <discount-ipgpagsegurodireto>
53
+ <class>ipgpagsegurodireto/sales_quote_address_total_discount</class>
54
+ <after>grand_total</after>
55
+ </discount-ipgpagsegurodireto>
56
+ </totals>
57
+ </quote>
58
+ <order_invoice>
59
+ <totals>
60
+ <discount-ipgpagsegurodireto>
61
+ <class>ipgpagsegurodireto/sales_order_invoice_total_discount</class>
62
+ <after>grand_total</after>
63
+ </discount-ipgpagsegurodireto>
64
+ </totals>
65
+ </order_invoice>
66
+ </sales>
67
+ <fieldsets>
68
+ <sales_convert_quote_address>
69
+ <ipg_pagsegurodireto_discount_amount>
70
+ <to_order>*</to_order>
71
+ </ipg_pagsegurodireto_discount_amount>
72
+ <ipg_pagsegurodireto_base_discount_amount>
73
+ <to_order>*</to_order>
74
+ </ipg_pagsegurodireto_base_discount_amount>
75
+ </sales_convert_quote_address>
76
+ </fieldsets>
77
+
78
+ <resources>
79
+ <ipgpagsegurodireto_setup>
80
+ <setup>
81
+ <module>Ipagare_IpgPagSeguroDireto</module>
82
+ <class>Mage_Sales_Model_Mysql4_Setup</class>
83
+ </setup>
84
+ <connection>
85
+ <use>core_setup</use>
86
+ </connection>
87
+ </ipgpagsegurodireto_setup>
88
+ </resources>
89
+ </global>
90
+
91
+ <frontend>
92
+ <secure_url>
93
+ <ipgpagsegurodireto>/ipgpagsegurodireto</ipgpagsegurodireto>
94
+ </secure_url>
95
+ <routers>
96
+ <ipgpagsegurodireto>
97
+ <use>standard</use>
98
+ <args>
99
+ <module>Ipagare_IpgPagSeguroDireto</module>
100
+ <frontName>ipgpagsegurodireto</frontName>
101
+ <modules>
102
+ <Ipagare_IpgPagSeguroDireto before="Mage_Checkout">Ipagare_IpgPagSeguroDireto</Ipagare_IpgPagSeguroDireto>
103
+ </modules>
104
+ </args>
105
+ </ipgpagsegurodireto>
106
+ </routers>
107
+ <layout>
108
+ <updates>
109
+ <ipgpagsegurodireto>
110
+ <file>ipagare/ipgpagsegurodireto.xml</file>
111
+ </ipgpagsegurodireto>
112
+ </updates>
113
+ </layout>
114
+ <translate>
115
+ <modules>
116
+ <Ipagare_IpgPagSeguroDireto>
117
+ <files>
118
+ <default>Ipagare_IpgPagSeguroDireto.csv</default>
119
+ </files>
120
+ </Ipagare_IpgPagSeguroDireto>
121
+ </modules>
122
+ </translate>
123
+ <events>
124
+ <!--
125
+ <controller_front_init_before>
126
+ <observers>
127
+ <ipgpagsegurodireto>
128
+ <type>singleton</type>
129
+ <class>ipgpagsegurodireto/observer</class>
130
+ <method>loadLibrary</method>
131
+ </ipgpagsegurodireto>
132
+ </observers>
133
+ </controller_front_init_before>
134
+ -->
135
+ <ipgpagsegurodireto_process_success>
136
+ <observers>
137
+ <ipgpagsegurodireto_process_success>
138
+ <class>ipgpagsegurodireto/observer</class>
139
+ <method>processSuccess</method>
140
+ </ipgpagsegurodireto_process_success>
141
+ </observers>
142
+ </ipgpagsegurodireto_process_success>
143
+ <ipgpagsegurodireto_process_cancel>
144
+ <observers>
145
+ <ipgpagsegurodireto_process_cancel>
146
+ <class>ipgpagsegurodireto/observer</class>
147
+ <method>processCancel</method>
148
+ </ipgpagsegurodireto_process_cancel>
149
+ </observers>
150
+ </ipgpagsegurodireto_process_cancel>
151
+ <ipgpagsegurodireto_send_new_order_email>
152
+ <observers>
153
+ <ipgpagsegurodireto_send_new_order_email>
154
+ <class>ipgpagsegurodireto/observer</class>
155
+ <method>sendNewOrderEmail</method>
156
+ </ipgpagsegurodireto_send_new_order_email>
157
+ </observers>
158
+ </ipgpagsegurodireto_send_new_order_email>
159
+ </events>
160
+ </frontend>
161
+
162
+ <admin>
163
+ <routers>
164
+ <ipgpagsegurodireto>
165
+ <use>admin</use>
166
+ <args>
167
+ <module>Ipagare_IpgPagSeguroDireto</module>
168
+ <frontName>ipgpagsegurodireto</frontName>
169
+ </args>
170
+ </ipgpagsegurodireto>
171
+ </routers>
172
+ </admin>
173
+
174
+ <adminhtml>
175
+ <layout>
176
+ <updates>
177
+ <ipgpagsegurodireto module='ipgpagsegurodireto'>
178
+ <file>ipagare/ipgpagsegurodireto.xml</file>
179
+ </ipgpagsegurodireto>
180
+ </updates>
181
+ </layout>
182
+ </adminhtml>
183
+
184
+ <default>
185
+ <sales>
186
+ <totals_sort>
187
+ <discount-ipgpagsegurodireto>26</discount-ipgpagsegurodireto>
188
+ </totals_sort>
189
+ </sales>
190
+ <adminhtml>
191
+ <sales>
192
+ <totals_sort>
193
+ <discount-ipgpagsegurodireto>26</discount-ipgpagsegurodireto>
194
+ </totals_sort>
195
+ </sales>
196
+ </adminhtml>
197
+ <payment>
198
+ <ipgpagsegurodireto>
199
+ <active>1</active>
200
+ <model>ipgpagsegurodireto/IpgPagSeguroDireto</model>
201
+ <title>Pagamento Online com PagSeguro</title>
202
+ <allowspecific>0</allowspecific>
203
+ </ipgpagsegurodireto>
204
+ </payment>
205
+ <ipgpagsegurodireto>
206
+ <geral>
207
+ <invoice>1</invoice>
208
+ <cancel_order>1</cancel_order>
209
+ <custom_css>0</custom_css>
210
+ </geral>
211
+ <cartao>
212
+ <valor_minimo>0,01</valor_minimo>
213
+ </cartao>
214
+ <debito>
215
+ <valor_minimo>0,01</valor_minimo>
216
+ </debito>
217
+ <boleto>
218
+ <valor_minimo>0,01</valor_minimo>
219
+ </boleto>
220
+ <environment>
221
+
222
+ </environment>
223
+ </ipgpagsegurodireto>
224
+ </default>
225
+
226
+ <crontab>
227
+ <jobs>
228
+ <ipagare_ipgpagsegurodireto_status_payment>
229
+ <schedule>
230
+ <cron_expr>*/30 * * * *</cron_expr>
231
+ </schedule>
232
+ <run>
233
+ <model>ipgpagsegurodireto/observer::paymentSonda</model>
234
+ </run>
235
+ </ipagare_ipgpagsegurodireto_status_payment>
236
+ </jobs>
237
+ </crontab>
238
+ </config>
app/code/local/Ipagare/IpgPagSeguroDireto/etc/system.xml ADDED
@@ -0,0 +1,402 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <ipgpagsegurodireto>
5
+ <label>PagSeguro Direto</label>
6
+ <sort_order>7</sort_order>
7
+ <show_in_default>1</show_in_default>
8
+ <show_in_website>1</show_in_website>
9
+ <show_in_store>1</show_in_store>
10
+ <tab>ipagare</tab>
11
+ <groups>
12
+ <licenca_expira>
13
+ <frontend_model>ipgbase/adminhtml_system_config_fieldset_licenca</frontend_model>
14
+ <sort_order>1</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ </licenca_expira>
19
+ <geral translate="label">
20
+ <label><![CDATA[Configurações Gerais]]> (1.1.3)
21
+ </label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>2</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <expanded>1</expanded>
28
+ <fields>
29
+ <ajuda translate="label">
30
+ <label><![CDATA[Precisa de Ajuda? <a href="https://superempreendedor.zendesk.com/hc/pt-br" target="_blank">Clique aqui</a><br/>]]>
31
+ </label>
32
+ <frontend_model>ipgbase/adminhtml_system_config_form_field_needHelp</frontend_model>
33
+ <sort_order>1</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ </ajuda>
38
+ <active translate="label">
39
+ <label>Ativo</label>
40
+ <frontend_type>select</frontend_type>
41
+ <source_model>adminhtml/system_config_source_yesno</source_model>
42
+ <config_path>payment/ipgpagsegurodireto/active</config_path>
43
+ <sort_order>2</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ <comment><![CDATA[]]>
48
+ </comment>
49
+ </active>
50
+ <title translate="label">
51
+ <label>Titulo</label>
52
+ <frontend_type>text</frontend_type>
53
+ <config_path>payment/ipgpagsegurodireto/title</config_path>
54
+ <sort_order>3</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ <depends>
59
+ <active>1</active>
60
+ </depends>
61
+ </title>
62
+ <convenio translate="label">
63
+ <label><![CDATA[<strong>CONVÊNIO</strong>]]>
64
+ </label>
65
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
66
+ <sort_order>4</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ <depends>
71
+ <active>1</active>
72
+ </depends>
73
+ </convenio>
74
+ <email translate="label">
75
+ <label>Email</label>
76
+ <frontend_type>text</frontend_type>
77
+ <sort_order>5</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>1</show_in_store>
81
+ <comment><![CDATA[E-mail do lojista cadastrado no PagSeguro]]>
82
+ </comment>
83
+ <depends>
84
+ <active>1</active>
85
+ </depends>
86
+ </email>
87
+ <token translate="label">
88
+ <label>Token</label>
89
+ <frontend_type>text</frontend_type>
90
+ <sort_order>6</sort_order>
91
+ <show_in_default>1</show_in_default>
92
+ <show_in_website>1</show_in_website>
93
+ <show_in_store>1</show_in_store>
94
+ <comment><![CDATA[Logado no Painel de Controle do PagSeguro, acesse o menu "Integrações" > "Token de segurança".]]>
95
+ </comment>
96
+ <depends>
97
+ <active>1</active>
98
+ </depends>
99
+ </token>
100
+ <controle translate="label">
101
+ <label><![CDATA[<strong>OPÇÕES DE CONTROLE</strong>]]>
102
+ </label>
103
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
104
+ <sort_order>7</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>1</show_in_store>
108
+ <depends>
109
+ <active>1</active>
110
+ </depends>
111
+ </controle>
112
+ <invoice translate="label">
113
+ <label><![CDATA[Gerar fatura ao confirmar pagamento]]></label>
114
+ <frontend_type>select</frontend_type>
115
+ <source_model>adminhtml/system_config_source_yesno</source_model>
116
+ <sort_order>8</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ <depends>
121
+ <active>1</active>
122
+ </depends>
123
+ <comment><![CDATA[Para gerar a fatura do pedido selecione "Sim". Após a fatura ser gerada é possivel cancelar o pagamento no PagSeguro mas não é possível cancelar o pedido na sua loja Magento..]]>
124
+ </comment>
125
+ </invoice>
126
+ <cancel_order translate="label">
127
+ <label><![CDATA[Cancelar pedido em caso de falha de pagamento]]></label>
128
+ <frontend_type>select</frontend_type>
129
+ <source_model>adminhtml/system_config_source_yesno</source_model>
130
+ <sort_order>9</sort_order>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>1</show_in_store>
134
+ <depends>
135
+ <active>1</active>
136
+ </depends>
137
+ <comment><![CDATA[Para cancelar o pedido selecione "Sim". Após o cancelamento o produto voltará para o estoque.]]>
138
+ </comment>
139
+ </cancel_order>
140
+ <custom_css translate="label">
141
+ <label>Habilitar arquivo "custom.css"</label>
142
+ <frontend_type>select</frontend_type>
143
+ <source_model>adminhtml/system_config_source_yesno</source_model>
144
+ <sort_order>10</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>1</show_in_store>
148
+ <comment>
149
+ <![CDATA[O arquivo custom.css preserva as modificações de layout que você têm no PagSeguro. <br />
150
+ Este deverá ser criado por você e inserido na pasta "/skin/frontend/base/default/ipgpagsegurodireto/css"]]>
151
+ </comment>
152
+ </custom_css>
153
+ </fields>
154
+ </geral>
155
+
156
+ <cartao translate="label">
157
+ <label><![CDATA[Cartão de Crédito]]></label>
158
+ <frontend_type>text</frontend_type>
159
+ <sort_order>3</sort_order>
160
+ <show_in_default>1</show_in_default>
161
+ <show_in_website>1</show_in_website>
162
+ <show_in_store>1</show_in_store>
163
+ <expanded>1</expanded>
164
+ <fields>
165
+ <active translate="label">
166
+ <label>Ativo</label>
167
+ <frontend_type>select</frontend_type>
168
+ <source_model>adminhtml/system_config_source_yesno</source_model>
169
+ <sort_order>1</sort_order>
170
+ <show_in_default>1</show_in_default>
171
+ <show_in_website>1</show_in_website>
172
+ <show_in_store>1</show_in_store>
173
+ <comment><![CDATA[]]>
174
+ </comment>
175
+ </active>
176
+ <codigos translate="label">
177
+ <label>Bandeiras ativas</label>
178
+ <frontend_type>multiselect</frontend_type>
179
+ <source_model>ipgpagsegurodireto/system_config_source_allCardMethods</source_model>
180
+ <sort_order>2</sort_order>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_website>1</show_in_website>
183
+ <show_in_store>1</show_in_store>
184
+ <depends>
185
+ <active>1</active>
186
+ </depends>
187
+ </codigos>
188
+ <valor_minimo translate="label">
189
+ <label><![CDATA[Valor mínimo do pedido (R$)]]>
190
+ </label>
191
+ <frontend_type>text</frontend_type>
192
+ <validate>required-entry validate-length maximum-length-15 moeda</validate>
193
+ <sort_order>3</sort_order>
194
+ <show_in_default>1</show_in_default>
195
+ <show_in_website>1</show_in_website>
196
+ <show_in_store>1</show_in_store>
197
+ <depends>
198
+ <active>1</active>
199
+ </depends>
200
+ <comment><![CDATA[Este meio de pagamento só estará disponível para
201
+ pedidos com valor igual ou superior ao definido neste campo. <br/>Ex: 1,00]]>
202
+ </comment>
203
+ </valor_minimo>
204
+ <valor_maximo translate="label">
205
+ <label><![CDATA[Valor máximo do pedido (R$)]]>
206
+ </label>
207
+ <frontend_type>text</frontend_type>
208
+ <validate>validate-length maximum-length-15 moeda</validate>
209
+ <sort_order>4</sort_order>
210
+ <show_in_default>1</show_in_default>
211
+ <show_in_website>1</show_in_website>
212
+ <show_in_store>1</show_in_store>
213
+ <depends>
214
+ <active>1</active>
215
+ </depends>
216
+ <comment><![CDATA[Este meio de pagamento só estará disponível
217
+ para pedidos com valor igual ou inferior ao definido neste campo.
218
+ Caso não seja informado, nenhum limite será aplicado. <br/>Ex: 1,00]]>
219
+ </comment>
220
+ </valor_maximo>
221
+ <desconto_avista translate="label">
222
+ <label>Desconto à vista (%)</label>
223
+ <frontend_type>text</frontend_type>
224
+ <validate>validate-length maximum-length-5 moeda</validate>
225
+ <sort_order>5</sort_order>
226
+ <show_in_default>1</show_in_default>
227
+ <show_in_website>1</show_in_website>
228
+ <show_in_store>1</show_in_store>
229
+ <depends>
230
+ <active>1</active>
231
+ </depends>
232
+ <comment><![CDATA[Desconto percentual que será aplicado apenas na forma de pagamento à vista. Caso não seja informado, nenhum desconto será aplicado. Valor máximo: 99,99 <br/> Ex: 10,00.<br/><br/><br/><br/>]]>
233
+ </comment>
234
+ </desconto_avista>
235
+ </fields>
236
+ </cartao>
237
+
238
+ <debito translate="label">
239
+ <label><![CDATA[Débito Bancário]]>
240
+ </label>
241
+ <frontend_type>text</frontend_type>
242
+ <sort_order>4</sort_order>
243
+ <show_in_default>1</show_in_default>
244
+ <show_in_website>1</show_in_website>
245
+ <show_in_store>1</show_in_store>
246
+ <expanded>1</expanded>
247
+ <fields>
248
+ <active translate="label">
249
+ <label>Ativo</label>
250
+ <frontend_type>select</frontend_type>
251
+ <source_model>adminhtml/system_config_source_yesno</source_model>
252
+ <sort_order>1</sort_order>
253
+ <show_in_default>1</show_in_default>
254
+ <show_in_website>1</show_in_website>
255
+ <show_in_store>1</show_in_store>
256
+ </active>
257
+ <codigos translate="label">
258
+ <label>Bancos aceitos</label>
259
+ <frontend_type>multiselect</frontend_type>
260
+ <source_model>ipgpagsegurodireto/system_config_source_allDebitMethods</source_model>
261
+ <sort_order>2</sort_order>
262
+ <show_in_default>1</show_in_default>
263
+ <show_in_website>1</show_in_website>
264
+ <show_in_store>1</show_in_store>
265
+ <depends>
266
+ <active>1</active>
267
+ </depends>
268
+ </codigos>
269
+ <valor_minimo translate="label">
270
+ <label><![CDATA[Valor mínimo do pedido (R$)]]>
271
+ </label>
272
+ <frontend_type>text</frontend_type>
273
+ <validate>required-entry validate-length maximum-length-15 moeda</validate>
274
+ <sort_order>3</sort_order>
275
+ <show_in_default>1</show_in_default>
276
+ <show_in_website>1</show_in_website>
277
+ <show_in_store>1</show_in_store>
278
+ <depends>
279
+ <active>1</active>
280
+ </depends>
281
+ <comment><![CDATA[Este meio de pagamento só estará disponível para
282
+ pedidos com valor igual ou superior ao definido neste campo. <br/>Ex: 1,00]]>
283
+ </comment>
284
+ </valor_minimo>
285
+ <valor_maximo translate="label">
286
+ <label><![CDATA[Valor máximo do pedido (R$)]]>
287
+ </label>
288
+ <frontend_type>text</frontend_type>
289
+ <validate>validate-length maximum-length-15 moeda</validate>
290
+ <sort_order>4</sort_order>
291
+ <show_in_default>1</show_in_default>
292
+ <show_in_website>1</show_in_website>
293
+ <show_in_store>1</show_in_store>
294
+ <depends>
295
+ <active>1</active>
296
+ </depends>
297
+ <comment><![CDATA[Este meio de pagamento só estará disponível
298
+ para pedidos com valor igual ou inferior ao definido neste campo.
299
+ Caso não seja informado, nenhum limite será aplicado. <br/>Ex: 1,00]]>
300
+ </comment>
301
+ </valor_maximo>
302
+ <desconto_avista translate="label">
303
+ <label>Desconto à vista (%)</label>
304
+ <frontend_type>text</frontend_type>
305
+ <validate>validate-length maximum-length-5 moeda</validate>
306
+ <sort_order>5</sort_order>
307
+ <show_in_default>1</show_in_default>
308
+ <show_in_website>1</show_in_website>
309
+ <show_in_store>1</show_in_store>
310
+ <depends>
311
+ <active>1</active>
312
+ </depends>
313
+ <comment><![CDATA[Desconto percentual que será aplicado apenas na forma de pagamento à vista. Caso não seja informado, nenhum desconto será aplicado. Valor máximo: 99,99 <br/> Ex: 10,00.<br/><br/><br/><br/>]]>
314
+ </comment>
315
+ </desconto_avista>
316
+ </fields>
317
+ </debito>
318
+
319
+ <boleto translate="label">
320
+ <label><![CDATA[Boleto Bancário]]>
321
+ </label>
322
+ <frontend_type>text</frontend_type>
323
+ <sort_order>5</sort_order>
324
+ <show_in_default>1</show_in_default>
325
+ <show_in_website>1</show_in_website>
326
+ <show_in_store>1</show_in_store>
327
+ <expanded>1</expanded>
328
+ <fields>
329
+ <active translate="label">
330
+ <label>Ativo</label>
331
+ <frontend_type>select</frontend_type>
332
+ <source_model>adminhtml/system_config_source_yesno</source_model>
333
+ <sort_order>1</sort_order>
334
+ <show_in_default>1</show_in_default>
335
+ <show_in_website>1</show_in_website>
336
+ <show_in_store>1</show_in_store>
337
+ </active>
338
+ <codigos translate="label">
339
+ <label>Boletos aceitos</label>
340
+ <frontend_type>multiselect</frontend_type>
341
+ <source_model>ipgpagsegurodireto/system_config_source_allBoletoMethods</source_model>
342
+ <sort_order>2</sort_order>
343
+ <show_in_default>1</show_in_default>
344
+ <show_in_website>1</show_in_website>
345
+ <show_in_store>1</show_in_store>
346
+ <depends>
347
+ <active>1</active>
348
+ </depends>
349
+ </codigos>
350
+ <valor_minimo translate="label">
351
+ <label><![CDATA[Valor mínimo do pedido (R$)]]>
352
+ </label>
353
+ <frontend_type>text</frontend_type>
354
+ <validate>required-entry validate-length maximum-length-15 moeda</validate>
355
+ <sort_order>3</sort_order>
356
+ <show_in_default>1</show_in_default>
357
+ <show_in_website>1</show_in_website>
358
+ <show_in_store>1</show_in_store>
359
+ <depends>
360
+ <active>1</active>
361
+ </depends>
362
+ <comment><![CDATA[Este meio de pagamento só estará disponível para
363
+ pedidos com valor igual ou superior ao definido neste campo. <br/>Ex: 1,00]]>
364
+ </comment>
365
+ </valor_minimo>
366
+ <valor_maximo translate="label">
367
+ <label><![CDATA[Valor máximo do pedido (R$)]]>
368
+ </label>
369
+ <frontend_type>text</frontend_type>
370
+ <validate>validate-length maximum-length-15 moeda</validate>
371
+ <sort_order>4</sort_order>
372
+ <show_in_default>1</show_in_default>
373
+ <show_in_website>1</show_in_website>
374
+ <show_in_store>1</show_in_store>
375
+ <depends>
376
+ <active>1</active>
377
+ </depends>
378
+ <comment><![CDATA[Este meio de pagamento só estará disponível
379
+ para pedidos com valor igual ou inferior ao definido neste campo.
380
+ Caso não seja informado, nenhum limite será aplicado. <br/>Ex: 1,00]]>
381
+ </comment>
382
+ </valor_maximo>
383
+ <desconto_avista translate="label">
384
+ <label>Desconto à vista (%)</label>
385
+ <frontend_type>text</frontend_type>
386
+ <validate>validate-length maximum-length-5 moeda</validate>
387
+ <sort_order>5</sort_order>
388
+ <show_in_default>1</show_in_default>
389
+ <show_in_website>1</show_in_website>
390
+ <show_in_store>1</show_in_store>
391
+ <depends>
392
+ <active>1</active>
393
+ </depends>
394
+ <comment><![CDATA[Desconto percentual que será aplicado apenas na forma de pagamento à vista. Caso não seja informado, nenhum desconto será aplicado. Valor máximo: 99,99 <br/> Ex: 10,00.<br/><br/><br/><br/>]]>
395
+ </comment>
396
+ </desconto_avista>
397
+ </fields>
398
+ </boleto>
399
+ </groups>
400
+ </ipgpagsegurodireto>
401
+ </sections>
402
+ </config>
app/code/local/Ipagare/IpgPagSeguroDireto/sql/ipgpagsegurodireto_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * iPAGARE PagSeguro para Magento
6
+ *
7
+ * @category Ipagare
8
+ * @packages IpgPagSeguroDireto
9
+ * @copyright Copyright (c) 2014 iPAGARE (http://www.ipagare.com.br)
10
+ * @version 1.1.3
11
+ * @license http://www.ipagare.com.br/magento/licenca
12
+ *
13
+ */
14
+
15
+ $installer = $this;
16
+
17
+ $installer->startSetup();
18
+
19
+ $conn = $installer->getConnection();
20
+ $tabelaPagamento = $installer->getTable('ipagare_pagsegurodireto_pagamento');
21
+ $tabelaSonda = $installer->getTable('ipagare_pagsegurodireto_sonda');
22
+ $tabelaErro = $installer->getTable('ipagare_pagsegurodireto_erro');
23
+
24
+ $installer->run("
25
+ CREATE TABLE IF NOT EXISTS `{$tabelaPagamento}` (
26
+ `id_ipagare_pagsegurodireto_pagamento` INT(11) NOT NULL AUTO_INCREMENT,
27
+ `order_id` VARCHAR(50) NOT NULL default '',
28
+ `meio_pagamento` INT(2) NOT NULL,
29
+ `forma_pagamento` VARCHAR(3) NOT NULL,
30
+ `valor_total` VARCHAR(200) NOT NULL,
31
+ `transaction_code` VARCHAR(50) NOT NULL,
32
+ `payment_link` TEXT NOT NULL,
33
+ `status` VARCHAR(3) NOT NULL,
34
+ `created_time` DATETIME NULL,
35
+ `mensagem_cancelamento` VARCHAR(200) NULL,
36
+ PRIMARY KEY (`id_ipagare_pagsegurodireto_pagamento`)
37
+ )ENGINE=InnoDB DEFAULT CHARSET=utf8;
38
+
39
+ CREATE TABLE IF NOT EXISTS `{$tabelaSonda}` (
40
+ `id_ipagare_pagsegurodireto_sonda` INT(11) NOT NULL AUTO_INCREMENT,
41
+ `order_id` VARCHAR(50) NOT NULL,
42
+ `register_date` DATETIME NULL,
43
+ PRIMARY KEY (`id_ipagare_pagsegurodireto_sonda`)
44
+ )ENGINE=InnoDB DEFAULT CHARSET=utf8;
45
+
46
+ CREATE TABLE IF NOT EXISTS `{$tabelaErro}` (
47
+ `id_ipagare_pagsegurodireto_erro` INT(11) NOT NULL AUTO_INCREMENT,
48
+ `order_id` VARCHAR(50) NOT NULL,
49
+ `code` VARCHAR(10) NOT NULL,
50
+ PRIMARY KEY (`id_ipagare_pagsegurodireto_erro`)
51
+ )ENGINE=InnoDB DEFAULT CHARSET=utf8;
52
+ ");
53
+
54
+
55
+ $tableSalesOrder = $installer->getTable('sales/order');
56
+ $tableQuoteAddress = $installer->getTable('sales/quote_address');
57
+ $tableInvoice = $installer->getTable('sales/invoice');
58
+
59
+ if (!$conn->tableColumnExists($tableSalesOrder, 'ipg_pagsegurodireto_discount_amount')) {
60
+ $conn->addColumn($tableSalesOrder, 'ipg_pagsegurodireto_discount_amount', 'DECIMAL(10,4) NOT NULL');
61
+ }
62
+ if (!$conn->tableColumnExists($tableSalesOrder, 'ipg_pagsegurodireto_base_discount_amount')) {
63
+ $conn->addColumn($tableSalesOrder, 'ipg_pagsegurodireto_base_discount_amount', 'DECIMAL(10,4) NOT NULL');
64
+ }
65
+ if (!$conn->tableColumnExists($tableQuoteAddress, 'ipg_pagsegurodireto_discount_amount')) {
66
+ $conn->addColumn($tableQuoteAddress, 'ipg_pagsegurodireto_discount_amount', 'DECIMAL(10,4) NOT NULL');
67
+ }
68
+ if (!$conn->tableColumnExists($tableQuoteAddress, 'ipg_pagsegurodireto_base_discount_amount')) {
69
+ $conn->addColumn($tableQuoteAddress, 'ipg_pagsegurodireto_base_discount_amount', 'DECIMAL(10,4) NOT NULL');
70
+ }
71
+ if (!$conn->tableColumnExists($tableInvoice, 'ipg_pagsegurodireto_discount_amount')) {
72
+ $conn->addColumn($tableInvoice, 'ipg_pagsegurodireto_discount_amount', 'DECIMAL(10,4) NOT NULL');
73
+ }
74
+ if (!$conn->tableColumnExists($tableInvoice, 'ipg_pagsegurodireto_base_discount_amount')) {
75
+ $conn->addColumn($tableInvoice, 'ipg_pagsegurodireto_base_discount_amount', 'DECIMAL(10,4) NOT NULL');
76
+ }
77
+
78
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/ipagare/ipgbase.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss">
6
+ <stylesheet>ipgbase/css/styles.css</stylesheet>
7
+ </action>
8
+ <action method="addItem">
9
+ <type>js</type>
10
+ <name>ipagare/lib/ipagare.js</name>
11
+ </action>
12
+ <action method="addJs">
13
+ <script>ipagare/ipgbase/adminhtml/index.js</script>
14
+ </action>
15
+ </reference>
16
+ </default>
17
+ </layout>
app/design/adminhtml/default/default/layout/ipagare/ipgpagsegurodireto.xml ADDED
File without changes
app/etc/modules/Ipagare_IpgBase.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ipagare_IpgBase>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <version>1.16.4</version>
8
+ </Ipagare_IpgBase>
9
+ </modules>
10
+ </config>
app/etc/modules/Ipagare_IpgPagSeguroDireto.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ipagare_IpgPagSeguroDireto>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <version>1.1.3</version>
8
+ <depends>
9
+ <Mage_Payment />
10
+ </depends>
11
+ </Ipagare_IpgPagSeguroDireto>
12
+ </modules>
13
+ </config>
app/locale/pt_BR/Ipagare_IpgBase.csv ADDED
@@ -0,0 +1 @@
 
1
+ "Payment Discount","Desconto à vista"
app/locale/pt_BR/Ipagare_IpgPagSeguroDireto.csv ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "txt.msgTituloMetodoPagamentoCartao","Cartão de Crédito"
2
+ "txt.msgTituloMetodoPagamentoDebito","Débito Online"
3
+ "txt.msgTituloMetodoPagamentoBoleto","Boleto"
4
+ "txt.numParcelas","Número de parcelas"
5
+ "txt.numeroCartao","Número do cartão"
6
+ "txt.validade","Validade"
7
+ "txt.codigoSeguranca","Código de segurança"
8
+ "txt.Parcelas","Escolha a forma de pagamento"
9
+ "txt.msgAjudaCodSeguranca","o que é isso?"
10
+
11
+ "txt.titularCartao","Titular do cartão de crédito"
12
+ "txt.msgTituloNomeTitularCartao","Nome"
13
+ "txt.cpfTitularCartao","CPF"
14
+ "txt.nascimentoTitularCartao","Data de Nascimento"
15
+ "txt.foneTitularCartao","Telefone"
16
+ "txt.msgInformacaoDebito","Após o fechamento do pedido você será redirecionado ao ambiente da operadora para informar os dados do cartão."
17
+
18
+ "txt.msgBin1","O número do BIN para o cartão de crédito Hipercard é uma sequência numérica integrante do número do cartão."
19
+ "txt.msgBin2","Para o cartão Hipercard:"
20
+ "txt.msgBin3","Informar os seis números localizados acima do número do cartão."
21
+ "txt.msgBin4","Em cartões Hipercard, que não tem número BIN, você deve digitar os 16 números no campo: Número do cartão."
22
+
23
+ "txt.msgPagSegTransacaoProcessada","Sua transação foi processada pelo PagSeguro."
24
+ "txt.msgPagSegTransacao1","A sua transação está: "
25
+ "txt.msgPagSegTransacao2"," O código da transação no PagSeguro é: "
26
+ "txt.msgPagSegTransacao3","Caso tenha alguma dúvida referente à transação, entre em contato com o PagSeguro."
27
+
28
+ "txt.msgPagamentoPagSeguro", "Seu pagamento será processado pelo"
29
+
30
+ "Zip/Postal Code","CEP"
31
+ "Please wait...","Por favor, aguarde..."
32
+ "txt.MsgPagSeg1","Após a conclusão do pedido, você será redirecionado ao PagSeguro para realizar o pagamento."
33
+ "txt.MsgPagSeg2"," Você está sendo redirecionado para o PagSeguro. Por favor, aguarde..."
34
+
35
+ "txt.MsgErro","O pagamento não foi processado com sucesso. Motivo(s): "
36
+ "txt.MsgErroAjuda","Em caso de dúvidas entre em contato com o PagSeguro e informe o código do erro apresentado."
37
+ "txt.MsgErroConexao","Ocorreu um erro ao enviar o pedido ao PagSeguro, por favor, tente mais tarde."
38
+ "txt.undefined","Não possível processar essa requisição. Por favor, entre em contato com a loja informando o código: "
39
+ "Payment Discount","Desconto"
40
+
41
+ "txt.abrirPagBanco","Abrir página do banco"
42
+ "txt.Parcelas","Escolha a forma de pagamento"
43
+ "txt.avista"," &agrave; vista "
44
+ "txt.descontoDe","(desconto de "
45
+ "txt.percent","%)"
46
+ "txt.xde","x de "
47
+ "txt.cJuros"," c/ juros ("
48
+ "txt.percAM","% a.m)"
49
+ "txt.semjuros"," sem juros"
50
+ "txt.astDescontoDe","* desconto de "
51
+ "txt.perc","%"
52
+
53
+ "txt.msgGerarBoleto","Clique em ""Gerar boleto"" e realize o pagamento através de seu Internet Banking ou agência bancária."
54
+
55
+ "txt.msgTelaDebito1","Quando você clicar no botão 'Abrir página do banco', uma nova janela será aberta no ambiente seguro do Banco."
56
+ "txt.msgTelaDebito2","Siga as instruções de pagamento no ambiente do banco."
57
+ "txt.msgTelaDebito3","Após finalizar o pagamento, você será automaticamente redirecionado para a página da loja."
58
+ "txt.msgTelaDebito4","Após fechar a janela do Banco ou Operadora, por favor aguarde 10 segundos para que o seu pagamento seja processado. "
59
+ "txt.msgTelaDebito5","Por favor, não feche esta janela até que seu pagamento seja processado."
60
+ "txt.abrirPagBanco","Abrir página do banco"
js/ipagare/ipgbase/adminhtml/index.js ADDED
@@ -0,0 +1 @@
 
1
+ if(typeof admin=="undefined"||!admin){var admin={};var formIpagare=null;var formIpagareClearSaleStart=null}admin.bindInput=function(){$$(".moeda").each(function(a){a.observe("blur",function(){Moeda.mascara(a,2)})})};var IpagareMessages=Class.create({initialize:function(){this.messageContainer="messages";this.errorMessageClass="error-msg";this.infoMessageClass="notice-msg";this.successMessageClass="success-msg"},error:function(a){this._add(this.errorMessageClass,a)},info:function(a){this._add(this.infoMessageClass,a)},success:function(a){this._add(this.successMessageClass,a)},remove:function(){$(this.messageContainer).update("")},_add:function(b,g){var d=new Element("ul",{"class":"messages"});var a=new Element("li",{"class":b});var f=new Element("ul");var c=new Element("li");var e=new Element("span");e.update(g);c.insert(e);f.insert(c);a.insert(c);d.insert(a);$(this.messageContainer).update(d)}});var ipgMessages=new IpagareMessages();Event.observe(window,"load",function(){admin.bindInput();formIpagare=setTimeout("admin.formIpagareClearSale()",500);formIpagareClearSaleStart=setTimeout("admin.formIpagareClearSaleStart()",500)});admin.formIpagareClearSale=function(){if($("formIpagare")){$("formIpagare").submit();clearTimeout(formIpagare)}};admin.formIpagareClearSaleStart=function(){if($("formIpagareClearSaleStart")){$("formIpagareClearSaleStart").submit();clearTimeout(formIpagareClearSaleStart)}};
js/ipagare/ipgbase/frontend/front.js ADDED
File without changes
js/ipagare/ipgpagsegurodireto/adminhtml/index.js ADDED
File without changes
js/ipagare/ipgpagsegurodireto/adminhtml/sales/order/view.js ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ var IpagarePagSeguroDiretoOrderView = Class.create({
2
+
3
+ initialize : function() {
4
+ $$('h4.head-payment-method')[0].up('div').addClassName('entry-edit-head-ipagare').removeClassName('entry-edit-head');
5
+ $$('div.entry-edit-head-ipagare')[0].down('h4').removeClassName('head-payment-method');
6
+ }
7
+
8
+ });
js/ipagare/ipgpagsegurodireto/frontend/payment/pagseguro.directpayment.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(){if(window._PagSeguroDirectPayment){return;}function onDocumentReady(callback){var eventName=document.addEventListener?"DOMContentLoaded":"onreadystatechange";if(document.readyState==="complete"||(document.readyState!=="loading"&&!document.attachEvent)){callback();return;}document[document.addEventListener?"addEventListener":"attachEvent"](eventName,function(){if(eventName=="DOMContentLoaded"||document.readyState==="complete"){callback();document[document.removeEventListener?"removeEventListener":"detachEvent"](eventName,arguments.callee,false);}},false);}var pagsegurosession,PagSeguro=PagSeguro||function(){},gateway=document.createElement("iframe"),styleNode=document.createElement("style"),styleSheets=[".directpaymentgateway {position:absolute; width:0px; height:0px; display:none;}"].join("");gateway.setAttribute("src","https://pagseguro.uol.com.br/checkout/direct-payment/i-ck.html");gateway.setAttribute("width","1px");gateway.setAttribute("height","1px");gateway.setAttribute("id","directpaymentgateway");gateway.setAttribute("class","directpaymentgateway");gateway.setAttribute("allowtransparency","true");gateway.setAttribute("frameborder","0");PagSeguro.DirectPayment=function(config){var _that=this;this.gateway=gateway;this.ready=false;this.mediator=false;this.queue=[];this.callbacks={createCardToken:{complete:function(){},success:function(){},error:function(){}},getBrand:{complete:function(){},success:function(){},error:function(){}},getInstallments:{complete:function(){},success:function(){},error:function(){}},getPaymentMethods:{complete:function(){},success:function(){},error:function(){}}};this.dnahash;this.init();window._PagSeguroDirectPayment=this;};PagSeguro.DirectPayment.prototype={constructor:PagSeguro.DirectPayment,init:function(){var _that=this;onDocumentReady(function(){document.getElementsByTagName("body")[0].appendChild(gateway);document.getElementsByTagName("head")[0].appendChild(styleNode);if(styleNode.styleSheet){styleNode.styleSheet.cssText=styleSheets;}else{styleNode.appendChild(document.createTextNode(styleSheets));}var _onload=function(){_that.mediator=new PagSeguro.APIMediator({gateway:_that.gateway});_that.listenChannels();_that.syntonize();_that.execQueue();};if(!window.addEventListener){_that.gateway.attachEvent("onload",_onload);}else{_that.gateway.addEventListener("load",_onload);}});},syntonize:function(){this.publish({command:"registerVendor",url:window.location.protocol+"//"+window.location.host},"gateway");},publish:function(message,channel){this.mediator.postMessage(message,channel);},subscribe:function(channel,callback){this.mediator.acceptMessage(channel,callback);},setSessionId:function(sessionId){var _that=this;pagsegurosession=sessionId;this.queue.push(function(){_that.publish({command:"setSessionId",sessionId:pagsegurosession},"gateway");});this.execQueue();},createCardToken:function(config){var _that=this;this.setCallbacks(this.callbacks.createCardToken,config);this.queue.push(function(){_that.publish({command:"createCardToken",config:_that.deleteFunctions(config)},"gateway");});this.execQueue();},getInstallments:function(config){var _that=this;this.setCallbacks(this.callbacks.getInstallments,config);this.queue.push(function(){_that.publish({command:"getInstallments",config:_that.deleteFunctions(config)},"gateway");});this.execQueue();},getPaymentMethods:function(config){var _that=this;this.setCallbacks(this.callbacks.getPaymentMethods,config);this.queue.push(function(){_that.publish({command:"getPaymentMethods",config:_that.deleteFunctions(config)},"gateway");});this.execQueue();},getBrand:function(config){var _that=this;this.setCallbacks(this.callbacks.getBrand,config);this.queue.push(function(){_that.publish({command:"getBrand",config:_that.deleteFunctions(config)},"gateway");});this.execQueue();},execQueue:function(){var _that=this;if(this.ready===true){while(this.queue.length){this.queue.shift()();}}else{setTimeout(function(){_that.execQueue();},100);}},setDnaHash:function(value){this.dnahash=value;},getSenderHash:function(){return this.dnahash;},listenChannels:function(){var _that=this;this.subscribe("gateway",function(data){if(data.command){switch(data.command){case"createCardToken":_that.runCallback(_that.callbacks.createCardToken,data.result);break;case"getBrand":_that.runCallback(_that.callbacks.getBrand,data.result);break;case"getInstallments":_that.runCallback(_that.callbacks.getInstallments,data.result);break;case"getPaymentMethods":_that.runCallback(_that.callbacks.getPaymentMethods,data.result);break;case"getReady":_that.ready=true;break;case"setDnaHash":_that.setDnaHash(data.result);}}});},runCallback:function(callback,result){callback.complete(result);if(result.error){callback.error(result);}else{callback.success(result);}},deleteFunctions:function(config){delete config.success;delete config.error;delete config.complete;return config;},setCallbacks:function(callback,config){callback.success=config.success?config.success:function(){};callback.error=config.error?config.error:function(){};callback.complete=config.complete?config.complete:function(){};}};PagSeguro.APIMediator=function(core){var channels={gateway:{context:core.gateway.contentWindow,url:"https://pagseguro.uol.com.br",callbacks:[]}};this.postMessage=function(message,channel){if(channels[channel]){channels[channel].context.postMessage(JSON.stringify(message),channels[channel].url);}};this.acceptMessage=function(channel,callback){var _that=this,callbacks=channels[channel].callbacks;callbacks[callbacks.length]=function(event){if(!channels[channel]){return;}if(event.origin==channels[channel].url){callback(JSON.parse(event.data));}};window[window.addEventListener?"addEventListener":"attachEvent"]((window.addEventListener?"message":"onmessage"),callbacks[callbacks.length-1]);};this.commandDispatch=function(command){var _that=this,commands=channels[channel].commands;commands[commands.length]=function(event){if(!channels[channel]){return;}if(event.origin==channels[channel].url){callback(event.data);}};window[window.addEventListener?"addEventListener":"attachEvent"]((window.addEventListener?"message":"onmessage"),callbacks[callbacks.length-1]);};this.commandAccept=function(){};this.ignoreMessage=function(channel){var _that=this,i=channels[channel].callbacks.length;if(channels[channel]){while(i--){window[window.removeEventListener?"removeEventListener":"detachEvent"]((window.removeEventListener?"message":"onmessage"),channels[channel].callbacks[i]);}}};};window.PagSeguroDirectPayment=window._PagSeguroDirectPayment||new PagSeguro.DirectPayment();})();
js/ipagare/ipgpagsegurodireto/frontend/payment/transferencia/index.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var x = 2;
2
+ var y = 1;
3
+ var financeira = null;
4
+
5
+ ipagare.startClock = function() {
6
+
7
+ x = x - y;
8
+ setTimeout("ipagare.startClock()", 1000);
9
+ if (x == 0) {
10
+ try {
11
+ if (financeira.closed) {
12
+ document.location.href = URL_VERIFY;
13
+ } else {
14
+ x = 1; // intervalo de segundos
15
+ }
16
+ } catch (e) {
17
+ x = 1; // intervalo de segundos
18
+ }
19
+ }
20
+ };
21
+
22
+ ipagare.openPopup = function() {
23
+ window.name = "IpagarePagSeguroDireto";
24
+ financeira = window.open(URL_PAYMENT, 'formPagSeguroDireto', 'width=780,height=500,toolbar=0,location=0,directories=0,dependent=0,status=1,scrollbars=1,resizable=1');
25
+
26
+ if (ipagare.isNotNull(financeira)) {
27
+ ipagare.startClock();
28
+ }
29
+ };
js/ipagare/lib/checkout.js ADDED
@@ -0,0 +1 @@
 
1
+ var IpgValidator=Class.create({initialize:function(a){this.paymentMethod="payment_form_"+a.paymentMethod},cpf:function(a){a.value=this._mcpf(a.value)},numeric:function(a){a.value=this._mnum(a.value)},upper:function(a){a.value=this._upper(a.value)},_mcpf:function(a){a=a.replace(/\D/g,"");a=a.replace(/(\d{3})(\d)/,"$1.$2");a=a.replace(/(\d{3})(\d)/,"$1.$2");a=a.replace(/(\d{3})(\d{1,2})$/,"$1-$2");return a},_mnum:function(a){a=a.replace(/\D/g,"");return a},_upper:function(a){a=a.replace(/\d/g,"");a=a.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi,"");return a.replace(/[a-z]/g,function b(c){return c.toUpperCase()})}});String.prototype.isCPF=function(){var e=this;if(e==""){return true}if((e=e.replace(/[^\d]/g,"").split("")).length!=11){return false}if(new RegExp("^"+e[0]+"{11}$").test(e.join(""))){return false}for(var b=10,d=0,a=0;b>=2;d+=e[a++]*b--){}if(e[9]!=(((d%=11)<2)?0:11-d)){return false}for(var b=11,d=0,a=0;b>=2;d+=e[a++]*b--){}if(e[10]!=(((d%=11)<2)?0:11-d)){return false}return true};String.prototype.isCNPJ=function(){var f=this;if(f==""){return true}var a=[6,5,4,3,2,9,8,7,6,5,4,3,2];if((f=f.replace(/[^\d]/g,"").split("")).length!=14){return false}for(var d=0,e=0;d<12;e+=f[d]*a[++d]){}if(f[12]!=(((e%=11)<2)?0:11-e)){return false}for(var d=0,e=0;d<=12;e+=f[d]*a[d++]){}if(f[13]!=(((e%=11)<2)?0:11-e)){return false}return true};Validation.add("cpf",Translator.translate("CPF Inválido."),function(a){return a.isCPF()});Validation.add("ipg-validate-alpha","Somente letras",function(a){return Validation.get("IsEmpty").test(a)||/^[a-zA-Z ]+$/.test(a)});Validation.add("validate-one-payment-brand",Translator.translate("Por favor, selecione uma opção de pagamento: Cartão de Crédito, Débito ou Boleto."),function(b,d){var a=$(d).readAttribute("data-method");var c=$$("#payment_form_"+a+" span.select").length;return(c>0)});var IpgToggleToolTip=Class.create({initialize:function(a){this.tip=$("ipagare-payment-"+a+"-tool-tip")},insert:function(a){if(this.tip){this.tip.setStyle({left:(Event.pointerX(a)-100)+"px",top:(Event.pointerY(a)-300)+"px"});this.tip.toggle()}Event.stop(a)}});$$('[name="payment[method]"]').invoke("observe","click",function(){$$(".ipagare input[type=radio]").each(function(a){a.setAttribute("name","")});$$(".ipagare .ipagare-parcelas select").each(function(a){a.setAttribute("name","")});$$(".select").each(function(a){a.removeClassName("select")});$$(".divPagForm").invoke("hide");if(element.checked){$$("input[name=payment[selected]]").each(function(a){$(a).removeClassName("validate-one-payment-brand");if($(a).readAttribute("data-method")==element.id){$(a).addClassName("validate-one-payment-brand")}})}if(isUrlTelevendas){ipagare.review()}});ipagare.review=function(){var a=Form.serialize("co-payment-form");ipagare.updateReview(a)};ipagare.updateReview=function(a){$("loadingmask").show();$("form-items").innerHTML="";new Ajax.Request(urlTelev,{method:"post",parameters:a,onComplete:function(b){$("loadingmask").hide();$("form-items").innerHTML=b.responseText}})};
js/ipagare/lib/ipagare.js ADDED
@@ -0,0 +1 @@
 
1
+ if(typeof ipagare=="undefined"||!ipagare){var ipagare={}}ipagare.irPara=function(a){document.location.href=a};ipagare.isNotNull=function(a){if(a!="undefined"&&a!="null"&&a!=null&&a!=""){return true}return false};ipagare.wait=function(a){a+=new Date().getTime();while(new Date()<a){}};ipagare.isDataValida=function(h,l){var c=h.value;if(!ipagare.isNotNull(c)){return false}c=c.replace(/[\/]/g,"");var b=c.search(/[^0-9]/);if(b!=-1){return false}if(l==undefined||l==null){l=""}var a=c.replace(" ","");var g=a.length;var d="";var k=null;var e=null;var j=null;if(g<8){d="falsa"}k=(c.substring(0,2));e=(c.substring(2,4));j=(c.substring(4,8));if((k<1)||(k<1||k>30)){if(k>31){d="falsa"}else{if(k>30){if(e==4||e==6||e==9||e==11){d="falsa"}}else{if(k<1){d="falsa"}}}}if(e<1||e>12){d="falsa"}if(e==2){if(k>29){d="falsa"}else{var f=j%4;if(f!=0){if(k>28){d="falsa"}}}}if(c==""){d="falsa"}if(d=="falsa"){if(l!=""){alert(l)}else{alert("Data inv�lida!")}h.value="";h.value.focus();return false}return true};if(typeof Data=="undefined"||!Data){var Data={}}if(typeof Moeda=="undefined"||!Moeda){var Moeda={}}Moeda.digitos=2;Moeda.mascara=function(b,e){if(b.value=="="){b.value="0,00";return true}if(isNaN(e)){e=Moeda.digitos}if(b.value.slice(0,1)=="="){if(!Moeda.analisaExpressao(b,e)){b.focus();return b.value}else{b.maxLength=b.TamanhoOriginal}b.TamanhoOriginal=0}var c=b.value;if(c==""){return false}c=Moeda.formataNumeroUS(c);c=c.replace(/[\.]/g,",");var d=Moeda.getFront(c,",")*1;if(c!=d){var a=Moeda.getEnd(c,",");a=a+""}else{var a=""}if(isNaN(d)){d="0"}if(isNaN(a)){a=""}if(e>0){while(a.length<e){a=a+"0"}}if(a.length>e){a=a.substring(0,e)}for(i=d.toString().length-3;i>0;i=i-3){d=d.toString().substr(0,i)+"."+d.toString().substr(i)}if(d.toString().substr(0,2)=="-."){d="-"+d.toString().substr(2)}if(e>0){b.value=d.toString()+","+a}else{b.value=d.toString()}return};Moeda.format=function(b,d){b=Moeda.formataNumeroUS(b);b=b.replace(/[\.]/g,",");var c=Moeda.getFront(b,",")*1;if(b!=c){var a=Moeda.getEnd(b,",");a=a+""}else{var a=""}if(isNaN(c)){c="0"}if(isNaN(a)){a=""}if(d>0){while(a.length<d){a=a+"0"}}if(a.length>d){a=a.substring(0,d)}for(i=c.toString().length-3;i>0;i=i-3){c=c.toString().substr(0,i)+"."+c.toString().substr(i)}if(c.toString().substr(0,2)=="-."){c="-"+c.toString().substr(2)}if(d>0){return c.toString()+","+a}else{return c.toString()}return null};ipagare.formataMilhar=function(a){for(i=a.toString().length-3;i>0;i=i-3){a=a.toString().substr(0,i)+"."+a.toString().substr(i)}return a};ipagare.verifyListCheckeds=function(){var b=false;var a=document.getElementsByName("checkedElements");for(i=0;i<a.length;i++){if(a[i].checked){b=true;break}}return b};Moeda.getFront=function(a,b){var c=a.indexOf(b);if(c==-1){return a}return a.substring(0,c)};Moeda.getEnd=function(a,b){var c=a.indexOf(b);if(c==-1){return a}return a.substring(c+b.length,a.length)};Moeda.formataNumeroUS=function(a){if(!a){return"0"}if(a.toString().indexOf(",")!=-1){a=a.toString().replace(/\$|\./g,"")}return a.toString().replace(/\$|\,/g,".")};Moeda.analisaExpressao=function(campo,digit){var valor=new String;valor=campo.value;var Numero=new Number;valor=valor.replace(/\s/g,"");valor=valor.replace(/[=]/g,"");iPos=valor.search(/[^0-9,\.\+\-\*\/\%\(\)]/);if(iPos>=0){alert("Expressão inválida. Utilize somente caracteres numéricos, vírgula ou ponto decimal, parênteses e os operadores +, -, *, /, %");campo.focus();return false}iPos=valor.search(/[,\.\+\-\*\/\%]{2,}/g);if(iPos>-1){alert("Expressão inválida. Não é permitida a repetição contígua de operadores");campo.focus();return false}valor=valor.replace(/\%/g,"/100,0*");valor=valor.replace(/,/g,".");try{campo.value=Math.round(eval(valor)*Math.pow(10,digit))/Math.pow(10,digit)}catch(e){alert("Expressão inválida.");campo.focus();return false}campo.value=campo.value.replace(/\./g,",");return true};var Lightbox=Class.create({initialize:function(){this.isLighboxDone=false;this.messagePopupClosed=false;this.messagePopupWindowMask="message-popup-window-mask";this.messagePopupWindow="message-popup-window"},open:function(b){if(!this.isLighboxDone){this._makeContainer();this.isLighboxDone=true}this._updateContent(b);var a=$$("body").invoke("getHeight");$(this.messagePopupWindowMask).setStyle({height:a+"px"});this._toggleSelectsUnderBlock($(this.messagePopupWindowMask),false);Element.show(this.messagePopupWindowMask);$(this.messagePopupWindow).addClassName("show");this._monitor()},close:function(){this._toggleSelectsUnderBlock($(this.messagePopupWindowMask),true);Element.hide(this.messagePopupWindowMask);$(this.messagePopupWindow).removeClassName("show");this.messagePopupClosed=true;this.isLighboxDone=false},_updateContent:function(a){$$("#"+this.messagePopupWindow+" .message-popup-content .message").invoke("update",a)},_monitor:function(){Event.observe(window,"keyup",function(a){if(this.messagePopupClosed){return}var b;if(a.keyCode){b=a.keyCode}else{if(a.which){b=a.which}}if(b==Event.KEY_ESC){this.close()}})},_makeContainer:function(){if($(this.messagePopupWindowMask)){return}var c='<div class="message-popup-head">';c=c+'<a href="#" onclick="lightBoxInst.close(); return false;" title="'+Translator.translate("Fechar")+'"><span>'+Translator.translate("fechar")+"</span></a>";c=c+"<h2>"+Translator.translate("Mensagem")+"</h2>";c=c+"</div>";c=c+'<div class="message-popup-content">';c=c+'<div class="message">';c=c+"</div>";var b=new Element("div",{id:this.messagePopupWindowMask,style:"display:none;"});document.body.appendChild(b);var a=new Element("div",{id:this.messagePopupWindow,"class":"message-popup show"});a.insert(c);document.body.appendChild(a)},_toggleSelectsUnderBlock:function(d,a){if(Prototype.Browser.IE){var c=document.getElementsByTagName("select");for(var b=0;b<c.length;b++){if(a){if(c[b].needShowOnSuccess){c[b].needShowOnSuccess=false;c[b].style.visibility=""}}else{if(Element.visible(c[b])){c[b].style.visibility="hidden";c[b].needShowOnSuccess=true}}}}}});Number.prototype.formatMoney=function(k,g,e){var h=this,k=isNaN(k=Math.abs(k))?2:k,g=g==undefined?".":g,e=e==undefined?",":e,f=h<0?"-":"",b=parseInt(h=Math.abs(+h||0).toFixed(k))+"",a=(a=b.length)>3?a%3:0;return f+(a?b.substr(0,a)+e:"")+b.substr(a).replace(/(\d{3})(?=\d)/g,"$1"+e)+(k?g+Math.abs(h-b).toFixed(k).slice(2):"")};var lightBoxInst=new Lightbox();
js/ipagare/lib/json2.js ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var JSON;
2
+ if (!JSON) {
3
+ JSON = {};
4
+ }
5
+
6
+ (function () {
7
+ 'use strict';
8
+
9
+ function f(n) {
10
+ // Format integers to have at least two digits.
11
+ return n < 10 ? '0' + n : n;
12
+ }
13
+
14
+ if (typeof Date.prototype.toJSON !== 'function') {
15
+
16
+ Date.prototype.toJSON = function (key) {
17
+
18
+ return isFinite(this.valueOf())
19
+ ? this.getUTCFullYear() + '-' +
20
+ f(this.getUTCMonth() + 1) + '-' +
21
+ f(this.getUTCDate()) + 'T' +
22
+ f(this.getUTCHours()) + ':' +
23
+ f(this.getUTCMinutes()) + ':' +
24
+ f(this.getUTCSeconds()) + 'Z'
25
+ : null;
26
+ };
27
+
28
+ String.prototype.toJSON =
29
+ Number.prototype.toJSON =
30
+ Boolean.prototype.toJSON = function (key) {
31
+ return this.valueOf();
32
+ };
33
+ }
34
+
35
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
36
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
37
+ gap,
38
+ indent,
39
+ meta = { // table of character substitutions
40
+ '\b': '\\b',
41
+ '\t': '\\t',
42
+ '\n': '\\n',
43
+ '\f': '\\f',
44
+ '\r': '\\r',
45
+ '"' : '\\"',
46
+ '\\': '\\\\'
47
+ },
48
+ rep;
49
+
50
+
51
+ function quote(string) {
52
+
53
+ // If the string contains no control characters, no quote characters, and no
54
+ // backslash characters, then we can safely slap some quotes around it.
55
+ // Otherwise we must also replace the offending characters with safe escape
56
+ // sequences.
57
+
58
+ escapable.lastIndex = 0;
59
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
60
+ var c = meta[a];
61
+ return typeof c === 'string'
62
+ ? c
63
+ : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
64
+ }) + '"' : '"' + string + '"';
65
+ }
66
+
67
+
68
+ function str(key, holder) {
69
+
70
+ // Produce a string from holder[key].
71
+
72
+ var i, // The loop counter.
73
+ k, // The member key.
74
+ v, // The member value.
75
+ length,
76
+ mind = gap,
77
+ partial,
78
+ value = holder[key];
79
+
80
+ // If the value has a toJSON method, call it to obtain a replacement value.
81
+
82
+ if (value && typeof value === 'object' &&
83
+ typeof value.toJSON === 'function') {
84
+ value = value.toJSON(key);
85
+ }
86
+
87
+ // If we were called with a replacer function, then call the replacer to
88
+ // obtain a replacement value.
89
+
90
+ if (typeof rep === 'function') {
91
+ value = rep.call(holder, key, value);
92
+ }
93
+
94
+ // What happens next depends on the value's type.
95
+
96
+ switch (typeof value) {
97
+ case 'string':
98
+ return quote(value);
99
+
100
+ case 'number':
101
+
102
+ // JSON numbers must be finite. Encode non-finite numbers as null.
103
+
104
+ return isFinite(value) ? String(value) : 'null';
105
+
106
+ case 'boolean':
107
+ case 'null':
108
+
109
+ // If the value is a boolean or null, convert it to a string. Note:
110
+ // typeof null does not produce 'null'. The case is included here in
111
+ // the remote chance that this gets fixed someday.
112
+
113
+ return String(value);
114
+
115
+ // If the type is 'object', we might be dealing with an object or an array or
116
+ // null.
117
+
118
+ case 'object':
119
+
120
+ // Due to a specification blunder in ECMAScript, typeof null is 'object',
121
+ // so watch out for that case.
122
+
123
+ if (!value) {
124
+ return 'null';
125
+ }
126
+
127
+ // Make an array to hold the partial results of stringifying this object value.
128
+
129
+ gap += indent;
130
+ partial = [];
131
+
132
+ // Is the value an array?
133
+
134
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
135
+
136
+ // The value is an array. Stringify every element. Use null as a placeholder
137
+ // for non-JSON values.
138
+
139
+ length = value.length;
140
+ for (i = 0; i < length; i += 1) {
141
+ partial[i] = str(i, value) || 'null';
142
+ }
143
+
144
+ // Join all of the elements together, separated with commas, and wrap them in
145
+ // brackets.
146
+
147
+ v = partial.length === 0
148
+ ? '[]'
149
+ : gap
150
+ ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
151
+ : '[' + partial.join(',') + ']';
152
+ gap = mind;
153
+ return v;
154
+ }
155
+
156
+ // If the replacer is an array, use it to select the members to be stringified.
157
+
158
+ if (rep && typeof rep === 'object') {
159
+ length = rep.length;
160
+ for (i = 0; i < length; i += 1) {
161
+ if (typeof rep[i] === 'string') {
162
+ k = rep[i];
163
+ v = str(k, value);
164
+ if (v) {
165
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
166
+ }
167
+ }
168
+ }
169
+ } else {
170
+
171
+ // Otherwise, iterate through all of the keys in the object.
172
+
173
+ for (k in value) {
174
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
175
+ v = str(k, value);
176
+ if (v) {
177
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
178
+ }
179
+ }
180
+ }
181
+ }
182
+
183
+ // Join all of the member texts together, separated with commas,
184
+ // and wrap them in braces.
185
+
186
+ v = partial.length === 0
187
+ ? '{}'
188
+ : gap
189
+ ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
190
+ : '{' + partial.join(',') + '}';
191
+ gap = mind;
192
+ return v;
193
+ }
194
+ }
195
+
196
+ // If the JSON object does not yet have a stringify method, give it one.
197
+
198
+ if (typeof JSON.stringify !== 'function') {
199
+ JSON.stringify = function (value, replacer, space) {
200
+
201
+ // The stringify method takes a value and an optional replacer, and an optional
202
+ // space parameter, and returns a JSON text. The replacer can be a function
203
+ // that can replace values, or an array of strings that will select the keys.
204
+ // A default replacer method can be provided. Use of the space parameter can
205
+ // produce text that is more easily readable.
206
+
207
+ var i;
208
+ gap = '';
209
+ indent = '';
210
+
211
+ // If the space parameter is a number, make an indent string containing that
212
+ // many spaces.
213
+
214
+ if (typeof space === 'number') {
215
+ for (i = 0; i < space; i += 1) {
216
+ indent += ' ';
217
+ }
218
+
219
+ // If the space parameter is a string, it will be used as the indent string.
220
+
221
+ } else if (typeof space === 'string') {
222
+ indent = space;
223
+ }
224
+
225
+ // If there is a replacer, it must be a function or an array.
226
+ // Otherwise, throw an error.
227
+
228
+ rep = replacer;
229
+ if (replacer && typeof replacer !== 'function' &&
230
+ (typeof replacer !== 'object' ||
231
+ typeof replacer.length !== 'number')) {
232
+ throw new Error('JSON.stringify');
233
+ }
234
+
235
+ // Make a fake root object containing our value under the key of ''.
236
+ // Return the result of stringifying the value.
237
+
238
+ return str('', {'': value});
239
+ };
240
+ }
241
+
242
+
243
+ // If the JSON object does not yet have a parse method, give it one.
244
+
245
+ if (typeof JSON.parse !== 'function') {
246
+ JSON.parse = function (text, reviver) {
247
+
248
+ // The parse method takes a text and an optional reviver function, and returns
249
+ // a JavaScript value if the text is a valid JSON text.
250
+
251
+ var j;
252
+
253
+ function walk(holder, key) {
254
+
255
+ // The walk method is used to recursively walk the resulting structure so
256
+ // that modifications can be made.
257
+
258
+ var k, v, value = holder[key];
259
+ if (value && typeof value === 'object') {
260
+ for (k in value) {
261
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
262
+ v = walk(value, k);
263
+ if (v !== undefined) {
264
+ value[k] = v;
265
+ } else {
266
+ delete value[k];
267
+ }
268
+ }
269
+ }
270
+ }
271
+ return reviver.call(holder, key, value);
272
+ }
273
+
274
+
275
+ // Parsing happens in four stages. In the first stage, we replace certain
276
+ // Unicode characters with escape sequences. JavaScript handles many characters
277
+ // incorrectly, either silently deleting them, or treating them as line endings.
278
+
279
+ text = String(text);
280
+ cx.lastIndex = 0;
281
+ if (cx.test(text)) {
282
+ text = text.replace(cx, function (a) {
283
+ return '\\u' +
284
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
285
+ });
286
+ }
287
+
288
+ // In the second stage, we run the text against regular expressions that look
289
+ // for non-JSON patterns. We are especially concerned with '()' and 'new'
290
+ // because they can cause invocation, and '=' because it can cause mutation.
291
+ // But just to be safe, we want to reject all unexpected forms.
292
+
293
+ // We split the second stage into 4 regexp operations in order to work around
294
+ // crippling inefficiencies in IE's and Safari's regexp engines. First we
295
+ // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
296
+ // replace all simple value tokens with ']' characters. Third, we delete all
297
+ // open brackets that follow a colon or comma or that begin the text. Finally,
298
+ // we look to see that the remaining characters are only whitespace or ']' or
299
+ // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
300
+
301
+ if (/^[\],:{}\s]*$/
302
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
303
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
304
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
305
+
306
+ // In the third stage we use the eval function to compile the text into a
307
+ // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
308
+ // in JavaScript: it can begin a block or an object literal. We wrap the text
309
+ // in parens to eliminate the ambiguity.
310
+
311
+ j = eval('(' + text + ')');
312
+
313
+ // In the optional fourth stage, we recursively walk the new structure, passing
314
+ // each name/value pair to a reviver function for possible transformation.
315
+
316
+ return typeof reviver === 'function'
317
+ ? walk({'': j}, '')
318
+ : j;
319
+ }
320
+
321
+ // If the text is not JSON parseable, then a SyntaxError is thrown.
322
+
323
+ throw new SyntaxError('JSON.parse');
324
+ };
325
+ }
326
+ }());
js/ipagare/lib/prototype/maskedinput.js ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Masked Input plugin for prototype ported from jQuery
3
+ Bjarte K. Vebjørnsen <bjartekv at gmail dot com>
4
+
5
+ Note that the onchange event isn't fired for masked inputs. It won't fire unless event.simulate.js is available.
6
+
7
+ Requires: Prototype >= 1.6.1
8
+ Optional: event.simulate.js from http://github.com/kangax/protolicious to trigger native change event.
9
+
10
+ Tested on windows IE6, IE7, IE8, Opera 9.6, Chrome 3, FireFox 3, Safari 3
11
+
12
+ Masked Input plugin for jQuery
13
+ Copyright (c) 2007-2009 Josh Bush (digitalbush.com)
14
+ Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
15
+ Version: 1.2.2 (03/09/2009 22:39:06)
16
+ */
17
+
18
+ (function() {
19
+ var pasteEventName = (Prototype.Browser.IE ? 'paste' : 'input'),
20
+ iPhone = (window.orientation != undefined);
21
+
22
+ if(typeof(Prototype) == "undefined")
23
+ throw "MaskedInput requires Prototype to be loaded.";
24
+
25
+ Element.addMethods({
26
+ caret: function(element, begin, end) {
27
+ if (element.length == 0) return;
28
+ if (typeof begin == 'number') {
29
+ end = (typeof end == 'number') ? end : begin;
30
+ if (element.setSelectionRange) {
31
+ element.focus();
32
+ element.setSelectionRange(begin, end);
33
+ } else if (element.createTextRange) {
34
+ var range = element.createTextRange();
35
+ range.collapse(true);
36
+ range.moveEnd('character', end);
37
+ range.moveStart('character', begin);
38
+ range.select();
39
+ }
40
+ } else {
41
+ if (element.setSelectionRange) {
42
+ begin = element.selectionStart;
43
+ end = element.selectionEnd;
44
+ } else if (document.selection && document.selection.createRange) {
45
+ var range = document.selection.createRange();
46
+ begin = 0 - range.duplicate().moveStart('character', -100000);
47
+ end = begin + range.text.length;
48
+ }
49
+ return { begin: begin, end: end };
50
+ }
51
+ }
52
+ });
53
+
54
+ MaskedInput = Class.create({
55
+ initialize: function(selector, mask, settings) {
56
+ this.elements = $$(selector);
57
+ this.mask(mask, settings);
58
+ },
59
+ unmask: function() {
60
+ this.elements.each(function(el) {
61
+ el.fire("mask:unmask");
62
+ });
63
+ return this;
64
+ },
65
+ mask: function (mask, settings) {
66
+ if (!mask && this.elements.length > 0) {
67
+ var input = $(this.elements[0]);
68
+ var tests = input.retrieve("tests");
69
+ return $A(input.retrieve("buffer")).map(function(c, i) {
70
+ return tests[i] ? c : null;
71
+ }).join('');
72
+ }
73
+ settings = Object.extend({
74
+ placeholder: "_",
75
+ completed: null
76
+ }, settings || {});
77
+
78
+ var defs = MaskedInput.definitions;
79
+ var tests = [];
80
+ var partialPosition = mask.length;
81
+ var firstNonMaskPos = null;
82
+ var len = mask.length;
83
+
84
+ $A(mask.split("")).each(function(c, i) {
85
+ if (c == '?') {
86
+ len--;
87
+ partialPosition = i;
88
+ } else if (defs[c]) {
89
+ tests.push(new RegExp(defs[c]));
90
+ if(firstNonMaskPos==null)
91
+ firstNonMaskPos = tests.length - 1;
92
+ } else {
93
+ tests.push(null);
94
+ }
95
+ });
96
+
97
+ this.elements.each(function(el) {
98
+
99
+ var input = $(el);
100
+
101
+ var buffer = $A(mask.replace(/\?/,'').split("")).map( function(c, i) { return defs[c] ? settings.placeholder : c });
102
+
103
+ var ignore = false; //Variable for ignoring control keys
104
+ var focusText = input.getValue();
105
+
106
+ input.store("buffer", buffer).store("tests", tests);
107
+
108
+ function seekNext(pos) {
109
+ while (++pos < len && !tests[pos]);
110
+ return pos;
111
+ };
112
+
113
+ function shiftL(pos) {
114
+ while (!tests[pos] && --pos >= 0);
115
+ for (var i = pos; i < len; i++) {
116
+ if (tests[i]) {
117
+ buffer[i] = settings.placeholder;
118
+ var j = seekNext(i);
119
+ if (j < len && tests[i].test(buffer[j])) {
120
+ buffer[i] = buffer[j];
121
+ } else
122
+ break;
123
+ }
124
+ }
125
+ writeBuffer();
126
+ input.caret(Math.max(firstNonMaskPos, pos));
127
+ };
128
+
129
+ function shiftR(pos) {
130
+ for (var i = pos, c = settings.placeholder; i < len; i++) {
131
+ if (tests[i]) {
132
+ var j = seekNext(i);
133
+ var t = buffer[i];
134
+ buffer[i] = c;
135
+ if (j < len && tests[j].test(t))
136
+ c = t;
137
+ else
138
+ break;
139
+ }
140
+ }
141
+ };
142
+
143
+ function keydownEvent(e) {
144
+ var pos = input.caret();
145
+ var k = e.keyCode;
146
+ ignore = (k < 16 || (k > 16 && k < 32) || (k > 32 && k < 41));
147
+ //delete selection before proceeding
148
+ if ((pos.begin - pos.end) != 0 && (!ignore || k == 8 || k == 46))
149
+ clearBuffer(pos.begin, pos.end);
150
+
151
+ //backspace, delete, and escape get special treatment
152
+ if (k == 8 || k == 46 || (iPhone && k == 127)) {//backspace/delete
153
+ shiftL(pos.begin + (k == 46 ? 0 : -1));
154
+ e.stop();
155
+ } else if (k == 27) {//escape
156
+ input.setValue(focusText);
157
+ input.caret(0, checkVal());
158
+ e.stop();
159
+ }
160
+ };
161
+
162
+ function keypressEvent(e) {
163
+ if (ignore) {
164
+ ignore = false;
165
+ //Fixes Mac FF bug on backspace
166
+ return (e.keyCode == 8) ? false : null;
167
+ }
168
+ e = e || window.event;
169
+ var k = e.charCode || e.keyCode || e.which;
170
+ var pos = input.caret();
171
+ if (e.ctrlKey || e.altKey || e.metaKey) {//Ignore
172
+ return true;
173
+ } else if ((k >= 32 && k <= 125) || k > 186) {//typeable characters
174
+ var p = seekNext(pos.begin - 1);
175
+ if (p < len) {
176
+ var c = String.fromCharCode(k);
177
+ if (tests[p].test(c)) {
178
+ shiftR(p);
179
+ buffer[p] = c;
180
+ writeBuffer();
181
+ var next = seekNext(p);
182
+ input.caret(next);
183
+ if (settings.completed && next == len)
184
+ settings.completed.call(input);
185
+ }
186
+ }
187
+ }
188
+ e.stop();
189
+ };
190
+
191
+ function blurEvent(e) {
192
+ checkVal();
193
+ if (input.getValue() != focusText) {
194
+ // since the native change event doesn't fire we have to fire it ourselves
195
+ // since Event.fire doesn't support native events we're using Event.simulate if available
196
+ if (window.Event.simulate) {
197
+ input.simulate('change');
198
+ }
199
+ }
200
+ };
201
+
202
+ function focusEvent(e) {
203
+ focusText = input.getValue();
204
+ var pos = checkVal();
205
+ writeBuffer();
206
+
207
+ setTimeout(function() {
208
+ if (pos == mask.length)
209
+ input.caret(0, pos);
210
+ else
211
+ input.caret(pos);
212
+ }, 0);
213
+ };
214
+
215
+ function pasteEvent(e) {
216
+ setTimeout(function() { input.caret(checkVal(true)); }, 0);
217
+ };
218
+
219
+ function clearBuffer(start, end) {
220
+ for (var i = start; i < end && i < len; i++) {
221
+ if (tests[i])
222
+ buffer[i] = settings.placeholder;
223
+ }
224
+
225
+ };
226
+
227
+ function writeBuffer() { return input.setValue(buffer.join('')).getValue(); };
228
+
229
+ function checkVal(allow) {
230
+ //try to place characters where they belong
231
+ var test = input.getValue();
232
+ var lastMatch = -1;
233
+ for (var i = 0, pos = 0; i < len; i++) {
234
+ if (tests[i]) {
235
+ buffer[i] = settings.placeholder;
236
+ while (pos++ < test.length) {
237
+ var c = test.charAt(pos - 1);
238
+ if (tests[i].test(c)) {
239
+ buffer[i] = c;
240
+ lastMatch = i;
241
+ break;
242
+ }
243
+ }
244
+ if (pos > test.length)
245
+ break;
246
+ } else if (buffer[i] == test[pos] && i!=partialPosition) {
247
+ pos++;
248
+ lastMatch = i;
249
+ }
250
+ }
251
+
252
+ if (!allow && lastMatch + 1 < partialPosition) {
253
+ input.setValue("");
254
+ clearBuffer(0, len);
255
+ } else if (allow || lastMatch + 1 >= partialPosition) {
256
+ writeBuffer();
257
+ if (!allow) input.setValue(input.getValue().substring(0, lastMatch + 1));
258
+ }
259
+
260
+ return (partialPosition ? i : firstNonMaskPos);
261
+ };
262
+
263
+ if (!input.readAttribute("readonly"))
264
+ input
265
+ .observe("mask:unmask", function() {
266
+ input
267
+ .store("buffer",undefined)
268
+ .store("tests",undefined)
269
+ .stopObserving("mask:unmask")
270
+ .stopObserving("focus", focusEvent)
271
+ .stopObserving("blur", blurEvent)
272
+ .stopObserving("keydown", keydownEvent)
273
+ .stopObserving("keypress", keypressEvent)
274
+ .stopObserving(pasteEventName, pasteEvent);
275
+ })
276
+ .observe("focus", focusEvent)
277
+ .observe("blur", blurEvent)
278
+ .observe("keydown", keydownEvent)
279
+ .observe("keypress", keypressEvent)
280
+ .observe(pasteEventName, pasteEvent);
281
+
282
+ checkVal(); //Perform initial check for existing values
283
+ });
284
+ return this;
285
+ }
286
+ });
287
+
288
+ Object.extend(MaskedInput,{
289
+ definitions: {
290
+ '9': "[0-9]",
291
+ 'a': "[A-Za-z]",
292
+ '*': "[A-Za-z0-9]"
293
+ }
294
+ });
295
+ })();
lib/Ipagare/Log4php/Appenders/LoggerAppenderAdodb.php ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /** A docblok to make phpdoc happy */
22
+ require_once(ADODB_DIR . '/adodb.inc.php');
23
+
24
+ /**
25
+ * Appends log events to a db table using adodb class.
26
+ *
27
+ * <p>This appender uses a table in a database to log events.</p>
28
+ * <p>Parameters are {@link $host}, {@link $user}, {@link $password},
29
+ * {@link $database}, {@link $createTable}, {@link $table} and {@link $sql}.</p>
30
+ * <p>See examples in test directory.</p>
31
+ *
32
+ * @deprecated Use Ipagare_Log4php_Appenders_LoggerAppenderPDO instead
33
+ * @package log4php
34
+ * @subpackage appenders
35
+ * @since 0.9
36
+ */
37
+ class Ipagare_Log4php_Appenders_LoggerAppenderAdodb extends Ipagare_Log4php_LoggerAppender {
38
+
39
+ /**
40
+ * Create the log table if it does not exists (optional).
41
+ * @var boolean
42
+ */
43
+ var $createTable = true;
44
+
45
+ /**
46
+ * The type of database to connect to
47
+ * @var string
48
+ */
49
+ var $type;
50
+
51
+ /**
52
+ * Database user name
53
+ * @var string
54
+ */
55
+ var $user;
56
+
57
+ /**
58
+ * Database password
59
+ * @var string
60
+ */
61
+ var $password;
62
+
63
+ /**
64
+ * Database host to connect to
65
+ * @var string
66
+ */
67
+ var $host;
68
+
69
+ /**
70
+ * Name of the database to connect to
71
+ * @var string
72
+ */
73
+ var $database;
74
+
75
+ /**
76
+ * A {@link LoggerPatternLayout} string used to format a valid insert query (mandatory).
77
+ * @var string
78
+ */
79
+ var $sql;
80
+
81
+ /**
82
+ * Table name to write events. Used only if {@link $createTable} is true.
83
+ * @var string
84
+ */
85
+ var $table;
86
+
87
+ /**
88
+ * @var object Adodb instance
89
+ * @access private
90
+ */
91
+ var $db = null;
92
+
93
+ /**
94
+ * @var boolean used to check if all conditions to append are true
95
+ * @access private
96
+ */
97
+ var $canAppend = true;
98
+
99
+ /**
100
+ * @access private
101
+ */
102
+ var $requiresLayout = false;
103
+
104
+ /**
105
+ * Constructor.
106
+ *
107
+ * @param string $name appender name
108
+ */
109
+ function __construct($name)
110
+ {
111
+ parent::__construct($name);
112
+ }
113
+
114
+ /**
115
+ * Setup db connection.
116
+ * Based on defined options, this method connects to db defined in {@link $dsn}
117
+ * and creates a {@link $table} table if {@link $createTable} is true.
118
+ * @return boolean true if all ok.
119
+ */
120
+ function activateOptions()
121
+ {
122
+ $this->db = &ADONewConnection($this->type);
123
+ if (! $this->db->PConnect($this->host, $this->user, $this->password, $this->database)) {
124
+ $this->db = null;
125
+ $this->closed = true;
126
+ $this->canAppend = false;
127
+ return;
128
+ }
129
+
130
+ $this->layout = Ipagare_Log4php_LoggerReflectionUtils::createObject('Ipagare_Log4php_Layouts_LoggerLayoutPattern');
131
+ $this->layout->setConversionPattern($this->getSql());
132
+
133
+ // test if log table exists
134
+ $sql = 'select * from ' . $this->table . ' where 1 = 0';
135
+ $dbrs = $this->db->Execute($sql);
136
+ if ($dbrs == false and $this->getCreateTable()) {
137
+ $query = "CREATE TABLE {$this->table} (timestamp varchar(32),logger varchar(32),level varchar(32),message varchar(64),thread varchar(32),file varchar(64),line varchar(4) );";
138
+
139
+
140
+ $result = $this->db->Execute($query);
141
+ if (! $result) {
142
+ $this->canAppend = false;
143
+ return;
144
+ }
145
+ }
146
+ $this->canAppend = true;
147
+ }
148
+
149
+ function append(Ipagare_Log4php_LoggerLoggingEvent $event) {
150
+ if ($this->canAppend) {
151
+ $query = $this->layout->format($event);
152
+ $this->db->Execute($query);
153
+ }
154
+ }
155
+
156
+ function close()
157
+ {
158
+ if ($this->db !== null)
159
+ $this->db->Close();
160
+ $this->closed = true;
161
+ }
162
+
163
+ /**
164
+ * @return boolean
165
+ */
166
+ function getCreateTable()
167
+ {
168
+ return $this->createTable;
169
+ }
170
+
171
+ /**
172
+ * @return string the sql pattern string
173
+ */
174
+ function getSql()
175
+ {
176
+ return $this->sql;
177
+ }
178
+
179
+ /**
180
+ * @return string the table name to create
181
+ */
182
+ function getTable()
183
+ {
184
+ return $this->table;
185
+ }
186
+
187
+ /**
188
+ * @return string the database to connect to
189
+ */
190
+ function getDatabase() {
191
+ return $this->database;
192
+ }
193
+
194
+ /**
195
+ * @return string the database to connect to
196
+ */
197
+ function getHost() {
198
+ return $this->host;
199
+ }
200
+
201
+ /**
202
+ * @return string the user to connect with
203
+ */
204
+ function getUser() {
205
+ return $this->user;
206
+ }
207
+
208
+ /**
209
+ * @return string the password to connect with
210
+ */
211
+ function getPassword() {
212
+ return $this->password;
213
+ }
214
+
215
+ /**
216
+ * @return string the type of database to connect to
217
+ */
218
+ function getType() {
219
+ return $this->type;
220
+ }
221
+
222
+ function setCreateTable($flag)
223
+ {
224
+ $this->createTable = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($flag, true);
225
+ }
226
+
227
+ function setType($newType)
228
+ {
229
+ $this->type = $newType;
230
+ }
231
+
232
+ function setDatabase($newDatabase)
233
+ {
234
+ $this->database = $newDatabase;
235
+ }
236
+
237
+ function setHost($newHost)
238
+ {
239
+ $this->host = $newHost;
240
+ }
241
+
242
+ function setUser($newUser)
243
+ {
244
+ $this->user = $newUser;
245
+ }
246
+
247
+ function setPassword($newPassword)
248
+ {
249
+ $this->password = $newPassword;
250
+ }
251
+
252
+ function setSql($sql)
253
+ {
254
+ $this->sql = $sql;
255
+ }
256
+
257
+ function setTable($table)
258
+ {
259
+ $this->table = $table;
260
+ }
261
+
262
+ }
263
+
lib/Ipagare/Log4php/Appenders/LoggerAppenderConsole.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * ConsoleAppender appends log events to STDOUT or STDERR.
23
+ *
24
+ * <p><b>Note</b>: Use this Appender with command-line php scripts.
25
+ * On web scripts this appender has no effects.</p>
26
+ *
27
+ * Configurable parameters of this appender are:
28
+ *
29
+ * - layout - The layout (required)
30
+ * - target - "stdout" or "stderr"
31
+ *
32
+ * An example php file:
33
+ *
34
+ * {@example ../../examples/php/appender_console.php 19}
35
+ *
36
+ * An example configuration file:
37
+ *
38
+ * {@example ../../examples/resources/appender_console.properties 18}
39
+ *
40
+ * @version $Revision: 1062667 $
41
+ * @package log4php
42
+ * @subpackage appenders
43
+ */
44
+ class Ipagare_Log4php_Appenders_LoggerAppenderConsole extends Ipagare_Log4php_LoggerAppender {
45
+
46
+ const STDOUT = 'php://stdout';
47
+ const STDERR = 'php://stderr';
48
+
49
+ /**
50
+ * Can be 'php://stdout' or 'php://stderr'. But it's better to use keywords <b>STDOUT</b> and <b>STDERR</b> (case insensitive).
51
+ * Default is STDOUT
52
+ * @var string
53
+ */
54
+ private $target = self::STDOUT;
55
+
56
+ /**
57
+ * @var mixed the resource used to open stdout/stderr
58
+ */
59
+ protected $fp = null;
60
+
61
+ public function __destruct() {
62
+ $this->close();
63
+ }
64
+
65
+ /**
66
+ * Set console target.
67
+ * @param mixed $value a constant or a string
68
+ */
69
+ public function setTarget($value) {
70
+ $v = trim($value);
71
+ if ($v == self::STDOUT || strtoupper($v) == 'STDOUT') {
72
+ $this->target = self::STDOUT;
73
+ } elseif ($v == self::STDERR || strtoupper($v) == 'STDERR') {
74
+ $this->target = self::STDERR;
75
+ }
76
+ }
77
+
78
+ public function activateOptions() {
79
+ $this->fp = fopen($this->target, 'w');
80
+ if(is_resource($this->fp) && $this->layout !== null) {
81
+ fwrite($this->fp, $this->layout->getHeader());
82
+ }
83
+ $this->closed = (bool)is_resource($this->fp) === false;
84
+ }
85
+
86
+ /**
87
+ * @see Ipagare_Log4php_LoggerAppender::close()
88
+ */
89
+ public function close() {
90
+ if($this->closed != true) {
91
+ if (is_resource($this->fp) && $this->layout !== null) {
92
+ fwrite($this->fp, $this->layout->getFooter());
93
+ fclose($this->fp);
94
+ }
95
+ $this->closed = true;
96
+ }
97
+ }
98
+
99
+ public function append(Ipagare_Log4php_LoggerLoggingEvent $event) {
100
+ if (is_resource($this->fp) && $this->layout !== null) {
101
+ fwrite($this->fp, $this->layout->format($event));
102
+ }
103
+ }
104
+ }
105
+
lib/Ipagare/Log4php/Appenders/LoggerAppenderDailyFile.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * An Appender that automatically creates a new logfile each day.
23
+ *
24
+ * The file is rolled over once a day. That means, for each day a new file
25
+ * is created. A formatted version of the date pattern is used as to create
26
+ * the file name using the {@link PHP_MANUAL#sprintf} function.
27
+ *
28
+ * This appender uses a layout.
29
+ *
30
+ * Configurable parameters for this appender are:
31
+ * - datePattern - The date format for the file name. Should be set before
32
+ * $file. Default value: "Ymd".
33
+ * - file - The path to the target log file. The filename should
34
+ * contain a '%s' which will be substituted by the date.
35
+ * - append - Sets if the appender should append to the end of the
36
+ * file or overwrite content ("true" or "false"). Default
37
+ * value: true.
38
+ *
39
+ * An example php file:
40
+ *
41
+ * {@example ../../examples/php/appender_dailyfile.php 19}
42
+ *
43
+ * An example configuration file:
44
+ *
45
+ * {@example ../../examples/resources/appender_dailyfile.properties 18}
46
+ *
47
+ * The above will create a file like: daily_20090908.log
48
+ *
49
+ * @version $Revision: 1059522 $
50
+ * @package log4php
51
+ * @subpackage appenders
52
+ */
53
+ class Ipagare_Log4php_Appenders_LoggerAppenderDailyFile extends Ipagare_Log4php_Appenders_LoggerAppenderFile {
54
+
55
+ /**
56
+ * Format date.
57
+ * It follows the {@link PHP_MANUAL#date()} formatting rules and <b>should always be set before {@link $file} param</b>.
58
+ * @var string
59
+ */
60
+ public $datePattern = "Ymd";
61
+
62
+ public function __destruct() {
63
+ parent::__destruct();
64
+ }
65
+
66
+ /**
67
+ * Sets date format for the file name.
68
+ * @param string $datePattern a regular date() string format
69
+ */
70
+ public function setDatePattern($datePattern) {
71
+ $this->datePattern = $datePattern;
72
+ }
73
+
74
+ /**
75
+ * @return string returns date format for the filename
76
+ */
77
+ public function getDatePattern() {
78
+ return $this->datePattern;
79
+ }
80
+
81
+ /**
82
+ * Similar to the parent method, but replaces "%s" in the file name with
83
+ * the current date in format specified by $datePattern.
84
+ *
85
+ * @see Ipagare_Log4php_Appenders_LoggerAppenderFile::setFile()
86
+ */
87
+ public function setFile($file) {
88
+ $date = date($this->getDatePattern());
89
+ $file = sprintf($file, $date);
90
+ parent::setFile(sprintf($file, $date));
91
+ }
92
+ }
lib/Ipagare/Log4php/Appenders/LoggerAppenderEcho.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Ipagare_Log4php_Appenders_LoggerAppenderEcho uses {@link PHP_MANUAL#echo echo} function to output events.
23
+ *
24
+ * <p>This appender requires a layout.</p>
25
+ *
26
+ * An example php file:
27
+ *
28
+ * {@example ../../examples/php/appender_echo.php 19}
29
+ *
30
+ * An example configuration file:
31
+ *
32
+ * {@example ../../examples/resources/appender_echo.properties 18}
33
+ *
34
+ * The above example would print the following:
35
+ * <pre>
36
+ * Tue Sep 8 22:44:55 2009,812 [6783] DEBUG appender_echo - Hello World!
37
+ * </pre>
38
+ *
39
+ * @version $Revision: 1062665 $
40
+ * @package log4php
41
+ * @subpackage appenders
42
+ */
43
+ class Ipagare_Log4php_Appenders_LoggerAppenderEcho extends Ipagare_Log4php_LoggerAppender {
44
+ /** boolean used internally to mark first append */
45
+ private $firstAppend = true;
46
+
47
+ /**
48
+ * If set to true, a <br /> element will be inserted before each line
49
+ * break in the logged message. Default value is false. @var boolean
50
+ */
51
+ private $htmlLineBreaks = false;
52
+
53
+ public function __construct($name = '') {
54
+ parent::__construct($name);
55
+ $this->firstAppend = true;
56
+ }
57
+
58
+ public function __destruct() {
59
+ $this->close();
60
+ }
61
+
62
+ public function activateOptions() {
63
+ $this->closed = false;
64
+ }
65
+
66
+ public function close() {
67
+ if($this->closed != true) {
68
+ if(!$this->firstAppend) {
69
+ echo $this->layout->getFooter();
70
+ }
71
+ }
72
+ $this->closed = true;
73
+ }
74
+
75
+ public function append(Ipagare_Log4php_LoggerLoggingEvent $event) {
76
+ if($this->layout !== null) {
77
+ if($this->firstAppend) {
78
+ echo $this->layout->getHeader();
79
+ $this->firstAppend = false;
80
+ }
81
+ $text = $this->layout->format($event);
82
+
83
+ if ($this->htmlLineBreaks) {
84
+ $text = nl2br($text);
85
+ }
86
+ echo $text;
87
+ }
88
+ }
89
+
90
+ public function setHtmlLineBreaks($value) {
91
+ $this->htmlLineBreaks = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($value, false);
92
+ }
93
+
94
+ public function getHtmlLineBreaks() {
95
+ return $this->htmlLineBreaks;
96
+ }
97
+ }
98
+
lib/Ipagare/Log4php/Appenders/LoggerAppenderFile.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * FileAppender appends log events to a file.
23
+ *
24
+ * This appender uses a layout.
25
+ *
26
+ * Configurable parameters for this appender are:
27
+ * - file - The target file to write to
28
+ * - filename - The target file to write to (deprecated, use "file" instead)
29
+ * - append - Sets if the appender should append to the end of the file or overwrite content ("true" or "false")
30
+ *
31
+ * An example php file:
32
+ *
33
+ * {@example ../../examples/php/appender_file.php 19}
34
+ *
35
+ * An example configuration file:
36
+ *
37
+ * {@example ../../examples/resources/appender_file.properties 18}
38
+ *
39
+ * @version $Revision: 1062665 $
40
+ * @package log4php
41
+ * @subpackage appenders
42
+ */
43
+ class Ipagare_Log4php_Appenders_LoggerAppenderFile extends Ipagare_Log4php_LoggerAppender {
44
+
45
+ /**
46
+ * @var boolean if {@link $file} exists, appends events.
47
+ */
48
+ private $append = true;
49
+
50
+ /**
51
+ * @var string the file name used to append events
52
+ */
53
+ protected $file;
54
+
55
+ /**
56
+ * @var mixed file resource
57
+ */
58
+ protected $fp = false;
59
+
60
+ public function __construct($name = '') {
61
+ parent::__construct($name);
62
+ }
63
+
64
+ public function __destruct() {
65
+ $this->close();
66
+ }
67
+
68
+ public function activateOptions() {
69
+ $fileName = $this->getFile();
70
+
71
+ if(!is_file($fileName)) {
72
+ $dir = dirname($fileName);
73
+ if(!is_dir($dir)) {
74
+ mkdir($dir, 0777, true);
75
+ }
76
+ }
77
+
78
+ $this->fp = fopen($fileName, ($this->getAppend()? 'a':'w'));
79
+ if($this->fp) {
80
+ if(flock($this->fp, LOCK_EX)) {
81
+ if($this->getAppend()) {
82
+ fseek($this->fp, 0, SEEK_END);
83
+ }
84
+ fwrite($this->fp, $this->layout->getHeader());
85
+ flock($this->fp, LOCK_UN);
86
+ $this->closed = false;
87
+ } else {
88
+ // TODO: should we take some action in this case?
89
+ $this->closed = true;
90
+ }
91
+ } else {
92
+ $this->closed = true;
93
+ }
94
+ }
95
+
96
+ public function close() {
97
+ if($this->closed != true) {
98
+ if($this->fp and $this->layout !== null) {
99
+ if(flock($this->fp, LOCK_EX)) {
100
+ fwrite($this->fp, $this->layout->getFooter());
101
+ flock($this->fp, LOCK_UN);
102
+ }
103
+ fclose($this->fp);
104
+ }
105
+ $this->closed = true;
106
+ }
107
+ }
108
+
109
+ public function append(Ipagare_Log4php_LoggerLoggingEvent $event) {
110
+ if($this->fp and $this->layout !== null) {
111
+ if(flock($this->fp, LOCK_EX)) {
112
+ fwrite($this->fp, $this->layout->format($event));
113
+ flock($this->fp, LOCK_UN);
114
+ } else {
115
+ $this->closed = true;
116
+ }
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Sets the file where the log output will go.
122
+ * @param string $file
123
+ */
124
+ public function setFile($file) {
125
+ $this->file = $file;
126
+ }
127
+
128
+ /**
129
+ * @return string
130
+ */
131
+ public function getFile() {
132
+ return $this->file;
133
+ }
134
+
135
+ /**
136
+ * @return boolean
137
+ */
138
+ public function getAppend() {
139
+ return $this->append;
140
+ }
141
+
142
+ public function setAppend($flag) {
143
+ $this->append = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($flag, true);
144
+ }
145
+
146
+ /**
147
+ * Sets the file where the log output will go.
148
+ * @param string $fileName
149
+ * @deprecated Use setFile() instead.
150
+ */
151
+ public function setFileName($fileName) {
152
+ $this->setFile($fileName);
153
+ }
154
+
155
+ /**
156
+ * @return string
157
+ * @deprecated Use getFile() instead.
158
+ */
159
+ public function getFileName() {
160
+ return $this->getFile();
161
+ }
162
+
163
+
164
+ }
lib/Ipagare/Log4php/Appenders/LoggerAppenderMail.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Appends log events to mail using php function {@link PHP_MANUAL#mail}.
23
+ *
24
+ * The appender sends all log events at once after the request has been
25
+ * finsished and the appender is beeing closed.
26
+ *
27
+ * Configurable parameters for this appender:
28
+ *
29
+ * - layout - Sets the layout class for this appender (required)
30
+ * - to - Sets the recipient of the mail (required)
31
+ * - from - Sets the sender of the mail (optional)
32
+ * - subject - Sets the subject of the mail (optional)
33
+ *
34
+ * An example:
35
+ *
36
+ * {@example ../../examples/php/appender_mail.php 19}
37
+ *
38
+ * {@example ../../examples/resources/appender_mail.properties 18}
39
+ *
40
+ * The above will output something like:
41
+ * <pre>
42
+ * Date: Tue, 8 Sep 2009 21:51:04 +0200 (CEST)
43
+ * From: someone@example.com
44
+ * To: root@localhost
45
+ * Subject: Log4php test
46
+ *
47
+ * Tue Sep 8 21:51:04 2009,120 [5485] FATAL root - Some critical message!
48
+ * Tue Sep 8 21:51:06 2009,120 [5485] FATAL root - Some more critical message!
49
+ * </pre>
50
+
51
+ * @version $Revision: 1062665 $
52
+ * @package log4php
53
+ * @subpackage appenders
54
+ */
55
+ class Ipagare_Log4php_Appenders_LoggerAppenderMail extends Ipagare_Log4php_LoggerAppender {
56
+
57
+ /** @var string 'from' field */
58
+ private $from = null;
59
+
60
+ /** @var string 'subject' field */
61
+ private $subject = 'Log4php Report';
62
+
63
+ /** @var string 'to' field */
64
+ private $to = null;
65
+
66
+ /** @var indiciates if this appender should run in dry mode */
67
+ private $dry = false;
68
+
69
+ /** @var string used to create mail body */
70
+ private $body = '';
71
+
72
+ /**
73
+ * Constructor.
74
+ *
75
+ * @param string $name appender name
76
+ */
77
+ public function __construct($name = '') {
78
+ parent::__construct($name);
79
+ }
80
+
81
+ public function __destruct() {
82
+ $this->close();
83
+ }
84
+
85
+ public function activateOptions() {
86
+ $this->closed = false;
87
+ }
88
+
89
+ public function close() {
90
+ if($this->closed != true) {
91
+ $from = $this->from;
92
+ $to = $this->to;
93
+
94
+ if(!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) {
95
+ $subject = $this->subject;
96
+ if(!$this->dry) {
97
+ mail(
98
+ $to, $subject,
99
+ $this->layout->getHeader() . $this->body . $this->layout->getFooter(),
100
+ "From: {$from}\r\n");
101
+ } else {
102
+ echo "DRY MODE OF MAIL APP.: Send mail to: ".$to." with content: ".$this->body;
103
+ }
104
+ }
105
+ $this->closed = true;
106
+ }
107
+ }
108
+
109
+ public function setSubject($subject) {
110
+ $this->subject = $subject;
111
+ }
112
+
113
+ public function setTo($to) {
114
+ $this->to = $to;
115
+ }
116
+
117
+ public function setFrom($from) {
118
+ $this->from = $from;
119
+ }
120
+
121
+ public function setDry($dry) {
122
+ $this->dry = $dry;
123
+ }
124
+
125
+ public function append(Ipagare_Log4php_LoggerLoggingEvent $event) {
126
+ if($this->layout !== null) {
127
+ $this->body .= $this->layout->format($event);
128
+ }
129
+ }
130
+ }
lib/Ipagare/Log4php/Appenders/LoggerAppenderMailEvent.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Log every events as a separate email.
23
+ *
24
+ * Configurable parameters for this appender are:
25
+ *
26
+ * - layout - Sets the layout class for this appender (required)
27
+ * - to - Sets the recipient of the mail (required)
28
+ * - from - Sets the sender of the mail (optional)
29
+ * - subject - Sets the subject of the mail (optional)
30
+ * - smtpHost - Sets the mail server (optional, default is ini_get('SMTP'))
31
+ * - port - Sets the port of the mail server (optional, default is 25)
32
+ *
33
+ * An example:
34
+ *
35
+ * {@example ../../examples/php/appender_mailevent.php 19}
36
+ *
37
+ * {@example ../../examples/resources/appender_mailevent.properties 18}
38
+ *
39
+ *
40
+ * The above will output something like:
41
+ * <pre>
42
+ * Date: Tue, 8 Sep 2009 21:51:04 +0200 (CEST)
43
+ * From: someone@example.com
44
+ * To: root@localhost
45
+ * Subject: Log4php test
46
+ *
47
+ * Tue Sep 8 21:51:04 2009,120 [5485] FATAL root - Some critical message!
48
+ * </pre>
49
+ *
50
+ * @version $Revision: 1137177 $
51
+ * @package log4php
52
+ * @subpackage appenders
53
+ */
54
+ class Ipagare_Log4php_Appenders_LoggerAppenderMailEvent extends Ipagare_Log4php_LoggerAppender {
55
+
56
+ /** 'from' field (defaults to 'sendmail_from' from php.ini on win32).
57
+ * @var string
58
+ */
59
+ private $from = null;
60
+
61
+ /** Mailserver port (win32 only).
62
+ * @var integer
63
+ */
64
+ private $port = 25;
65
+
66
+ /** Mailserver hostname (win32 only).
67
+ * @var string
68
+ */
69
+ private $smtpHost = null;
70
+
71
+ /**
72
+ * @var string 'subject' field
73
+ */
74
+ private $subject = '';
75
+
76
+ /**
77
+ * @var string 'to' field
78
+ */
79
+ private $to = null;
80
+
81
+ /** @var indiciates if this appender should run in dry mode */
82
+ private $dry = false;
83
+
84
+ /**
85
+ * Constructor.
86
+ *
87
+ * @param string $name appender name
88
+ */
89
+ public function __construct($name = '') {
90
+ parent::__construct($name);
91
+ }
92
+
93
+ public function __destruct() {
94
+ $this->close();
95
+ }
96
+
97
+ public function activateOptions() {
98
+ if (empty($this->layout)) {
99
+ throw new Ipagare_Log4php_LoggerException("Ipagare_Log4php_Appenders_LoggerAppenderMailEvent requires layout!");
100
+ }
101
+ if (empty($this->to)) {
102
+ throw new Ipagare_Log4php_LoggerException("Ipagare_Log4php_Appenders_LoggerAppenderMailEvent was initialized with empty 'from' ($this->from) or 'to' ($this->to) Adress!");
103
+ }
104
+
105
+ $sendmail_from = ini_get('sendmail_from');
106
+ if (empty($this->from) and empty($sendmail_from)) {
107
+ throw new Ipagare_Log4php_LoggerException("Ipagare_Log4php_Appenders_LoggerAppenderMailEvent requires 'from' or on win32 at least the ini variable sendmail_from!");
108
+ }
109
+
110
+ $this->closed = false;
111
+ }
112
+
113
+ public function close() {
114
+ $this->closed = true;
115
+ }
116
+
117
+ public function setFrom($from) {
118
+ $this->from = $from;
119
+ }
120
+
121
+ public function setPort($port) {
122
+ $this->port = (int)$port;
123
+ }
124
+
125
+ public function setSmtpHost($smtpHost) {
126
+ $this->smtpHost = $smtpHost;
127
+ }
128
+
129
+ public function setSubject($subject) {
130
+ $this->subject = $subject;
131
+ }
132
+
133
+ public function setTo($to) {
134
+ $this->to = $to;
135
+ }
136
+
137
+ public function setDry($dry) {
138
+ $this->dry = $dry;
139
+ }
140
+
141
+ public function append(Ipagare_Log4php_LoggerLoggingEvent $event) {
142
+ $smtpHost = $this->smtpHost;
143
+ $prevSmtpHost = ini_get('SMTP');
144
+ if(!empty($smtpHost)) {
145
+ ini_set('SMTP', $smtpHost);
146
+ }
147
+
148
+ $smtpPort = $this->port;
149
+ $prevSmtpPort= ini_get('smtp_port');
150
+ if($smtpPort > 0 and $smtpPort < 65535) {
151
+ ini_set('smtp_port', $smtpPort);
152
+ }
153
+
154
+ // On unix only sendmail_path, which is PHP_INI_SYSTEM i.e. not changeable here, is used.
155
+
156
+ $addHeader = empty($this->from) ? '' : "From: {$this->from}\r\n";
157
+
158
+ if(!$this->dry) {
159
+ $result = mail($this->to, $this->subject, $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), $addHeader);
160
+ } else {
161
+ echo "DRY MODE OF MAIL APP.: Send mail to: ".$this->to." with additional headers '".trim($addHeader)."' and content: ".$this->layout->format($event);
162
+ }
163
+
164
+ ini_set('SMTP', $prevSmtpHost);
165
+ ini_set('smtp_port', $prevSmtpPort);
166
+ }
167
+ }
lib/Ipagare/Log4php/Appenders/LoggerAppenderMongoDB.php ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Appender for writing to MongoDB.
23
+ *
24
+ * This class was originally contributed by Vladimir Gorej.
25
+ *
26
+ * @link http://github.com/log4mongo/log4mongo-php Vladimir Gorej's original submission.
27
+ * @link http://www.mongodb.org/ MongoDB website.
28
+ *
29
+ * @version $Revision: 806678 $
30
+ * @package log4php
31
+ * @subpackage appenders
32
+ * @since 2.1
33
+ */
34
+ class Ipagare_Log4php_Appenders_LoggerAppenderMongoDB extends Ipagare_Log4php_LoggerAppender {
35
+
36
+ // ******************************************
37
+ // ** Constants **
38
+ // ******************************************
39
+
40
+ /** Default prefix for the {@link $host}. */
41
+ const DEFAULT_MONGO_URL_PREFIX = 'mongodb://';
42
+
43
+ /** Default value for {@link $host}, without a prefix. */
44
+ const DEFAULT_MONGO_HOST = 'localhost';
45
+
46
+ /** Default value for {@link $port} */
47
+ const DEFAULT_MONGO_PORT = 27017;
48
+
49
+ /** Default value for {@link $databaseName} */
50
+ const DEFAULT_DB_NAME = 'log4php_mongodb';
51
+
52
+ /** Default value for {@link $collectionName} */
53
+ const DEFAULT_COLLECTION_NAME = 'logs';
54
+
55
+ // ******************************************
56
+ // ** Configurable parameters **
57
+ // ******************************************
58
+
59
+ /** Server on which mongodb instance is located. */
60
+ protected $host;
61
+
62
+ /** Port on which the instance is bound. */
63
+ protected $port;
64
+
65
+ /** Name of the database to which to log. */
66
+ protected $databaseName;
67
+
68
+ /** Name of the collection within the given database. */
69
+ protected $collectionName;
70
+
71
+ /** Username used to connect to the database. */
72
+ protected $userName;
73
+
74
+ /** Password used to connect to the database. */
75
+ protected $password;
76
+
77
+ // ******************************************
78
+ // ** Member variables **
79
+ // ******************************************
80
+
81
+ /**
82
+ * Connection to the MongoDB instance.
83
+ * @var Mongo
84
+ */
85
+ protected $connection;
86
+
87
+ /**
88
+ * The collection to which log is written.
89
+ * @var MongoCollection
90
+ */
91
+ protected $collection;
92
+
93
+ /**
94
+ * Set to true if the appender can append.
95
+ * @todo Maybe we should use $closed here instead?
96
+ */
97
+ protected $canAppend = false;
98
+
99
+ /** Appender does not require a layout. */
100
+ protected $requiresLayout = false;
101
+
102
+ public function __construct($name = '') {
103
+ parent::__construct($name);
104
+ $this->host = self::DEFAULT_MONGO_URL_PREFIX . self::DEFAULT_MONGO_HOST;
105
+ $this->port = self::DEFAULT_MONGO_PORT;
106
+ $this->databaseName = self::DEFAULT_DB_NAME;
107
+ $this->collectionName = self::DEFAULT_COLLECTION_NAME;
108
+ }
109
+
110
+ /**
111
+ * Setup db connection.
112
+ * Based on defined options, this method connects to the database and
113
+ * creates a {@link $collection}.
114
+ *
115
+ * @throws Exception if the attempt to connect to the requested database fails.
116
+ */
117
+ public function activateOptions() {
118
+ try {
119
+ $this->connection = new Mongo(sprintf('%s:%d', $this->host, $this->port));
120
+ $db = $this->connection->selectDB($this->databaseName);
121
+ if ($this->userName !== null && $this->password !== null) {
122
+ $authResult = $db->authenticate($this->userName, $this->password);
123
+ if ($authResult['ok'] == floatval(0)) {
124
+ throw new Exception($authResult['errmsg'], $authResult['ok']);
125
+ }
126
+ }
127
+
128
+ $this->collection = $db->selectCollection($this->collectionName);
129
+ } catch (Exception $ex) {
130
+ $this->canAppend = false;
131
+ throw new Ipagare_Log4php_LoggerException($ex);
132
+ }
133
+
134
+ $this->canAppend = true;
135
+ }
136
+
137
+ /**
138
+ * Appends a new event to the mongo database.
139
+ *
140
+ * @throws Ipagare_Log4php_LoggerException If the pattern conversion or the INSERT statement fails.
141
+ */
142
+ public function append(Ipagare_Log4php_LoggerLoggingEvent $event) {
143
+ if ($this->canAppend == true && $this->collection != null) {
144
+ $document = $this->format($event);
145
+ $this->collection->insert($document);
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Converts the logging event into an array which can be logged to mongodb.
151
+ *
152
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
153
+ * @return array The array representation of the logging event.
154
+ */
155
+ protected function format(Ipagare_Log4php_LoggerLoggingEvent $event) {
156
+ $timestampSec = (int) $event->getTimestamp();
157
+ $timestampUsec = (int) (($event->getTimestamp() - $timestampSec) * 1000000);
158
+
159
+ $document = array(
160
+ 'timestamp' => new MongoDate($timestampSec, $timestampUsec),
161
+ 'level' => $event->getLevel()->toString(),
162
+ 'thread' => (int) $event->getThreadName(),
163
+ 'message' => $event->getMessage(),
164
+ 'loggerName' => $event->getLoggerName()
165
+ );
166
+
167
+ $locationInfo = $event->getLocationInformation();
168
+ if ($locationInfo != null) {
169
+ $document['fileName'] = $locationInfo->getFileName();
170
+ $document['method'] = $locationInfo->getMethodName();
171
+ $document['lineNumber'] = ($locationInfo->getLineNumber() == 'NA') ? 'NA' : (int) $locationInfo->getLineNumber();
172
+ $document['className'] = $locationInfo->getClassName();
173
+ }
174
+
175
+ $throwableInfo = $event->getThrowableInformation();
176
+ if ($throwableInfo != null) {
177
+ $document['exception'] = $this->formatThrowable($throwableInfo->getThrowable());
178
+ }
179
+
180
+ return $document;
181
+ }
182
+
183
+ /**
184
+ * Converts an Exception into an array which can be logged to mongodb.
185
+ *
186
+ * Supports innner exceptions (PHP >= 5.3)
187
+ *
188
+ * @param Exception $ex
189
+ * @return array
190
+ */
191
+ protected function formatThrowable(Exception $ex) {
192
+ $array = array(
193
+ 'message' => $ex->getMessage(),
194
+ 'code' => $ex->getCode(),
195
+ 'stackTrace' => $ex->getTraceAsString(),
196
+ );
197
+
198
+ if (method_exists($ex, 'getPrevious') && $ex->getPrevious() !== null) {
199
+ $array['innerException'] = $this->formatThrowable($ex->getPrevious());
200
+ }
201
+
202
+ return $array;
203
+ }
204
+
205
+ /**
206
+ * Closes the connection to the logging database
207
+ */
208
+ public function close() {
209
+ if($this->closed != true) {
210
+ $this->collection = null;
211
+ if ($this->connection !== null) {
212
+ $this->connection->close();
213
+ $this->connection = null;
214
+ }
215
+ $this->closed = true;
216
+ }
217
+ }
218
+
219
+ public function __destruct() {
220
+ $this->close();
221
+ }
222
+
223
+ /** Sets the value of {@link $host} parameter. */
224
+ public function setHost($host) {
225
+ if (!preg_match('/^mongodb\:\/\//', $host)) {
226
+ $host = self::DEFAULT_MONGO_URL_PREFIX . $host;
227
+ }
228
+ $this->host = $host;
229
+ }
230
+
231
+ /** Returns the value of {@link $host} parameter. */
232
+ public function getHost() {
233
+ return $this->host;
234
+ }
235
+
236
+ /** Sets the value of {@link $port} parameter. */
237
+ public function setPort($port) {
238
+ $this->port = $port;
239
+ }
240
+
241
+ /** Returns the value of {@link $port} parameter. */
242
+ public function getPort() {
243
+ return $this->port;
244
+ }
245
+
246
+ /** Sets the value of {@link $databaseName} parameter. */
247
+ public function setDatabaseName($databaseName) {
248
+ $this->databaseName = $databaseName;
249
+ }
250
+
251
+ /** Returns the value of {@link $databaseName} parameter. */
252
+ public function getDatabaseName() {
253
+ return $this->databaseName;
254
+ }
255
+
256
+ /** Sets the value of {@link $collectionName} parameter. */
257
+ public function setCollectionName($collectionName) {
258
+ $this->collectionName = $collectionName;
259
+ }
260
+
261
+ /** Returns the value of {@link $collectionName} parameter. */
262
+ public function getCollectionName() {
263
+ return $this->collectionName;
264
+ }
265
+
266
+ /** Sets the value of {@link $userName} parameter. */
267
+ public function setUserName($userName) {
268
+ $this->userName = $userName;
269
+ }
270
+
271
+ /** Returns the value of {@link $userName} parameter. */
272
+ public function getUserName() {
273
+ return $this->userName;
274
+ }
275
+
276
+ /** Sets the value of {@link $password} parameter. */
277
+ public function setPassword($password) {
278
+ $this->password = $password;
279
+ }
280
+
281
+ /** Returns the value of {@link $password} parameter. */
282
+ public function getPassword() {
283
+ return $this->password;
284
+ }
285
+
286
+ /**
287
+ * Returns the mongodb connection.
288
+ * @return Mongo
289
+ */
290
+ public function getConnection() {
291
+ return $this->connection;
292
+ }
293
+
294
+ /**
295
+ * Returns the active mongodb collection.
296
+ * @return MongoCollection
297
+ */
298
+ public function getCollection() {
299
+ return $this->collection;
300
+ }
301
+ }
302
+ ?>
lib/Ipagare/Log4php/Appenders/LoggerAppenderNull.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * A NullAppender merely exists, it never outputs a message to any device.
23
+ *
24
+ * This appender has no configurable parameters.
25
+ *
26
+ * An example:
27
+ *
28
+ * {@example ../../examples/php/appender_null.php 19}
29
+ *
30
+ * {@example ../../examples/resources/appender_null.properties 18}
31
+ *
32
+ * @version $Revision: 1059292 $
33
+ * @package log4php
34
+ * @subpackage appenders
35
+ */
36
+ class Ipagare_Log4php_Appenders_LoggerAppenderNull extends Ipagare_Log4php_LoggerAppender {
37
+
38
+ protected $requiresLayout = false;
39
+
40
+ public function __destruct() {
41
+ $this->close();
42
+ }
43
+
44
+ public function activateOptions() {
45
+ $this->closed = false;
46
+ }
47
+
48
+ public function close() {
49
+ $this->closed = true;
50
+ }
51
+
52
+ /**
53
+ * Do nothing.
54
+ *
55
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
56
+ */
57
+ public function append(Ipagare_Log4php_LoggerLoggingEvent $event) {
58
+ }
59
+ }
60
+
lib/Ipagare/Log4php/Appenders/LoggerAppenderPDO.php ADDED
@@ -0,0 +1,323 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Appends log events to a db table using PDO.
23
+ *
24
+ * Configurable parameters of this appender are:
25
+ *
26
+ * - user - Sets the user of this database connection
27
+ * - password - Sets the password of this database connection
28
+ * - createTable - true, if the table should be created if necessary. false otherwise
29
+ * - table - Sets the table name (default: log4php_log)
30
+ * - sql - Sets the insert statement for a logging event. Defaults
31
+ * to the correct one - change only if you are sure what you are doing.
32
+ * - dsn - Sets the DSN string for this connection
33
+ *
34
+ * If $sql is set then $table and $sql are used, else $table, $insertSql and $insertPattern.
35
+ *
36
+ * An example:
37
+ *
38
+ * {@example ../../examples/php/appender_pdo.php 19}
39
+ *
40
+ * {@example ../../examples/resources/appender_pdo.properties 18}
41
+ *
42
+ * @version $Revision: 806678 $
43
+ * @package log4php
44
+ * @subpackage appenders
45
+ * @since 2.0
46
+ */
47
+ class Ipagare_Log4php_Appenders_LoggerAppenderPDO extends Ipagare_Log4php_LoggerAppender {
48
+
49
+ /**
50
+ * Create the log table if it does not exists (optional).
51
+ * @var string
52
+ */
53
+ private $createTable = true;
54
+
55
+ /**
56
+ * Database user name.
57
+ * @var string
58
+ */
59
+ private $user = '';
60
+
61
+ /**
62
+ * Database password
63
+ * @var string
64
+ */
65
+ private $password = '';
66
+
67
+ /**
68
+ * DSN string for enabling a connection.
69
+ * @var string
70
+ */
71
+ private $dsn;
72
+
73
+ /**
74
+ * A {@link LoggerPatternLayout} string used to format a valid insert query.
75
+ * @deprecated Use {@link $insertSql} and {@link $insertPattern} which properly handle quotes in the messages!
76
+ * @var string
77
+ */
78
+ private $sql;
79
+
80
+ /**
81
+ * Can be set to a complete insert statement with ? that are replaced using {@link insertPattern}.
82
+ * @var string
83
+ */
84
+ private $insertSql = "INSERT INTO __TABLE__ (timestamp, logger, level, message, thread, file, line) VALUES (?,?,?,?,?,?,?)";
85
+
86
+ /**
87
+ * A comma separated list of {@link LoggerPatternLayout} format strings that replace the "?" in {@link $sql}.
88
+ * @var string
89
+ */
90
+ private $insertPattern = "%d,%c,%p,%m,%t,%F,%L";
91
+
92
+ /**
93
+ * Table name to write events. Used only for CREATE TABLE if {@link $createTable} is true.
94
+ * @var string
95
+ */
96
+ private $table = 'log4php_log';
97
+
98
+ /**
99
+ * The PDO instance.
100
+ * @var PDO
101
+ */
102
+ private $db = null;
103
+
104
+ /**
105
+ * Prepared statement for the INSERT INTO query.
106
+ * @var PDOStatement
107
+ */
108
+ private $preparedInsert;
109
+
110
+ /**
111
+ * Set in activateOptions() and later used in append() to check if all conditions to append are true.
112
+ * @var boolean
113
+ */
114
+ private $canAppend = true;
115
+
116
+ /**
117
+ * This appender does not require a layout.
118
+ */
119
+ protected $requiresLayout = false;
120
+
121
+ /**
122
+ * Constructor.
123
+ * This apender doesn't require a layout.
124
+ * @param string $name appender name
125
+ */
126
+ public function __construct($name = '') {
127
+ parent::__construct($name);
128
+ }
129
+
130
+ public function __destruct() {
131
+ $this->close();
132
+ }
133
+
134
+ /**
135
+ * Setup db connection.
136
+ * Based on defined options, this method connects to db defined in {@link $dsn}
137
+ * and creates a {@link $table} table if {@link $createTable} is true.
138
+ * @return boolean true if all ok.
139
+ * @throws a PDOException if the attempt to connect to the requested database fails.
140
+ */
141
+ public function activateOptions() {
142
+ try {
143
+ if($this->user === null) {
144
+ $this->db = new PDO($this->dsn);
145
+ } else if($this->password === null) {
146
+ $this->db = new PDO($this->dsn, $this->user);
147
+ } else {
148
+ $this->db = new PDO($this->dsn,$this->user,$this->password);
149
+ }
150
+ $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
151
+
152
+ // test if log table exists
153
+ try {
154
+ $result = $this->db->query('SELECT * FROM ' . $this->table . ' WHERE 1 = 0');
155
+ $result->closeCursor();
156
+ } catch (PDOException $e) {
157
+ // It could be something else but a "no such table" is the most likely
158
+ $result = false;
159
+ }
160
+
161
+ // create table if necessary
162
+ if ($result == false and $this->createTable) {
163
+ // The syntax should at least be compatible with MySQL, PostgreSQL, SQLite and Oracle.
164
+ $query = "CREATE TABLE {$this->table} (".
165
+ "timestamp varchar(32)," .
166
+ "logger varchar(64)," .
167
+ "level varchar(32)," .
168
+ "message varchar(9999)," .
169
+ "thread varchar(32)," .
170
+ "file varchar(255)," .
171
+ "line varchar(6))";
172
+ $result = $this->db->query($query);
173
+ }
174
+ } catch (PDOException $e) {
175
+ $this->canAppend = false;
176
+ throw new Ipagare_Log4php_LoggerException($e);
177
+ }
178
+
179
+ $this->layout = new Ipagare_Log4php_Layouts_LoggerLayoutPattern();
180
+
181
+ //
182
+ // Keep compatibility to legacy option $sql which already included the format patterns!
183
+ //
184
+ if (empty($this->sql)) {
185
+ // new style with prepared Statment and $insertSql and $insertPattern
186
+ // Maybe the tablename has to be substituted.
187
+ $this->insertSql = preg_replace('/__TABLE__/', $this->table, $this->insertSql);
188
+ $this->preparedInsert = $this->db->prepare($this->insertSql);
189
+ $this->layout->setConversionPattern($this->insertPattern);
190
+ } else {
191
+ // Old style with format strings in the $sql query should be used.
192
+ $this->layout->setConversionPattern($this->sql);
193
+ }
194
+
195
+ $this->canAppend = true;
196
+ return true;
197
+ }
198
+
199
+ /**
200
+ * Appends a new event to the database.
201
+ *
202
+ * @throws Ipagare_Log4php_LoggerException If the pattern conversion or the INSERT statement fails.
203
+ */
204
+ public function append(Ipagare_Log4php_LoggerLoggingEvent $event) {
205
+ // TODO: Can't activateOptions() simply throw an Exception if it encounters problems?
206
+ if ( ! $this->canAppend) return;
207
+
208
+ try {
209
+ if (empty($this->sql)) {
210
+ // new style with prepared statement
211
+ $params = $this->layout->formatToArray($event);
212
+ $this->preparedInsert->execute($params);
213
+ } else {
214
+ // old style
215
+ $query = $this->layout->format($event);
216
+ $this->db->exec($query);
217
+ }
218
+ } catch (Exception $e) {
219
+ throw new Ipagare_Log4php_LoggerException($e);
220
+ }
221
+ }
222
+
223
+ /**
224
+ * Closes the connection to the logging database
225
+ */
226
+ public function close() {
227
+ if($this->closed != true) {
228
+ if ($this->db !== null) {
229
+ $this->db = null;
230
+ }
231
+ $this->closed = true;
232
+ }
233
+ }
234
+
235
+ /**
236
+ * Sets the username for this connection.
237
+ * Defaults to ''
238
+ */
239
+ public function setUser($user) {
240
+ $this->user = $user;
241
+ }
242
+
243
+ /**
244
+ * Sets the password for this connection.
245
+ * Defaults to ''
246
+ */
247
+ public function setPassword($password) {
248
+ $this->password = $password;
249
+ }
250
+
251
+ /**
252
+ * Indicator if the logging table should be created on startup,
253
+ * if its not existing.
254
+ */
255
+ public function setCreateTable($flag) {
256
+ $this->createTable = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($flag, true);
257
+ }
258
+
259
+ /**
260
+ * Sets the SQL string into which the event should be transformed.
261
+ * Defaults to:
262
+ *
263
+ * INSERT INTO $this->table
264
+ * ( timestamp, logger, level, message, thread, file, line)
265
+ * VALUES
266
+ * ('%d','%c','%p','%m','%t','%F','%L')
267
+ *
268
+ * It's not necessary to change this except you have customized logging'
269
+ *
270
+ * @deprecated See {@link setInsertSql} and {@link setInsertPattern}.
271
+ */
272
+ public function setSql($sql) {
273
+ $this->sql = $sql;
274
+ }
275
+
276
+ /**
277
+ * Sets the SQL INSERT string to use with {@link $insertPattern}.
278
+ *
279
+ * @param $sql A complete INSERT INTO query with "?" that gets replaced.
280
+ */
281
+ public function setInsertSql($sql) {
282
+ $this->insertSql = $sql;
283
+ }
284
+
285
+ /**
286
+ * Sets the {@link Ipagare_Log4php_Layouts_LoggerLayoutPattern} format strings for {@link $insertSql}.
287
+ *
288
+ * It's not necessary to change this except you have customized logging.
289
+ *
290
+ * @param $pattern Comma separated format strings like "%p,%m,%C"
291
+ */
292
+ public function setInsertPattern($pattern) {
293
+ $this->insertPattern = $pattern;
294
+ }
295
+
296
+ /**
297
+ * Sets the tablename to which this appender should log.
298
+ * Defaults to log4php_log
299
+ */
300
+ public function setTable($table) {
301
+ $this->table = $table;
302
+ }
303
+
304
+ /**
305
+ * Sets the DSN string for this connection. In case of
306
+ * SQLite it could look like this: 'sqlite:appenders/pdotest.sqlite'
307
+ */
308
+ public function setDSN($dsn) {
309
+ $this->dsn = $dsn;
310
+ }
311
+
312
+ /**
313
+ * Sometimes databases allow only one connection to themselves in one thread.
314
+ * SQLite has this behaviour. In that case this handle is needed if the database
315
+ * must be checked for events.
316
+ *
317
+ * @return PDO
318
+ */
319
+ public function getDatabaseHandle() {
320
+ return $this->db;
321
+ }
322
+ }
323
+
lib/Ipagare/Log4php/Appenders/LoggerAppenderPhp.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Log events using php {@link PHP_MANUAL#trigger_error} function and a {@link Ipagare_Log4php_Layouts_LoggerLayoutTTCC} default layout.
23
+ *
24
+ * This appender has no configurable parameters.
25
+ *
26
+ * <p>Levels are mapped as follows:</p>
27
+ * - <b>level &lt; WARN</b> mapped to E_USER_NOTICE
28
+ * - <b>WARN &lt;= level &lt; ERROR</b> mapped to E_USER_WARNING
29
+ * - <b>level &gt;= ERROR</b> mapped to E_USER_ERROR
30
+ *
31
+ * An example:
32
+ *
33
+ * {@example ../../examples/php/appender_php.php 19}
34
+ *
35
+ * {@example ../../examples/resources/appender_php.properties 18}
36
+ *
37
+ * @version $Revision: 1062665 $
38
+ * @package log4php
39
+ * @subpackage appenders
40
+ */
41
+ class Ipagare_Log4php_Appenders_LoggerAppenderPhp extends Ipagare_Log4php_LoggerAppender {
42
+
43
+ public function __construct($name = '') {
44
+ parent::__construct($name);
45
+ }
46
+
47
+ public function __destruct() {
48
+ $this->close();
49
+ }
50
+
51
+ public function activateOptions() {
52
+ $this->closed = false;
53
+ }
54
+
55
+ public function close() {
56
+ $this->closed = true;
57
+ }
58
+
59
+ public function append(Ipagare_Log4php_LoggerLoggingEvent $event) {
60
+ if($this->layout !== null) {
61
+ $level = $event->getLevel();
62
+ if($level->isGreaterOrEqual(Ipagare_Log4php_LoggerLevel::getLevelError())) {
63
+ trigger_error($this->layout->format($event), E_USER_ERROR);
64
+ } else if ($level->isGreaterOrEqual(Ipagare_Log4php_LoggerLevel::getLevelWarn())) {
65
+ trigger_error($this->layout->format($event), E_USER_WARNING);
66
+ } else {
67
+ trigger_error($this->layout->format($event), E_USER_NOTICE);
68
+ }
69
+ }
70
+ }
71
+ }
lib/Ipagare/Log4php/Appenders/LoggerAppenderRollingFile.php ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Ipagare_Log4php_Appenders_LoggerAppenderRollingFile extends Ipagare_Log4php_Appenders_LoggerAppenderFile to backup the log files
23
+ * when they reach a certain size.
24
+ *
25
+ * This appender uses a layout.
26
+ *
27
+ * Parameters are:
28
+ * - file - The target file to write to
29
+ * - filename - The target file to write to (deprecated, use "file" instead).
30
+ * - append - Sets if the appender should append to the end of the file or overwrite content ("true" or "false")
31
+ * - maxBackupIndex - Set the maximum number of backup files to keep around (int)
32
+ * - maxFileSize - Set the maximum size that the output file is allowed to
33
+ * reach before being rolled over to backup files.
34
+ * Suffixes like "KB", "MB" or "GB" are allowed, f. e. "10KB" is interpreted as 10240
35
+ * - maximumFileSize - Alias to maxFileSize (deprecated, use "maxFileSize" instead)
36
+ *
37
+ * <p>Contributors: Sergio Strampelli.</p>
38
+ *
39
+ * An example:
40
+ *
41
+ * {@example ../../examples/php/appender_socket.php 19}
42
+ *
43
+ * {@example ../../examples/resources/appender_socket.properties 18}
44
+ *
45
+ * @version $Revision: 1134244 $
46
+ * @package log4php
47
+ * @subpackage appenders
48
+ */
49
+ class Ipagare_Log4php_Appenders_LoggerAppenderRollingFile extends Ipagare_Log4php_Appenders_LoggerAppenderFile {
50
+
51
+ /**
52
+ * Set the maximum size that the output file is allowed to reach
53
+ * before being rolled over to backup files.
54
+ *
55
+ * <p>In configuration files, the <var>MaxFileSize</var> option takes a
56
+ * long integer in the range 0 - 2^63. You can specify the value
57
+ * with the suffixes "KB", "MB" or "GB" so that the integer is
58
+ * interpreted being expressed respectively in kilobytes, megabytes
59
+ * or gigabytes. For example, the value "10KB" will be interpreted
60
+ * as 10240.</p>
61
+ * <p>The default maximum file size is 10MB.</p>
62
+ *
63
+ * <p>Note that MaxFileSize cannot exceed <b>2 GB</b>.</p>
64
+ *
65
+ * @var integer
66
+ */
67
+ private $maxFileSize = 10485760;
68
+
69
+ /**
70
+ * Set the maximum number of backup files to keep around.
71
+ *
72
+ * <p>The <var>MaxBackupIndex</var> option determines how many backup
73
+ * files are kept before the oldest is erased. This option takes
74
+ * a positive integer value. If set to zero, then there will be no
75
+ * backup files and the log file will be truncated when it reaches
76
+ * MaxFileSize.</p>
77
+ * <p>There is one backup file by default.</p>
78
+ *
79
+ * @var integer
80
+ */
81
+ private $maxBackupIndex = 1;
82
+
83
+ /**
84
+ * @var string the filename expanded
85
+ */
86
+ private $expandedFileName = null;
87
+
88
+ public function __destruct() {
89
+ parent::__destruct();
90
+ }
91
+
92
+ /**
93
+ * Returns the value of the MaxBackupIndex option.
94
+ * @return integer
95
+ */
96
+ private function getExpandedFileName() {
97
+ return $this->expandedFileName;
98
+ }
99
+
100
+ /**
101
+ * Get the maximum size that the output file is allowed to reach
102
+ * before being rolled over to backup files.
103
+ * @return integer
104
+ */
105
+ public function getMaximumFileSize() {
106
+ return $this->maxFileSize;
107
+ }
108
+
109
+ /**
110
+ * Implements the usual roll over behaviour.
111
+ *
112
+ * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex.
113
+ * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output.
114
+ *
115
+ * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created.
116
+ *
117
+ * Rollover must be called while the file is locked so that it is safe for concurrent access.
118
+ */
119
+ private function rollOver() {
120
+ // If maxBackups <= 0, then there is no file renaming to be done.
121
+ if($this->maxBackupIndex > 0) {
122
+ $fileName = $this->getExpandedFileName();
123
+
124
+ // Delete the oldest file, to keep Windows happy.
125
+ $file = $fileName . '.' . $this->maxBackupIndex;
126
+ if(is_writable($file))
127
+ unlink($file);
128
+
129
+ // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
130
+ for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) {
131
+ $file = $fileName . "." . $i;
132
+ if(is_readable($file)) {
133
+ $target = $fileName . '.' . ($i + 1);
134
+ rename($file, $target);
135
+ }
136
+ }
137
+
138
+ // Backup the active file
139
+ copy($fileName, "$fileName.1");
140
+ }
141
+
142
+ // Truncate the active file
143
+ ftruncate($this->fp, 0);
144
+ rewind($this->fp);
145
+ }
146
+
147
+ public function setFile($fileName) {
148
+ $this->file = $fileName;
149
+ // As Ipagare_Log4php_Appenders_LoggerAppenderFile does not create the directory, it has to exist.
150
+ // realpath() fails if the argument does not exist so the filename is separated.
151
+ $this->expandedFileName = realpath(dirname($fileName));
152
+ if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!");
153
+ $this->expandedFileName .= DIRECTORY_SEPARATOR . basename($fileName);
154
+ }
155
+
156
+
157
+ /**
158
+ * Set the maximum number of backup files to keep around.
159
+ *
160
+ * <p>The <b>MaxBackupIndex</b> option determines how many backup
161
+ * files are kept before the oldest is erased. This option takes
162
+ * a positive integer value. If set to zero, then there will be no
163
+ * backup files and the log file will be truncated when it reaches
164
+ * MaxFileSize.
165
+ *
166
+ * @param mixed $maxBackups
167
+ */
168
+ public function setMaxBackupIndex($maxBackups) {
169
+ if(is_numeric($maxBackups)) {
170
+ $this->maxBackupIndex = abs((int)$maxBackups);
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Set the maximum size that the output file is allowed to reach
176
+ * before being rolled over to backup files.
177
+ *
178
+ * @param mixed $maxFileSize
179
+ * @see setMaxFileSize()
180
+ * @deprecated
181
+ */
182
+ public function setMaximumFileSize($maxFileSize) {
183
+ return $this->setMaxFileSize($maxFileSize);
184
+ }
185
+
186
+ /**
187
+ * Set the maximum size that the output file is allowed to reach
188
+ * before being rolled over to backup files.
189
+ * <p>In configuration files, the <b>maxFileSize</b> option takes an
190
+ * long integer in the range 0 - 2^63. You can specify the value
191
+ * with the suffixes "KB", "MB" or "GB" so that the integer is
192
+ * interpreted being expressed respectively in kilobytes, megabytes
193
+ * or gigabytes. For example, the value "10KB" will be interpreted
194
+ * as 10240.
195
+ *
196
+ * @param mixed $value
197
+ * @return the actual file size set
198
+ */
199
+ public function setMaxFileSize($value) {
200
+ $maxFileSize = null;
201
+ $numpart = substr($value,0, strlen($value) -2);
202
+ $suffix = strtoupper(substr($value, -2));
203
+
204
+ switch($suffix) {
205
+ case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break;
206
+ case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break;
207
+ case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break;
208
+ default:
209
+ if(is_numeric($value)) {
210
+ $maxFileSize = (int)$value;
211
+ }
212
+ }
213
+
214
+ if($maxFileSize !== null) {
215
+ $this->maxFileSize = abs($maxFileSize);
216
+ }
217
+ return $this->maxFileSize;
218
+ }
219
+
220
+ public function append(Ipagare_Log4php_LoggerLoggingEvent $event) {
221
+ if($this->fp and $this->layout !== null) {
222
+ if(flock($this->fp, LOCK_EX)) {
223
+ fwrite($this->fp, $this->layout->format($event));
224
+
225
+ // Stats cache must be cleared, otherwise filesize() returns cached results
226
+ clearstatcache();
227
+
228
+ // Rollover if needed
229
+ if (filesize($this->expandedFileName) > $this->maxFileSize) {
230
+ $this->rollOver();
231
+ }
232
+
233
+ flock($this->fp, LOCK_UN);
234
+ } else {
235
+ $this->closed = true;
236
+ }
237
+ }
238
+ }
239
+
240
+ /**
241
+ * @return Returns the maximum number of backup files to keep around.
242
+ */
243
+ public function getMaxBackupIndex() {
244
+ return $this->maxBackupIndex;
245
+ }
246
+
247
+ /**
248
+ * @return Returns the maximum size that the output file is allowed to reach
249
+ * before being rolled over to backup files.
250
+ */
251
+ public function getMaxFileSize() {
252
+ return $this->maxFileSize;
253
+ }
254
+ }
lib/Ipagare/Log4php/Appenders/LoggerAppenderSocket.php ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Serialize events and send them to a network socket.
23
+ *
24
+ * This appender can be configured by changing the following attributes:
25
+ *
26
+ * - locationInfo - Sets the location info for the xml layout (true or false)
27
+ * - log4jNamespace - Sets the namespace for log4j (true or false)
28
+ * - port - Sets the port of the socket.
29
+ * - remoteHost - Sets the remote host
30
+ * - timeout - Sets the timeout in ms
31
+ * - useXml - true, if xml should be transmitted.
32
+ * false, if a serialized php object should be transmitted
33
+ *
34
+ * Parameters are {@link $remoteHost}, {@link $port}, {@link $timeout},
35
+ * {@link $locationInfo}, {@link $useXml} and {@link $log4jNamespace}.
36
+ *
37
+ * An example:
38
+ *
39
+ * {@example ../../examples/php/appender_socket.php 19}
40
+ *
41
+ * {@example ../../examples/resources/appender_socket.properties 18}
42
+ *
43
+ * @version $Revision: 1062667 $
44
+ * @package log4php
45
+ * @subpackage appenders
46
+ */
47
+ class Ipagare_Log4php_Appenders_LoggerAppenderSocket extends Ipagare_Log4php_LoggerAppender {
48
+
49
+ /**
50
+ * This appender does not require a layout.
51
+ */
52
+ protected $requiresLayout = false;
53
+
54
+ /**
55
+ * @var mixed socket connection resource
56
+ */
57
+ private $sp = false;
58
+
59
+ /**
60
+ * Target host. On how to define remote hostaname see
61
+ * {@link PHP_MANUAL#fsockopen}
62
+ * @var string
63
+ */
64
+ private $remoteHost = '';
65
+
66
+ /**
67
+ * @var integer the network port.
68
+ */
69
+ private $port = 4446;
70
+
71
+ /**
72
+ * @var boolean get event's location info.
73
+ */
74
+ private $locationInfo = false;
75
+
76
+ /**
77
+ * @var integer connection timeout
78
+ */
79
+ private $timeout = 30;
80
+
81
+ /**
82
+ * @var boolean output events via {@link LoggerXmlLayout}
83
+ */
84
+ private $useXml = false;
85
+
86
+ /**
87
+ * @var boolean forward this option to {@link LoggerXmlLayout}.
88
+ * Ignored if {@link $useXml} is <i>false</i>.
89
+ */
90
+ private $log4jNamespace = false;
91
+
92
+ /**
93
+ * @var LoggerXmlLayout
94
+ */
95
+ private $xmlLayout = null;
96
+
97
+ /** @var indiciates if this appender should run in dry mode */
98
+ private $dry = false;
99
+
100
+ public function __destruct() {
101
+ $this->close();
102
+ }
103
+
104
+ /**
105
+ * Create a socket connection using defined parameters
106
+ */
107
+ public function activateOptions() {
108
+ if(!$this->dry) {
109
+ $this->sp = @fsockopen($this->getRemoteHost(), $this->getPort(), $errno, $errstr, $this->getTimeout());
110
+ if ($this->sp === false) {
111
+ throw new Ipagare_Log4php_LoggerException("Could not open socket to ".$this->getRemoteHost().":".$this->getPort().": $errstr ($errno)");
112
+ }
113
+ }
114
+ if($this->getUseXml()) {
115
+ $this->xmlLayout = Ipagare_Log4php_LoggerReflectionUtils::createObject('Ipagare_Log4php_Layouts_LoggerLayoutXml');
116
+ if($this->xmlLayout === null) {
117
+ $this->setUseXml(false);
118
+ } else {
119
+ $this->xmlLayout->setLocationInfo($this->getLocationInfo());
120
+ $this->xmlLayout->setLog4jNamespace($this->getLog4jNamespace());
121
+ $this->xmlLayout->activateOptions();
122
+ }
123
+ }
124
+ $this->closed = false;
125
+ }
126
+
127
+ public function close() {
128
+ if($this->closed != true) {
129
+ if(!$this->dry and $this->sp !== false) {
130
+ fclose($this->sp);
131
+ }
132
+ $this->closed = true;
133
+ }
134
+ }
135
+
136
+ public function setDry($dry) {
137
+ $this->dry = $dry;
138
+ }
139
+
140
+ /**
141
+ * @return string
142
+ */
143
+ public function getHostname() {
144
+ return $this->getRemoteHost();
145
+ }
146
+
147
+ /**
148
+ * @return boolean
149
+ */
150
+ public function getLocationInfo() {
151
+ return $this->locationInfo;
152
+ }
153
+
154
+ /**
155
+ * @return boolean
156
+ */
157
+ public function getLog4jNamespace() {
158
+ return $this->log4jNamespace;
159
+ }
160
+
161
+ /**
162
+ * @return integer
163
+ */
164
+ public function getPort() {
165
+ return $this->port;
166
+ }
167
+
168
+ public function getRemoteHost() {
169
+ return $this->remoteHost;
170
+ }
171
+
172
+ /**
173
+ * @return integer
174
+ */
175
+ public function getTimeout() {
176
+ return $this->timeout;
177
+ }
178
+
179
+ /**
180
+ * @var boolean
181
+ */
182
+ public function getUseXml() {
183
+ return $this->useXml;
184
+ }
185
+
186
+ public function reset() {
187
+ $this->close();
188
+ parent::reset();
189
+ }
190
+
191
+ /**
192
+ * @param mixed
193
+ */
194
+ public function setLocationInfo($flag) {
195
+ $this->locationInfo = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($flag, $this->getLocationInfo());
196
+ }
197
+
198
+ /**
199
+ * @param mixed
200
+ */
201
+ public function setLog4jNamespace($flag) {
202
+ $this->log4jNamespace = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($flag, $this->getLog4jNamespace());
203
+ }
204
+
205
+ /**
206
+ * @param integer
207
+ */
208
+ public function setPort($port) {
209
+ $port = Ipagare_Log4php_Helpers_LoggerOptionConverter::toInt($port, 0);
210
+ if($port > 0 and $port < 65535) {
211
+ $this->port = $port;
212
+ }
213
+ }
214
+
215
+ /**
216
+ * @param string
217
+ */
218
+ public function setRemoteHost($hostname) {
219
+ $this->remoteHost = $hostname;
220
+ }
221
+
222
+ /**
223
+ * @param integer
224
+ */
225
+ public function setTimeout($timeout) {
226
+ $this->timeout = Ipagare_Log4php_Helpers_LoggerOptionConverter::toInt($timeout, $this->getTimeout());
227
+ }
228
+
229
+ /**
230
+ * @param mixed
231
+ */
232
+ public function setUseXml($flag) {
233
+ $this->useXml = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($flag, $this->getUseXml());
234
+ }
235
+
236
+ public function append(Ipagare_Log4php_LoggerLoggingEvent $event) {
237
+ if($this->sp || $this->dry) {
238
+ if($this->getLocationInfo()) {
239
+ $event->getLocationInformation();
240
+ }
241
+
242
+ if(!$this->getUseXml()) {
243
+ $sEvent = serialize($event);
244
+ if(!$this->dry) {
245
+ fwrite($this->sp, $sEvent, strlen($sEvent));
246
+ } else {
247
+ echo "DRY MODE OF SOCKET APPENDER: ".$sEvent;
248
+ }
249
+ } else {
250
+ if(!$this->dry) {
251
+ fwrite($this->sp, $this->xmlLayout->format($event));
252
+ } else {
253
+ echo "DRY MODE OF SOCKET APPENDER: ".$this->xmlLayout->format($event);
254
+ }
255
+ }
256
+
257
+ // not sure about it...
258
+ if(!$this->dry) {
259
+ fflush($this->sp);
260
+ }
261
+ }
262
+ }
263
+ }
lib/Ipagare/Log4php/Appenders/LoggerAppenderSyslog.php ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Log events using php {@link PHP_MANUAL#syslog} function.
23
+ *
24
+ * This appender can be configured by changing the following attributes:
25
+ *
26
+ * - layout - Sets the layout class for this appender
27
+ * - ident - Set the ident of the syslog message.
28
+ * - priority - Set the priority value for the syslog message.
29
+ * - facility - Set the facility value for the syslog message
30
+ * - overridePriority - If the priority of the message to be sent can be
31
+ * defined by a value in the properties-file, set
32
+ * parameter value to "true"
33
+ * - option - Set the option value for the syslog message.
34
+ * This value is used as a parameter for php openlog()
35
+ * and passed on to the syslog daemon.
36
+ *
37
+ * Levels are mapped as follows:
38
+ * - <b>level >= FATAL</b> to LOG_ALERT
39
+ * - <b>FATAL > level >= ERROR</b> to LOG_ERR
40
+ * - <b>ERROR > level >= WARN</b> to LOG_WARNING
41
+ * - <b>WARN > level >= INFO</b> to LOG_INFO
42
+ * - <b>INFO > level >= DEBUG</b> to LOG_DEBUG
43
+ * - <b>DEBUG > level >= TRACE</b> to LOG_DEBUG
44
+ *
45
+ * An example:
46
+ *
47
+ * {@example ../../examples/php/appender_syslog.php 19}
48
+ *
49
+ * {@example ../../examples/resources/appender_syslog.properties 18}
50
+ *
51
+ * @version $Revision: 1062665 $
52
+ * @package log4php
53
+ * @subpackage appenders
54
+ */
55
+ class Ipagare_Log4php_Appenders_LoggerAppenderSyslog extends Ipagare_Log4php_LoggerAppender {
56
+
57
+ /**
58
+ * The ident string is added to each message. Typically the name of your application.
59
+ *
60
+ * @var string Ident for your application
61
+ */
62
+ private $_ident = "Log4PHP Syslog-Event";
63
+
64
+ /**
65
+ * The priority parameter value indicates the level of importance of the message.
66
+ * It is passed on to the Syslog daemon.
67
+ *
68
+ * @var int Syslog priority
69
+ */
70
+ private $_priority;
71
+
72
+ /**
73
+ * The option used when generating a log message.
74
+ * It is passed on to the Syslog daemon.
75
+ *
76
+ * @var int Syslog priority
77
+ */
78
+ private $_option;
79
+
80
+ /**
81
+ * The facility value indicates the source of the message.
82
+ * It is passed on to the Syslog daemon.
83
+ *
84
+ * @var const int Syslog facility
85
+ */
86
+ private $_facility;
87
+
88
+ /**
89
+ * If it is necessary to define logging priority in the .properties-file,
90
+ * set this variable to "true".
91
+ *
92
+ * @var const int value indicating whether the priority of the message is defined in the .properties-file
93
+ * (or properties-array)
94
+ */
95
+ private $_overridePriority;
96
+
97
+ /** @var indiciates if this appender should run in dry mode */
98
+ private $dry = false;
99
+
100
+ public function __construct($name = '') {
101
+ parent::__construct($name);
102
+ }
103
+
104
+ public function __destruct() {
105
+ $this->close();
106
+ }
107
+
108
+ public function setDry($dry) {
109
+ $this->dry = $dry;
110
+ }
111
+
112
+ /**
113
+ * Set the ident of the syslog message.
114
+ *
115
+ * @param string Ident
116
+ */
117
+ public function setIdent($ident) {
118
+ $this->_ident = $ident;
119
+ }
120
+
121
+ /**
122
+ * Set the priority value for the syslog message.
123
+ *
124
+ * @param const int Priority
125
+ */
126
+ public function setPriority($priority) {
127
+ $this->_priority = $priority;
128
+ }
129
+
130
+
131
+ /**
132
+ * Set the facility value for the syslog message.
133
+ *
134
+ * @param const int Facility
135
+ */
136
+ public function setFacility($facility) {
137
+ $this->_facility = $facility;
138
+ }
139
+
140
+ /**
141
+ * If the priority of the message to be sent can be defined by a value in the properties-file,
142
+ * set parameter value to "true".
143
+ *
144
+ * @param bool Override priority
145
+ */
146
+ public function setOverridePriority($overridePriority) {
147
+ $this->_overridePriority = $overridePriority;
148
+ }
149
+
150
+ /**
151
+ * Set the option value for the syslog message.
152
+ * This value is used as a parameter for php openlog()
153
+ * and passed on to the syslog daemon.
154
+ *
155
+ * @param string $option
156
+ */
157
+ public function setOption($option) {
158
+ $this->_option = $option;
159
+ }
160
+
161
+ public function activateOptions() {
162
+ // Deprecated as of 5.3 and removed in 6.0
163
+ // define_syslog_variables();
164
+ $this->closed = false;
165
+ }
166
+
167
+ public function close() {
168
+ if($this->closed != true) {
169
+ closelog();
170
+ $this->closed = true;
171
+ }
172
+ }
173
+
174
+ public function append(Ipagare_Log4php_LoggerLoggingEvent $event) {
175
+ if($this->_option == NULL){
176
+ $this->_option = LOG_PID | LOG_CONS;
177
+ }
178
+
179
+ $level = $event->getLevel();
180
+ if($this->layout === null) {
181
+ $message = $event->getRenderedMessage();
182
+ } else {
183
+ $message = $this->layout->format($event);
184
+ }
185
+
186
+ // If the priority of a syslog message can be overridden by a value defined in the properties-file,
187
+ // use that value, else use the one that is defined in the code.
188
+ if(!$this->dry) {
189
+ // Attach the process ID to the message, use the facility defined in the .properties-file
190
+ openlog($this->_ident, $this->_option, $this->_facility);
191
+
192
+ if($this->_overridePriority) {
193
+ syslog($this->_priority, $message);
194
+ } else {
195
+ if($level->isGreaterOrEqual(Ipagare_Log4php_LoggerLevel::getLevelFatal())) {
196
+ syslog(LOG_ALERT, $message);
197
+ } else if ($level->isGreaterOrEqual(Ipagare_Log4php_LoggerLevel::getLevelError())) {
198
+ syslog(LOG_ERR, $message);
199
+ } else if ($level->isGreaterOrEqual(Ipagare_Log4php_LoggerLevel::getLevelWarn())) {
200
+ syslog(LOG_WARNING, $message);
201
+ } else if ($level->isGreaterOrEqual(Ipagare_Log4php_LoggerLevel::getLevelInfo())) {
202
+ syslog(LOG_INFO, $message);
203
+ } else if ($level->isGreaterOrEqual(Ipagare_Log4php_LoggerLevel::getLevelDebug())) {
204
+ syslog(LOG_DEBUG, $message);
205
+ } else if ($level->isGreaterOrEqual(Ipagare_Log4php_LoggerLevel::getLevelTrace())) {
206
+ syslog(LOG_DEBUG, $message); // No trace level in syslog
207
+ }
208
+ }
209
+ closelog();
210
+ } else {
211
+ echo "DRY MODE OF SYSLOG APPENDER: ".$message;
212
+ }
213
+ }
214
+ }
lib/Ipagare/Log4php/Configurators/LoggerConfiguratorBasic.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Use this class to quickly configure the package.
23
+ *
24
+ * An example how to use this configurator:
25
+ *
26
+ * {@example ../../examples/php/configurator_basic.php 19}
27
+ *
28
+ * @version $Revision: 883108 $
29
+ * @package log4php
30
+ * @subpackage configurators
31
+ */
32
+ class Ipagare_Log4php_Configurators_LoggerConfiguratorBasic implements Ipagare_Log4php_LoggerConfigurator {
33
+
34
+ /**
35
+ * Add a {@link Ipagare_Log4php_Appenders_LoggerAppenderConsole} that uses
36
+ * the {@link Ipagare_Log4php_Layouts_LoggerLayoutTTCC} to the root category.
37
+ *
38
+ * @param string $url not used here
39
+ */
40
+ public function configure(Ipagare_Log4php_LoggerHierarchy $hierarchy, $url = null) {
41
+ $root = $hierarchy->getRootLogger();
42
+ $appender = new Ipagare_Log4php_Appenders_LoggerAppenderConsole('A1');
43
+ $appender->setLayout( new Ipagare_Log4php_Layouts_LoggerLayoutTTCC() );
44
+ $appender->activateOptions();
45
+ $root->addAppender($appender);
46
+ }
47
+ }
lib/Ipagare/Log4php/Configurators/LoggerConfiguratorIni.php ADDED
@@ -0,0 +1,463 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Allows the configuration of log4php from an external file.
23
+ *
24
+ * <p>This is the most commonly used method of configuring log4php.</p>
25
+ *
26
+ * <p>It is sometimes useful to see how log4php is reading configuration
27
+ * files. You can enable log4php internal logging by defining the
28
+ * <b>log4php.debug</b> variable.</p>
29
+ *
30
+ * <p>The <i>Ipagare_Log4php_Configurators_LoggerConfiguratorIni</i> does not handle the
31
+ * advanced configuration features supported by the {@link Ipagare_Log4php_Configurators_LoggerConfiguratorXml}
32
+ * such as support for {@link Ipagare_Log4php_LoggerFilter},
33
+ * custom {@link LoggerErrorHandlers}, nested appenders such as the {@link Logger AsyncAppender},
34
+ * etc.</p>
35
+ *
36
+ * <p>All option <i>values</i> admit variable substitution. The
37
+ * syntax of variable substitution is similar to that of Unix
38
+ * shells. The string between an opening <b>"${"</b> and
39
+ * closing <b>"}"</b> is interpreted as a key. The value of
40
+ * the substituted variable can be defined as a system property or in
41
+ * the configuration file itself. The value of the key is first
42
+ * searched in the defined constants, in the enviroments variables
43
+ * and if not found there, it is
44
+ * then searched in the configuration file being parsed. The
45
+ * corresponding value replaces the ${variableName} sequence.</p>
46
+ * <p>For example, if <b>$_ENV['home']</b> env var is set to
47
+ * <b>/home/xyz</b>, then every occurrence of the sequence
48
+ * <b>${home}</b> will be interpreted as
49
+ * <b>/home/xyz</b>. See {@link Ipagare_Log4php_Helpers_LoggerOptionConverter::getSystemProperty()}
50
+ * for details.</p>
51
+ *
52
+ * <p>An example how to use this appender:</p>
53
+ *
54
+ * {@example ../../examples/php/appender_dailyfile.php 19}
55
+ *
56
+ * <p>And the corresponding ini file:</p>
57
+ *
58
+ * {@example ../../examples/resources/appender_dailyfile.properties 18}
59
+ *
60
+ * @version $Revision: 1071033 $
61
+ * @package log4php
62
+ * @subpackage configurators
63
+ * @since 0.5
64
+ */
65
+ class Ipagare_Log4php_Configurators_LoggerConfiguratorIni implements Ipagare_Log4php_LoggerConfigurator {
66
+ const CATEGORY_PREFIX = "log4php.category.";
67
+ const LOGGER_PREFIX = "log4php.logger.";
68
+ const FACTORY_PREFIX = "log4php.factory";
69
+ const ADDITIVITY_PREFIX = "log4php.additivity.";
70
+ const ROOT_CATEGORY_PREFIX = "log4php.rootCategory";
71
+ const ROOT_LOGGER_PREFIX = "log4php.rootLogger";
72
+ const APPENDER_PREFIX = "log4php.appender.";
73
+ const RENDERER_PREFIX = "log4php.renderer.";
74
+ const THRESHOLD_PREFIX = "log4php.threshold";
75
+
76
+ /**
77
+ * Key for specifying the {@link LoggerFactory}.
78
+ */
79
+ const LOGGER_FACTORY_KEY = "log4php.loggerFactory";
80
+ const LOGGER_DEBUG_KEY = "log4php.debug";
81
+ const INTERNAL_ROOT_NAME = "root";
82
+
83
+ /**
84
+ * Constructor
85
+ */
86
+ public function __construct() {
87
+ }
88
+
89
+ /**
90
+ * Read configuration from a file.
91
+ *
92
+ * <p>The function {@link PHP_MANUAL#parse_ini_file} is used to read the
93
+ * file.</p>
94
+ *
95
+ * <b>The existing configuration is not cleared nor reset.</b>
96
+ * If you require a different behavior, then call
97
+ * {@link Logger::resetConfiguration()}
98
+ * method before calling {@link doConfigure()}.
99
+ *
100
+ * <p>The configuration file consists of statements in the format
101
+ * <b>key=value</b>. The syntax of different configuration
102
+ * elements are discussed below.
103
+ *
104
+ * <p><b>Repository-wide threshold</b></p>
105
+ *
106
+ * <p>The repository-wide threshold filters logging requests by level
107
+ * regardless of logger. The syntax is:
108
+ *
109
+ * <pre>
110
+ * log4php.threshold=[level]
111
+ * </pre>
112
+ *
113
+ * <p>The level value can consist of the string values OFF, FATAL,
114
+ * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A
115
+ * custom level value can be specified in the form
116
+ * <samp>level#classname</samp>. By default the repository-wide threshold is set
117
+ * to the lowest possible value, namely the level <b>ALL</b>.
118
+ * </p>
119
+ *
120
+ *
121
+ * <p><b>Appender configuration</b></p>
122
+ *
123
+ * <p>Appender configuration syntax is:</p>
124
+ * <pre>
125
+ * ; For appender named <i>appenderName</i>, set its class.
126
+ * ; Note: The appender name can contain dots.
127
+ * log4php.appender.appenderName=name_of_appender_class
128
+ *
129
+ * ; Set appender specific options.
130
+ *
131
+ * log4php.appender.appenderName.option1=value1
132
+ * log4php.appender.appenderName.optionN=valueN
133
+ * </pre>
134
+ *
135
+ * For each named appender you can configure its {@link Ipagare_Log4php_LoggerLayout}. The
136
+ * syntax for configuring an appender's layout is:
137
+ * <pre>
138
+ * log4php.appender.appenderName.layout=name_of_layout_class
139
+ * log4php.appender.appenderName.layout.option1=value1
140
+ * ....
141
+ * log4php.appender.appenderName.layout.optionN=valueN
142
+ * </pre>
143
+ *
144
+ * <p><b>Configuring loggers</b></p>
145
+ *
146
+ * <p>The syntax for configuring the root logger is:
147
+ * <pre>
148
+ * log4php.rootLogger=[level], appenderName, appenderName, ...
149
+ * </pre>
150
+ *
151
+ * <p>This syntax means that an optional <i>level</i> can be
152
+ * supplied followed by appender names separated by commas.
153
+ *
154
+ * <p>The level value can consist of the string values OFF, FATAL,
155
+ * ERROR, WARN, INFO, DEBUG, ALL or a <i>custom level</i> value. A
156
+ * custom level value can be specified in the form</p>
157
+ *
158
+ * <pre>level#classname</pre>
159
+ *
160
+ * <p>If a level value is specified, then the root level is set
161
+ * to the corresponding level. If no level value is specified,
162
+ * then the root level remains untouched.
163
+ *
164
+ * <p>The root logger can be assigned multiple appenders.
165
+ *
166
+ * <p>Each <i>appenderName</i> (separated by commas) will be added to
167
+ * the root logger. The named appender is defined using the
168
+ * appender syntax defined above.
169
+ *
170
+ * <p>For non-root categories the syntax is almost the same:
171
+ * <pre>
172
+ * log4php.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName, ...
173
+ * </pre>
174
+ *
175
+ * <p>The meaning of the optional level value is discussed above
176
+ * in relation to the root logger. In addition however, the value
177
+ * INHERITED can be specified meaning that the named logger should
178
+ * inherit its level from the logger hierarchy.</p>
179
+ *
180
+ * <p>If no level value is supplied, then the level of the
181
+ * named logger remains untouched.</p>
182
+ *
183
+ * <p>By default categories inherit their level from the
184
+ * hierarchy. However, if you set the level of a logger and later
185
+ * decide that that logger should inherit its level, then you should
186
+ * specify INHERITED as the value for the level value. NULL is a
187
+ * synonym for INHERITED.</p>
188
+ *
189
+ * <p>Similar to the root logger syntax, each <i>appenderName</i>
190
+ * (separated by commas) will be attached to the named logger.</p>
191
+ *
192
+ * <p>See the <i>appender additivity rule</i> in the user manual for
193
+ * the meaning of the <b>additivity</b> flag.
194
+ *
195
+ * <p><b>ObjectRenderers</b></p>
196
+ *
197
+ * <p>You can customize the way message objects of a given type are
198
+ * converted to String before being logged. This is done by
199
+ * specifying a {@link Ipagare_Log4php_Renderers_LoggerRendererObject}
200
+ * for the object type would like to customize.</p>
201
+ *
202
+ * <p>The syntax is:
203
+ *
204
+ * <pre>
205
+ * log4php.renderer.name_of_rendered_class=name_of_rendering.class
206
+ * </pre>
207
+ *
208
+ * As in,
209
+ * <pre>
210
+ * log4php.renderer.myFruit=myFruitRenderer
211
+ * </pre>
212
+ *
213
+ * <p><b>Logger Factories</b></p>
214
+ *
215
+ * The usage of custom logger factories is discouraged and no longer
216
+ * documented.
217
+ *
218
+ * <p><b>Example</b></p>
219
+ *
220
+ * <p>An example configuration is given below. Other configuration
221
+ * file examples are given in the <b>tests</b> folder.
222
+ *
223
+ * <pre>
224
+ * ; Set options for appender named "A1".
225
+ * ; Appender "A1" will be a Ipagare_Log4php_Appenders_LoggerAppenderSyslog
226
+ * log4php.appender.A1=Ipagare_Log4php_Appenders_LoggerAppenderSyslog
227
+ *
228
+ * ; The syslog daemon resides on www.abc.net
229
+ * log4php.appender.A1.ident=log4php-test
230
+ *
231
+ * ; A1's layout is a LoggerPatternLayout, using the conversion pattern
232
+ * ; <b>%r %-5p %c{2} %M.%L %x - %m%n</b>. Thus, the log output will
233
+ * ; include the relative time since the start of the application in
234
+ * ; milliseconds, followed by the level of the log request,
235
+ * ; followed by the two rightmost components of the logger name,
236
+ * ; followed by the callers method name, followed by the line number,
237
+ * ; the nested disgnostic context and finally the message itself.
238
+ * ; Refer to the documentation of LoggerPatternLayout} for further information
239
+ * ; on the syntax of the ConversionPattern key.
240
+ * log4php.appender.A1.layout=LoggerPatternLayout
241
+ * log4php.appender.A1.layout.ConversionPattern="%-4r %-5p %c{2} %M.%L %x - %m%n"
242
+ *
243
+ * ; Set options for appender named "A2"
244
+ * ; A2 should be a Ipagare_Log4php_Appenders_LoggerAppenderRollingFile, with maximum file size of 10 MB
245
+ * ; using at most one backup file. A2's layout is TTCC, using the
246
+ * ; ISO8061 date format with context printing enabled.
247
+ * log4php.appender.A2=Ipagare_Log4php_Appenders_LoggerAppenderRollingFile
248
+ * log4php.appender.A2.MaxFileSize=10MB
249
+ * log4php.appender.A2.MaxBackupIndex=1
250
+ * log4php.appender.A2.layout=Ipagare_Log4php_Layouts_LoggerLayoutTTCC
251
+ * log4php.appender.A2.layout.ContextPrinting="true"
252
+ * log4php.appender.A2.layout.DateFormat="%c"
253
+ *
254
+ * ; Root logger set to DEBUG using the A2 appender defined above.
255
+ * log4php.rootLogger=DEBUG, A2
256
+ *
257
+ * ; Logger definitions:
258
+ * ; The SECURITY logger inherits is level from root. However, it's output
259
+ * ; will go to A1 appender defined above. It's additivity is non-cumulative.
260
+ * log4php.logger.SECURITY=INHERIT, A1
261
+ * log4php.additivity.SECURITY=false
262
+ *
263
+ * ; Only warnings or above will be logged for the logger "SECURITY.access".
264
+ * ; Output will go to A1.
265
+ * log4php.logger.SECURITY.access=WARN
266
+ *
267
+ *
268
+ * ; The logger "class.of.the.day" inherits its level from the
269
+ * ; logger hierarchy. Output will go to the appender's of the root
270
+ * ; logger, A2 in this case.
271
+ * log4php.logger.class.of.the.day=INHERIT
272
+ * </pre>
273
+ *
274
+ * <p>Refer to the <b>setOption</b> method in each Appender and
275
+ * Layout for class specific options.</p>
276
+ *
277
+ * <p>Use the <b>&quot;;&quot;</b> character at the
278
+ * beginning of a line for comments.</p>
279
+ *
280
+ * @param string $url The name of the configuration file where the
281
+ * configuration information is stored.
282
+ * @param Ipagare_Log4php_LoggerHierarchy $repository the repository to apply the configuration
283
+ */
284
+ public function configure(Ipagare_Log4php_LoggerHierarchy $hierarchy, $url = '') {
285
+ $properties = @parse_ini_file($url);
286
+ if ($properties === false) {
287
+ $error = error_get_last();
288
+ throw new Ipagare_Log4php_LoggerException("Ipagare_Log4php_Configurators_LoggerConfiguratorIni: Error parsing configuration file: ".$error['message']);
289
+ }
290
+ if (count($properties) == 0) {
291
+ trigger_error("Ipagare_Log4php_Configurators_LoggerConfiguratorIni: Configuration file is empty.", E_USER_WARNING);
292
+ }
293
+
294
+ return $this->doConfigureProperties($properties, $hierarchy);
295
+ }
296
+
297
+ /**
298
+ * Read configuration options from <b>properties</b>.
299
+ *
300
+ * @see doConfigure().
301
+ * @param array $properties
302
+ * @param Ipagare_Log4php_LoggerHierarchy $hierarchy
303
+ */
304
+ private function doConfigureProperties($properties, Ipagare_Log4php_LoggerHierarchy $hierarchy) {
305
+ $thresholdStr = @$properties[self::THRESHOLD_PREFIX];
306
+ $hierarchy->setThreshold(Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel($thresholdStr, Ipagare_Log4php_LoggerLevel::getLevelAll()));
307
+ $this->configureRootCategory($properties, $hierarchy);
308
+ $this->parseCatsAndRenderers($properties, $hierarchy);
309
+ return true;
310
+ }
311
+
312
+ /**
313
+ * @param array $props array of properties
314
+ * @param Ipagare_Log4php_LoggerHierarchy $hierarchy
315
+ */
316
+ private function configureRootCategory($props, Ipagare_Log4php_LoggerHierarchy $hierarchy) {
317
+ $effectivePrefix = self::ROOT_LOGGER_PREFIX;
318
+ $value = @$props[self::ROOT_LOGGER_PREFIX];
319
+
320
+ if(empty($value)) {
321
+ $value = @$props[self::ROOT_CATEGORY_PREFIX];
322
+ $effectivePrefix = self::ROOT_CATEGORY_PREFIX;
323
+ }
324
+
325
+ if(empty($value)) {
326
+ // TODO "Could not find root logger information. Is this OK?"
327
+ } else {
328
+ $root = $hierarchy->getRootLogger();
329
+ $this->parseCategory($props, $root, $effectivePrefix, self::INTERNAL_ROOT_NAME, $value);
330
+ }
331
+ }
332
+
333
+ /**
334
+ * Parse non-root elements, such non-root categories and renderers.
335
+ *
336
+ * @param array $props array of properties
337
+ * @param Ipagare_Log4php_LoggerHierarchy $hierarchy
338
+ */
339
+ private function parseCatsAndRenderers($props, Ipagare_Log4php_LoggerHierarchy $hierarchy) {
340
+ while(list($key,$value) = each($props)) {
341
+ if(strpos($key, self::CATEGORY_PREFIX) === 0 or
342
+ strpos($key, self::LOGGER_PREFIX) === 0) {
343
+ if(strpos($key, self::CATEGORY_PREFIX) === 0) {
344
+ $loggerName = substr($key, strlen(self::CATEGORY_PREFIX));
345
+ } else if(strpos($key, self::LOGGER_PREFIX) === 0) {
346
+ $loggerName = substr($key, strlen(self::LOGGER_PREFIX));
347
+ }
348
+
349
+ $logger = $hierarchy->getLogger($loggerName);
350
+ $this->parseCategory($props, $logger, $key, $loggerName, $value);
351
+ $this->parseAdditivityForLogger($props, $logger, $loggerName);
352
+ } else if(strpos($key, self::RENDERER_PREFIX) === 0) {
353
+ $renderedClass = substr($key, strlen(self::RENDERER_PREFIX));
354
+ $renderingClass = $value;
355
+ $hierarchy->getRendererMap()->addRenderer($renderedClass, $renderingClass);
356
+ }
357
+ }
358
+ }
359
+
360
+ /**
361
+ * Parse the additivity option for a non-root category.
362
+ *
363
+ * @param array $props array of properties
364
+ * @param Logger $cat
365
+ * @param string $loggerName
366
+ */
367
+ private function parseAdditivityForLogger($props, Ipagare_Log4php_Logger $cat, $loggerName) {
368
+ $value = Ipagare_Log4php_Helpers_LoggerOptionConverter::findAndSubst(self::ADDITIVITY_PREFIX . $loggerName, $props);
369
+ $additivity = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($value, true);
370
+ $cat->setAdditivity($additivity);
371
+ }
372
+
373
+ /**
374
+ * This method must work for the root category as well.
375
+ *
376
+ * @param array $props array of properties
377
+ * @param Ipagare_Log4php_Logger $logger
378
+ * @param string $optionKey
379
+ * @param string $loggerName
380
+ * @param string $value
381
+ * @return Ipagare_Log4php_Logger
382
+ */
383
+ private function parseCategory($props, Ipagare_Log4php_Logger $logger, $optionKey, $loggerName, $value) {
384
+ // We must skip over ',' but not white space
385
+ $st = explode(',', $value);
386
+
387
+ // If value is not in the form ", appender.." or "", then we should set
388
+ // the level of the loggeregory.
389
+
390
+ if(!(empty($value) || @$value[0] == ',')) {
391
+ // just to be on the safe side...
392
+ if(count($st) == 0) {
393
+ return;
394
+ }
395
+ $levelStr = current($st);
396
+
397
+ // If the level value is inherited, set category level value to
398
+ // null. We also check that the user has not specified inherited for the
399
+ // root category.
400
+ if('INHERITED' == strtoupper($levelStr) || 'NULL' == strtoupper($levelStr)) {
401
+ if($loggerName == self::INTERNAL_ROOT_NAME) {
402
+ // TODO: throw exception? "The root logger cannot be set to null."
403
+ } else {
404
+ $logger->setLevel(null);
405
+ }
406
+ } else {
407
+ $logger->setLevel(Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel($levelStr, Ipagare_Log4php_LoggerLevel::getLevelDebug()));
408
+ }
409
+ }
410
+
411
+ // TODO: removing should be done by the logger, if necessary and wanted
412
+ // $logger->removeAllAppenders();
413
+ while($appenderName = next($st)) {
414
+ $appenderName = trim($appenderName);
415
+ if(empty($appenderName)) {
416
+ continue;
417
+ }
418
+
419
+ $appender = $this->parseAppender($props, $appenderName);
420
+ if($appender !== null) {
421
+ $logger->addAppender($appender);
422
+ }
423
+ }
424
+ }
425
+
426
+ /**
427
+ * @param array $props array of properties
428
+ * @param string $appenderName
429
+ * @return Ipagare_Log4php_LoggerAppender
430
+ */
431
+ private function parseAppender($props, $appenderName) {
432
+ $appender = Ipagare_Log4php_LoggerAppenderPool::getAppenderFromPool($appenderName);
433
+ $prefix = self::APPENDER_PREFIX . $appenderName;
434
+ if($appender === null) {
435
+ // Appender was not previously initialized.
436
+ $appenderClass = @$props[$prefix];
437
+ $appender = Ipagare_Log4php_LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderClass);
438
+ if($appender === null) {
439
+ return null;
440
+ }
441
+ }
442
+
443
+ if($appender->requiresLayout() ) {
444
+ $layoutPrefix = $prefix . ".layout";
445
+ $layoutClass = @$props[$layoutPrefix];
446
+ $layoutClass = Ipagare_Log4php_Helpers_LoggerOptionConverter::substVars($layoutClass, $props);
447
+ if(empty($layoutClass)) {
448
+ $layout = Ipagare_Log4php_LoggerReflectionUtils::createObject('Ipagare_Log4php_Layouts_LoggerLayoutSimple');
449
+ } else {
450
+ $layout = Ipagare_Log4php_LoggerReflectionUtils::createObject($layoutClass);
451
+ if($layout === null) {
452
+ $layout = Ipagare_Log4php_LoggerReflectionUtils::createObject('Ipagare_Log4php_Layouts_LoggerLayoutSimple');
453
+ }
454
+ }
455
+
456
+ Ipagare_Log4php_LoggerReflectionUtils::setPropertiesByObject($layout, $props, $layoutPrefix . ".");
457
+ $appender->setLayout($layout);
458
+
459
+ }
460
+ Ipagare_Log4php_LoggerReflectionUtils::setPropertiesByObject($appender, $props, $prefix . ".");
461
+ return $appender;
462
+ }
463
+ }
lib/Ipagare/Log4php/Configurators/LoggerConfiguratorPhp.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Ipagare_Log4php_Configurators_LoggerConfiguratorPhp class
23
+ *
24
+ * This class allows configuration of log4php through a PHP array or an external file that
25
+ * returns a PHP array. If you use the PHP array option, you can simply give an array instead
26
+ * of an URL parameter.
27
+ *
28
+ * An example for this configurator is:
29
+ *
30
+ * {@example ../../examples/php/configurator_php.php 19}
31
+ *
32
+ * Which includes the following snippet:
33
+ *
34
+ * {@example ../../examples/resources/configurator_php.php 18}
35
+ *
36
+ * @package log4php
37
+ * @subpackage configurators
38
+ * @since 2.0
39
+ */
40
+ class Ipagare_Log4php_Configurators_LoggerConfiguratorPhp implements Ipagare_Log4php_LoggerConfigurator {
41
+
42
+ public function configure(Ipagare_Log4php_LoggerHierarchy $hierarchy, $url = '') {
43
+ return $this->doConfigure($url, $hierarchy);
44
+ }
45
+
46
+ private function doConfigure($url, Ipagare_Log4php_LoggerHierarchy $hierarchy) {
47
+ if (!is_array($url)) {
48
+ $config = require $url;
49
+ } else {
50
+ $config = $url;
51
+ }
52
+
53
+ // set threshold
54
+ if(isset($config['threshold'])) {
55
+ $hierarchy->setThreshold(Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel($config['threshold'], Ipagare_Log4php_LoggerLevel::getLevelAll()));
56
+ }
57
+
58
+ // add renderes
59
+ if (isset($config['renderers'])) {
60
+ foreach ($config['renderers'] as $renderedClass => $renderingClass) {
61
+ $hierarchy->getRendererMap()->addRenderer($renderedClass, $renderingClass);
62
+ }
63
+ }
64
+
65
+ // parse and create appenders
66
+ if(isset($config['appenders'])) {
67
+
68
+ foreach($config['appenders'] as $appenderName => $appenderProperties) {
69
+
70
+ $appender = Ipagare_Log4php_LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderProperties['class']);
71
+
72
+ // unset so that the property wont be drawn up again
73
+ unset($appenderProperties['class']);
74
+
75
+ if($appender->requiresLayout()) {
76
+
77
+ if(isset($appenderProperties['layout'])) {
78
+
79
+ if(isset($appenderProperties['layout']['class']) and !empty($appenderProperties['layout']['class'])) {
80
+ $layoutClass = $appenderProperties['layout']['class'];
81
+ } else {
82
+ $layoutClass = 'Ipagare_Log4php_Layouts_LoggerLayoutSimple';
83
+ }
84
+
85
+ $layout = Ipagare_Log4php_LoggerReflectionUtils::createObject($layoutClass);
86
+ if($layout === null) {
87
+ $layout = Ipagare_Log4php_LoggerReflectionUtils::createObject('Ipagare_Log4php_Layouts_LoggerLayoutSimple');
88
+ }
89
+
90
+ if(isset($appenderProperties['file']) && method_exists($appender, 'setFileName')) {
91
+ $appender->setFile($appenderProperties['file'], true);
92
+ }
93
+
94
+ if($layout instanceof Ipagare_Log4php_Layouts_LoggerLayoutPattern) {
95
+ $layout->setConversionPattern($appenderProperties['layout']['conversionPattern']);
96
+ }
97
+
98
+ $appender->setLayout($layout);
99
+
100
+ // unset so that the property wont be drawn up again
101
+ unset($appenderProperties['layout']);
102
+ } else {
103
+ // TODO: throw exception?
104
+ }
105
+
106
+ }
107
+ // set remaining properties and activate appender
108
+ $setter = new Ipagare_Log4php_LoggerReflectionUtils($appender);
109
+ foreach ($appenderProperties as $key => $val) {
110
+ $setter->setProperty($key, $val);
111
+ }
112
+ $setter->activate();
113
+ }
114
+
115
+ }
116
+
117
+ // parse and create root logger
118
+ if(isset($config['rootLogger'])) {
119
+ $rootLogger = $hierarchy->getRootLogger();
120
+ if(isset($config['rootLogger']['level'])) {
121
+ $rootLogger->setLevel(Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel($config['rootLogger']['level'], Ipagare_Log4php_LoggerLevel::getLevelDebug()));
122
+ if(isset($config['rootLogger']['appenders'])) {
123
+ foreach($config['rootLogger']['appenders'] as $appenderName) {
124
+ $appender = Ipagare_Log4php_LoggerAppenderPool::getAppenderFromPool($appenderName);
125
+ if($appender !== null) {
126
+ $rootLogger->addAppender($appender);
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+
133
+ // parse and create loggers
134
+ if(isset($config['loggers'])) {
135
+ foreach($config['loggers'] as $loggerName => $loggerProperties) {
136
+ if(is_string($loggerName)) {
137
+ $logger = $hierarchy->getLogger($loggerName);
138
+
139
+ if(isset($loggerProperties['level'])) {
140
+ $logger->setLevel(Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel($loggerProperties['level'], Ipagare_Log4php_LoggerLevel::getLevelDebug()));
141
+ if(isset($loggerProperties['appenders'])) {
142
+ foreach($loggerProperties['appenders'] as $appenderName) {
143
+ $appender = Ipagare_Log4php_LoggerAppenderPool::getAppenderFromPool($appenderName);
144
+ if($appender !== null) {
145
+ $logger->addAppender($appender);
146
+ }
147
+ }
148
+ }
149
+ }
150
+ } else {
151
+ // TODO: throw exception
152
+ }
153
+ }
154
+ }
155
+
156
+ return true;
157
+ }
158
+
159
+ }
lib/Ipagare/Log4php/Configurators/LoggerConfiguratorXml.php ADDED
@@ -0,0 +1,441 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Use this class to initialize the log4php environment using XML files.
23
+ *
24
+ * <p>Read the log4php.dtd included in the documentation directory. Note that
25
+ * php parser does not validate the document.</p>
26
+ *
27
+ * <p>Sometimes it is useful to see how log4php is reading configuration
28
+ * files. You can enable log4php internal logging by setting the <var>debug</var>
29
+ * attribute in the <var>log4php:configuration</var> element.</p>
30
+ *
31
+ * <p>An example for this configurator:</p>
32
+ *
33
+ * {@example ../../examples/php/configurator_xml.php 19}<br>
34
+ *
35
+ * <p>The corresponding XML file:</p>
36
+ *
37
+ * {@example ../../examples/resources/configurator_xml.xml 18}
38
+ *
39
+ * <p>There are more sample XML files included in the package under tests/ subdirectories.</p>
40
+ *
41
+ * @version $Revision: 1059292 $
42
+ * @package log4php
43
+ * @subpackage configurators
44
+ * @since 0.4
45
+ */
46
+ class Ipagare_Log4php_Configurators_LoggerConfiguratorXml implements Ipagare_Log4php_LoggerConfigurator {
47
+ const APPENDER_STATE = 1000;
48
+ const LAYOUT_STATE = 1010;
49
+ const ROOT_STATE = 1020;
50
+ const LOGGER_STATE = 1030;
51
+ const FILTER_STATE = 1040;
52
+
53
+ const DEFAULT_FILENAME = './log4php.xml';
54
+
55
+ /**
56
+ * @var string the default configuration document
57
+ */
58
+ const DEFAULT_CONFIGURATION =
59
+ '<?xml version="1.0" ?>
60
+ <log4php:configuration threshold="all">
61
+ <appender name="A1" class="Ipagare_Log4php_Appenders_LoggerAppenderEcho">
62
+ <layout class="Ipagare_Log4php_Layouts_LoggerLayoutSimple" />
63
+ </appender>
64
+ <root>
65
+ <level value="debug" />
66
+ <appender_ref ref="A1" />
67
+ </root>
68
+ </log4php:configuration>';
69
+
70
+ /**
71
+ * @var string the elements namespace
72
+ */
73
+ const XMLNS = 'HTTP://LOGGING.APACHE.ORG/LOG4PHP/';
74
+
75
+ /**
76
+ * @var Ipagare_Log4php_LoggerHierarchy
77
+ */
78
+ private $repository;
79
+
80
+ /**
81
+ * @var array state stack
82
+ */
83
+ private $state;
84
+
85
+ /**
86
+ * @var Ipagare_Log4php_Logger parsed Logger
87
+ */
88
+ private $logger;
89
+
90
+ /**
91
+ * @var Ipagare_Log4php_LoggerAppender parsed Ipagare_Log4php_LoggerAppender
92
+ */
93
+ private $appender;
94
+
95
+ /**
96
+ * @var Ipagare_Log4php_LoggerFilter parsed Ipagare_Log4php_LoggerFilter
97
+ */
98
+ private $filter;
99
+
100
+ /**
101
+ * @var Ipagare_Log4php_LoggerLayout parsed Ipagare_Log4php_LoggerLayout
102
+ */
103
+ private $layout;
104
+
105
+ /**
106
+ * Constructor
107
+ */
108
+ public function __construct() {
109
+ $this->state = array();
110
+ $this->logger = null;
111
+ $this->appender = null;
112
+ $this->filter = null;
113
+ $this->layout = null;
114
+ }
115
+
116
+ /**
117
+ * Configure the default repository using the resource pointed by <b>url</b>.
118
+ * <b>Url</b> is any valid resource as defined in {@link PHP_MANUAL#file} function.
119
+ * Note that the resource will be search with <i>use_include_path</i> parameter
120
+ * set to "1".
121
+ *
122
+ * @param string $url
123
+ * @static
124
+ */
125
+ public function configure(Ipagare_Log4php_LoggerHierarchy $hierarchy, $url = '') {
126
+ return $this->doConfigure($url, $hierarchy);
127
+ }
128
+
129
+ /**
130
+ * Configure the given <b>repository</b> using the resource pointed by <b>url</b>.
131
+ * <b>Url</b> is any valid resurce as defined in {@link PHP_MANUAL#file} function.
132
+ * Note that the resource will be search with <i>use_include_path</i> parameter
133
+ * set to "1".
134
+ *
135
+ * @param string $url
136
+ * @param Ipagare_Log4php_LoggerHierarchy $repository
137
+ */
138
+ private function doConfigure($url = '', Ipagare_Log4php_LoggerHierarchy $repository)
139
+ {
140
+ $xmlData = '';
141
+ if (!empty($url))
142
+ $xmlData = implode('', file($url, 1));
143
+ return $this->doConfigureByString($xmlData, $repository);
144
+ }
145
+
146
+ /**
147
+ * Configure the given <b>repository</b> using the configuration written in <b>xmlData</b>.
148
+ * Do not call this method directly. Use {@link doConfigure()} instead.
149
+ * @param string $xmlData
150
+ * @param Ipagare_Log4php_LoggerHierarchy $repository
151
+ */
152
+ private function doConfigureByString($xmlData, Ipagare_Log4php_LoggerHierarchy $repository)
153
+ {
154
+ return $this->parse($xmlData, $repository);
155
+ }
156
+
157
+ /**
158
+ * @param Ipagare_Log4php_LoggerHierarchy $repository
159
+ */
160
+ private function doConfigureDefault(Ipagare_Log4php_LoggerHierarchy $repository)
161
+ {
162
+ return $this->doConfigureByString(self::DEFAULT_CONFIGURATION, $repository);
163
+ }
164
+
165
+ /**
166
+ * @param string $xmlData
167
+ */
168
+ private function parse($xmlData, Ipagare_Log4php_LoggerHierarchy $repository)
169
+ {
170
+ // Logger::resetConfiguration();
171
+ $this->repository = $repository;
172
+
173
+ $parser = xml_parser_create_ns();
174
+
175
+ xml_set_object($parser, $this);
176
+ xml_set_element_handler($parser, "tagOpen", "tagClose");
177
+
178
+ $result = xml_parse($parser, $xmlData, true);
179
+ if (!$result) {
180
+ $errorCode = xml_get_error_code($parser);
181
+ $errorStr = xml_error_string($errorCode);
182
+ $errorLine = xml_get_current_line_number($parser);
183
+ $this->repository->resetConfiguration();
184
+ } else {
185
+ xml_parser_free($parser);
186
+ }
187
+ return $result;
188
+ }
189
+
190
+ /**
191
+ * @param mixed $parser
192
+ * @param string $tag
193
+ * @param array $attribs
194
+ *
195
+ * @todo In 'LOGGER' case find a better way to detect 'getLogger()' method
196
+ */
197
+ private function tagOpen($parser, $tag, $attribs)
198
+ {
199
+ switch ($tag) {
200
+
201
+ case 'CONFIGURATION' :
202
+ case self::XMLNS.':CONFIGURATION':
203
+
204
+ if (isset($attribs['THRESHOLD'])) {
205
+
206
+ $this->repository->setThreshold(
207
+ Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel(
208
+ $this->subst($attribs['THRESHOLD']),
209
+ $this->repository->getThreshold()
210
+ )
211
+ );
212
+ }
213
+ break;
214
+
215
+ case 'APPENDER' :
216
+ case self::XMLNS.':APPENDER':
217
+
218
+ unset($this->appender);
219
+ $this->appender = null;
220
+
221
+ $name = $this->subst(@$attribs['NAME']);
222
+ $class = $this->subst(@$attribs['CLASS']);
223
+
224
+ $this->appender = Ipagare_Log4php_LoggerAppenderPool::getAppenderFromPool($name, $class);
225
+
226
+ if (isset($attribs['THRESHOLD'])) {
227
+ $this->appender->setThreshold(
228
+ Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel(
229
+ $this->subst($attribs['THRESHOLD']), $this->appender->getThreshold()));
230
+ }
231
+
232
+ $this->state[] = self::APPENDER_STATE;
233
+ break;
234
+
235
+ case 'APPENDER_REF' :
236
+ case 'APPENDER-REF' :
237
+ case self::XMLNS.':APPENDER_REF':
238
+ case self::XMLNS.':APPENDER-REF':
239
+ if (isset($attribs['REF']) and !empty($attribs['REF'])) {
240
+ $appenderName = $this->subst($attribs['REF']);
241
+
242
+ $appender = Ipagare_Log4php_LoggerAppenderPool::getAppenderFromPool($appenderName);
243
+ if ($appender !== null) {
244
+ switch (end($this->state)) {
245
+ case self::LOGGER_STATE:
246
+ case self::ROOT_STATE:
247
+ $this->logger->addAppender($appender);
248
+ break;
249
+ }
250
+ }
251
+ }
252
+ break;
253
+
254
+ case 'FILTER' :
255
+ case self::XMLNS.':FILTER':
256
+ unset($this->filter);
257
+ $this->filter = null;
258
+
259
+ $filterName = basename($this->subst(@$attribs['CLASS']));
260
+ if (!empty($filterName)) {
261
+ $this->filter = new $filterName();
262
+ $this->state[] = self::FILTER_STATE;
263
+ }
264
+ break;
265
+
266
+ case 'LAYOUT':
267
+ case self::XMLNS.':LAYOUT':
268
+ $class = @$attribs['CLASS'];
269
+ $this->layout = Ipagare_Log4php_LoggerReflectionUtils::createObject($this->subst($class));
270
+ $this->state[] = self::LAYOUT_STATE;
271
+ break;
272
+
273
+ case 'LOGGER':
274
+ case self::XMLNS.':LOGGER':
275
+ // $this->logger is assigned by reference.
276
+ // Only '$this->logger=null;' destroys referenced object
277
+ unset($this->logger);
278
+ $this->logger = null;
279
+
280
+ $loggerName = $this->subst(@$attribs['NAME']);
281
+ if (!empty($loggerName)) {
282
+ $this->logger = $this->repository->getLogger($loggerName);
283
+ if ($this->logger !== null and isset($attribs['ADDITIVITY'])) {
284
+ $additivity = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($this->subst($attribs['ADDITIVITY']), true);
285
+ $this->logger->setAdditivity($additivity);
286
+ }
287
+ }
288
+ $this->state[] = self::LOGGER_STATE;;
289
+ break;
290
+
291
+ case 'LEVEL':
292
+ case self::XMLNS.':LEVEL':
293
+ case 'PRIORITY':
294
+ case self::XMLNS.':PRIORITY':
295
+
296
+ if (!isset($attribs['VALUE'])) {
297
+ // LoggerDOMConfigurator::tagOpen() LEVEL value not set
298
+ break;
299
+ }
300
+
301
+ if ($this->logger === null) {
302
+ // LoggerDOMConfigurator::tagOpen() LEVEL. parent logger is null
303
+ break;
304
+ }
305
+
306
+ switch (end($this->state)) {
307
+ case self::ROOT_STATE:
308
+ $this->logger->setLevel(
309
+ Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel(
310
+ $this->subst($attribs['VALUE']),
311
+ $this->logger->getLevel()
312
+ )
313
+ );
314
+ break;
315
+ case self::LOGGER_STATE:
316
+ $this->logger->setLevel(
317
+ Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel(
318
+ $this->subst($attribs['VALUE']),
319
+ $this->logger->getLevel()
320
+ )
321
+ );
322
+ break;
323
+ default:
324
+ //LoggerLog::warn("LoggerDOMConfigurator::tagOpen() LEVEL state '{$this->state}' not allowed here");
325
+ }
326
+ break;
327
+
328
+ case 'PARAM':
329
+ case self::XMLNS.':PARAM':
330
+ if (!isset($attribs['NAME'])) {
331
+ // LoggerDOMConfigurator::tagOpen() PARAM attribute 'name' not defined.
332
+ break;
333
+ }
334
+ if (!isset($attribs['VALUE'])) {
335
+ // LoggerDOMConfigurator::tagOpen() PARAM. attribute 'value' not defined.
336
+ break;
337
+ }
338
+
339
+ switch (end($this->state)) {
340
+ case self::APPENDER_STATE:
341
+ if ($this->appender !== null) {
342
+ Ipagare_Log4php_LoggerReflectionUtils::setter($this->appender, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE']));
343
+ }
344
+ break;
345
+ case self::LAYOUT_STATE:
346
+ if ($this->layout !== null) {
347
+ Ipagare_Log4php_LoggerReflectionUtils::setter($this->layout, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE']));
348
+ }
349
+ break;
350
+ case self::FILTER_STATE:
351
+ if ($this->filter !== null) {
352
+ Ipagare_Log4php_LoggerReflectionUtils::setter($this->filter, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE']));
353
+ }
354
+ break;
355
+ default:
356
+ //LoggerLog::warn("LoggerDOMConfigurator::tagOpen() PARAM state '{$this->state}' not allowed here");
357
+ }
358
+ break;
359
+
360
+ case 'RENDERER':
361
+ case self::XMLNS.':RENDERER':
362
+
363
+ $renderedClass = $this->subst(@$attribs['RENDEREDCLASS']);
364
+ $renderingClass = $this->subst(@$attribs['RENDERINGCLASS']);
365
+
366
+ if (!empty($renderedClass) and !empty($renderingClass)) {
367
+ $this->repository->getRendererMap()->addRenderer($renderedClass, $renderingClass);
368
+ }
369
+ break;
370
+
371
+ case 'ROOT':
372
+ case self::XMLNS.':ROOT':
373
+ $this->logger = Ipagare_Log4php_Logger::getRootLogger();
374
+ $this->state[] = self::ROOT_STATE;
375
+ break;
376
+ }
377
+ }
378
+
379
+
380
+ /**
381
+ * @param mixed $parser
382
+ * @param string $tag
383
+ */
384
+ private function tagClose($parser, $tag)
385
+ {
386
+ switch ($tag) {
387
+
388
+ case 'CONFIGURATION' :
389
+ case self::XMLNS.':CONFIGURATION':
390
+ break;
391
+
392
+ case 'APPENDER' :
393
+ case self::XMLNS.':APPENDER':
394
+ if ($this->appender !== null) {
395
+ if ($this->appender->requiresLayout() and $this->appender->getLayout() === null) {
396
+ $appenderName = $this->appender->getName();
397
+ $this->appender->setLayout(Ipagare_Log4php_LoggerReflectionUtils::createObject('Ipagare_Log4php_Layouts_LoggerLayoutSimple'));
398
+ }
399
+ $this->appender->activateOptions();
400
+ }
401
+ array_pop($this->state);
402
+ break;
403
+
404
+ case 'FILTER' :
405
+ case self::XMLNS.':FILTER':
406
+ if ($this->filter !== null) {
407
+ $this->filter->activateOptions();
408
+ $this->appender->addFilter($this->filter);
409
+ $this->filter = null;
410
+ }
411
+ array_pop($this->state);
412
+ break;
413
+
414
+ case 'LAYOUT':
415
+ case self::XMLNS.':LAYOUT':
416
+ if ($this->appender !== null and $this->layout !== null and $this->appender->requiresLayout()) {
417
+ $this->layout->activateOptions();
418
+ $this->appender->setLayout($this->layout);
419
+ $this->layout = null;
420
+ }
421
+ array_pop($this->state);
422
+ break;
423
+
424
+ case 'LOGGER':
425
+ case self::XMLNS.':LOGGER':
426
+ array_pop($this->state);
427
+ break;
428
+
429
+ case 'ROOT':
430
+ case self::XMLNS.':ROOT':
431
+ array_pop($this->state);
432
+ break;
433
+ }
434
+ }
435
+
436
+ private function subst($value)
437
+ {
438
+ return Ipagare_Log4php_Helpers_LoggerOptionConverter::substVars($value);
439
+ }
440
+
441
+ }
lib/Ipagare/Log4php/Filters/LoggerFilterDenyAll.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * This filter drops all logging events.
23
+ *
24
+ * You can add this filter to the end of a filter chain to
25
+ * switch from the default "accept all unless instructed otherwise"
26
+ * filtering behaviour to a "deny all unless instructed otherwise"
27
+ * behaviour.
28
+ *
29
+ * <p>
30
+ * An example for this filter:
31
+ *
32
+ * {@example ../../examples/php/filter_denyall.php 19}
33
+ *
34
+ * <p>
35
+ * The corresponding XML file:
36
+ *
37
+ * {@example ../../examples/resources/filter_denyall.xml 18}
38
+ *
39
+ * @version $Revision: 883108 $
40
+ * @package log4php
41
+ * @subpackage filters
42
+ * @since 0.3
43
+ */
44
+ class Ipagare_Log4php_Filters_LoggerFilterDenyAll extends Ipagare_Log4php_LoggerFilter {
45
+
46
+ /**
47
+ * Always returns the integer constant {@link Ipagare_Log4php_LoggerFilter::DENY}
48
+ * regardless of the {@link Ipagare_Log4php_LoggerLoggingEvent} parameter.
49
+ *
50
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event The {@link Ipagare_Log4php_LoggerLoggingEvent} to filter.
51
+ * @return Ipagare_Log4php_LoggerFilter::DENY Always returns {@link Ipagare_Log4php_LoggerFilter::DENY}
52
+ */
53
+ public function decide(Ipagare_Log4php_LoggerLoggingEvent $event) {
54
+ return Ipagare_Log4php_LoggerFilter::DENY;
55
+ }
56
+ }
lib/Ipagare/Log4php/Filters/LoggerFilterLevelMatch.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * This is a very simple filter based on level matching.
23
+ *
24
+ * <p>The filter admits two options <b><var>LevelToMatch</var></b> and
25
+ * <b><var>AcceptOnMatch</var></b>. If there is an exact match between the value
26
+ * of the <b><var>LevelToMatch</var></b> option and the level of the
27
+ * {@link Ipagare_Log4php_LoggerLoggingEvent}, then the {@link decide()} method returns
28
+ * {@link Ipagare_Log4php_LoggerFilter::ACCEPT} in case the <b><var>AcceptOnMatch</var></b>
29
+ * option value is set to <i>true</i>, if it is <i>false</i> then
30
+ * {@link Ipagare_Log4php_LoggerFilter::DENY} is returned. If there is no match,
31
+ * {@link Ipagare_Log4php_LoggerFilter::NEUTRAL} is returned.</p>
32
+ *
33
+ * <p>
34
+ * An example for this filter:
35
+ *
36
+ * {@example ../../examples/php/filter_levelmatch.php 19}
37
+ *
38
+ * <p>
39
+ * The corresponding XML file:
40
+ *
41
+ * {@example ../../examples/resources/filter_levelmatch.xml 18}
42
+ *
43
+ * @version $Revision: 1059292 $
44
+ * @package log4php
45
+ * @subpackage filters
46
+ * @since 0.6
47
+ */
48
+ class Ipagare_Log4php_Filters_LoggerFilterLevelMatch extends Ipagare_Log4php_LoggerFilter {
49
+
50
+ /**
51
+ * Indicates if this event should be accepted or denied on match
52
+ * @var boolean
53
+ */
54
+ private $acceptOnMatch = true;
55
+
56
+ /**
57
+ * The level, when to match
58
+ * @var Ipagare_Log4php_LoggerLevel
59
+ */
60
+ private $levelToMatch;
61
+
62
+ /**
63
+ * @param boolean $acceptOnMatch
64
+ */
65
+ public function setAcceptOnMatch($acceptOnMatch) {
66
+ $this->acceptOnMatch = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($acceptOnMatch, true);
67
+ }
68
+
69
+ /**
70
+ * @param string $l the level to match
71
+ */
72
+ public function setLevelToMatch($l) {
73
+ if($l instanceof Ipagare_Log4php_LoggerLevel) {
74
+ $this->levelToMatch = $l;
75
+ } else {
76
+ $this->levelToMatch = Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel($l, null);
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Return the decision of this filter.
82
+ *
83
+ * Returns {@link Ipagare_Log4php_LoggerFilter::NEUTRAL} if the <b><var>LevelToMatch</var></b>
84
+ * option is not set or if there is not match. Otherwise, if there is a
85
+ * match, then the returned decision is {@link Ipagare_Log4php_LoggerFilter::ACCEPT} if the
86
+ * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The
87
+ * returned decision is {@link Ipagare_Log4php_LoggerFilter::DENY} if the
88
+ * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>.
89
+ *
90
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
91
+ * @return integer
92
+ */
93
+ public function decide(Ipagare_Log4php_LoggerLoggingEvent $event) {
94
+ if($this->levelToMatch === null) {
95
+ return Ipagare_Log4php_LoggerFilter::NEUTRAL;
96
+ }
97
+
98
+ if($this->levelToMatch->equals($event->getLevel())) {
99
+ return $this->acceptOnMatch ? Ipagare_Log4php_LoggerFilter::ACCEPT : Ipagare_Log4php_LoggerFilter::DENY;
100
+ } else {
101
+ return Ipagare_Log4php_LoggerFilter::NEUTRAL;
102
+ }
103
+ }
104
+ }
lib/Ipagare/Log4php/Filters/LoggerFilterLevelRange.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * This is a very simple filter based on level matching, which can be
23
+ * used to reject messages with priorities outside a certain range.
24
+ *
25
+ * <p>The filter admits three options <b><var>LevelMin</var></b>, <b><var>LevelMax</var></b>
26
+ * and <b><var>AcceptOnMatch</var></b>.</p>
27
+ *
28
+ * <p>If the level of the {@link Ipagare_Log4php_LoggerLoggingEvent} is not between Min and Max
29
+ * (inclusive), then {@link Ipagare_Log4php_LoggerFilter::DENY} is returned.</p>
30
+ *
31
+ * <p>If the Logging event level is within the specified range, then if
32
+ * <b><var>AcceptOnMatch</var></b> is <i>true</i>,
33
+ * {@link Ipagare_Log4php_LoggerFilter::ACCEPT} is returned, and if
34
+ * <b><var>AcceptOnMatch</var></b> is <i>false</i>,
35
+ * {@link Ipagare_Log4php_LoggerFilter::NEUTRAL} is returned.</p>
36
+ *
37
+ * <p>If <b><var>LevelMin</var></b> is not defined, then there is no
38
+ * minimum acceptable level (i.e. a level is never rejected for
39
+ * being too "low"/unimportant). If <b><var>LevelMax</var></b> is not
40
+ * defined, then there is no maximum acceptable level (ie a
41
+ * level is never rejected for being too "high"/important).</p>
42
+ *
43
+ * <p>Refer to the {@link Ipagare_Log4php_LoggerAppender::setThreshold()} method
44
+ * available to <b>all</b> appenders extending {@link Ipagare_Log4php_LoggerAppender}
45
+ * for a more convenient way to filter out events by level.</p>
46
+ *
47
+ * <p>
48
+ * An example for this filter:
49
+ *
50
+ * {@example ../../examples/php/filter_levelrange.php 19}
51
+ *
52
+ * <p>
53
+ * The corresponding XML file:
54
+ *
55
+ * {@example ../../examples/resources/filter_levelrange.xml 18}
56
+ *
57
+ * @author Simon Kitching
58
+ * @author based on the org.apache.log4j.varia.LevelRangeFilte Java code by Ceki G&uuml;lc&uuml;
59
+ *
60
+ * @version $Revision: 1059292 $
61
+ * @package log4php
62
+ * @subpackage filters
63
+ * @since 0.6
64
+ */
65
+ class Ipagare_Log4php_Filters_LoggerFilterLevelRange extends Ipagare_Log4php_LoggerFilter {
66
+
67
+ /**
68
+ * @var boolean
69
+ */
70
+ private $acceptOnMatch = true;
71
+
72
+ /**
73
+ * @var Ipagare_Log4php_LoggerLevel
74
+ */
75
+ private $levelMin;
76
+
77
+ /**
78
+ * @var Ipagare_Log4php_LoggerLevel
79
+ */
80
+ private $levelMax;
81
+
82
+ /**
83
+ * @param boolean $acceptOnMatch
84
+ */
85
+ public function setAcceptOnMatch($acceptOnMatch) {
86
+ $this->acceptOnMatch = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($acceptOnMatch, true);
87
+ }
88
+
89
+ /**
90
+ * @param string $l the level min to match
91
+ */
92
+ public function setLevelMin($l) {
93
+ if($l instanceof Ipagare_Log4php_LoggerLevel) {
94
+ $this->levelMin = $l;
95
+ } else {
96
+ $this->levelMin = Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel($l, null);
97
+ }
98
+ }
99
+
100
+ /**
101
+ * @param string $l the level max to match
102
+ */
103
+ public function setLevelMax($l) {
104
+ if($l instanceof Ipagare_Log4php_LoggerLevel) {
105
+ $this->levelMax = $l;
106
+ } else {
107
+ $this->levelMax = Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel($l, null);
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Return the decision of this filter.
113
+ *
114
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
115
+ * @return integer
116
+ */
117
+ public function decide(Ipagare_Log4php_LoggerLoggingEvent $event) {
118
+ $level = $event->getLevel();
119
+
120
+ if($this->levelMin !== null) {
121
+ if($level->isGreaterOrEqual($this->levelMin) == false) {
122
+ // level of event is less than minimum
123
+ return Ipagare_Log4php_LoggerFilter::DENY;
124
+ }
125
+ }
126
+
127
+ if($this->levelMax !== null) {
128
+ if($level->toInt() > $this->levelMax->toInt()) {
129
+ // level of event is greater than maximum
130
+ // Alas, there is no Level.isGreater method. and using
131
+ // a combo of isGreaterOrEqual && !Equal seems worse than
132
+ // checking the int values of the level objects..
133
+ return Ipagare_Log4php_LoggerFilter::DENY;
134
+ }
135
+ }
136
+
137
+ if($this->acceptOnMatch) {
138
+ // this filter set up to bypass later filters and always return
139
+ // accept if level in range
140
+ return Ipagare_Log4php_LoggerFilter::ACCEPT;
141
+ } else {
142
+ // event is ok for this filter; allow later filters to have a look..
143
+ return Ipagare_Log4php_LoggerFilter::NEUTRAL;
144
+ }
145
+ }
146
+ }
lib/Ipagare/Log4php/Filters/LoggerFilterStringMatch.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * This is a very simple filter based on string matching.
23
+ *
24
+ * <p>The filter admits two options {@link $stringToMatch} and
25
+ * {@link $acceptOnMatch}. If there is a match (using {@link PHP_MANUAL#strpos}
26
+ * between the value of the {@link $stringToMatch} option and the message
27
+ * of the {@link Ipagare_Log4php_LoggerLoggingEvent},
28
+ * then the {@link decide()} method returns {@link Ipagare_Log4php_LoggerFilter::ACCEPT} if
29
+ * the <b>AcceptOnMatch</b> option value is true, if it is false then
30
+ * {@link Ipagare_Log4php_LoggerFilter::DENY} is returned. If there is no match, {@link Ipagare_Log4php_LoggerFilter::NEUTRAL}
31
+ * is returned.</p>
32
+ *
33
+ * <p>
34
+ * An example for this filter:
35
+ *
36
+ * {@example ../../examples/php/filter_stringmatch.php 19}
37
+ *
38
+ * <p>
39
+ * The corresponding XML file:
40
+ *
41
+ * {@example ../../examples/resources/filter_stringmatch.xml 18}
42
+ *
43
+ * @version $Revision: 883108 $
44
+ * @package log4php
45
+ * @subpackage filters
46
+ * @since 0.3
47
+ */
48
+ class Ipagare_Log4php_Filters_LoggerFilterStringMatch extends Ipagare_Log4php_LoggerFilter {
49
+
50
+ /**
51
+ * @var boolean
52
+ */
53
+ private $acceptOnMatch = true;
54
+
55
+ /**
56
+ * @var string
57
+ */
58
+ private $stringToMatch = null;
59
+
60
+ /**
61
+ * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
62
+ */
63
+ public function setAcceptOnMatch($acceptOnMatch) {
64
+ $this->acceptOnMatch = is_bool($acceptOnMatch) ? $acceptOnMatch : (bool)(strtolower($acceptOnMatch) == 'true');
65
+ }
66
+
67
+ /**
68
+ * @param string $s the string to match
69
+ */
70
+ public function setStringToMatch($s) {
71
+ $this->stringToMatch = $s;
72
+ }
73
+
74
+ /**
75
+ * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
76
+ */
77
+ public function decide(Ipagare_Log4php_LoggerLoggingEvent $event) {
78
+ $msg = $event->getRenderedMessage();
79
+
80
+ if($msg === null or $this->stringToMatch === null) {
81
+ return Ipagare_Log4php_LoggerFilter::NEUTRAL;
82
+ }
83
+
84
+ if(strpos($msg, $this->stringToMatch) !== false ) {
85
+ return ($this->acceptOnMatch) ? Ipagare_Log4php_LoggerFilter::ACCEPT : Ipagare_Log4php_LoggerFilter::DENY;
86
+ }
87
+ return Ipagare_Log4php_LoggerFilter::NEUTRAL;
88
+ }
89
+ }
lib/Ipagare/Log4php/Helpers/LoggerBasicPatternConverter.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * @package log4php
23
+ * @subpackage helpers
24
+ */
25
+ class Ipagare_Log4php_Helpers_LoggerBasicPatternConverter extends Ipagare_Log4php_Helpers_LoggerPatternConverter {
26
+
27
+ /**
28
+ * @var integer
29
+ */
30
+ private $type;
31
+
32
+ /**
33
+ * Constructor
34
+ *
35
+ * @param string $formattingInfo
36
+ * @param integer $type
37
+ */
38
+ public function __construct($formattingInfo, $type) {
39
+ parent::__construct($formattingInfo);
40
+ $this->type = $type;
41
+ }
42
+
43
+ /**
44
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
45
+ * @return string
46
+ */
47
+ public function convert($event) {
48
+ switch($this->type) {
49
+ case Ipagare_Log4php_Helpers_LoggerPatternParser::RELATIVE_TIME_CONVERTER:
50
+ $timeStamp = $event->getTimeStamp();
51
+ $startTime = Ipagare_Log4php_LoggerLoggingEvent::getStartTime();
52
+ return (string)(int)($timeStamp * 1000 - $startTime * 1000);
53
+
54
+ case Ipagare_Log4php_Helpers_LoggerPatternParser::THREAD_CONVERTER:
55
+ return $event->getThreadName();
56
+
57
+ case Ipagare_Log4php_Helpers_LoggerPatternParser::LEVEL_CONVERTER:
58
+ $level = $event->getLevel();
59
+ return $level->toString();
60
+
61
+ case Ipagare_Log4php_Helpers_LoggerPatternParser::NDC_CONVERTER:
62
+ return $event->getNDC();
63
+
64
+ case Ipagare_Log4php_Helpers_LoggerPatternParser::MESSAGE_CONVERTER:
65
+ return $event->getRenderedMessage();
66
+
67
+ default:
68
+ return '';
69
+ }
70
+ }
71
+ }
lib/Ipagare/Log4php/Helpers/LoggerCategoryPatternConverter.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * @package log4php
23
+ * @subpackage helpers
24
+ */
25
+ class Ipagare_Log4php_Helpers_LoggerCategoryPatternConverter extends Ipagare_Log4php_Helpers_LoggerNamedPatternConverter {
26
+
27
+ /**
28
+ * Constructor
29
+ *
30
+ * @param string $formattingInfo
31
+ * @param integer $precision
32
+ */
33
+ public function __construct($formattingInfo, $precision) {
34
+ parent::__construct($formattingInfo, $precision);
35
+ }
36
+
37
+ /**
38
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
39
+ * @return string
40
+ */
41
+ public function getFullyQualifiedName($event) {
42
+ return $event->getLoggerName();
43
+ }
44
+ }
lib/Ipagare/Log4php/Helpers/LoggerClassNamePatternConverter.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * @package log4php
23
+ * @subpackage helpers
24
+ */
25
+ class Ipagare_Log4php_Helpers_LoggerClassNamePatternConverter extends Ipagare_Log4php_Helpers_LoggerNamedPatternConverter {
26
+
27
+ /**
28
+ * Constructor
29
+ *
30
+ * @param string $formattingInfo
31
+ * @param integer $precision
32
+ */
33
+ public function __construct($formattingInfo, $precision) {
34
+ parent::__construct($formattingInfo, $precision);
35
+ }
36
+
37
+ /**
38
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
39
+ * @return string
40
+ */
41
+ public function getFullyQualifiedName($event) {
42
+ return $event->getFullQualifiedClassname();
43
+ }
44
+ }
45
+
lib/Ipagare/Log4php/Helpers/LoggerDatePatternConverter.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * @package log4php
23
+ * @subpackage helpers
24
+ */
25
+ class Ipagare_Log4php_Helpers_LoggerDatePatternConverter extends Ipagare_Log4php_Helpers_LoggerPatternConverter {
26
+
27
+ /**
28
+ * @var string
29
+ */
30
+ private $df;
31
+
32
+ /**
33
+ * Constructor
34
+ *
35
+ * @param string $formattingInfo
36
+ * @param string $df
37
+ */
38
+ public function __construct($formattingInfo, $df) {
39
+ parent::__construct($formattingInfo);
40
+ $this->df = $df;
41
+ }
42
+
43
+ /**
44
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
45
+ * @return string
46
+ */
47
+ public function convert($event) {
48
+ $timeStamp = $event->getTimeStamp();
49
+ $usecs = round(($timeStamp - (int)$timeStamp) * 1000);
50
+ $df = preg_replace('/((?<!\\\\)(?:\\\\{2})*)u/', '${1}' . sprintf('%03d', $usecs), $this->df);
51
+ return date($df, $timeStamp);
52
+ }
53
+ }
lib/Ipagare/Log4php/Helpers/LoggerFormattingInfo.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * This class encapsulates the information obtained when parsing
23
+ * formatting modifiers in conversion modifiers.
24
+ *
25
+ * @package log4php
26
+ * @subpackage helpers
27
+ * @since 0.3
28
+ */
29
+ class Ipagare_Log4php_Helpers_LoggerFormattingInfo {
30
+
31
+ public $min = -1;
32
+ public $max = 0x7FFFFFFF;
33
+ public $leftAlign = false;
34
+
35
+ /**
36
+ * Constructor
37
+ */
38
+ public function __construct() {}
39
+
40
+ public function reset() {
41
+ $this->min = -1;
42
+ $this->max = 0x7FFFFFFF;
43
+ $this->leftAlign = false;
44
+ }
45
+
46
+ public function dump() {
47
+ // TODO: other option to dump?
48
+ // LoggerLog::debug("Ipagare_Log4php_Helpers_LoggerFormattingInfo::dump() min={$this->min}, max={$this->max}, leftAlign={$this->leftAlign}");
49
+ }
50
+ }
lib/Ipagare/Log4php/Helpers/LoggerLiteralPatternConverter.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * @package log4php
23
+ * @subpackage helpers
24
+ */
25
+ class Ipagare_Log4php_Helpers_LoggerLiteralPatternConverter extends Ipagare_Log4php_Helpers_LoggerPatternConverter {
26
+
27
+ /**
28
+ * @var string
29
+ */
30
+ private $literal;
31
+
32
+ /**
33
+ * Constructor
34
+ *
35
+ * @param string $value
36
+ */
37
+ public function __construct($value) {
38
+ $this->literal = $value;
39
+ }
40
+
41
+ /**
42
+ * @param string &$sbuf
43
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
44
+ */
45
+ public function format(&$sbuf, $event) {
46
+ $sbuf .= $this->literal;
47
+ }
48
+
49
+ /**
50
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
51
+ * @return string
52
+ */
53
+ public function convert($event) {
54
+ return $this->literal;
55
+ }
56
+ }
57
+
lib/Ipagare/Log4php/Helpers/LoggerLocationPatternConverter.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * @package log4php
23
+ * @subpackage helpers
24
+ */
25
+ class Ipagare_Log4php_Helpers_LoggerLocationPatternConverter extends Ipagare_Log4php_Helpers_LoggerPatternConverter {
26
+
27
+ /**
28
+ * @var integer
29
+ */
30
+ private $type;
31
+
32
+ /**
33
+ * Constructor
34
+ *
35
+ * @param string $formattingInfo
36
+ * @param integer $type
37
+ */
38
+ public function __construct($formattingInfo, $type) {
39
+ parent::__construct($formattingInfo);
40
+ $this->type = $type;
41
+ }
42
+
43
+ /**
44
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
45
+ * @return string
46
+ */
47
+ public function convert($event) {
48
+ $locationInfo = $event->getLocationInformation();
49
+ switch($this->type) {
50
+ case Ipagare_Log4php_Helpers_LoggerPatternParser::FULL_LOCATION_CONVERTER:
51
+ return $locationInfo->getFullInfo();
52
+ case Ipagare_Log4php_Helpers_LoggerPatternParser::METHOD_LOCATION_CONVERTER:
53
+ return $locationInfo->getMethodName();
54
+ case Ipagare_Log4php_Helpers_LoggerPatternParser::LINE_LOCATION_CONVERTER:
55
+ return $locationInfo->getLineNumber();
56
+ case Ipagare_Log4php_Helpers_LoggerPatternParser::FILE_LOCATION_CONVERTER:
57
+ return $locationInfo->getFileName();
58
+ case Ipagare_Log4php_Helpers_LoggerPatternParser::CLASS_LOCATION_CONVERTER:
59
+ return $locationInfo->getFullQualifiedClassname();
60
+ default:
61
+ return '';
62
+ }
63
+ }
64
+ }
65
+
lib/Ipagare/Log4php/Helpers/LoggerMDCPatternConverter.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * @package log4php
23
+ * @subpackage helpers
24
+ */
25
+ class Ipagare_Log4php_Helpers_LoggerMDCPatternConverter extends Ipagare_Log4php_Helpers_LoggerPatternConverter {
26
+
27
+ /**
28
+ * @var string
29
+ */
30
+ private $key;
31
+
32
+ /**
33
+ * Constructor
34
+ *
35
+ * @param string $formattingInfo
36
+ * @param string $key
37
+ */
38
+ public function __construct($formattingInfo, $key) {
39
+ parent::__construct($formattingInfo);
40
+ $this->key = $key;
41
+ }
42
+
43
+ /**
44
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
45
+ * @return string
46
+ */
47
+ public function convert($event) {
48
+ return $event->getMDC($this->key);
49
+ }
50
+ }
lib/Ipagare/Log4php/Helpers/LoggerNamedPatternConverter.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * @package log4php
23
+ * @subpackage helpers
24
+ * @abstract
25
+ */
26
+ class Ipagare_Log4php_Helpers_LoggerNamedPatternConverter extends Ipagare_Log4php_Helpers_LoggerPatternConverter {
27
+
28
+ /**
29
+ * @var integer
30
+ */
31
+ private $precision;
32
+
33
+ /**
34
+ * Constructor
35
+ *
36
+ * @param string $formattingInfo
37
+ * @param integer $precision
38
+ */
39
+ public function __construct($formattingInfo, $precision) {
40
+ parent::__construct($formattingInfo);
41
+ $this->precision = $precision;
42
+ }
43
+
44
+ /**
45
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
46
+ * @return string
47
+ * @abstract
48
+ */
49
+ public function getFullyQualifiedName($event) {
50
+ // abstract
51
+ return;
52
+ }
53
+
54
+ /**
55
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
56
+ * @return string
57
+ */
58
+ function convert($event) {
59
+ $n = $this->getFullyQualifiedName($event);
60
+ if($this->precision <= 0) {
61
+ return $n;
62
+ } else {
63
+ $len = strlen($n);
64
+ // We substract 1 from 'len' when assigning to 'end' to avoid out of
65
+ // bounds exception in return r.substring(end+1, len). This can happen if
66
+ // precision is 1 and the category name ends with a dot.
67
+ $end = $len -1 ;
68
+ for($i = $this->precision; $i > 0; $i--) {
69
+ $end = strrpos(substr($n, 0, ($end - 1)), '.');
70
+ if($end == false) {
71
+ return $n;
72
+ }
73
+ }
74
+ return substr($n, ($end + 1), $len);
75
+ }
76
+ }
77
+ }
lib/Ipagare/Log4php/Helpers/LoggerOptionConverter.php ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * A convenience class to convert property values to specific types.
23
+ *
24
+ * @version $Revision: 1059292 $
25
+ * @package log4php
26
+ * @subpackage helpers
27
+ * @static
28
+ * @since 0.5
29
+ */
30
+ class Ipagare_Log4php_Helpers_LoggerOptionConverter {
31
+
32
+ const DELIM_START = '${';
33
+ const DELIM_STOP = '}';
34
+ const DELIM_START_LEN = 2;
35
+ const DELIM_STOP_LEN = 1;
36
+
37
+ /**
38
+ * Read a predefined var.
39
+ *
40
+ * It returns a value referenced by <var>$key</var> using this search criteria:
41
+ * - if <var>$key</var> is a constant then return it. Else
42
+ * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
43
+ * - return <var>$def</var>.
44
+ *
45
+ * @param string $key The key to search for.
46
+ * @param string $def The default value to return.
47
+ * @return string the string value of the system property, or the default
48
+ * value if there is no property with that key.
49
+ *
50
+ * @static
51
+ */
52
+ public static function getSystemProperty($key, $def) {
53
+ if(defined($key)) {
54
+ return (string)constant($key);
55
+ } else if(isset($_SERVER[$key])) {
56
+ return (string)$_SERVER[$key];
57
+ } else if(isset($_ENV[$key])) {
58
+ return (string)$_ENV[$key];
59
+ } else {
60
+ return $def;
61
+ }
62
+ }
63
+
64
+ /**
65
+ * If <var>$value</var> is <i>true</i>, then <i>true</i> is
66
+ * returned. If <var>$value</var> is <i>false</i>, then
67
+ * <i>true</i> is returned. Otherwise, <var>$default</var> is
68
+ * returned.
69
+ *
70
+ * <p>Case of value is unimportant.</p>
71
+ *
72
+ * @param string $value
73
+ * @param boolean $default
74
+ * @return boolean
75
+ *
76
+ * @static
77
+ */
78
+ public static function toBoolean($value, $default=true) {
79
+ if (is_null($value)) {
80
+ return $default;
81
+ } elseif (is_string($value)) {
82
+ $trimmedVal = strtolower(trim($value));
83
+ if("1" == $trimmedVal or "true" == $trimmedVal or "yes" == $trimmedVal or "on" == $trimmedVal) {
84
+ return true;
85
+ } else if ("" == $trimmedVal or "0" == $trimmedVal or "false" == $trimmedVal or "no" == $trimmedVal or "off" == $trimmedVal) {
86
+ return false;
87
+ }
88
+ } elseif (is_bool($value)) {
89
+ return $value;
90
+ } elseif (is_int($value)) {
91
+ return !($value == 0); // true is everything but 0 like in C
92
+ }
93
+
94
+ trigger_error("Could not convert ".var_export($value,1)." to boolean!", E_USER_WARNING);
95
+ return $default;
96
+ }
97
+
98
+ /**
99
+ * @param string $value
100
+ * @param integer $default
101
+ * @return integer
102
+ * @static
103
+ */
104
+ public static function toInt($value, $default) {
105
+ $value = trim($value);
106
+ if(is_numeric($value)) {
107
+ return (int)$value;
108
+ } else {
109
+ return $default;
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Converts a standard or custom priority level to a Level
115
+ * object.
116
+ *
117
+ * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>",
118
+ * where <i>full_file_classname</i> means the class filename with path
119
+ * but without php extension, then the specified class' <i>toLevel()</i> method
120
+ * is called to process the specified level string; if no '#'
121
+ * character is present, then the default {@link Ipagare_Log4php_LoggerLevel}
122
+ * class is used to process the level value.</p>
123
+ *
124
+ * <p>As a special case, if the <var>$value</var> parameter is
125
+ * equal to the string "NULL", then the value <i>null</i> will
126
+ * be returned.</p>
127
+ *
128
+ * <p>If any error occurs while converting the value to a level,
129
+ * the <var>$defaultValue</var> parameter, which may be
130
+ * <i>null</i>, is returned.</p>
131
+ *
132
+ * <p>Case of <var>$value</var> is insignificant for the level level, but is
133
+ * significant for the class name part, if present.</p>
134
+ *
135
+ * @param string $value
136
+ * @param Ipagare_Log4php_LoggerLevel $defaultValue
137
+ * @return Ipagare_Log4php_LoggerLevel a {@link Ipagare_Log4php_LoggerLevel} or null
138
+ * @static
139
+ */
140
+ public static function toLevel($value, $defaultValue) {
141
+ if($value === null) {
142
+ return $defaultValue;
143
+ }
144
+ $hashIndex = strpos($value, '#');
145
+ if($hashIndex === false) {
146
+ if("NULL" == strtoupper($value)) {
147
+ return null;
148
+ } else {
149
+ // no class name specified : use standard Level class
150
+ return Ipagare_Log4php_LoggerLevel::toLevel($value, $defaultValue);
151
+ }
152
+ }
153
+
154
+ $result = $defaultValue;
155
+
156
+ $clazz = substr($value, ($hashIndex + 1));
157
+ $levelName = substr($value, 0, $hashIndex);
158
+
159
+ // This is degenerate case but you never know.
160
+ if("NULL" == strtoupper($levelName)) {
161
+ return null;
162
+ }
163
+
164
+ $clazz = basename($clazz);
165
+
166
+ if(class_exists($clazz)) {
167
+ $result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue);
168
+ if(!$result instanceof Ipagare_Log4php_LoggerLevel) {
169
+ $result = $defaultValue;
170
+ }
171
+ }
172
+ return $result;
173
+ }
174
+
175
+ /**
176
+ * @param string $value
177
+ * @param float $default
178
+ * @return float
179
+ *
180
+ * @static
181
+ */
182
+ public static function toFileSize($value, $default) {
183
+ if($value === null) {
184
+ return $default;
185
+ }
186
+
187
+ $s = strtoupper(trim($value));
188
+ $multiplier = (float)1;
189
+ if(($index = strpos($s, 'KB')) !== false) {
190
+ $multiplier = 1024;
191
+ $s = substr($s, 0, $index);
192
+ } else if(($index = strpos($s, 'MB')) !== false) {
193
+ $multiplier = 1024 * 1024;
194
+ $s = substr($s, 0, $index);
195
+ } else if(($index = strpos($s, 'GB')) !== false) {
196
+ $multiplier = 1024 * 1024 * 1024;
197
+ $s = substr($s, 0, $index);
198
+ }
199
+ if(is_numeric($s)) {
200
+ return (float)$s * $multiplier;
201
+ }
202
+ return $default;
203
+ }
204
+
205
+ /**
206
+ * Find the value corresponding to <var>$key</var> in
207
+ * <var>$props</var>. Then perform variable substitution on the
208
+ * found value.
209
+ *
210
+ * @param string $key
211
+ * @param array $props
212
+ * @return string
213
+ *
214
+ * @static
215
+ */
216
+ public static function findAndSubst($key, $props) {
217
+ $value = @$props[$key];
218
+
219
+ // If coming from the Ipagare_Log4php_Configurators_LoggerConfiguratorIni, some options were
220
+ // already mangled by parse_ini_file:
221
+ //
222
+ // not specified => never reaches this code
223
+ // ""|off|false|null => string(0) ""
224
+ // "1"|on|true => string(1) "1"
225
+ // "true" => string(4) "true"
226
+ // "false" => string(5) "false"
227
+ //
228
+ // As the integer 1 and the boolean true are therefore indistinguable
229
+ // it's up to the setter how to deal with it, they can not be cast
230
+ // into a boolean here. {@see toBoolean}
231
+ // Even an empty value has to be given to the setter as it has been
232
+ // explicitly set by the user and is different from an option which
233
+ // has not been specified and therefore keeps its default value.
234
+ //
235
+ // if(!empty($value)) {
236
+ return Ipagare_Log4php_Helpers_LoggerOptionConverter::substVars($value, $props);
237
+ // }
238
+ }
239
+
240
+ /**
241
+ * Perform variable substitution in string <var>$val</var> from the
242
+ * values of keys found with the {@link getSystemProperty()} method.
243
+ *
244
+ * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
245
+ *
246
+ * <p>For example, if the "MY_CONSTANT" contains "value", then
247
+ * the call
248
+ * <code>
249
+ * $s = Ipagare_Log4php_Helpers_LoggerOptionConverter::substVars("Value of key is ${MY_CONSTANT}.");
250
+ * </code>
251
+ * will set the variable <i>$s</i> to "Value of key is value.".</p>
252
+ *
253
+ * <p>If no value could be found for the specified key, then the
254
+ * <var>$props</var> parameter is searched, if the value could not
255
+ * be found there, then substitution defaults to the empty string.</p>
256
+ *
257
+ * <p>For example, if {@link getSystemProperty()} cannot find any value for the key
258
+ * "inexistentKey", then the call
259
+ * <code>
260
+ * $s = Ipagare_Log4php_Helpers_LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]");
261
+ * </code>
262
+ * will set <var>$s</var> to "Value of inexistentKey is []".</p>
263
+ *
264
+ * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${"
265
+ * which is not balanced by a stop delimeter "}" and an empty string is returned.</p>
266
+ *
267
+ * @param string $val The string on which variable substitution is performed.
268
+ * @param array $props
269
+ * @return string
270
+ *
271
+ * @static
272
+ */
273
+ // TODO: this method doesn't work correctly with key = true, it needs key = "true" which is odd
274
+ public static function substVars($val, $props = null) {
275
+ $sbuf = '';
276
+ $i = 0;
277
+ while(true) {
278
+ $j = strpos($val, self::DELIM_START, $i);
279
+ if($j === false) {
280
+ // no more variables
281
+ if($i == 0) { // this is a simple string
282
+ return $val;
283
+ } else { // add the tail string which contails no variables and return the result.
284
+ $sbuf .= substr($val, $i);
285
+ return $sbuf;
286
+ }
287
+ } else {
288
+
289
+ $sbuf .= substr($val, $i, $j-$i);
290
+ $k = strpos($val, self::DELIM_STOP, $j);
291
+ if($k === false) {
292
+ // Ipagare_Log4php_Helpers_LoggerOptionConverter::substVars() has no closing brace. Opening brace
293
+ return '';
294
+ } else {
295
+ $j += self::DELIM_START_LEN;
296
+ $key = substr($val, $j, $k - $j);
297
+ // first try in System properties
298
+ $replacement = Ipagare_Log4php_Helpers_LoggerOptionConverter::getSystemProperty($key, null);
299
+ // then try props parameter
300
+ if($replacement == null and $props !== null) {
301
+ $replacement = @$props[$key];
302
+ }
303
+
304
+ if(!empty($replacement)) {
305
+ // Do variable substitution on the replacement string
306
+ // such that we can solve "Hello ${x2}" as "Hello p1"
307
+ // the where the properties are
308
+ // x1=p1
309
+ // x2=${x1}
310
+ $recursiveReplacement = Ipagare_Log4php_Helpers_LoggerOptionConverter::substVars($replacement, $props);
311
+ $sbuf .= $recursiveReplacement;
312
+ }
313
+ $i = $k + self::DELIM_STOP_LEN;
314
+ }
315
+ }
316
+ }
317
+ }
318
+
319
+ }
lib/Ipagare/Log4php/Helpers/LoggerPatternConverter.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+
22
+ /**
23
+ * Ipagare_Log4php_Helpers_LoggerPatternConverter is an abstract class that provides the formatting
24
+ * functionality that derived classes need.
25
+ *
26
+ * <p>Conversion specifiers in a conversion patterns are parsed to
27
+ * individual PatternConverters. Each of which is responsible for
28
+ * converting a logging event in a converter specific manner.</p>
29
+ *
30
+ * @version $Revision: 925973 $
31
+ * @package log4php
32
+ * @subpackage helpers
33
+ * @abstract
34
+ * @since 0.3
35
+ */
36
+ class Ipagare_Log4php_Helpers_LoggerPatternConverter {
37
+
38
+ /**
39
+ * Array for fast space padding
40
+ * Used by {@link Ipagare_Log4php_Helpers_LoggerPatternConverter::spacePad()}.
41
+ */
42
+ private $spaces = array(
43
+ " ", // 1 space
44
+ " ", // 2 spaces
45
+ " ", // 4 spaces
46
+ " ", // 8 spaces
47
+ " ", // 16 spaces
48
+ " "); // 32 spaces
49
+
50
+ /**
51
+ * @var Ipagare_Log4php_Helpers_LoggerPatternConverter next converter in converter chain
52
+ */
53
+ public $next = null;
54
+
55
+ public $min = -1;
56
+ public $max = 0x7FFFFFFF;
57
+ public $leftAlign = false;
58
+
59
+ /**
60
+ * Constructor
61
+ *
62
+ * @param Ipagare_Log4php_Helpers_LoggerFormattingInfo $fi
63
+ */
64
+ public function __construct($fi = null) {
65
+ if($fi !== null) {
66
+ $this->min = $fi->min;
67
+ $this->max = $fi->max;
68
+ $this->leftAlign = $fi->leftAlign;
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Derived pattern converters must override this method in order to
74
+ * convert conversion specifiers in the correct way.
75
+ *
76
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
77
+ */
78
+ public function convert($event) {}
79
+
80
+ /**
81
+ * A template method for formatting in a converter specific way.
82
+ *
83
+ * @param string &$sbuf string buffer
84
+ * @param Ipagare_Log4php_LoggerLoggingEvent $e
85
+ */
86
+ public function format(&$sbuf, $e) {
87
+ $s = $this->convert($e);
88
+
89
+ if($s == null or empty($s)) {
90
+ if(0 < $this->min) {
91
+ $this->spacePad($sbuf, $this->min);
92
+ }
93
+ return;
94
+ }
95
+
96
+ $len = strlen($s);
97
+
98
+ if($len > $this->max) {
99
+ $sbuf .= substr($s , 0, ($len - $this->max));
100
+ } else if($len < $this->min) {
101
+ if($this->leftAlign) {
102
+ $sbuf .= $s;
103
+ $this->spacePad($sbuf, ($this->min - $len));
104
+ } else {
105
+ $this->spacePad($sbuf, ($this->min - $len));
106
+ $sbuf .= $s;
107
+ }
108
+ } else {
109
+ $sbuf .= $s;
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Fast space padding method.
115
+ *
116
+ * @param string &$sbuf string buffer
117
+ * @param integer $length pad length
118
+ *
119
+ * @todo reimplement using PHP string functions
120
+ */
121
+ public function spacePad(&$sbuf, $length) {
122
+ while($length >= 32) {
123
+ $sbuf .= $this->spaces[5];
124
+ $length -= 32;
125
+ }
126
+
127
+ for($i = 4; $i >= 0; $i--) {
128
+ if(($length & (1<<$i)) != 0) {
129
+ $sbuf .= $this->spaces[$i];
130
+ }
131
+ }
132
+
133
+ // $sbuf = str_pad($sbuf, $length);
134
+ }
135
+ }
lib/Ipagare/Log4php/Helpers/LoggerPatternParser.php ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Most of the work of the {@link LoggerPatternLayout} class
23
+ * is delegated to the {@link Ipagare_Log4php_Helpers_LoggerPatternParser} class.
24
+ *
25
+ * <p>It is this class that parses conversion patterns and creates
26
+ * a chained list of {@link Ipagare_Log4php_Helpers_LoggerPatternConverter} converters.</p>
27
+ *
28
+ * @version $Revision: 948675 $
29
+ * @package log4php
30
+ * @subpackage helpers
31
+ *
32
+ * @since 0.3
33
+ */
34
+ class Ipagare_Log4php_Helpers_LoggerPatternParser {
35
+
36
+ const ESCAPE_CHAR = '%';
37
+
38
+ const LITERAL_STATE = 0;
39
+ const CONVERTER_STATE = 1;
40
+ const MINUS_STATE = 2;
41
+ const DOT_STATE = 3;
42
+ const MIN_STATE = 4;
43
+ const MAX_STATE = 5;
44
+
45
+ const FULL_LOCATION_CONVERTER = 1000;
46
+ const METHOD_LOCATION_CONVERTER = 1001;
47
+ const CLASS_LOCATION_CONVERTER = 1002;
48
+ const FILE_LOCATION_CONVERTER = 1003;
49
+ const LINE_LOCATION_CONVERTER = 1004;
50
+
51
+ const RELATIVE_TIME_CONVERTER = 2000;
52
+ const THREAD_CONVERTER = 2001;
53
+ const LEVEL_CONVERTER = 2002;
54
+ const NDC_CONVERTER = 2003;
55
+ const MESSAGE_CONVERTER = 2004;
56
+
57
+ const DATE_FORMAT_ISO8601 = 'Y-m-d H:i:s,u';
58
+ const DATE_FORMAT_ABSOLUTE = 'H:i:s';
59
+ const DATE_FORMAT_DATE = 'd M Y H:i:s,u';
60
+
61
+ private $state;
62
+ private $currentLiteral;
63
+ private $patternLength;
64
+ private $i;
65
+
66
+ /**
67
+ * @var Ipagare_Log4php_Helpers_LoggerPatternConverter
68
+ */
69
+ private $head = null;
70
+
71
+ /**
72
+ * @var Ipagare_Log4php_Helpers_LoggerPatternConverter
73
+ */
74
+ private $tail = null;
75
+
76
+ /**
77
+ * @var Ipagare_Log4php_Helpers_LoggerFormattingInfo
78
+ */
79
+ private $formattingInfo;
80
+
81
+ /**
82
+ * @var string pattern to parse
83
+ */
84
+ private $pattern;
85
+
86
+ /**
87
+ * Constructor
88
+ *
89
+ * @param string $pattern
90
+ */
91
+ public function __construct($pattern) {
92
+ $this->pattern = $pattern;
93
+ $this->patternLength = strlen($pattern);
94
+ $this->formattingInfo = new Ipagare_Log4php_Helpers_LoggerFormattingInfo();
95
+ $this->state = self::LITERAL_STATE;
96
+ }
97
+
98
+ /**
99
+ * @param Ipagare_Log4php_Helpers_LoggerPatternConverter $pc
100
+ */
101
+ public function addToList($pc) {
102
+ if($this->head == null) {
103
+ $this->head = $pc;
104
+ $this->tail = $this->head;
105
+ } else {
106
+ $this->tail->next = $pc;
107
+ $this->tail = $this->tail->next;
108
+ }
109
+ }
110
+
111
+ /**
112
+ * @return string
113
+ */
114
+ public function extractOption() {
115
+ if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) {
116
+ $end = strpos($this->pattern, '}' , $this->i);
117
+ if($end !== false) {
118
+ $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1));
119
+ $this->i= $end + 1;
120
+ return $r;
121
+ }
122
+ }
123
+ return null;
124
+ }
125
+
126
+ /**
127
+ * The option is expected to be in decimal and positive. In case of
128
+ * error, zero is returned.
129
+ */
130
+ public function extractPrecisionOption() {
131
+ $opt = $this->extractOption();
132
+ $r = 0;
133
+ if($opt !== null) {
134
+ if(is_numeric($opt)) {
135
+ $r = (int)$opt;
136
+ if($r <= 0) {
137
+ $r = 0;
138
+ }
139
+ }
140
+ }
141
+ return $r;
142
+ }
143
+
144
+
145
+ /** Parser.
146
+ *
147
+ * @return Ipagare_Log4php_Helpers_LoggerPatternConverter Returns $this->head.
148
+ */
149
+ public function parse() {
150
+ $c = '';
151
+ $this->i = 0;
152
+ $this->currentLiteral = '';
153
+ while($this->i < $this->patternLength) {
154
+ $c = $this->pattern{$this->i++};
155
+
156
+ switch($this->state) {
157
+ case self::LITERAL_STATE:
158
+ // In literal state, the last char is always a literal.
159
+ if($this->i == $this->patternLength) {
160
+ $this->currentLiteral .= $c;
161
+ continue;
162
+ }
163
+ if($c == self::ESCAPE_CHAR) {
164
+ // peek at the next char.
165
+ switch($this->pattern{$this->i}) {
166
+ case self::ESCAPE_CHAR:
167
+ $this->currentLiteral .= $c;
168
+ $this->i++; // move pointer
169
+ break;
170
+ case 'n':
171
+ $this->currentLiteral .= PHP_EOL;
172
+ $this->i++; // move pointer
173
+ break;
174
+ default:
175
+ if(strlen($this->currentLiteral) != 0) {
176
+ $this->addToList(new Ipagare_Log4php_Helpers_LoggerLiteralPatternConverter($this->currentLiteral));
177
+ }
178
+ $this->currentLiteral = $c;
179
+ $this->state = self::CONVERTER_STATE;
180
+ $this->formattingInfo->reset();
181
+ }
182
+ } else {
183
+ $this->currentLiteral .= $c;
184
+ }
185
+ break;
186
+ case self::CONVERTER_STATE:
187
+ $this->currentLiteral .= $c;
188
+ switch($c) {
189
+ case '-':
190
+ $this->formattingInfo->leftAlign = true;
191
+ break;
192
+ case '.':
193
+ $this->state = self::DOT_STATE;
194
+ break;
195
+ default:
196
+ if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
197
+ $this->formattingInfo->min = ord($c) - ord('0');
198
+ $this->state = self::MIN_STATE;
199
+ } else {
200
+ $this->finalizeConverter($c);
201
+ }
202
+ } // switch
203
+ break;
204
+ case self::MIN_STATE:
205
+ $this->currentLiteral .= $c;
206
+ if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
207
+ $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0'));
208
+ } else if ($c == '.') {
209
+ $this->state = self::DOT_STATE;
210
+ } else {
211
+ $this->finalizeConverter($c);
212
+ }
213
+ break;
214
+ case self::DOT_STATE:
215
+ $this->currentLiteral .= $c;
216
+ if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
217
+ $this->formattingInfo->max = ord($c) - ord('0');
218
+ $this->state = self::MAX_STATE;
219
+ } else {
220
+ $this->state = self::LITERAL_STATE;
221
+ }
222
+ break;
223
+ case self::MAX_STATE:
224
+ $this->currentLiteral .= $c;
225
+ if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
226
+ $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0'));
227
+ } else {
228
+ $this->finalizeConverter($c);
229
+ $this->state = self::LITERAL_STATE;
230
+ }
231
+ break;
232
+ } // switch
233
+ } // while
234
+ if(strlen($this->currentLiteral) != 0) {
235
+ $this->addToList(new Ipagare_Log4php_Helpers_LoggerLiteralPatternConverter($this->currentLiteral));
236
+ }
237
+ return $this->head;
238
+ }
239
+
240
+ public function finalizeConverter($c) {
241
+ $pc = null;
242
+ switch($c) {
243
+ case 'c':
244
+ $pc = new Ipagare_Log4php_Helpers_LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption());
245
+ $this->currentLiteral = '';
246
+ break;
247
+ case 'C':
248
+ $pc = new Ipagare_Log4php_Helpers_LoggerClassNamePatternConverter($this->formattingInfo, self::CLASS_LOCATION_CONVERTER);
249
+ $this->currentLiteral = '';
250
+ break;
251
+ case 'd':
252
+ $dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT;
253
+ $dOpt = $this->extractOption();
254
+
255
+ if($dOpt !== null)
256
+ $dateFormatStr = $dOpt;
257
+
258
+ if($dateFormatStr == 'ISO8601') {
259
+ $df = self::DATE_FORMAT_ISO8601;
260
+ } else if($dateFormatStr == 'ABSOLUTE') {
261
+ $df = self::DATE_FORMAT_ABSOLUTE;
262
+ } else if($dateFormatStr == 'DATE') {
263
+ $df = self::DATE_FORMAT_DATE;
264
+ } else {
265
+ $df = $dateFormatStr;
266
+ if($df == null) {
267
+ $df = self::DATE_FORMAT_ISO8601;
268
+ }
269
+ }
270
+ $pc = new Ipagare_Log4php_Helpers_LoggerDatePatternConverter($this->formattingInfo, $df);
271
+ $this->currentLiteral = '';
272
+ break;
273
+ case 'F':
274
+ $pc = new Ipagare_Log4php_Helpers_LoggerLocationPatternConverter($this->formattingInfo, self::FILE_LOCATION_CONVERTER);
275
+ $this->currentLiteral = '';
276
+ break;
277
+ case 'l':
278
+ $pc = new Ipagare_Log4php_Helpers_LoggerLocationPatternConverter($this->formattingInfo, self::FULL_LOCATION_CONVERTER);
279
+ $this->currentLiteral = '';
280
+ break;
281
+ case 'L':
282
+ $pc = new Ipagare_Log4php_Helpers_LoggerLocationPatternConverter($this->formattingInfo, self::LINE_LOCATION_CONVERTER);
283
+ $this->currentLiteral = '';
284
+ break;
285
+ case 'm':
286
+ $pc = new Ipagare_Log4php_Helpers_LoggerBasicPatternConverter($this->formattingInfo, self::MESSAGE_CONVERTER);
287
+ $this->currentLiteral = '';
288
+ break;
289
+ case 'M':
290
+ $pc = new Ipagare_Log4php_Helpers_LoggerLocationPatternConverter($this->formattingInfo, self::METHOD_LOCATION_CONVERTER);
291
+ $this->currentLiteral = '';
292
+ break;
293
+ case 'p':
294
+ $pc = new Ipagare_Log4php_Helpers_LoggerBasicPatternConverter($this->formattingInfo, self::LEVEL_CONVERTER);
295
+ $this->currentLiteral = '';
296
+ break;
297
+ case 'r':
298
+ $pc = new Ipagare_Log4php_Helpers_LoggerBasicPatternConverter($this->formattingInfo, self::RELATIVE_TIME_CONVERTER);
299
+ $this->currentLiteral = '';
300
+ break;
301
+ case 't':
302
+ $pc = new Ipagare_Log4php_Helpers_LoggerBasicPatternConverter($this->formattingInfo, self::THREAD_CONVERTER);
303
+ $this->currentLiteral = '';
304
+ break;
305
+ case 'u':
306
+ if($this->i < $this->patternLength) {
307
+ $cNext = $this->pattern{$this->i};
308
+ if(ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) {
309
+ $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0')));
310
+ $this->currentLiteral = '';
311
+ $this->i++;
312
+ }
313
+ }
314
+ break;
315
+ case 'x':
316
+ $pc = new Ipagare_Log4php_Helpers_LoggerBasicPatternConverter($this->formattingInfo, self::NDC_CONVERTER);
317
+ $this->currentLiteral = '';
318
+ break;
319
+ case 'X':
320
+ $xOpt = $this->extractOption();
321
+ $pc = new Ipagare_Log4php_Helpers_LoggerMDCPatternConverter($this->formattingInfo, $xOpt);
322
+ $this->currentLiteral = '';
323
+ break;
324
+ default:
325
+ $pc = new Ipagare_Log4php_Helpers_LoggerLiteralPatternConverter($this->currentLiteral);
326
+ $this->currentLiteral = '';
327
+ }
328
+ $this->addConverter($pc);
329
+ }
330
+
331
+ public function addConverter($pc) {
332
+ $this->currentLiteral = '';
333
+ // Add the pattern converter to the list.
334
+ $this->addToList($pc);
335
+ // Next pattern is assumed to be a literal.
336
+ $this->state = self::LITERAL_STATE;
337
+ // Reset formatting info
338
+ $this->formattingInfo->reset();
339
+ }
340
+ }
341
+
lib/Ipagare/Log4php/Layouts/LoggerLayoutHtml.php ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * This layout outputs events in a HTML table.
23
+ *
24
+ * Configurable parameters for this layout are:
25
+ *
26
+ * - title
27
+ * - locationInfo
28
+ *
29
+ * An example for this layout:
30
+ *
31
+ * {@example ../../examples/php/layout_html.php 19}<br>
32
+ *
33
+ * The corresponding XML file:
34
+ *
35
+ * {@example ../../examples/resources/layout_html.properties 18}
36
+ *
37
+ * The above will print a HTML table that looks, converted back to plain text, like the following:<br>
38
+ * <pre>
39
+ * Log session start time Wed Sep 9 00:11:30 2009
40
+ *
41
+ * Time Thread Level Category Message
42
+ * 0 8318 INFO root Hello World!
43
+ * </pre>
44
+ *
45
+ * @version $Revision: 1059292 $
46
+ * @package log4php
47
+ * @subpackage layouts
48
+ */
49
+ class Ipagare_Log4php_Layouts_LoggerLayoutHtml extends Ipagare_Log4php_LoggerLayout {
50
+
51
+ /**
52
+ * The <b>LocationInfo</b> option takes a boolean value. By
53
+ * default, it is set to false which means there will be no location
54
+ * information output by this layout. If the the option is set to
55
+ * true, then the file name and line number of the statement
56
+ * at the origin of the log statement will be output.
57
+ *
58
+ * <p>If you are embedding this layout within a {@link Ipagare_Log4php_Appenders_LoggerAppenderMail}
59
+ * or a {@link Ipagare_Log4php_Appenders_LoggerAppenderMailEvent} then make sure to set the
60
+ * <b>LocationInfo</b> option of that appender as well.
61
+ * @var boolean
62
+ */
63
+ private $locationInfo = false;
64
+
65
+ /**
66
+ * The <b>Title</b> option takes a String value. This option sets the
67
+ * document title of the generated HTML document.
68
+ * Defaults to 'Log4php Log Messages'.
69
+ * @var string
70
+ */
71
+ private $title = "Log4php Log Messages";
72
+
73
+ /**
74
+ * Constructor
75
+ */
76
+ public function __construct() {
77
+ }
78
+
79
+ /**
80
+ * The <b>LocationInfo</b> option takes a boolean value. By
81
+ * default, it is set to false which means there will be no location
82
+ * information output by this layout. If the the option is set to
83
+ * true, then the file name and line number of the statement
84
+ * at the origin of the log statement will be output.
85
+ *
86
+ * <p>If you are embedding this layout within a {@link Ipagare_Log4php_Appenders_LoggerAppenderMail}
87
+ * or a {@link Ipagare_Log4php_Appenders_LoggerAppenderMailEvent} then make sure to set the
88
+ * <b>LocationInfo</b> option of that appender as well.
89
+ */
90
+ public function setLocationInfo($flag) {
91
+ if (is_bool($flag)) {
92
+ $this->locationInfo = $flag;
93
+ } else {
94
+ $this->locationInfo = (bool)(strtolower($flag) == 'true');
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Returns the current value of the <b>LocationInfo</b> option.
100
+ */
101
+ public function getLocationInfo() {
102
+ return $this->locationInfo;
103
+ }
104
+
105
+ /**
106
+ * The <b>Title</b> option takes a String value. This option sets the
107
+ * document title of the generated HTML document.
108
+ * Defaults to 'Log4php Log Messages'.
109
+ */
110
+ public function setTitle($title) {
111
+ $this->title = $title;
112
+ }
113
+
114
+ /**
115
+ * @return string Returns the current value of the <b>Title</b> option.
116
+ */
117
+ public function getTitle() {
118
+ return $this->title;
119
+ }
120
+
121
+ /**
122
+ * @return string Returns the content type output by this layout, i.e "text/html".
123
+ */
124
+ public function getContentType() {
125
+ return "text/html";
126
+ }
127
+
128
+ /**
129
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
130
+ * @return string
131
+ */
132
+ public function format(Ipagare_Log4php_LoggerLoggingEvent $event) {
133
+ $sbuf = PHP_EOL . "<tr>" . PHP_EOL;
134
+
135
+ $sbuf .= "<td>";
136
+ $sbuf .= $event->getTime();
137
+ $sbuf .= "</td>" . PHP_EOL;
138
+
139
+ $sbuf .= "<td title=\"" . $event->getThreadName() . " thread\">";
140
+ $sbuf .= $event->getThreadName();
141
+ $sbuf .= "</td>" . PHP_EOL;
142
+
143
+ $sbuf .= "<td title=\"Level\">";
144
+
145
+ $level = $event->getLevel();
146
+
147
+ if ($level->equals(Ipagare_Log4php_LoggerLevel::getLevelDebug())) {
148
+ $sbuf .= "<font color=\"#339933\">$level</font>";
149
+ } else if ($level->equals(Ipagare_Log4php_LoggerLevel::getLevelWarn())) {
150
+ $sbuf .= "<font color=\"#993300\"><strong>$level</strong></font>";
151
+ } else {
152
+ $sbuf .= $level;
153
+ }
154
+ $sbuf .= "</td>" . PHP_EOL;
155
+
156
+ $sbuf .= "<td title=\"" . htmlentities($event->getLoggerName(), ENT_QUOTES) . " category\">";
157
+ $sbuf .= htmlentities($event->getLoggerName(), ENT_QUOTES);
158
+ $sbuf .= "</td>" . PHP_EOL;
159
+
160
+ if ($this->locationInfo) {
161
+ $locInfo = $event->getLocationInformation();
162
+ $sbuf .= "<td>";
163
+ $sbuf .= htmlentities($locInfo->getFileName(), ENT_QUOTES). ':' . $locInfo->getLineNumber();
164
+ $sbuf .= "</td>" . PHP_EOL;
165
+ }
166
+
167
+ $sbuf .= "<td title=\"Message\">";
168
+ $sbuf .= htmlentities($event->getRenderedMessage(), ENT_QUOTES);
169
+ $sbuf .= "</td>" . PHP_EOL;
170
+
171
+ $sbuf .= "</tr>" . PHP_EOL;
172
+
173
+ if ($event->getNDC() != null) {
174
+ $sbuf .= "<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"6\" title=\"Nested Diagnostic Context\">";
175
+ $sbuf .= "NDC: " . htmlentities($event->getNDC(), ENT_QUOTES);
176
+ $sbuf .= "</td></tr>" . PHP_EOL;
177
+ }
178
+ return $sbuf;
179
+ }
180
+
181
+ /**
182
+ * @return string Returns appropriate HTML headers.
183
+ */
184
+ public function getHeader() {
185
+ $sbuf = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" . PHP_EOL;
186
+ $sbuf .= "<html>" . PHP_EOL;
187
+ $sbuf .= "<head>" . PHP_EOL;
188
+ $sbuf .= "<title>" . $this->title . "</title>" . PHP_EOL;
189
+ $sbuf .= "<style type=\"text/css\">" . PHP_EOL;
190
+ $sbuf .= "<!--" . PHP_EOL;
191
+ $sbuf .= "body, table {font-family: arial,sans-serif; font-size: x-small;}" . PHP_EOL;
192
+ $sbuf .= "th {background: #336699; color: #FFFFFF; text-align: left;}" . PHP_EOL;
193
+ $sbuf .= "-->" . PHP_EOL;
194
+ $sbuf .= "</style>" . PHP_EOL;
195
+ $sbuf .= "</head>" . PHP_EOL;
196
+ $sbuf .= "<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">" . PHP_EOL;
197
+ $sbuf .= "<hr size=\"1\" noshade>" . PHP_EOL;
198
+ $sbuf .= "Log session start time " . strftime('%c', time()) . "<br>" . PHP_EOL;
199
+ $sbuf .= "<br>" . PHP_EOL;
200
+ $sbuf .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">" . PHP_EOL;
201
+ $sbuf .= "<tr>" . PHP_EOL;
202
+ $sbuf .= "<th>Time</th>" . PHP_EOL;
203
+ $sbuf .= "<th>Thread</th>" . PHP_EOL;
204
+ $sbuf .= "<th>Level</th>" . PHP_EOL;
205
+ $sbuf .= "<th>Category</th>" . PHP_EOL;
206
+ if ($this->locationInfo) {
207
+ $sbuf .= "<th>File:Line</th>" . PHP_EOL;
208
+ }
209
+ $sbuf .= "<th>Message</th>" . PHP_EOL;
210
+ $sbuf .= "</tr>" . PHP_EOL;
211
+
212
+ return $sbuf;
213
+ }
214
+
215
+ /**
216
+ * @return string Returns the appropriate HTML footers.
217
+ */
218
+ public function getFooter() {
219
+ $sbuf = "</table>" . PHP_EOL;
220
+ $sbuf .= "<br>" . PHP_EOL;
221
+ $sbuf .= "</body></html>";
222
+
223
+ return $sbuf;
224
+ }
225
+ }
lib/Ipagare/Log4php/Layouts/LoggerLayoutPattern.php ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * A flexible layout configurable with pattern string.
23
+ *
24
+ * <p>Example:</p>
25
+ *
26
+ * {@example ../../examples/php/layout_pattern.php 19}<br>
27
+ *
28
+ * <p>with the following properties file:</p>
29
+ *
30
+ * {@example ../../examples/resources/layout_pattern.properties 18}<br>
31
+ *
32
+ * <p>would print the following:</p>
33
+ *
34
+ * <pre>
35
+ * 2009-09-09 00:27:35,787 [INFO] root: Hello World! (at src/examples/php/layout_pattern.php line 6)
36
+ * 2009-09-09 00:27:35,787 [DEBUG] root: Second line (at src/examples/php/layout_pattern.php line 7)
37
+ * </pre>
38
+ *
39
+ * <p>The conversion pattern is closely related to the conversion pattern of the printf function in C.
40
+ * A conversion pattern is composed of literal text and format control expressions called conversion specifiers.
41
+ * You are free to insert any literal text within the conversion pattern.</p>
42
+ *
43
+ * <p>Each conversion specifier starts with a percent sign (%) and is followed by optional
44
+ * format modifiers and a conversion character.</p>
45
+ *
46
+ * <p>The conversion character specifies the type of data, e.g. category, priority, date, thread name.
47
+ * The format modifiers control such things as field width, padding, left and right justification.</p>
48
+ *
49
+ * <p>Note that there is no explicit separator between text and conversion specifiers.</p>
50
+ *
51
+ * <p>The pattern parser knows when it has reached the end of a conversion specifier when it reads a conversion character.
52
+ * In the example above the conversion specifier %-5p means the priority of the logging event should be
53
+ * left justified to a width of five characters.</p>
54
+ *
55
+ * Not all log4j conversion characters are implemented. The recognized conversion characters are:
56
+ * - <b>c</b> Used to output the category of the logging event. The category conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.
57
+ * If a precision specifier is given, then only the corresponding number of right most components of the category name will be printed.
58
+ * By default the category name is printed in full.
59
+ * For example, for the category name "a.b.c" the pattern %c{2} will output "b.c".
60
+ * - <b>C</b> Used to output the fully qualified class name of the caller issuing the logging request.
61
+ * This conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.
62
+ * If a precision specifier is given, then only the corresponding number of right most components of the class name will be printed.
63
+ * By default the class name is output in fully qualified form.
64
+ * For example, for the class name "org.apache.xyz.SomeClass", the pattern %C{1} will output "SomeClass".
65
+ * - <b>d</b> Used to output the date of the logging event.
66
+ * The date conversion specifier may be followed by a date format specifier enclosed between braces.
67
+ * The format specifier follows the {@link PHP_MANUAL#date} function.
68
+ * Note that the special character <b>u</b> is used to as microseconds replacement (to avoid replacement,
69
+ * use <b>\u</b>).
70
+ * For example, %d{H:i:s,u} or %d{d M Y H:i:s,u}. If no date format specifier is given then ISO8601 format is assumed.
71
+ * The date format specifier admits the same syntax as the time pattern string of the SimpleDateFormat.
72
+ * It is recommended to use the predefined log4php date formatters.
73
+ * These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifying
74
+ * AbsoluteTimeDateFormat, DateTimeDateFormat and respectively ISO8601DateFormat.
75
+ * For example, %d{ISO8601} or %d{ABSOLUTE}.
76
+ * - <b>F</b> Used to output the file name where the logging request was issued.
77
+ * - <b>l</b> Used to output location information of the caller which generated the logging event.
78
+ * - <b>L</b> Used to output the line number from where the logging request was issued.
79
+ * - <b>m</b> Used to output the application supplied message associated with the logging event.
80
+ * - <b>M</b> Used to output the method name where the logging request was issued.
81
+ * - <b>p</b> Used to output the priority of the logging event.
82
+ * - <b>r</b> Used to output the number of milliseconds elapsed since the start of
83
+ * the application until the creation of the logging event.
84
+ * - <b>t</b> Used to output the name of the thread that generated the logging event.
85
+ * - <b>x</b> Used to output the NDC (nested diagnostic context) associated with
86
+ * the thread that generated the logging event.
87
+ * - <b>X</b> Used to output the MDC (mapped diagnostic context) associated with
88
+ * the thread that generated the logging event.
89
+ * The X conversion character must be followed by the key for the map placed between braces,
90
+ * as in <i>%X{clientNumber}</i> where clientNumber is the key.
91
+ * The value in the MDC corresponding to the key will be output.
92
+ * See {@link Ipagare_Log4php_LoggerMDC} class for more details.
93
+ * - <b>%</b> The sequence %% outputs a single percent sign.
94
+ *
95
+ * <p>By default the relevant information is output as is.
96
+ * However, with the aid of format modifiers it is possible to change the minimum field width,
97
+ * the maximum field width and justification.</p>
98
+ *
99
+ * <p>The optional format modifier is placed between the percent sign and the conversion character.</p>
100
+ * <p>The first optional format modifier is the left justification flag which is just the minus (-) character.
101
+ * Then comes the optional minimum field width modifier.
102
+ * This is a decimal constant that represents the minimum number of characters to output.
103
+ * If the data item requires fewer characters, it is padded on either the left or the right until the minimum width is reached. The default is to pad on the left (right justify) but you can specify right padding with the left justification flag. The padding character is space. If the data item is larger than the minimum field width, the field is expanded to accommodate the data.
104
+ * The value is never truncated.</p>
105
+ *
106
+ * <p>This behavior can be changed using the maximum field width modifier which is designated by a period
107
+ * followed by a decimal constant.
108
+ * If the data item is longer than the maximum field,
109
+ * then the extra characters are removed from the beginning of the data item and not from the end.
110
+ * For example, it the maximum field width is eight and the data item is ten characters long,
111
+ * then the first two characters of the data item are dropped.
112
+ * This behavior deviates from the printf function in C where truncation is done from the end.</p>
113
+ *
114
+ * <p>Below are various format modifier examples for the category conversion specifier.</p>
115
+ * <pre>
116
+ * Format modifier left justify minimum width maximum width comment
117
+ * %20c false 20 none Left pad with spaces if the category name
118
+ * is less than 20 characters long.
119
+ * %-20c true 20 none Right pad with spaces if the category name
120
+ * is less than 20 characters long.
121
+ * %.30c NA none 30 Truncate from the beginning if the category name
122
+ * is longer than 30 characters.
123
+ * %20.30c false 20 30 Left pad with spaces if the category name
124
+ * is shorter than 20 characters.
125
+ * However, if category name is longer than 30 chars,
126
+ * then truncate from the beginning.
127
+ * %-20.30c true 20 30 Right pad with spaces if the category name is
128
+ * shorter than 20 chars.
129
+ * However, if category name is longer than 30 chars,
130
+ * then truncate from the beginning.
131
+ * </pre>
132
+ *
133
+ * @version $Revision: 1059292 $
134
+ * @package log4php
135
+ * @subpackage layouts
136
+ * @since 0.3
137
+ */
138
+ class Ipagare_Log4php_Layouts_LoggerLayoutPattern extends Ipagare_Log4php_LoggerLayout {
139
+ /** Default conversion Pattern */
140
+ const DEFAULT_CONVERSION_PATTERN = '%m%n';
141
+
142
+ /** Default conversion TTCC Pattern */
143
+ const TTCC_CONVERSION_PATTERN = '%r [%t] %p %c %x - %m%n';
144
+
145
+ /** The pattern.
146
+ * @var string */
147
+ private $pattern;
148
+
149
+ /** Head of a chain of Converters.
150
+ * @var Ipagare_Log4php_Helpers_LoggerPatternConverter */
151
+ private $head;
152
+
153
+ private $timezone;
154
+
155
+ /**
156
+ * Constructs a PatternLayout using the
157
+ * {@link DEFAULT_LAYOUT_PATTERN}.
158
+ * The default pattern just produces the application supplied message.
159
+ */
160
+ public function __construct($pattern = null) {
161
+ if ($pattern === null) {
162
+ $this->setConversionPattern(self::DEFAULT_CONVERSION_PATTERN);
163
+ } else {
164
+ $this->pattern = $pattern;
165
+ }
166
+ }
167
+
168
+ /**
169
+ * Set the <b>ConversionPattern</b> option. This is the string which
170
+ * controls formatting and consists of a mix of literal content and
171
+ * conversion specifiers.
172
+ */
173
+ public function setConversionPattern($conversionPattern) {
174
+ $this->pattern = $conversionPattern;
175
+ $patternParser = new Ipagare_Log4php_Helpers_LoggerPatternParser($this->pattern);
176
+ $this->head = $patternParser->parse();
177
+ }
178
+
179
+ /**
180
+ * Produces a formatted string as specified by the conversion pattern.
181
+ *
182
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
183
+ * @return string
184
+ */
185
+ public function format(Ipagare_Log4php_LoggerLoggingEvent $event) {
186
+ $sbuf = '';
187
+ $c = $this->head;
188
+ while ($c !== null) {
189
+ $c->format($sbuf, $event);
190
+ $c = $c->next;
191
+ }
192
+ return $sbuf;
193
+ }
194
+
195
+ /**
196
+ * Returns an array with the formatted elements.
197
+ *
198
+ * This method is mainly used for the prepared statements of {@see Ipagare_Log4php_Appenders_LoggerAppenderPDO}.
199
+ *
200
+ * It requires {@link $this->pattern} to be a comma separated string of patterns like
201
+ * e.g. <code>%d,%c,%p,%m,%t,%F,%L</code>.
202
+ *
203
+ * @return array(string) An array of the converted elements i.e. timestamp, message, filename etc.
204
+ */
205
+ public function formatToArray(Ipagare_Log4php_LoggerLoggingEvent $event) {
206
+ $results = array();
207
+ $c = $this->head;
208
+ while ($c !== null) {
209
+ if ( ! $c instanceOf Ipagare_Log4php_Helpers_LoggerLiteralPatternConverter) {
210
+ $sbuf = null;
211
+ $c->format($sbuf, $event);
212
+ $results[] = $sbuf;
213
+ }
214
+ $c = $c->next;
215
+ }
216
+ return $results;
217
+ }
218
+
219
+ }
lib/Ipagare/Log4php/Layouts/LoggerLayoutSimple.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * A simple layout.
23
+ *
24
+ * Returns the log statement in a format consisting of the
25
+ * <b>level</b>, followed by " - " and then the <b>message</b>.
26
+ *
27
+ * For example the following php and properties files
28
+ *
29
+ * {@example ../../examples/php/layout_simple.php 19}<br>
30
+ *
31
+ * {@example ../../examples/resources/layout_simple.properties 18}<br>
32
+ *
33
+ * would result in:
34
+ *
35
+ * <samp>INFO - Hello World!</samp>
36
+ *
37
+ * @version $Revision: 1059292 $
38
+ * @package log4php
39
+ * @subpackage layouts
40
+ */
41
+ class Ipagare_Log4php_Layouts_LoggerLayoutSimple extends Ipagare_Log4php_LoggerLayout {
42
+ /**
43
+ * Constructor
44
+ */
45
+ public function __construct() {
46
+ }
47
+
48
+ /**
49
+ * Returns the log statement in a format consisting of the
50
+ * <b>level</b>, followed by " - " and then the
51
+ * <b>message</b>. For example,
52
+ * <samp> INFO - "A message" </samp>
53
+ *
54
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
55
+ * @return string
56
+ */
57
+ public function format(Ipagare_Log4php_LoggerLoggingEvent $event) {
58
+ $level = $event->getLevel();
59
+ $message = $event->getRenderedMessage();
60
+ return "$level - $message" . PHP_EOL;
61
+ }
62
+ }
lib/Ipagare/Log4php/Layouts/LoggerLayoutTTCC.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * TTCC layout format consists of <b>t</b>ime, <b>t</b>hread, <b>c</b>ategory and nested
23
+ * diagnostic <b>c</b>ontext information, hence the name.
24
+ *
25
+ * <p>Each of the four fields can be individually enabled or
26
+ * disabled. The time format depends on the <b>DateFormat</b> used.</p>
27
+ *
28
+ * <p>If no dateFormat is specified it defaults to '%c'.
29
+ * See php {@link PHP_MANUAL#date} function for details.</p>
30
+ *
31
+ * Configurable parameters for this layout are:
32
+ * - {@link $threadPrinting} (true|false) enable/disable pid reporting.
33
+ * - {@link $categoryPrefixing} (true|false) enable/disable logger category reporting.
34
+ * - {@link $contextPrinting} (true|false) enable/disable NDC reporting.
35
+ * - {@link $microSecondsPrinting} (true|false) enable/disable micro seconds reporting in timestamp.
36
+ * - {@link $dateFormat} (string) set date format. See php {@link PHP_MANUAL#date} function for details.
37
+ *
38
+ * An example how to use this layout:
39
+ *
40
+ * {@example ../../examples/php/layout_ttcc.php 19}<br>
41
+ *
42
+ * {@example ../../examples/resources/layout_ttcc.properties 18}<br>
43
+ *
44
+ * The above would print:<br>
45
+ * <samp>02:28 [13714] INFO root - Hello World!</samp>
46
+ *
47
+ * @version $Revision: 1136787 $
48
+ * @package log4php
49
+ * @subpackage layouts
50
+ */
51
+ class Ipagare_Log4php_Layouts_LoggerLayoutTTCC extends Ipagare_Log4php_LoggerLayout {
52
+
53
+ // Internal representation of options
54
+ protected $threadPrinting = true;
55
+ protected $categoryPrefixing = true;
56
+ protected $contextPrinting = true;
57
+ protected $microSecondsPrinting = true;
58
+
59
+ /**
60
+ * @var string date format. See {@link PHP_MANUAL#strftime} for details
61
+ */
62
+ protected $dateFormat = '%c';
63
+
64
+ /**
65
+ * Constructor
66
+ *
67
+ * @param string date format
68
+ * @see dateFormat
69
+ */
70
+ public function __construct($dateFormat = '') {
71
+ if (!empty($dateFormat)) {
72
+ $this->dateFormat = $dateFormat;
73
+ }
74
+ return;
75
+ }
76
+
77
+ /**
78
+ * The <b>ThreadPrinting</b> option specifies whether the name of the
79
+ * current thread is part of log output or not. This is true by default.
80
+ */
81
+ public function setThreadPrinting($threadPrinting) {
82
+ $this->threadPrinting = is_bool($threadPrinting) ?
83
+ $threadPrinting :
84
+ (bool)(strtolower($threadPrinting) == 'true');
85
+ }
86
+
87
+ /**
88
+ * @return boolean Returns value of the <b>ThreadPrinting</b> option.
89
+ */
90
+ public function getThreadPrinting() {
91
+ return $this->threadPrinting;
92
+ }
93
+
94
+ /**
95
+ * The <b>CategoryPrefixing</b> option specifies whether {@link Category}
96
+ * name is part of log output or not. This is true by default.
97
+ */
98
+ public function setCategoryPrefixing($categoryPrefixing) {
99
+ $this->categoryPrefixing = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($categoryPrefixing);
100
+ }
101
+
102
+ /**
103
+ * @return boolean Returns value of the <b>CategoryPrefixing</b> option.
104
+ */
105
+ public function getCategoryPrefixing() {
106
+ return $this->categoryPrefixing;
107
+ }
108
+
109
+ /**
110
+ * The <b>ContextPrinting</b> option specifies log output will include
111
+ * the nested context information belonging to the current thread.
112
+ * This is true by default.
113
+ */
114
+ public function setContextPrinting($contextPrinting) {
115
+ $this->contextPrinting = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($contextPrinting);
116
+ }
117
+
118
+ /**
119
+ * @return boolean Returns value of the <b>ContextPrinting</b> option.
120
+ */
121
+ public function getContextPrinting() {
122
+ return $this->contextPrinting;
123
+ }
124
+
125
+ /**
126
+ * The <b>MicroSecondsPrinting</b> option specifies if microseconds infos
127
+ * should be printed at the end of timestamp.
128
+ * This is true by default.
129
+ */
130
+ public function setMicroSecondsPrinting($microSecondsPrinting) {
131
+ $this->microSecondsPrinting = is_bool($microSecondsPrinting) ?
132
+ $microSecondsPrinting :
133
+ (bool)(strtolower($microSecondsPrinting) == 'true');
134
+ }
135
+
136
+ /**
137
+ * @return boolean Returns value of the <b>MicroSecondsPrinting</b> option.
138
+ */
139
+ public function getMicroSecondsPrinting() {
140
+ return $this->microSecondsPrinting;
141
+ }
142
+
143
+
144
+ public function setDateFormat($dateFormat) {
145
+ $this->dateFormat = $dateFormat;
146
+ }
147
+
148
+ /**
149
+ * @return string
150
+ */
151
+ public function getDateFormat() {
152
+ return $this->dateFormat;
153
+ }
154
+
155
+ /**
156
+ * In addition to the level of the statement and message, the
157
+ * returned string includes time, thread, category.
158
+ * <p>Time, thread, category are printed depending on options.
159
+ *
160
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
161
+ * @return string
162
+ */
163
+ public function format(Ipagare_Log4php_LoggerLoggingEvent $event) {
164
+ $timeStamp = (float)$event->getTimeStamp();
165
+ $format = strftime($this->dateFormat, (int)$timeStamp);
166
+
167
+ if ($this->microSecondsPrinting) {
168
+ $usecs = floor(($timeStamp - (int)$timeStamp) * 1000);
169
+ $format .= sprintf(',%03d', $usecs);
170
+ }
171
+
172
+ $format .= ' ';
173
+
174
+ if ($this->threadPrinting) {
175
+ $format .= '['.getmypid().'] ';
176
+ }
177
+
178
+ $level = $event->getLevel();
179
+ $format .= $level.' ';
180
+
181
+ if($this->categoryPrefixing) {
182
+ $format .= $event->getLoggerName().' ';
183
+ }
184
+
185
+ if($this->contextPrinting) {
186
+ $ndc = $event->getNDC();
187
+ if($ndc != null) {
188
+ $format .= $ndc.' ';
189
+ }
190
+ }
191
+
192
+ $format .= '- '.$event->getRenderedMessage();
193
+ $format .= PHP_EOL;
194
+
195
+ return $format;
196
+ }
197
+
198
+ public function ignoresThrowable() {
199
+ return true;
200
+ }
201
+ }
lib/Ipagare/Log4php/Layouts/LoggerLayoutXml.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * The output of the LoggerXmlLayout consists of a series of log4php:event elements.
23
+ *
24
+ * <p>Parameters: {@link $locationInfo}.</p>
25
+ *
26
+ * <p>It does not output a complete well-formed XML file.
27
+ * The output is designed to be included as an external entity in a separate file to form
28
+ * a correct XML file.</p>
29
+ *
30
+ * Example:
31
+ *
32
+ * {@example ../../examples/php/layout_xml.php 19}<br>
33
+ *
34
+ * {@example ../../examples/resources/layout_xml.properties 18}<br>
35
+ *
36
+ * The above would print:
37
+ *
38
+ * <pre>
39
+ * <log4php:eventSet xmlns:log4php="http://logging.apache.org/log4php/" version="0.3" includesLocationInfo="true">
40
+ * <log4php:event logger="root" level="INFO" thread="13802" timestamp="1252456226491">
41
+ * <log4php:message><![CDATA[Hello World!]]></log4php:message>
42
+ * <log4php:locationInfo class="main" file="examples/php/layout_xml.php" line="6" method="main" />
43
+ * </log4php:event>
44
+ * </log4php:eventSet>
45
+ * </pre>
46
+ *
47
+ * @version $Revision: 1059292 $
48
+ * @package log4php
49
+ * @subpackage layouts
50
+ */
51
+ class Ipagare_Log4php_Layouts_LoggerLayoutXml extends Ipagare_Log4php_LoggerLayout {
52
+ const LOG4J_NS_PREFIX ='log4j';
53
+ const LOG4J_NS = 'http://jakarta.apache.org/log4j/';
54
+
55
+ const LOG4PHP_NS_PREFIX = 'log4php';
56
+ const LOG4PHP_NS = 'http://logging.apache.org/log4php/';
57
+
58
+ const CDATA_START = '<![CDATA[';
59
+ const CDATA_END = ']]>';
60
+ const CDATA_PSEUDO_END = ']]&gt;';
61
+
62
+ const CDATA_EMBEDDED_END = ']]>]]&gt;<![CDATA[';
63
+
64
+ /**
65
+ * If set to true then the file name and line number of the origin of the
66
+ * log statement will be output.
67
+ *
68
+ * @var boolean
69
+ */
70
+ private $locationInfo = true;
71
+
72
+ /**
73
+ * @var boolean set the elements namespace
74
+ */
75
+ private $log4jNamespace = false;
76
+
77
+
78
+ /**
79
+ * @var string namespace
80
+ * @private
81
+ */
82
+ private $_namespace = self::LOG4PHP_NS;
83
+
84
+ /**
85
+ * @var string namespace prefix
86
+ * @private
87
+ */
88
+ private $_namespacePrefix = self::LOG4PHP_NS_PREFIX;
89
+
90
+ /**
91
+ * No options to activate.
92
+ */
93
+ public function activateOptions() {
94
+ if ($this->getLog4jNamespace()) {
95
+ $this->_namespace = self::LOG4J_NS;
96
+ $this->_namespacePrefix = self::LOG4J_NS_PREFIX;
97
+ } else {
98
+ $this->_namespace = self::LOG4PHP_NS;
99
+ $this->_namespacePrefix = self::LOG4PHP_NS_PREFIX;
100
+ }
101
+ }
102
+
103
+ /**
104
+ * @return string
105
+ */
106
+ public function getHeader() {
107
+ return "<{$this->_namespacePrefix}:eventSet ".
108
+ "xmlns:{$this->_namespacePrefix}=\"{$this->_namespace}\" ".
109
+ "version=\"0.3\" ".
110
+ "includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"".
111
+ ">\r\n";
112
+ }
113
+
114
+ /**
115
+ * Formats a {@link Ipagare_Log4php_LoggerLoggingEvent} in conformance with the log4php.dtd.
116
+ *
117
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
118
+ * @return string
119
+ */
120
+ public function format(Ipagare_Log4php_LoggerLoggingEvent $event) {
121
+ $loggerName = $event->getLoggerName();
122
+ $timeStamp = number_format((float)($event->getTimeStamp() * 1000), 0, '', '');
123
+ $thread = $event->getThreadName();
124
+ $level = $event->getLevel();
125
+ $levelStr = $level->toString();
126
+
127
+ $buf = "<{$this->_namespacePrefix}:event logger=\"{$loggerName}\" level=\"{$levelStr}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">".PHP_EOL;
128
+ $buf .= "<{$this->_namespacePrefix}:message><![CDATA[";
129
+ $this->appendEscapingCDATA($buf, $event->getRenderedMessage());
130
+ $buf .= "]]></{$this->_namespacePrefix}:message>".PHP_EOL;
131
+
132
+ $ndc = $event->getNDC();
133
+ if($ndc != null) {
134
+ $buf .= "<{$this->_namespacePrefix}:NDC><![CDATA[";
135
+ $this->appendEscapingCDATA($buf, $ndc);
136
+ $buf .= "]]></{$this->_namespacePrefix}:NDC>".PHP_EOL;
137
+ }
138
+
139
+ if ($this->getLocationInfo()) {
140
+ $locationInfo = $event->getLocationInformation();
141
+ $buf .= "<{$this->_namespacePrefix}:locationInfo ".
142
+ "class=\"" . $locationInfo->getClassName() . "\" ".
143
+ "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ".
144
+ "line=\"" . $locationInfo->getLineNumber() . "\" ".
145
+ "method=\"" . $locationInfo->getMethodName() . "\" ";
146
+ $buf .= "/>".PHP_EOL;
147
+
148
+ }
149
+
150
+ $buf .= "</{$this->_namespacePrefix}:event>".PHP_EOL.PHP_EOL;
151
+
152
+ return $buf;
153
+
154
+ }
155
+
156
+ /**
157
+ * @return string
158
+ */
159
+ public function getFooter() {
160
+ return "</{$this->_namespacePrefix}:eventSet>\r\n";
161
+ }
162
+
163
+
164
+ /** Whether or not file name and line number will be included in the output.
165
+ *
166
+ * @return boolean
167
+ */
168
+ public function getLocationInfo() {
169
+ return $this->locationInfo;
170
+ }
171
+
172
+ /**
173
+ * The {@link $locationInfo} option takes a boolean value. By default,
174
+ * it is set to false which means there will be no location
175
+ * information output by this layout. If the the option is set to
176
+ * true, then the file name and line number of the statement at the
177
+ * origin of the log statement will be output.
178
+ */
179
+ public function setLocationInfo($flag) {
180
+ $this->locationInfo = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($flag, true);
181
+ }
182
+
183
+ /**
184
+ * @return boolean
185
+ */
186
+ public function getLog4jNamespace() {
187
+ return $this->log4jNamespace;
188
+ }
189
+
190
+ /**
191
+ * @param boolean
192
+ */
193
+ public function setLog4jNamespace($flag) {
194
+ $this->log4jNamespace = Ipagare_Log4php_Helpers_LoggerOptionConverter::toBoolean($flag, true);
195
+ }
196
+
197
+ /**
198
+ * Ensures that embeded CDEnd strings (]]&gt;) are handled properly
199
+ * within message, NDC and throwable tag text.
200
+ *
201
+ * @param string $buf String holding the XML data to this point. The
202
+ * initial CDStart (<![CDATA[) and final CDEnd (]]>)
203
+ * of the CDATA section are the responsibility of
204
+ * the calling method.
205
+ * @param string str The String that is inserted into an existing
206
+ * CDATA Section within buf.
207
+ * @static
208
+ */
209
+ private function appendEscapingCDATA(&$buf, $str) {
210
+ if(empty($str)) {
211
+ return;
212
+ }
213
+
214
+ $rStr = str_replace(
215
+ self::CDATA_END,
216
+ self::CDATA_EMBEDDED_END,
217
+ $str
218
+ );
219
+ $buf .= $rStr;
220
+ }
221
+ }
222
+
lib/Ipagare/Log4php/Logger.php ADDED
@@ -0,0 +1,555 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * This is the central class in the log4php package. All logging operations
23
+ * are done through this class.
24
+ *
25
+ * The main logging methods are:
26
+ * <ul>
27
+ * <li>{@link trace()}</li>
28
+ * <li>{@link debug()}</li>
29
+ * <li>{@link info()}</li>
30
+ * <li>{@link warn()}</li>
31
+ * <li>{@link error()}</li>
32
+ * <li>{@link fatal()}</li>
33
+ * </ul>
34
+ *
35
+ * @category log4php
36
+ * @package log4php
37
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
38
+ * @version SVN: $Id: Logger.php 1137439 2011-06-19 21:13:04Z ihabunek $
39
+ * @link http://logging.apache.org/log4php
40
+ */
41
+ class Ipagare_Log4php_Logger {
42
+
43
+ /**
44
+ * Logger additivity. If set to true then child loggers will inherit
45
+ * the appenders of their ancestors by default.
46
+ * @var boolean
47
+ */
48
+ private $additive = true;
49
+
50
+ /** The Logger's fully qualified class name. */
51
+ private $fqcn = 'Ipagare_Log4php_Logger';
52
+
53
+ /** The assigned Logger level. */
54
+ private $level;
55
+
56
+ /** The name of this Logger instance. */
57
+ private $name;
58
+
59
+ /** The parent logger. Set to null if this is the root logger. */
60
+ private $parent;
61
+
62
+ /**
63
+ * A collection of appenders associated with this logger.
64
+ * @see Ipagare_Log4php_LoggerAppender
65
+ */
66
+ private $appenders = array();
67
+
68
+ /** The logger hierarchy used by log4php. */
69
+ private static $hierarchy;
70
+
71
+ /**
72
+ * Name of the configurator class used to configure log4php.
73
+ * Populated by {@link configure()} and used in {@link initialize()}.
74
+ */
75
+ private static $configurationClass = 'Ipagare_Log4php_Configurators_LoggerConfiguratorBasic';
76
+
77
+ /**
78
+ * Path to the configuration file which may be used by the configurator.
79
+ * Populated by {@link configure()} and used in {@link initialize()}.
80
+ */
81
+ private static $configurationFile;
82
+
83
+ /** Inidicates if log4php has been initialized */
84
+ private static $initialized = false;
85
+
86
+ /**
87
+ * Constructor.
88
+ * @param string $name Name of the logger.
89
+ */
90
+ public function __construct($name) {
91
+ $this->name = $name;
92
+ }
93
+
94
+ /**
95
+ * Returns the logger name.
96
+ * @return string
97
+ */
98
+ public function getName() {
99
+ return $this->name;
100
+ }
101
+
102
+ /**
103
+ * Returns the parent Logger. Can be null if this is the root logger.
104
+ * @return Logger
105
+ */
106
+ public function getParent() {
107
+ return $this->parent;
108
+ }
109
+
110
+ /**
111
+ * Returns the hierarchy used by this Logger.
112
+ * Caution: do not use this hierarchy unless you have called initialize().
113
+ * To get Loggers, use the Logger::getLogger and Logger::getRootLogger methods
114
+ * instead of operating on on the hierarchy directly.
115
+ *
116
+ * @deprecated - will be moved to private
117
+ * @return Ipagare_Log4php_LoggerHierarchy
118
+ */
119
+ public static function getHierarchy() {
120
+ if(!isset(self::$hierarchy)) {
121
+ self::$hierarchy = new Ipagare_Log4php_LoggerHierarchy(new Ipagare_Log4php_LoggerRoot());
122
+ }
123
+ return self::$hierarchy;
124
+ }
125
+
126
+ /* Logging methods */
127
+ /**
128
+ * Log a message object with the TRACE level.
129
+ *
130
+ * @param mixed $message message
131
+ * @param mixed $caller caller object or caller string id
132
+ */
133
+ public function trace($message, $caller = null) {
134
+ $this->log(Ipagare_Log4php_LoggerLevel::getLevelTrace(), $message, $caller);
135
+ }
136
+
137
+ /**
138
+ * Log a message object with the DEBUG level.
139
+ *
140
+ * @param mixed $message message
141
+ * @param mixed $caller caller object or caller string id
142
+ */
143
+ public function debug($message, $caller = null) {
144
+ $this->log(Ipagare_Log4php_LoggerLevel::getLevelDebug(), $message, $caller);
145
+ }
146
+
147
+
148
+ /**
149
+ * Log a message object with the INFO Level.
150
+ *
151
+ * @param mixed $message message
152
+ * @param mixed $caller caller object or caller string id
153
+ */
154
+ public function info($message, $caller = null) {
155
+ $this->log(Ipagare_Log4php_LoggerLevel::getLevelInfo(), $message, $caller);
156
+ }
157
+
158
+ /**
159
+ * Log a message with the WARN level.
160
+ *
161
+ * @param mixed $message message
162
+ * @param mixed $caller caller object or caller string id
163
+ */
164
+ public function warn($message, $caller = null) {
165
+ $this->log(Ipagare_Log4php_LoggerLevel::getLevelWarn(), $message, $caller);
166
+ }
167
+
168
+ /**
169
+ * Log a message object with the ERROR level.
170
+ *
171
+ * @param mixed $message message
172
+ * @param mixed $caller caller object or caller string id
173
+ */
174
+ public function error($message, $caller = null) {
175
+ $this->log(Ipagare_Log4php_LoggerLevel::getLevelError(), $message, $caller);
176
+ }
177
+
178
+ /**
179
+ * Log a message object with the FATAL level.
180
+ *
181
+ * @param mixed $message message
182
+ * @param mixed $caller caller object or caller string id
183
+ */
184
+ public function fatal($message, $caller = null) {
185
+ $this->log(Ipagare_Log4php_LoggerLevel::getLevelFatal(), $message, $caller);
186
+ }
187
+
188
+ /**
189
+ * This method creates a new logging event and logs the event without
190
+ * further checks.
191
+ *
192
+ * It should not be called directly. Use {@link trace()}, {@link debug()},
193
+ * {@link info()}, {@link warn()}, {@link error()} and {@link fatal()}
194
+ * wrappers.
195
+ *
196
+ * @param string $fqcn Fully qualified class name of the Logger
197
+ * @param mixed $caller caller object or caller string id
198
+ * @param Ipagare_Log4php_LoggerLevel $level log level
199
+ * @param mixed $message message to log
200
+ */
201
+ public function forcedLog($fqcn, $caller, $level, $message) {
202
+ $throwable = ($caller !== null && $caller instanceof Exception) ? $caller : null;
203
+
204
+ $this->callAppenders(new Ipagare_Log4php_LoggerLoggingEvent($fqcn, $this, $level, $message, null, $throwable));
205
+ }
206
+
207
+
208
+ /**
209
+ * Check whether this Logger is enabled for the DEBUG Level.
210
+ * @return boolean
211
+ */
212
+ public function isDebugEnabled() {
213
+ return $this->isEnabledFor(Ipagare_Log4php_LoggerLevel::getLevelDebug());
214
+ }
215
+
216
+ /**
217
+ * Check whether this Logger is enabled for a given Level passed as parameter.
218
+ *
219
+ * @param Ipagare_Log4php_LoggerLevel level
220
+ * @return boolean
221
+ */
222
+ public function isEnabledFor($level) {
223
+ return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel()));
224
+ }
225
+
226
+ /**
227
+ * Check whether this Logger is enabled for the INFO Level.
228
+ * @return boolean
229
+ */
230
+ public function isInfoEnabled() {
231
+ return $this->isEnabledFor(Ipagare_Log4php_LoggerLevel::getLevelInfo());
232
+ }
233
+
234
+ /**
235
+ * Log a message using the provided logging level.
236
+ *
237
+ * @param Ipagare_Log4php_LoggerLevel $priority The logging level.
238
+ * @param mixed $message Message to log.
239
+ * @param mixed $caller caller object or caller string id
240
+ */
241
+ public function log($priority, $message, $caller = null) {
242
+ if($this->isEnabledFor($priority)) {
243
+ $this->forcedLog($this->fqcn, $caller, $priority, $message);
244
+ }
245
+ }
246
+
247
+ /**
248
+ * If assertion parameter is false, then logs the message as an error.
249
+ *
250
+ * @param bool $assertion
251
+ * @param string $msg message to log
252
+ */
253
+ public function assertLog($assertion = true, $msg = '') {
254
+ if($assertion == false) {
255
+ $this->error($msg);
256
+ }
257
+ }
258
+
259
+ /* Factory methods */
260
+
261
+ /**
262
+ * Get a Logger by name (Delegate to {@link Logger})
263
+ *
264
+ * @param string $name logger name
265
+ * @param LoggerFactory $factory a {@link LoggerFactory} instance or null
266
+ * @return Logger
267
+ * @static
268
+ */
269
+ public static function getLogger($name) {
270
+ if(!self::isInitialized()) {
271
+ self::initialize();
272
+ }
273
+ return self::getHierarchy()->getLogger($name);
274
+ }
275
+
276
+ /**
277
+ * Get the Root Logger (Delegate to {@link Logger})
278
+ * @return Ipagare_Log4php_LoggerRoot
279
+ * @static
280
+ */
281
+ public static function getRootLogger() {
282
+ if(!self::isInitialized()) {
283
+ self::initialize();
284
+ }
285
+ return self::getHierarchy()->getRootLogger();
286
+ }
287
+
288
+ /* Configuration methods */
289
+
290
+ /**
291
+ * Add a new appender to the Logger.
292
+ *
293
+ * @param Ipagare_Log4php_LoggerAppender $appender The appender to add.
294
+ */
295
+ public function addAppender($appender) {
296
+ $appenderName = $appender->getName();
297
+ $this->appenders[$appenderName] = $appender;
298
+ }
299
+
300
+ /**
301
+ * Remove all previously added appenders from the Logger.
302
+ */
303
+ public function removeAllAppenders() {
304
+ $appenderNames = array_keys($this->appenders);
305
+ $enumAppenders = count($appenderNames);
306
+ for($i = 0; $i < $enumAppenders; $i++) {
307
+ $this->removeAppender($appenderNames[$i]);
308
+ }
309
+ }
310
+
311
+ /**
312
+ * Remove the appender passed as parameter form the Logger.
313
+ *
314
+ * @param string|Ipagare_Log4php_LoggerAppender $appender an appender name or a {@link Ipagare_Log4php_LoggerAppender} instance.
315
+ */
316
+ public function removeAppender($appender) {
317
+ if($appender instanceof Ipagare_Log4php_LoggerAppender) {
318
+ $appender->close();
319
+ unset($this->appenders[$appender->getName()]);
320
+ } else if (is_string($appender) and isset($this->appenders[$appender])) {
321
+ $this->appenders[$appender]->close();
322
+ unset($this->appenders[$appender]);
323
+ }
324
+ }
325
+
326
+ /**
327
+ * Forwards the given logging event to all appenders associated with the
328
+ * Logger.
329
+ *
330
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
331
+ */
332
+ public function callAppenders($event) {
333
+ foreach($this->appenders as $appender) {
334
+ $appender->doAppend($event);
335
+ }
336
+
337
+ if($this->parent != null and $this->getAdditivity()) {
338
+ $this->parent->callAppenders($event);
339
+ }
340
+ }
341
+
342
+ /**
343
+ * Get the appenders contained in this logger as an array.
344
+ * @return array collection of appender names
345
+ */
346
+ public function getAllAppenders() {
347
+ return array_values($this->appenders);
348
+ }
349
+
350
+ /**
351
+ * Get an appender by name.
352
+ * @return Ipagare_Log4php_LoggerAppender
353
+ */
354
+ public function getAppender($name) {
355
+ return $this->appenders[$name];
356
+ }
357
+
358
+ /**
359
+ * Get the additivity flag.
360
+ * @return boolean
361
+ */
362
+ public function getAdditivity() {
363
+ return $this->additive;
364
+ }
365
+
366
+ /**
367
+ * Starting from this Logger, search the Logger hierarchy for a non-null level and return it.
368
+ * @see Ipagare_Log4php_LoggerLevel
369
+ * @return Ipagare_Log4php_LoggerLevel or null
370
+ */
371
+ public function getEffectiveLevel() {
372
+ for($c = $this; $c != null; $c = $c->parent) {
373
+ if($c->getLevel() !== null) {
374
+ return $c->getLevel();
375
+ }
376
+ }
377
+ return null;
378
+ }
379
+
380
+ /**
381
+ * Get the assigned Logger level.
382
+ * @return Ipagare_Log4php_LoggerLevel The assigned level or null if none is assigned.
383
+ */
384
+ public function getLevel() {
385
+ return $this->level;
386
+ }
387
+
388
+ /**
389
+ * Set the Logger level.
390
+ *
391
+ * @param Ipagare_Log4php_LoggerLevel $level the level to set
392
+ */
393
+ public function setLevel($level) {
394
+ $this->level = $level;
395
+ }
396
+
397
+ /**
398
+ * Clears all Logger definitions from the logger hierarchy.
399
+ *
400
+ * @static
401
+ * @return boolean
402
+ */
403
+ public static function clear() {
404
+ return self::getHierarchy()->clear();
405
+ }
406
+
407
+ /**
408
+ * Destroy configurations for logger definitions
409
+ *
410
+ * @static
411
+ * @return boolean
412
+ */
413
+ public static function resetConfiguration() {
414
+ $result = self::getHierarchy()->resetConfiguration();
415
+ self::$initialized = false;
416
+ self::$configurationClass = 'Ipagare_Log4php_Configurators_LoggerConfiguratorBasic';
417
+ self::$configurationFile = null;
418
+ return $result;
419
+ }
420
+
421
+ /**
422
+ * Safely close all appenders.
423
+ *
424
+ * @deprecated This is no longer necessary due the appenders shutdown via
425
+ * destructors.
426
+ * @static
427
+ */
428
+ public static function shutdown() {
429
+ return self::getHierarchy()->shutdown();
430
+ }
431
+
432
+ /**
433
+ * check if a given logger exists.
434
+ *
435
+ * @param string $name logger name
436
+ * @static
437
+ * @return boolean
438
+ */
439
+ public static function exists($name) {
440
+ return self::getHierarchy()->exists($name);
441
+ }
442
+
443
+ /**
444
+ * Returns an array this whole Logger instances.
445
+ *
446
+ * @static
447
+ * @see Logger
448
+ * @return array
449
+ */
450
+ public static function getCurrentLoggers() {
451
+ return self::getHierarchy()->getCurrentLoggers();
452
+ }
453
+
454
+ /**
455
+ * Checks whether an appender is attached to this logger instance.
456
+ *
457
+ * @param Ipagare_Log4php_LoggerAppender $appender
458
+ * @return boolean
459
+ */
460
+ public function isAttached(Ipagare_Log4php_LoggerAppender $appender) {
461
+ return isset($this->appenders[$appender->getName()]);
462
+ }
463
+
464
+ /**
465
+ * Sets the additivity flag.
466
+ * @param boolean $additive
467
+ */
468
+ public function setAdditivity($additive) {
469
+ $this->additive = (bool)$additive;
470
+ }
471
+
472
+ /**
473
+ * Sets the parent logger.
474
+ * @param Logger $logger
475
+ */
476
+ public function setParent(Ipagare_Log4php_Logger $logger) {
477
+ $this->parent = $logger;
478
+ }
479
+
480
+ /**
481
+ * Configures log4php by defining a configuration file and/or class.
482
+ *
483
+ * This method needs to be called before the first logging event has
484
+ * occured. If this method is not called before then, the standard
485
+ * configuration takes place (@see Ipagare_Log4php_Configurators_LoggerConfiguratorBasic).
486
+ *
487
+ * If only the configuration file is given, the configurator class will
488
+ * be determined by the config file extension.
489
+ *
490
+ * If a custom configurator class is provided, the configuration file
491
+ * should either be null or contain the path to file used by the custom
492
+ * configurator. Make sure the configurator class is already loaded, or
493
+ * that it can be included by PHP when necessary.
494
+ *
495
+ * @param string $configurationFile path to the configuration file
496
+ * @param string $configurationClass name of the custom configurator class
497
+ */
498
+ public static function configure($configurationFile = null, $configurationClass = null ) {
499
+ if($configurationClass === null && $configurationFile === null) {
500
+ self::$configurationClass = 'Ipagare_Log4php_Configurators_LoggerConfiguratorBasic';
501
+ return;
502
+ }
503
+
504
+ if($configurationClass !== null) {
505
+ self::$configurationFile = $configurationFile;
506
+ self::$configurationClass = $configurationClass;
507
+ return;
508
+ }
509
+
510
+ if (strtolower(substr( $configurationFile, -4 )) == '.xml') {
511
+ self::$configurationFile = $configurationFile;
512
+ self::$configurationClass = 'Ipagare_Log4php_Configurators_LoggerConfiguratorXml';
513
+ } else {
514
+ self::$configurationFile = $configurationFile;
515
+ self::$configurationClass = 'Ipagare_Log4php_Configurators_LoggerConfiguratorIni';
516
+ }
517
+ }
518
+
519
+ /**
520
+ * Returns the current {@link Logger::$configurationClass configurator class}.
521
+ * @return string the configurator class name
522
+ */
523
+ public static function getConfigurationClass() {
524
+ return self::$configurationClass;
525
+ }
526
+
527
+ /**
528
+ * Returns the current {@link Logger::$configurationFile configuration file}.
529
+ * @return string the configuration file
530
+ */
531
+ public static function getConfigurationFile() {
532
+ return self::$configurationFile;
533
+ }
534
+
535
+ /**
536
+ * Returns true if the log4php framework has been initialized.
537
+ * @return boolean
538
+ */
539
+ private static function isInitialized() {
540
+ return self::$initialized;
541
+ }
542
+
543
+ /**
544
+ * Initializes the log4php framework using the provided {@link
545
+ * Logger::$configurationClass configuration class} and {@link
546
+ * Logger::$configurationFile configuration file}.
547
+ * @return boolean
548
+ */
549
+ public static function initialize() {
550
+ self::$initialized = true;
551
+ $instance = Ipagare_Log4php_LoggerReflectionUtils::createObject(self::$configurationClass);
552
+ $result = $instance->configure(self::getHierarchy(), self::$configurationFile);
553
+ return $result;
554
+ }
555
+ }
lib/Ipagare/Log4php/LoggerAppender.php ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * 7 http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Abstract class that defines output logs strategies.
23
+ *
24
+ * @version $Revision: 1062665 $
25
+ * @package log4php
26
+ */
27
+ abstract class Ipagare_Log4php_LoggerAppender {
28
+
29
+ /**
30
+ * @var boolean closed appender flag
31
+ */
32
+ protected $closed = false;
33
+
34
+ /**
35
+ * The first filter in the filter chain
36
+ * @var Ipagare_Log4php_LoggerFilter
37
+ */
38
+ protected $filter = null;
39
+
40
+ /**
41
+ * Ipagare_Log4php_LoggerLayout for this appender. It can be null if appender has its own layout
42
+ * @var Ipagare_Log4php_LoggerLayout
43
+ */
44
+ protected $layout = null;
45
+
46
+ /**
47
+ * @var string Appender name
48
+ */
49
+ protected $name;
50
+
51
+ /**
52
+ * @var Ipagare_Log4php_LoggerLevel There is no level threshold filtering by default.
53
+ */
54
+ protected $threshold = null;
55
+
56
+ /**
57
+ * @var boolean needs a layout formatting ?
58
+ */
59
+ protected $requiresLayout = true;
60
+
61
+ /**
62
+ * Constructor
63
+ *
64
+ * @param string $name appender name
65
+ */
66
+ public function __construct($name = '') {
67
+ $this->name = $name;
68
+ }
69
+
70
+ /**
71
+ * Add a filter to the end of the filter list.
72
+ *
73
+ * @param Ipagare_Log4php_LoggerFilter $newFilter add a new Ipagare_Log4php_LoggerFilter
74
+ */
75
+ public function addFilter($newFilter) {
76
+ if($this->filter === null) {
77
+ $this->filter = $newFilter;
78
+ } else {
79
+ $this->filter->addNext($newFilter);
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Clear the list of filters by removing all the filters in it.
85
+ * @abstract
86
+ */
87
+ public function clearFilters() {
88
+ unset($this->filter);
89
+ $this->filter = null;
90
+ }
91
+
92
+ /**
93
+ * Return the first filter in the filter chain for this Appender.
94
+ * The return value may be <i>null</i> if no is filter is set.
95
+ * @return Ipagare_Log4php_LoggerFilter
96
+ */
97
+ public function getFilter() {
98
+ return $this->filter;
99
+ }
100
+
101
+ /**
102
+ * Return the first filter in the filter chain for this Appender.
103
+ * The return value may be <i>null</i> if no is filter is set.
104
+ * @return Ipagare_Log4php_LoggerFilter
105
+ */
106
+ public function getFirstFilter() {
107
+ return $this->filter;
108
+ }
109
+
110
+
111
+ /**
112
+ * This method performs threshold checks and invokes filters before
113
+ * delegating actual logging to the subclasses specific <i>append()</i> method.
114
+ * @see Ipagare_Log4php_LoggerAppender::doAppend()
115
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
116
+ */
117
+ public function doAppend(Ipagare_Log4php_LoggerLoggingEvent $event) {
118
+ if($this->closed) {
119
+ return;
120
+ }
121
+
122
+ if(!$this->isAsSevereAsThreshold($event->getLevel())) {
123
+ return;
124
+ }
125
+
126
+ $f = $this->getFirstFilter();
127
+ while($f !== null) {
128
+ switch ($f->decide($event)) {
129
+ case Ipagare_Log4php_LoggerFilter::DENY: return;
130
+ case Ipagare_Log4php_LoggerFilter::ACCEPT: return $this->append($event);
131
+ case Ipagare_Log4php_LoggerFilter::NEUTRAL: $f = $f->getNext();
132
+ }
133
+ }
134
+ $this->append($event);
135
+ }
136
+
137
+ /**
138
+ * Set the Layout for this appender.
139
+ * @see Ipagare_Log4php_LoggerAppender::setLayout()
140
+ * @param Ipagare_Log4php_LoggerLayout $layout
141
+ */
142
+ public function setLayout($layout) {
143
+ if($this->requiresLayout()) {
144
+ $this->layout = $layout;
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Returns this appender layout.
150
+ * @see Ipagare_Log4php_LoggerAppender::getLayout()
151
+ * @return Ipagare_Log4php_LoggerLayout
152
+ */
153
+ public function getLayout() {
154
+ return $this->layout;
155
+ }
156
+
157
+ /**
158
+ * Configurators call this method to determine if the appender
159
+ * requires a layout.
160
+ *
161
+ * <p>If this method returns <i>true</i>, meaning that layout is required,
162
+ * then the configurator will configure a layout using the configuration
163
+ * information at its disposal. If this method returns <i>false</i>,
164
+ * meaning that a layout is not required, then layout configuration will be
165
+ * skipped even if there is available layout configuration
166
+ * information at the disposal of the configurator.</p>
167
+ *
168
+ * <p>In the rather exceptional case, where the appender
169
+ * implementation admits a layout but can also work without it, then
170
+ * the appender should return <i>true</i>.</p>
171
+ *
172
+ * @see Ipagare_Log4php_LoggerAppender::requiresLayout()
173
+ * @return boolean
174
+ */
175
+ public function requiresLayout() {
176
+ return $this->requiresLayout;
177
+ }
178
+
179
+ /**
180
+ * Get the name of this appender.
181
+ * @see Ipagare_Log4php_LoggerAppender::getName()
182
+ * @return string
183
+ */
184
+ public function getName() {
185
+ return $this->name;
186
+ }
187
+
188
+ /**
189
+ * Set the name of this appender.
190
+ *
191
+ * The name is used by other components to identify this appender.
192
+ *
193
+ *
194
+ * @param string $name
195
+ */
196
+ public function setName($name) {
197
+ $this->name = $name;
198
+ }
199
+
200
+ /**
201
+ * Returns this appenders threshold level.
202
+ * See the {@link setThreshold()} method for the meaning of this option.
203
+ * @return Ipagare_Log4php_LoggerLevel
204
+ */
205
+ public function getThreshold() {
206
+ return $this->threshold;
207
+ }
208
+
209
+ /**
210
+ * Set the threshold level of this appender.
211
+ *
212
+ * @param mixed $threshold can be a {@link Ipagare_Log4php_LoggerLevel} object or a string.
213
+ * @see Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel()
214
+ */
215
+ public function setThreshold($threshold) {
216
+ if(is_string($threshold)) {
217
+ $this->threshold = Ipagare_Log4php_Helpers_LoggerOptionConverter::toLevel($threshold, null);
218
+ } else if($threshold instanceof Ipagare_Log4php_LoggerLevel) {
219
+ $this->threshold = $threshold;
220
+ }
221
+ }
222
+
223
+ /**
224
+ * Check whether the message level is below the appender's threshold.
225
+ *
226
+ *
227
+ * If there is no threshold set, then the return value is always <i>true</i>.
228
+ * @param Ipagare_Log4php_LoggerLevel $level
229
+ * @return boolean true if priority is greater or equal than threshold
230
+ */
231
+ public function isAsSevereAsThreshold($level) {
232
+ if($this->threshold === null) {
233
+ return true;
234
+ }
235
+ return $level->isGreaterOrEqual($this->getThreshold());
236
+ }
237
+
238
+ /**
239
+ * Derived appenders should override this method if option structure
240
+ * requires it.
241
+ */
242
+ abstract public function activateOptions();
243
+
244
+ /**
245
+ * Subclasses of {@link Ipagare_Log4php_LoggerAppender} should implement
246
+ * this method to perform actual logging.
247
+ *
248
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event
249
+ * @see doAppend()
250
+ * @abstract
251
+ */
252
+ abstract protected function append(Ipagare_Log4php_LoggerLoggingEvent $event);
253
+
254
+ /**
255
+ * Release any resources allocated.
256
+ * Subclasses of {@link Ipagare_Log4php_LoggerAppender} should implement
257
+ * this method to perform proper closing procedures.
258
+ * @abstract
259
+ */
260
+ abstract public function close();
261
+ }
lib/Ipagare/Log4php/LoggerAppenderPool.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Pool implmentation for Ipagare_Log4php_LoggerAppender instances
23
+ *
24
+ * @version $Revision: 795727 $
25
+ * @package log4php
26
+ */
27
+ class Ipagare_Log4php_LoggerAppenderPool {
28
+ /* Appender Pool */
29
+ public static $appenderPool = array();
30
+
31
+ /**
32
+ *
33
+ *
34
+ * @param string $name
35
+ * @param string $class
36
+ * @return Ipagare_Log4php_LoggerAppender
37
+ */
38
+ public static function getAppenderFromPool($name, $class = '') {
39
+ if(isset(self::$appenderPool[$name])) {
40
+ return self::$appenderPool[$name];
41
+ }
42
+
43
+ if(empty($class)) {
44
+ return null;
45
+ }
46
+
47
+ $appender = Ipagare_Log4php_LoggerReflectionUtils::createObject($class);
48
+ $appender->setName($name);
49
+ if($appender !== null) {
50
+ self::$appenderPool[$name] = $appender;
51
+ return self::$appenderPool[$name];
52
+ }
53
+ return null;
54
+ }
55
+
56
+ public static function clear()
57
+ {
58
+ self::$appenderPool = array();
59
+ }
60
+ }
lib/Ipagare/Log4php/LoggerConfigurator.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Implemented by classes capable of configuring log4php using a URL.
23
+ *
24
+ * @version $Revision: 822448 $
25
+ * @package log4php
26
+ */
27
+ interface Ipagare_Log4php_LoggerConfigurator {
28
+
29
+ /**
30
+ * Special level value signifying inherited behaviour. The current
31
+ * value of this string constant is <b>inherited</b>.
32
+ * {@link CONFIGURATOR_NULL} is a synonym.
33
+ */
34
+ const CONFIGURATOR_INHERITED = 'inherited';
35
+
36
+ /**
37
+ * Special level signifying inherited behaviour, same as
38
+ * {@link CONFIGURATOR_INHERITED}.
39
+ * The current value of this string constant is <b>null</b>.
40
+ */
41
+ const CONFIGURATOR_NULL = 'null';
42
+
43
+ /**
44
+ * Interpret a resource pointed by a <var>url</var> and configure accordingly.
45
+ *
46
+ * The configuration is done relative to the <var>repository</var>
47
+ * parameter.
48
+ *
49
+ * @param string $url The URL to parse
50
+ */
51
+ public function configure(Ipagare_Log4php_LoggerHierarchy $hierarchy, $url = null);
52
+
53
+ }
lib/Ipagare/Log4php/LoggerException.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Ipagare_Log4php_LoggerException class
23
+ *
24
+ * @version $Revision: 771547 $
25
+ * @package log4php
26
+ */
27
+ class Ipagare_Log4php_LoggerException extends Exception {
28
+ }
lib/Ipagare/Log4php/LoggerFilter.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Users should extend this class to implement customized logging
23
+ * event filtering. Note that {@link LoggerCategory} and {@link Ipagare_Log4php_LoggerAppender},
24
+ * the parent class of all standard
25
+ * appenders, have built-in filtering rules. It is suggested that you
26
+ * first use and understand the built-in rules before rushing to write
27
+ * your own custom filters.
28
+ *
29
+ * <p>This abstract class assumes and also imposes that filters be
30
+ * organized in a linear chain. The {@link #decide
31
+ * decide(Ipagare_Log4php_LoggerLoggingEvent)} method of each filter is called sequentially,
32
+ * in the order of their addition to the chain.
33
+ *
34
+ * <p>The {@link decide()} method must return one
35
+ * of the integer constants {@link Ipagare_Log4php_LoggerFilter::DENY},
36
+ * {@link Ipagare_Log4php_LoggerFilter::NEUTRAL} or {@link Ipagare_Log4php_LoggerFilter::ACCEPT}.
37
+ *
38
+ * <p>If the value {@link Ipagare_Log4php_LoggerFilter::DENY} is returned, then the log event is
39
+ * dropped immediately without consulting with the remaining
40
+ * filters.
41
+ *
42
+ * <p>If the value {@link Ipagare_Log4php_LoggerFilter::NEUTRAL} is returned, then the next filter
43
+ * in the chain is consulted. If there are no more filters in the
44
+ * chain, then the log event is logged. Thus, in the presence of no
45
+ * filters, the default behaviour is to log all logging events.
46
+ *
47
+ * <p>If the value {@link Ipagare_Log4php_LoggerFilter::ACCEPT} is returned, then the log
48
+ * event is logged without consulting the remaining filters.
49
+ *
50
+ * <p>The philosophy of log4php filters is largely inspired from the
51
+ * Linux ipchains.
52
+ *
53
+ * @version $Revision: 1059292 $
54
+ * @package log4php
55
+ */
56
+ abstract class Ipagare_Log4php_LoggerFilter {
57
+
58
+ /**
59
+ * The log event must be logged immediately without consulting with
60
+ * the remaining filters, if any, in the chain.
61
+ */
62
+ const ACCEPT = 1;
63
+
64
+ /**
65
+ * This filter is neutral with respect to the log event. The
66
+ * remaining filters, if any, should be consulted for a final decision.
67
+ */
68
+ const NEUTRAL = 0;
69
+
70
+ /**
71
+ * The log event must be dropped immediately without consulting
72
+ * with the remaining filters, if any, in the chain.
73
+ */
74
+ const DENY = -1;
75
+
76
+ /**
77
+ * @var Ipagare_Log4php_LoggerFilter Points to the next {@link Ipagare_Log4php_LoggerFilter} in the filter chain.
78
+ */
79
+ protected $next;
80
+
81
+ /**
82
+ * Usually filters options become active when set. We provide a
83
+ * default do-nothing implementation for convenience.
84
+ */
85
+ public function activateOptions() {
86
+ }
87
+
88
+ /**
89
+ * Decide what to do.
90
+ * <p>If the decision is {@link Ipagare_Log4php_LoggerFilter::DENY}, then the event will be
91
+ * dropped. If the decision is {@link Ipagare_Log4php_LoggerFilter::NEUTRAL}, then the next
92
+ * filter, if any, will be invoked. If the decision is {@link Ipagare_Log4php_LoggerFilter::ACCEPT} then
93
+ * the event will be logged without consulting with other filters in
94
+ * the chain.
95
+ *
96
+ * @param Ipagare_Log4php_LoggerLoggingEvent $event The {@link Ipagare_Log4php_LoggerLoggingEvent} to decide upon.
97
+ * @return integer {@link Ipagare_Log4php_LoggerFilter::NEUTRAL} or {@link Ipagare_Log4php_LoggerFilter::DENY}|{@link Ipagare_Log4php_LoggerFilter::ACCEPT}
98
+ */
99
+ public function decide(Ipagare_Log4php_LoggerLoggingEvent $event) {
100
+ return self::NEUTRAL;
101
+ }
102
+
103
+ /**
104
+ * Adds a new filter to the filter chain this filter is a part of.
105
+ * If this filter has already and follow up filter, the param filter
106
+ * is passed on until it is the last filter in chain.
107
+ *
108
+ * @param $filter - the filter to add to this chain
109
+ */
110
+ public function addNext($filter) {
111
+ if($this->next !== null) {
112
+ $this->next->addNext($filter);
113
+ } else {
114
+ $this->next = $filter;
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Returns the next filter in this chain
120
+ * @return the next filter
121
+ */
122
+ public function getNext() {
123
+ return $this->next;
124
+ }
125
+
126
+ }
lib/Ipagare/Log4php/LoggerHierarchy.php ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * This class is specialized in retrieving loggers by name and also maintaining
23
+ * the logger hierarchy. The logger hierarchy is dealing with the several Log-Levels
24
+ * Logger can have. From log4j website:
25
+ *
26
+ * "A logger is said to be an ancestor of another logger if its name followed
27
+ * by a dot is a prefix of the descendant logger name. A logger is said to be
28
+ * a parent of a child logger if there are no ancestors between itself and the
29
+ * descendant logger."
30
+ *
31
+ * Child Loggers do inherit their Log-Levels from their Ancestors. They can
32
+ * increase their Log-Level compared to their Ancestors, but they cannot decrease it.
33
+ *
34
+ * <p>The casual user does not have to deal with this class directly.</p>
35
+ *
36
+ * <p>The structure of the logger hierarchy is maintained by the
37
+ * getLogger method. The hierarchy is such that children link
38
+ * to their parent but parents do not have any pointers to their
39
+ * children. Moreover, loggers can be instantiated in any order, in
40
+ * particular descendant before ancestor.</p>
41
+ *
42
+ * <p>In case a descendant is created before a particular ancestor,
43
+ * then it creates a provision node for the ancestor and adds itself
44
+ * to the provision node. Other descendants of the same ancestor add
45
+ * themselves to the previously created provision node.</p>
46
+ *
47
+ * @version $Revision: 1059292 $
48
+ * @package log4php
49
+ */
50
+ /*
51
+ * TODO:
52
+ * - addHierarchyEventListener($listener) not supported
53
+ * - emitNoAppenderWarning($cat) not supported
54
+ * - fireAddAppenderEvent not supported
55
+ */
56
+ class Ipagare_Log4php_LoggerHierarchy {
57
+ /** Default Factory */
58
+ protected $defaultFactory;
59
+
60
+ /** array hierarchy tree. saves here all loggers */
61
+ protected $ht = array();
62
+
63
+ /** The root Ipagare_Log4php_Logger */
64
+ protected $root = null;
65
+
66
+ /** Ipagare_Log4php_Renderers_LoggerRendererMap */
67
+ protected $rendererMap;
68
+
69
+ /** Ipagare_Log4php_LoggerLevel main level threshold */
70
+ protected $threshold;
71
+
72
+ /**
73
+ * Create a new logger hierarchy.
74
+ * @param object $root the root logger
75
+ */
76
+ public function __construct(Ipagare_Log4php_LoggerRoot $root) {
77
+ $this->root = $root;
78
+ $this->setThreshold(Ipagare_Log4php_LoggerLevel::getLevelAll());
79
+ $this->rendererMap = new Ipagare_Log4php_Renderers_LoggerRendererMap();
80
+ }
81
+
82
+ /**
83
+ * This call will clear all logger definitions from the internal hashtable.
84
+ */
85
+ public function clear() {
86
+ $this->ht = array();
87
+ }
88
+
89
+ /**
90
+ * Check if the named logger exists in the hierarchy.
91
+ * @param string $name
92
+ * @return boolean
93
+ */
94
+ public function exists($name) {
95
+ return isset($this->ht[$name]);
96
+ }
97
+
98
+ /**
99
+ * Returns all the currently defined categories in this hierarchy as an array.
100
+ * @return array
101
+ */
102
+ public function getCurrentLoggers() {
103
+ return array_values($this->ht);
104
+ }
105
+
106
+ /**
107
+ * Return a new logger instance named as the first parameter using the default factory.
108
+ *
109
+ * @param string $name logger name
110
+ * @param LoggerFactory $factory a {@link LoggerFactory} instance or null
111
+ * @return Ipagare_Log4php_Logger
112
+ */
113
+ public function getLogger($name) {
114
+ if(!isset($this->ht[$name])) {
115
+ $this->ht[$name] = new Ipagare_Log4php_Logger($name);;
116
+ // TODO: isn't necessary, access via singleton?
117
+ // $this->ht[$name]->setHierarchy($this);
118
+ $nodes = explode('.', $name);
119
+ $firstNode = array_shift($nodes);
120
+
121
+ // if name is not a first node but another first node is their
122
+ if($firstNode != $name and isset($this->ht[$firstNode])) {
123
+ $this->ht[$name]->setParent($this->ht[$firstNode]);
124
+ } else {
125
+ // if there is no father, set root logger as father
126
+ $this->ht[$name]->setParent($this->root);
127
+ }
128
+
129
+ // if there are more nodes than one
130
+ if(count($nodes) > 0) {
131
+ // find parent node
132
+ foreach($nodes as $node) {
133
+ $parentNode = "$firstNode.$node";
134
+ if(isset($this->ht[$parentNode]) and $parentNode != $name) {
135
+
136
+ $this->ht[$name]->setParent($this->ht[$parentNode]);
137
+ }
138
+ $firstNode .= ".$node";
139
+ }
140
+ }
141
+ }
142
+
143
+ return $this->ht[$name];
144
+ }
145
+
146
+ /**
147
+ * @return Ipagare_Log4php_Renderers_LoggerRendererMap Get the renderer map for this hierarchy.
148
+ */
149
+ public function getRendererMap() {
150
+ return $this->rendererMap;
151
+ }
152
+
153
+ /**
154
+ * @return Ipagare_Log4php_LoggerRoot Get the root of this hierarchy.
155
+ */
156
+ public function getRootLogger() {
157
+ if(!isset($this->root) or $this->root == null) {
158
+ $this->root = new Ipagare_Log4php_LoggerRoot();
159
+ }
160
+ return $this->root;
161
+ }
162
+
163
+ /**
164
+ * @return Ipagare_Log4php_LoggerLevel Returns the threshold Level.
165
+ */
166
+ public function getThreshold() {
167
+ return $this->threshold;
168
+ }
169
+
170
+ /**
171
+ * This method will return true if this repository is disabled
172
+ * for level object passed as parameter and false otherwise.
173
+ * @return boolean
174
+ */
175
+ public function isDisabled(Ipagare_Log4php_LoggerLevel $level) {
176
+ return ($this->threshold->toInt() > $level->toInt());
177
+ }
178
+
179
+ /**
180
+ * Reset all values contained in this hierarchy instance to their
181
+ * default.
182
+ *
183
+ * This removes all appenders from all categories, sets
184
+ * the level of all non-root categories to <i>null</i>,
185
+ * sets their additivity flag to <i>true</i> and sets the level
186
+ * of the root logger to {@link LOGGER_LEVEL_DEBUG}. Moreover,
187
+ * message disabling is set its default "off" value.
188
+ *
189
+ * <p>Existing categories are not removed. They are just reset.
190
+ *
191
+ * <p>This method should be used sparingly and with care as it will
192
+ * block all logging until it is completed.</p>
193
+ */
194
+ public function resetConfiguration() {
195
+ $root = $this->getRootLogger();
196
+
197
+ $root->setLevel(Ipagare_Log4php_LoggerLevel::getLevelDebug());
198
+ $this->setThreshold(Ipagare_Log4php_LoggerLevel::getLevelAll());
199
+ $this->shutDown();
200
+ $loggers = $this->getCurrentLoggers();
201
+ $enumLoggers = count($loggers);
202
+ for($i = 0; $i < $enumLoggers; $i++) {
203
+ $loggers[$i]->setLevel(null);
204
+ $loggers[$i]->setAdditivity(true);
205
+ $loggers[$i]->removeAllAppenders();
206
+ }
207
+ $this->rendererMap->clear();
208
+ Ipagare_Log4php_LoggerAppenderPool::clear();
209
+ }
210
+
211
+ /**
212
+ * set a new threshold level
213
+ *
214
+ * @param Ipagare_Log4php_LoggerLevel $l
215
+ */
216
+ public function setThreshold(Ipagare_Log4php_LoggerLevel $l) {
217
+ if($l !== null) {
218
+ $this->threshold = $l;
219
+ }
220
+ }
221
+
222
+ /**
223
+ * Shutting down a hierarchy will <i>safely</i> close and remove
224
+ * all appenders in all categories including the root logger.
225
+ *
226
+ * <p>Some appenders such as {@link LoggerSocketAppender}
227
+ * need to be closed before the
228
+ * application exists. Otherwise, pending logging events might be
229
+ * lost.
230
+ *
231
+ * <p>The shutdown method is careful to close nested
232
+ * appenders before closing regular appenders. This is allows
233
+ * configurations where a regular appender is attached to a logger
234
+ * and again to a nested appender.
235
+ */
236
+ public function shutdown() {
237
+ $this->root->removeAllAppenders();
238
+ $cats = $this->getCurrentLoggers();
239
+ $enumCats = count($cats);
240
+ if($enumCats > 0) {
241
+ for($i = 0; $i < $enumCats; $i++) {
242
+ $cats[$i]->removeAllAppenders();
243
+ }
244
+ }
245
+ }
246
+ }
lib/Ipagare/Log4php/LoggerLayout.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Extend this abstract class to create your own log layout format.
23
+ *
24
+ * @version $Revision: 822415 $
25
+ * @package log4php
26
+ * @abstract
27
+ */
28
+ abstract class Ipagare_Log4php_LoggerLayout {
29
+ /**
30
+ * Activates options for this layout.
31
+ * Override this method if you have options to be activated.
32
+ */
33
+ public function activateOptions() {
34
+ return true;
35
+ }
36
+
37
+ /**
38
+ * Override this method to create your own layout format.
39
+ *
40
+ * @param Ipagare_Log4php_LoggerLoggingEvent
41
+ * @return string
42
+ */
43
+ public function format(Ipagare_Log4php_LoggerLoggingEvent $event) {
44
+ return $event->getRenderedMessage();
45
+ }
46
+
47
+ /**
48
+ * Returns the content type output by this layout.
49
+ * @return string
50
+ */
51
+ public function getContentType() {
52
+ return "text/plain";
53
+ }
54
+
55
+ /**
56
+ * Returns the footer for the layout format.
57
+ * @return string
58
+ */
59
+ public function getFooter() {
60
+ return null;
61
+ }
62
+
63
+ /**
64
+ * Returns the header for the layout format.
65
+ * @return string
66
+ */
67
+ public function getHeader() {
68
+ return null;
69
+ }
70
+ }
lib/Ipagare/Log4php/LoggerLevel.php ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Defines the minimum set of levels recognized by the system, that is
23
+ * <i>OFF</i>, <i>FATAL</i>, <i>ERROR</i>,
24
+ * <i>WARN</i>, <i>INFO</i>, <i>DEBUG</i> and
25
+ * <i>ALL</i>.
26
+ *
27
+ * <p>The <i>Ipagare_Log4php_LoggerLevel</i> class may be subclassed to define a larger
28
+ * level set.</p>
29
+ *
30
+ * @version $Revision: 1059292 $
31
+ * @package log4php
32
+ * @since 0.5
33
+ */
34
+ class Ipagare_Log4php_LoggerLevel {
35
+
36
+ const OFF = 2147483647;
37
+ const FATAL = 50000;
38
+ const ERROR = 40000;
39
+ const WARN = 30000;
40
+ const INFO = 20000;
41
+ const DEBUG = 10000;
42
+ const TRACE = 5000;
43
+ const ALL = -2147483647;
44
+
45
+ /**
46
+ * TODO: check if still necessary or to be refactored
47
+ * @var integer
48
+ */
49
+ private $level;
50
+
51
+ /**
52
+ * Contains a list of instantiated levels
53
+ */
54
+ private static $levelMap;
55
+
56
+ /**
57
+ * @var string
58
+ */
59
+ private $levelStr;
60
+
61
+ /**
62
+ * @var integer
63
+ */
64
+ private $syslogEquivalent;
65
+
66
+ /**
67
+ * Constructor
68
+ *
69
+ * @param integer $level
70
+ * @param string $levelStr
71
+ * @param integer $syslogEquivalent
72
+ */
73
+ private function __construct($level, $levelStr, $syslogEquivalent) {
74
+ $this->level = $level;
75
+ $this->levelStr = $levelStr;
76
+ $this->syslogEquivalent = $syslogEquivalent;
77
+ }
78
+
79
+ /**
80
+ * Two priorities are equal if their level fields are equal.
81
+ *
82
+ * @param object $o
83
+ * @return boolean
84
+ */
85
+ public function equals($o) {
86
+ if($o instanceof Ipagare_Log4php_LoggerLevel) {
87
+ if($this->level == $o->level) {
88
+ return true;
89
+ }
90
+ } else {
91
+ return false;
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Returns an Off Level
97
+ * @static
98
+ * @return Ipagare_Log4php_LoggerLevel
99
+ */
100
+ public static function getLevelOff() {
101
+ if(!isset(self::$levelMap[Ipagare_Log4php_LoggerLevel::OFF])) {
102
+ self::$levelMap[Ipagare_Log4php_LoggerLevel::OFF] = new Ipagare_Log4php_LoggerLevel(Ipagare_Log4php_LoggerLevel::OFF, 'OFF', 0);
103
+ }
104
+ return self::$levelMap[Ipagare_Log4php_LoggerLevel::OFF];
105
+ }
106
+
107
+ /**
108
+ * Returns a Fatal Level
109
+ * @static
110
+ * @return Ipagare_Log4php_LoggerLevel
111
+ */
112
+ public static function getLevelFatal() {
113
+ if(!isset(self::$levelMap[Ipagare_Log4php_LoggerLevel::FATAL])) {
114
+ self::$levelMap[Ipagare_Log4php_LoggerLevel::FATAL] = new Ipagare_Log4php_LoggerLevel(Ipagare_Log4php_LoggerLevel::FATAL, 'FATAL', 0);
115
+ }
116
+ return self::$levelMap[Ipagare_Log4php_LoggerLevel::FATAL];
117
+ }
118
+
119
+ /**
120
+ * Returns an Error Level
121
+ * @static
122
+ * @return Ipagare_Log4php_LoggerLevel
123
+ */
124
+ public static function getLevelError() {
125
+ if(!isset(self::$levelMap[Ipagare_Log4php_LoggerLevel::ERROR])) {
126
+ self::$levelMap[Ipagare_Log4php_LoggerLevel::ERROR] = new Ipagare_Log4php_LoggerLevel(Ipagare_Log4php_LoggerLevel::ERROR, 'ERROR', 3);
127
+ }
128
+ return self::$levelMap[Ipagare_Log4php_LoggerLevel::ERROR];
129
+ }
130
+
131
+ /**
132
+ * Returns a Warn Level
133
+ * @static
134
+ * @return Ipagare_Log4php_LoggerLevel
135
+ */
136
+ public static function getLevelWarn() {
137
+ if(!isset(self::$levelMap[Ipagare_Log4php_LoggerLevel::WARN])) {
138
+ self::$levelMap[Ipagare_Log4php_LoggerLevel::WARN] = new Ipagare_Log4php_LoggerLevel(Ipagare_Log4php_LoggerLevel::WARN, 'WARN', 4);
139
+ }
140
+ return self::$levelMap[Ipagare_Log4php_LoggerLevel::WARN];
141
+ }
142
+
143
+ /**
144
+ * Returns an Info Level
145
+ * @static
146
+ * @return Ipagare_Log4php_LoggerLevel
147
+ */
148
+ public static function getLevelInfo() {
149
+ if(!isset(self::$levelMap[Ipagare_Log4php_LoggerLevel::INFO])) {
150
+ self::$levelMap[Ipagare_Log4php_LoggerLevel::INFO] = new Ipagare_Log4php_LoggerLevel(Ipagare_Log4php_LoggerLevel::INFO, 'INFO', 6);
151
+ }
152
+ return self::$levelMap[Ipagare_Log4php_LoggerLevel::INFO];
153
+ }
154
+
155
+ /**
156
+ * Returns a Debug Level
157
+ * @static
158
+ * @return Ipagare_Log4php_LoggerLevel
159
+ */
160
+ public static function getLevelDebug() {
161
+ if(!isset(self::$levelMap[Ipagare_Log4php_LoggerLevel::DEBUG])) {
162
+ self::$levelMap[Ipagare_Log4php_LoggerLevel::DEBUG] = new Ipagare_Log4php_LoggerLevel(Ipagare_Log4php_LoggerLevel::DEBUG, 'DEBUG', 7);
163
+ }
164
+ return self::$levelMap[Ipagare_Log4php_LoggerLevel::DEBUG];
165
+ }
166
+
167
+ /**
168
+ * Returns a Trace Level
169
+ * @static
170
+ * @return Ipagare_Log4php_LoggerLevel
171
+ */
172
+ public static function getLevelTrace() {
173
+ if(!isset(self::$levelMap[Ipagare_Log4php_LoggerLevel::TRACE])) {
174
+ self::$levelMap[Ipagare_Log4php_LoggerLevel::TRACE] = new Ipagare_Log4php_LoggerLevel(Ipagare_Log4php_LoggerLevel::TRACE, 'TRACE', 7);
175
+ }
176
+ return self::$levelMap[Ipagare_Log4php_LoggerLevel::TRACE];
177
+ }
178
+
179
+ /**
180
+ * Returns an All Level
181
+ * @static
182
+ * @return Ipagare_Log4php_LoggerLevel
183
+ */
184
+ public static function getLevelAll() {
185
+ if(!isset(self::$levelMap[Ipagare_Log4php_LoggerLevel::ALL])) {
186
+ self::$levelMap[Ipagare_Log4php_LoggerLevel::ALL] = new Ipagare_Log4php_LoggerLevel(Ipagare_Log4php_LoggerLevel::ALL, 'ALL', 7);
187
+ }
188
+ return self::$levelMap[Ipagare_Log4php_LoggerLevel::ALL];
189
+ }
190
+
191
+ /**
192
+ * Return the syslog equivalent of this priority as an integer.
193
+ * @final
194
+ * @return integer
195
+ */
196
+ public function getSyslogEquivalent() {
197
+ return $this->syslogEquivalent;
198
+ }
199
+
200
+ /**
201
+ * Returns <i>true</i> if this level has a higher or equal
202
+ * level than the level passed as argument, <i>false</i>
203
+ * otherwise.
204
+ *
205
+ * <p>You should think twice before overriding the default
206
+ * implementation of <i>isGreaterOrEqual</i> method.
207
+ *
208
+ * @param Ipagare_Log4php_LoggerLevel $r
209
+ * @return boolean
210
+ */
211
+ public function isGreaterOrEqual($r) {
212
+ return $this->level >= $r->level;
213
+ }
214
+
215
+ /**
216
+ * Returns the string representation of this level.
217
+ * @return string
218
+ */
219
+ public function toString() {
220
+ return $this->levelStr;
221
+ }
222
+
223
+ /**
224
+ * Returns the string representation of this level.
225
+ * @return string
226
+ */
227
+ public function __toString() {
228
+ return $this->toString();
229
+ }
230
+
231
+ /**
232
+ * Returns the integer representation of this level.
233
+ * @return integer
234
+ */
235
+ public function toInt() {
236
+ return $this->level;
237
+ }
238
+
239
+ /**
240
+ * Convert the string passed as argument to a level. If the
241
+ * conversion fails, then this method returns a DEBUG Level.
242
+ *
243
+ * @param mixed $arg
244
+ * @param Ipagare_Log4php_LoggerLevel $default
245
+ * @static
246
+ */
247
+ public static function toLevel($arg, $defaultLevel = null) {
248
+ if($defaultLevel === null) {
249
+ return self::toLevel($arg, self::getLevelDebug());
250
+ } else {
251
+ if(is_int($arg)) {
252
+ switch($arg) {
253
+ case self::ALL: return self::getLevelAll();
254
+ case self::TRACE: return self::getLevelTrace();
255
+ case self::DEBUG: return self::getLevelDebug();
256
+ case self::INFO: return self::getLevelInfo();
257
+ case self::WARN: return self::getLevelWarn();
258
+ case self::ERROR: return self::getLevelError();
259
+ case self::FATAL: return self::getLevelFatal();
260
+ case self::OFF: return self::getLevelOff();
261
+ default: return $defaultLevel;
262
+ }
263
+ } else {
264
+ switch(strtoupper($arg)) {
265
+ case 'ALL': return self::getLevelAll();
266
+ case 'TRACE': return self::getLevelTrace();
267
+ case 'DEBUG': return self::getLevelDebug();
268
+ case 'INFO': return self::getLevelInfo();
269
+ case 'WARN': return self::getLevelWarn();
270
+ case 'ERROR': return self::getLevelError();
271
+ case 'FATAL': return self::getLevelFatal();
272
+ case 'OFF': return self::getLevelOff();
273
+ default: return $defaultLevel;
274
+ }
275
+ }
276
+ }
277
+ }
278
+ }
lib/Ipagare/Log4php/LoggerLocationInfo.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * The internal representation of caller location information.
23
+ *
24
+ * @version $Revision: 822448 $
25
+ * @package log4php
26
+ * @since 0.3
27
+ */
28
+ class Ipagare_Log4php_LoggerLocationInfo {
29
+ /**
30
+ * When location information is not available the constant
31
+ * <i>NA</i> is returned. Current value of this string
32
+ * constant is <b>?</b>.
33
+ */
34
+ const LOCATION_INFO_NA = 'NA';
35
+
36
+ /**
37
+ * @var string Caller's line number.
38
+ */
39
+ protected $lineNumber = null;
40
+
41
+ /**
42
+ * @var string Caller's file name.
43
+ */
44
+ protected $fileName = null;
45
+
46
+ /**
47
+ * @var string Caller's fully qualified class name.
48
+ */
49
+ protected $className = null;
50
+
51
+ /**
52
+ * @var string Caller's method name.
53
+ */
54
+ protected $methodName = null;
55
+
56
+ /**
57
+ * @var string
58
+ */
59
+ protected $fullInfo = null;
60
+
61
+ /**
62
+ * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
63
+ *
64
+ * @param array $trace
65
+ * @param mixed $caller
66
+ */
67
+ public function __construct($trace, $fqcn = null) {
68
+ $this->lineNumber = isset($trace['line']) ? $trace['line'] : null;
69
+ $this->fileName = isset($trace['file']) ? $trace['file'] : null;
70
+ $this->className = isset($trace['class']) ? $trace['class'] : null;
71
+ $this->methodName = isset($trace['function']) ? $trace['function'] : null;
72
+ $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() .
73
+ '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
74
+ }
75
+
76
+ public function getClassName() {
77
+ return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className;
78
+ }
79
+
80
+ /**
81
+ * Return the file name of the caller.
82
+ * <p>This information is not always available.
83
+ */
84
+ public function getFileName() {
85
+ return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName;
86
+ }
87
+
88
+ /**
89
+ * Returns the line number of the caller.
90
+ * <p>This information is not always available.
91
+ */
92
+ public function getLineNumber() {
93
+ return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber;
94
+ }
95
+
96
+ /**
97
+ * Returns the method name of the caller.
98
+ */
99
+ public function getMethodName() {
100
+ return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName;
101
+ }
102
+
103
+ /**
104
+ * Returns the full information of the caller.
105
+ */
106
+ public function getFullInfo() {
107
+ return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
108
+ }
109
+
110
+ }
lib/Ipagare/Log4php/LoggerLoggingEvent.php ADDED
@@ -0,0 +1,378 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * The internal representation of logging event.
23
+ *
24
+ * @version $Revision: 1059292 $
25
+ * @package log4php
26
+ */
27
+ class Ipagare_Log4php_LoggerLoggingEvent {
28
+
29
+ private static $startTime;
30
+
31
+ /**
32
+ * @var string Fully Qualified Class Name of the calling category class.
33
+ */
34
+ private $fqcn;
35
+
36
+ /**
37
+ * @var Logger reference
38
+ */
39
+ private $logger = null;
40
+
41
+ /**
42
+ * The category (logger) name.
43
+ * This field will be marked as private in future
44
+ * releases. Please do not access it directly.
45
+ * Use the {@link getLoggerName()} method instead.
46
+ * @deprecated
47
+ */
48
+ private $categoryName;
49
+
50
+ /**
51
+ * Level of logging event.
52
+ * <p> This field should not be accessed directly. You shoud use the
53
+ * {@link getLevel()} method instead.
54
+ *
55
+ * @deprecated
56
+ * @var Ipagare_Log4php_LoggerLevel
57
+ */
58
+ protected $level;
59
+
60
+ /**
61
+ * @var string The nested diagnostic context (NDC) of logging event.
62
+ */
63
+ private $ndc;
64
+
65
+ /**
66
+ * Have we tried to do an NDC lookup? If we did, there is no need
67
+ * to do it again. Note that its value is always false when
68
+ * serialized. Thus, a receiving SocketNode will never use it's own
69
+ * (incorrect) NDC. See also writeObject method.
70
+ * @var boolean
71
+ */
72
+ private $ndcLookupRequired = true;
73
+
74
+ /**
75
+ * Have we tried to do an MDC lookup? If we did, there is no need
76
+ * to do it again. Note that its value is always false when
77
+ * serialized. See also the getMDC and getMDCCopy methods.
78
+ * @var boolean
79
+ */
80
+ private $mdcCopyLookupRequired = true;
81
+
82
+ /**
83
+ * @var mixed The application supplied message of logging event.
84
+ */
85
+ private $message;
86
+
87
+ /**
88
+ * The application supplied message rendered through the log4php
89
+ * objet rendering mechanism. At present renderedMessage == message.
90
+ * @var string
91
+ */
92
+ private $renderedMessage = null;
93
+
94
+ /**
95
+ * The name of thread in which this logging event was generated.
96
+ * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()}
97
+ * @var mixed
98
+ */
99
+ private $threadName = null;
100
+
101
+ /**
102
+ * The number of seconds elapsed from 1/1/1970 until logging event
103
+ * was created plus microseconds if available.
104
+ * @var float
105
+ */
106
+ public $timeStamp;
107
+
108
+ /**
109
+ * @var Ipagare_Log4php_LoggerLocationInfo Location information for the caller.
110
+ */
111
+ private $locationInfo = null;
112
+
113
+ /**
114
+ * @var Ipagare_Log4php_LoggerThrowableInformation log4php internal representation of throwable
115
+ */
116
+ private $throwableInfo = null;
117
+
118
+ /**
119
+ * Instantiate a LoggingEvent from the supplied parameters.
120
+ *
121
+ * <p>Except {@link $timeStamp} all the other fields of
122
+ * Ipagare_Log4php_LoggerLoggingEvent are filled when actually needed.
123
+ *
124
+ * @param string $fqcn name of the caller class.
125
+ * @param mixed $logger The {@link Logger} category of this event or the logger name.
126
+ * @param Ipagare_Log4php_LoggerLevel $priority The level of this event.
127
+ * @param mixed $message The message of this event.
128
+ * @param integer $timeStamp the timestamp of this logging event.
129
+ * @param Exception $throwable The throwable associated with logging event
130
+ */
131
+ public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null, Exception $throwable = null) {
132
+ $this->fqcn = $fqcn;
133
+ if($logger instanceof Ipagare_Log4php_Logger) {
134
+ $this->logger = $logger;
135
+ $this->categoryName = $logger->getName();
136
+ } else {
137
+ $this->categoryName = strval($logger);
138
+ }
139
+ $this->level = $priority;
140
+ $this->message = $message;
141
+ if($timeStamp !== null && is_float($timeStamp)) {
142
+ $this->timeStamp = $timeStamp;
143
+ } else {
144
+ if(function_exists('microtime')) {
145
+ // get microtime as float
146
+ $this->timeStamp = microtime(true);
147
+ } else {
148
+ $this->timeStamp = floatval(time());
149
+ }
150
+ }
151
+
152
+ if ($throwable !== null && $throwable instanceof Exception) {
153
+ $this->throwableInfo = new Ipagare_Log4php_LoggerThrowableInformation($throwable);
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Returns the full qualified classname.
159
+ * TODO: PHP does contain namespaces in 5.3. Those should be returned too,
160
+ */
161
+ public function getFullQualifiedClassname() {
162
+ return $this->fqcn;
163
+ }
164
+
165
+ /**
166
+ * Set the location information for this logging event. The collected
167
+ * information is cached for future use.
168
+ *
169
+ * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
170
+ * to collect informations about caller.</p>
171
+ * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p>
172
+ * @return Ipagare_Log4php_LoggerLocationInfo
173
+ */
174
+ public function getLocationInformation() {
175
+ if($this->locationInfo === null) {
176
+
177
+ $locationInfo = array();
178
+
179
+ if(function_exists('debug_backtrace')) {
180
+ $trace = debug_backtrace();
181
+ $prevHop = null;
182
+ // make a downsearch to identify the caller
183
+ $hop = array_pop($trace);
184
+ while($hop !== null) {
185
+ if(isset($hop['class'])) {
186
+ // we are sometimes in functions = no class available: avoid php warning here
187
+ $className = strtolower($hop['class']);
188
+ if(!empty($className) and ($className == 'ipagare_log4php_logger' or $className == 'ipagare_log4php_loggercategory' or
189
+ strtolower(get_parent_class($className)) == 'ipagare_log4php_logger' or
190
+ strtolower(get_parent_class($className)) == 'ipagare_log4php_loggercategory')) {
191
+ $locationInfo['line'] = $hop['line'];
192
+ $locationInfo['file'] = $hop['file'];
193
+ break;
194
+ }
195
+ }
196
+ $prevHop = $hop;
197
+ $hop = array_pop($trace);
198
+ }
199
+ $locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
200
+ if(isset($prevHop['function']) and
201
+ $prevHop['function'] !== 'include' and
202
+ $prevHop['function'] !== 'include_once' and
203
+ $prevHop['function'] !== 'require' and
204
+ $prevHop['function'] !== 'require_once') {
205
+
206
+ $locationInfo['function'] = $prevHop['function'];
207
+ } else {
208
+ $locationInfo['function'] = 'main';
209
+ }
210
+ }
211
+
212
+ $this->locationInfo = new Ipagare_Log4php_LoggerLocationInfo($locationInfo, $this->fqcn);
213
+ }
214
+ return $this->locationInfo;
215
+ }
216
+
217
+ /**
218
+ * Return the level of this event. Use this form instead of directly
219
+ * accessing the {@link $level} field.
220
+ * @return Ipagare_Log4php_LoggerLevel
221
+ */
222
+ public function getLevel() {
223
+ return $this->level;
224
+ }
225
+
226
+ /**
227
+ * Return the name of the logger. Use this form instead of directly
228
+ * accessing the {@link $categoryName} field.
229
+ * @return string
230
+ */
231
+ public function getLoggerName() {
232
+ return $this->categoryName;
233
+ }
234
+
235
+ /**
236
+ * Return the message for this logging event.
237
+ *
238
+ * <p>Before serialization, the returned object is the message
239
+ * passed by the user to generate the logging event. After
240
+ * serialization, the returned value equals the String form of the
241
+ * message possibly after object rendering.
242
+ * @return mixed
243
+ */
244
+ public function getMessage() {
245
+ if($this->message !== null) {
246
+ return $this->message;
247
+ } else {
248
+ return $this->getRenderedMessage();
249
+ }
250
+ }
251
+
252
+ /**
253
+ * This method returns the NDC for this event. It will return the
254
+ * correct content even if the event was generated in a different
255
+ * thread or even on a different machine. The {@link Ipagare_Log4php_LoggerNDC::get()} method
256
+ * should <b>never</b> be called directly.
257
+ * @return string
258
+ */
259
+ public function getNDC() {
260
+ if($this->ndcLookupRequired) {
261
+ $this->ndcLookupRequired = false;
262
+ $this->ndc = Ipagare_Log4php_LoggerNDC::get();
263
+ }
264
+ return $this->ndc;
265
+ }
266
+
267
+ /**
268
+ * Returns the the context corresponding to the <code>key</code>
269
+ * parameter.
270
+ * @return string
271
+ */
272
+ public function getMDC($key) {
273
+ return Ipagare_Log4php_LoggerMDC::get($key);
274
+ }
275
+
276
+ /**
277
+ * Render message.
278
+ * @return string
279
+ */
280
+ public function getRenderedMessage() {
281
+ if($this->renderedMessage === null and $this->message !== null) {
282
+ if(is_string($this->message)) {
283
+ $this->renderedMessage = $this->message;
284
+ } else {
285
+ // $this->logger might be null or an instance of Logger or RootLogger
286
+ // But in contrast to log4j, in log4php there is only have one Ipagare_Log4php_LoggerHierarchy so there is
287
+ // no need figure out which one is $this->logger part of.
288
+ // TODO: Logger::getHierarchy() is marked @deprecated!
289
+ $repository = Ipagare_Log4php_Logger::getHierarchy();
290
+ $rendererMap = $repository->getRendererMap();
291
+ $this->renderedMessage= $rendererMap->findAndRender($this->message);
292
+ }
293
+ }
294
+ return $this->renderedMessage;
295
+ }
296
+
297
+ /**
298
+ * Returns the time when the application started, in seconds
299
+ * elapsed since 01.01.1970 plus microseconds if available.
300
+ *
301
+ * @return float
302
+ * @static
303
+ */
304
+ public static function getStartTime() {
305
+ if(!isset(self::$startTime)) {
306
+ if (function_exists('microtime')) {
307
+ // microtime as float
308
+ self::$startTime = microtime(true);
309
+ } else {
310
+ self::$startTime = floatval(time());
311
+ }
312
+ }
313
+ return self::$startTime;
314
+ }
315
+
316
+ /**
317
+ * @return float
318
+ */
319
+ public function getTimeStamp() {
320
+ return $this->timeStamp;
321
+ }
322
+
323
+ /**
324
+ * Calculates the time of this event.
325
+ * @return the time after event starttime when this event has occured
326
+ */
327
+ public function getTime() {
328
+ $eventTime = (float)$this->getTimeStamp();
329
+ $eventStartTime = (float)Ipagare_Log4php_LoggerLoggingEvent::getStartTime();
330
+ return number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
331
+ }
332
+
333
+ /**
334
+ * @return mixed
335
+ */
336
+ public function getThreadName() {
337
+ if ($this->threadName === null) {
338
+ $this->threadName = (string)getmypid();
339
+ }
340
+ return $this->threadName;
341
+ }
342
+
343
+ /**
344
+ * @return mixed Ipagare_Log4php_LoggerThrowableInformation
345
+ */
346
+ public function getThrowableInformation() {
347
+ return $this->throwableInfo;
348
+ }
349
+
350
+ /**
351
+ * Serialize this object
352
+ * @return string
353
+ */
354
+ public function toString() {
355
+ serialize($this);
356
+ }
357
+
358
+ /**
359
+ * Avoid serialization of the {@link $logger} object
360
+ */
361
+ public function __sleep() {
362
+ return array(
363
+ 'fqcn',
364
+ 'categoryName',
365
+ 'level',
366
+ 'ndc',
367
+ 'ndcLookupRequired',
368
+ 'message',
369
+ 'renderedMessage',
370
+ 'threadName',
371
+ 'timeStamp',
372
+ 'locationInfo',
373
+ );
374
+ }
375
+
376
+ }
377
+
378
+ Ipagare_Log4php_LoggerLoggingEvent::getStartTime();
lib/Ipagare/Log4php/LoggerMDC.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * The Ipagare_Log4php_LoggerMDC class provides <i>mapped diagnostic contexts</i>.
23
+ *
24
+ * <p>A <i>Mapped Diagnostic Context</i>, or
25
+ * MDC in short, is an instrument for distinguishing interleaved log
26
+ * output from different sources. Log output is typically interleaved
27
+ * when a server handles multiple clients near-simultaneously.
28
+ *
29
+ * <p>This class is similar to the {@link Ipagare_Log4php_LoggerNDC} class except that
30
+ * it is based on a map instead of a stack.
31
+ *
32
+ * <p><b>The MDC is managed on a per thread basis</b>.
33
+ *
34
+ * <p>Example:
35
+ *
36
+ * {@example ../../examples/php/mdc.php 19}<br>
37
+ *
38
+ * With the properties file:
39
+ *
40
+ * {@example ../../examples/resources/mdc.properties 18}<br>
41
+ *
42
+ * Will result in the following (notice the username "knut" in the output):
43
+ *
44
+ * <pre>
45
+ * 2009-09-13 18:48:28 DEBUG root knut: Testing MDC in src/examples/php/mdc.php at 23
46
+ * </pre>
47
+ *
48
+ * @version $Revision: 998444 $
49
+ * @since 0.3
50
+ * @package log4php
51
+ */
52
+ class Ipagare_Log4php_LoggerMDC {
53
+
54
+ /**
55
+ * This is the repository of user mappings
56
+ */
57
+ private static $map = array();
58
+
59
+ /**
60
+ * Put a context value as identified with the key parameter into the current thread's
61
+ * context map.
62
+ *
63
+ * <p>If the current thread does not have a context map it is
64
+ * created as a side effect.</p>
65
+ *
66
+ * <p>Note that you cannot put more than {@link self::HT_SIZE} keys.</p>
67
+ *
68
+ * @param string $key the key
69
+ * @param string $value the value
70
+ * @static
71
+ */
72
+ public static function put($key, $value) {
73
+ self::$map[$key] = $value;
74
+ }
75
+
76
+ /**
77
+ * Get the context identified by the key parameter.
78
+ *
79
+ * <p>You can use special key identifiers to map values in
80
+ * PHP $_SERVER and $_ENV vars. Just put a 'server.' or 'env.'
81
+ * followed by the var name you want to refer.</p>
82
+ *
83
+ * <p>This method has no side effects.</p>
84
+ *
85
+ * @param string $key the key
86
+ * @return string the context or an empty string if no context found
87
+ * for given key
88
+ * @static
89
+ */
90
+ public static function get($key) {
91
+ if(!empty($key)) {
92
+ if(strpos($key, 'server.') === 0) {
93
+ $varName = substr($key, 7);
94
+ return isset($_SERVER[$varName]) ? $_SERVER[$varName] : '';
95
+ } else if(strpos($key, 'env.') === 0) {
96
+ $varName = substr($key, 4);
97
+ $value = getenv($varName);
98
+ return ($value !== false) ? $value : '';
99
+ } else {
100
+ return isset(self::$map[$key]) ? self::$map[$key] : '';
101
+ }
102
+ }
103
+ return '';
104
+ }
105
+
106
+ /**
107
+ * Remove the the context identified by the key parameter.
108
+ *
109
+ * It only affects user mappings, not $_ENV or $_SERVER.
110
+ *
111
+ * @param string $key the key to be removed
112
+ * @static
113
+ */
114
+ public static function remove($key) {
115
+ unset(self::$map[$key]);
116
+ }
117
+ }
lib/Ipagare/Log4php/LoggerNDC.php ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * The NDC class implements <i>nested diagnostic contexts</i>.
23
+ *
24
+ * NDC was defined by Neil Harrison in the article "Patterns for Logging
25
+ * Diagnostic Messages" part of the book <i>"Pattern Languages of
26
+ * Program Design 3"</i> edited by Martin et al.
27
+ *
28
+ * A Nested Diagnostic Context, or NDC in short, is an instrument
29
+ * to distinguish interleaved log output from different sources. Log
30
+ * output is typically interleaved when a server handles multiple
31
+ * clients near-simultaneously.
32
+ *
33
+ * This class is similar to the {@link Ipagare_Log4php_LoggerMDC} class except that it is
34
+ * based on a stack instead of a map.
35
+ *
36
+ * Interleaved log output can still be meaningful if each log entry
37
+ * from different contexts had a distinctive stamp. This is where NDCs
38
+ * come into play.
39
+ *
40
+ * <b>Note that NDCs are managed on a per thread basis</b>.
41
+ *
42
+ * NDC operations such as {@link push()}, {@link pop()},
43
+ * {@link clear()}, {@link getDepth()} and {@link setMaxDepth()}
44
+ * affect the NDC of the <i>current</i> thread only. NDCs of other
45
+ * threads remain unaffected.
46
+ *
47
+ * For example, a servlet can build a per client request NDC
48
+ * consisting the clients host name and other information contained in
49
+ * the the request. <i>Cookies</i> are another source of distinctive
50
+ * information. To build an NDC one uses the {@link push()}
51
+ * operation.
52
+ *
53
+ * Simply put,
54
+ *
55
+ * - Contexts can be nested.
56
+ * - When entering a context, call <kbd>Ipagare_Log4php_LoggerNDC::push()</kbd>
57
+ * As a side effect, if there is no nested diagnostic context for the
58
+ * current thread, this method will create it.
59
+ * - When leaving a context, call <kbd>Ipagare_Log4php_LoggerNDC::pop()</kbd>
60
+ * - <b>When exiting a thread make sure to call {@link remove()}</b>
61
+ *
62
+ * There is no penalty for forgetting to match each
63
+ * <kbd>push</kbd> operation with a corresponding <kbd>pop</kbd>,
64
+ * except the obvious mismatch between the real application context
65
+ * and the context set in the NDC.
66
+ *
67
+ * If configured to do so, {@link LoggerPatternLayout} and {@link Ipagare_Log4php_Layouts_LoggerLayoutTTCC}
68
+ * instances automatically retrieve the nested diagnostic
69
+ * context for the current thread without any user intervention.
70
+ * Hence, even if a servlet is serving multiple clients
71
+ * simultaneously, the logs emanating from the same code (belonging to
72
+ * the same category) can still be distinguished because each client
73
+ * request will have a different NDC tag.
74
+ *
75
+ * Example:
76
+ *
77
+ * {@example ../../examples/php/ndc.php 19}<br>
78
+ *
79
+ * With the properties file:
80
+ *
81
+ * {@example ../../examples/resources/ndc.properties 18}<br>
82
+ *
83
+ * Will result in the following (notice the conn and client ids):
84
+ *
85
+ * <pre>
86
+ * 2009-09-13 19:04:27 DEBUG root conn=1234: just received a new connection in src/examples/php/ndc.php at 23
87
+ * 2009-09-13 19:04:27 DEBUG root conn=1234 client=ab23: some more messages that can in src/examples/php/ndc.php at 25
88
+ * 2009-09-13 19:04:27 DEBUG root conn=1234 client=ab23: now related to a client in src/examples/php/ndc.php at 26
89
+ * 2009-09-13 19:04:27 DEBUG root : back and waiting for new connections in src/examples/php/ndc.php at 29
90
+ * </pre>
91
+ *
92
+ * @version $Revision: 998456 $
93
+ * @package log4php
94
+ * @since 0.3
95
+ */
96
+ class Ipagare_Log4php_LoggerNDC {
97
+
98
+ /** This is the repository of NDC stack */
99
+ private static $stack = array();
100
+
101
+ /**
102
+ * Clear any nested diagnostic information if any. This method is
103
+ * useful in cases where the same thread can be potentially used
104
+ * over and over in different unrelated contexts.
105
+ *
106
+ * <p>This method is equivalent to calling the {@link setMaxDepth()}
107
+ * method with a zero <var>maxDepth</var> argument.
108
+ *
109
+ * @static
110
+ */
111
+ public static function clear() {
112
+ self::$stack = array();
113
+ }
114
+
115
+ /**
116
+ * Never use this method directly, use the {@link Ipagare_Log4php_LoggerLoggingEvent::getNDC()} method instead.
117
+ * @static
118
+ * @return array
119
+ */
120
+ public static function get() {
121
+ return implode(' ', self::$stack);
122
+ }
123
+
124
+ /**
125
+ * Get the current nesting depth of this diagnostic context.
126
+ *
127
+ * @see setMaxDepth()
128
+ * @return integer
129
+ * @static
130
+ */
131
+ public static function getDepth() {
132
+ return count(self::$stack);
133
+ }
134
+
135
+ /**
136
+ * Clients should call this method before leaving a diagnostic
137
+ * context.
138
+ *
139
+ * <p>The returned value is the value that was pushed last. If no
140
+ * context is available, then the empty string "" is returned.</p>
141
+ *
142
+ * @return string The innermost diagnostic context.
143
+ * @static
144
+ */
145
+ public static function pop() {
146
+ if(count(self::$stack) > 0) {
147
+ return array_pop(self::$stack);
148
+ } else {
149
+ return '';
150
+ }
151
+ }
152
+
153
+ /**
154
+ * Looks at the last diagnostic context at the top of this NDC
155
+ * without removing it.
156
+ *
157
+ * <p>The returned value is the value that was pushed last. If no
158
+ * context is available, then the empty string "" is returned.</p>
159
+ * @return string The innermost diagnostic context.
160
+ * @static
161
+ */
162
+ public static function peek(){
163
+ if(count(self::$stack) > 0) {
164
+ return end(self::$stack);
165
+ } else {
166
+ return '';
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Push new diagnostic context information for the current thread.
172
+ *
173
+ * <p>The contents of the <var>message</var> parameter is
174
+ * determined solely by the client.
175
+ *
176
+ * @param string $message The new diagnostic context information.
177
+ * @static
178
+ */
179
+ public static function push($message) {
180
+ array_push(self::$stack, (string)$message);
181
+ }
182
+
183
+ /**
184
+ * Remove the diagnostic context for this thread.
185
+ * @static
186
+ */
187
+ public static function remove() {
188
+ Ipagare_Log4php_LoggerNDC::clear();
189
+ }
190
+
191
+ /**
192
+ * Set maximum depth of this diagnostic context. If the current
193
+ * depth is smaller or equal to <var>maxDepth</var>, then no
194
+ * action is taken.
195
+ *
196
+ * <p>This method is a convenient alternative to multiple
197
+ * {@link pop()} calls. Moreover, it is often the case that at
198
+ * the end of complex call sequences, the depth of the NDC is
199
+ * unpredictable. The {@link setMaxDepth()} method circumvents
200
+ * this problem.
201
+ *
202
+ * @param integer $maxDepth
203
+ * @see getDepth()
204
+ * @static
205
+ */
206
+ public static function setMaxDepth($maxDepth) {
207
+ $maxDepth = (int)$maxDepth;
208
+ if(Ipagare_Log4php_LoggerNDC::getDepth() > $maxDepth) {
209
+ self::$stack = array_slice(self::$stack, 0, $maxDepth);
210
+ }
211
+ }
212
+ }
lib/Ipagare/Log4php/LoggerReflectionUtils.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Provides methods for reflective use on php objects
23
+ * @package log4php
24
+ */
25
+ class Ipagare_Log4php_LoggerReflectionUtils {
26
+ /** the target object */
27
+ private $obj;
28
+
29
+ /**
30
+ * Create a new Ipagare_Log4php_LoggerReflectionUtils for the specified Object.
31
+ * This is done in prepartion for invoking {@link setProperty()}
32
+ * one or more times.
33
+ * @param object &$obj the object for which to set properties
34
+ */
35
+ public function __construct($obj) {
36
+ $this->obj = $obj;
37
+ }
38
+
39
+ /**
40
+ * Set the properties of an object passed as a parameter in one
41
+ * go. The <code>properties</code> are parsed relative to a
42
+ * <code>prefix</code>.
43
+ *
44
+ * @param object $obj The object to configure.
45
+ * @param array $properties An array containing keys and values.
46
+ * @param string $prefix Only keys having the specified prefix will be set.
47
+ * @static
48
+ */
49
+ // TODO: check, if this is really useful
50
+ public static function setPropertiesByObject($obj, $properties, $prefix) {
51
+ $pSetter = new Ipagare_Log4php_LoggerReflectionUtils($obj);
52
+ return $pSetter->setProperties($properties, $prefix);
53
+ }
54
+
55
+
56
+ /**
57
+ * Set the properites for the object that match the
58
+ * <code>prefix</code> passed as parameter.
59
+ *
60
+ * Example:
61
+ *
62
+ * $arr['xxxname'] = 'Joe';
63
+ * $arr['xxxmale'] = true;
64
+ * and prefix xxx causes setName and setMale.
65
+ *
66
+ * @param array $properties An array containing keys and values.
67
+ * @param string $prefix Only keys having the specified prefix will be set.
68
+ */
69
+ // TODO: check, if this is really useful
70
+ public function setProperties($properties, $prefix) {
71
+ $len = strlen($prefix);
72
+ reset($properties);
73
+ while(list($key,) = each($properties)) {
74
+ if(strpos($key, $prefix) === 0) {
75
+ if(strpos($key, '.', ($len + 1)) > 0) {
76
+ continue;
77
+ }
78
+ $value = Ipagare_Log4php_Helpers_LoggerOptionConverter::findAndSubst($key, $properties);
79
+ $key = substr($key, $len);
80
+ if($key == 'layout' and ($this->obj instanceof Ipagare_Log4php_LoggerAppender)) {
81
+ continue;
82
+ }
83
+ $this->setProperty($key, $value);
84
+ }
85
+ }
86
+ $this->activate();
87
+ }
88
+
89
+ /**
90
+ * Set a property on this PropertySetter's Object. If successful, this
91
+ * method will invoke a setter method on the underlying Object. The
92
+ * setter is the one for the specified property name and the value is
93
+ * determined partly from the setter argument type and partly from the
94
+ * value specified in the call to this method.
95
+ *
96
+ * <p>If the setter expects a String no conversion is necessary.
97
+ * If it expects an int, then an attempt is made to convert 'value'
98
+ * to an int using new Integer(value). If the setter expects a boolean,
99
+ * the conversion is by new Boolean(value).
100
+ *
101
+ * @param string $name name of the property
102
+ * @param string $value String value of the property
103
+ */
104
+ public function setProperty($name, $value) {
105
+ if($value === null) {
106
+ return;
107
+ }
108
+
109
+ $method = "set" . ucfirst($name);
110
+
111
+ if(!method_exists($this->obj, $method)) {
112
+ throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
113
+ } else {
114
+ return call_user_func(array($this->obj, $method), $value);
115
+ }
116
+ }
117
+
118
+ public function activate() {
119
+ if(method_exists($this->obj, 'activateoptions')) {
120
+ return call_user_func(array($this->obj, 'activateoptions'));
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Creates an instances from the given class name.
126
+ *
127
+ * @param string $classname
128
+ * @return an object from the class with the given classname
129
+ */
130
+ public static function createObject($class) {
131
+ if(!empty($class)) {
132
+ $class = basename($class);
133
+ return new $class();
134
+ }
135
+ return null;
136
+ }
137
+
138
+ /**
139
+ * @param object $object
140
+ * @param string $name
141
+ * @param mixed $value
142
+ */
143
+ public static function setter($object, $name, $value) {
144
+ if (empty($name)) {
145
+ return false;
146
+ }
147
+ $methodName = 'set'.ucfirst($name);
148
+ if (method_exists($object, $methodName)) {
149
+ return call_user_func(array($object, $methodName), $value);
150
+ } else {
151
+ return false;
152
+ }
153
+ }
154
+
155
+ }
lib/Ipagare/Log4php/LoggerRoot.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * The root logger.
23
+ *
24
+ * @version $Revision: 822448 $
25
+ * @package log4php
26
+ * @see Ipagare_Log4php_Logger
27
+ */
28
+ class Ipagare_Log4php_LoggerRoot extends Ipagare_Log4php_Logger {
29
+ /**
30
+ * Constructor
31
+ *
32
+ * @param integer $level initial log level
33
+ */
34
+ public function __construct($level = null) {
35
+ parent::__construct('root');
36
+
37
+ if($level == null) {
38
+ $level = Ipagare_Log4php_LoggerLevel::getLevelAll();
39
+ }
40
+ $this->setLevel($level);
41
+ }
42
+
43
+ /**
44
+ * @return Ipagare_Log4php_LoggerLevel the level
45
+ */
46
+ public function getChainedLevel() {
47
+ return parent::getLevel();
48
+ }
49
+
50
+ /**
51
+ * Setting a null value to the level of the root category may have catastrophic results.
52
+ * @param Ipagare_Log4php_LoggerLevel $level
53
+ */
54
+ public function setLevel($level) {
55
+ if($level != null) {
56
+ parent::setLevel($level);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Always returns false.
62
+ * Because Ipagare_Log4php_LoggerRoot has no parents, it returns false.
63
+ * @param Ipagare_Log4php_Logger $parent
64
+ * @return boolean
65
+ */
66
+ public function setParent(Ipagare_Log4php_Logger $parent) {
67
+ return false;
68
+ }
69
+
70
+ }
lib/Ipagare/Log4php/LoggerThrowableInformation.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * The internal representation of throwables.
23
+ *
24
+ * @package log4php
25
+ * @since 2.1
26
+ */
27
+ class Ipagare_Log4php_LoggerThrowableInformation {
28
+
29
+ /** @var Exception Throwable to log */
30
+ private $throwable;
31
+
32
+ /** @var array Array of throwable messages */
33
+ private $throwableArray;
34
+
35
+ /** @var Ipagare_Log4php_Logger reference */
36
+ private $logger;
37
+
38
+ /**
39
+ * Create a new instance
40
+ *
41
+ * @param $throwable - a throwable as a exception
42
+ * @param $logger - Logger reference
43
+ */
44
+ public function __construct(Exception $throwable) {
45
+ $this->throwable = $throwable;
46
+ }
47
+
48
+ /**
49
+ * Return source exception
50
+ *
51
+ * @return Exception
52
+ */
53
+ public function getThrowable() {
54
+ return $this->throwable;
55
+ }
56
+
57
+ /**
58
+ * @desc Returns string representation of throwable
59
+ *
60
+ * @return array
61
+ */
62
+ public function getStringRepresentation() {
63
+ if (!is_array($this->throwableArray)) {
64
+ $renderer = Ipagare_Log4php_Logger::getHierarchy()->getRendererMap()->getByClassName(get_class($this->throwable));
65
+
66
+ // TODO: why this?
67
+ if ($renderer instanceof Ipagare_Log4php_Renderers_LoggerRendererDefault) {
68
+ $renderer = new Ipagare_Log4php_Renderers_LoggerRendererException();
69
+ }
70
+ $this->throwableArray = explode("\n", $renderer->render($this->throwable));
71
+ }
72
+
73
+ return $this->throwableArray;
74
+ }
75
+ }
76
+ ?>
lib/Ipagare/Log4php/Renderers/LoggerRendererDefault.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * The default Renderer renders objects by type casting.
23
+ *
24
+ * Example:
25
+ *
26
+ * {@example ../../examples/php/renderer_default.php 19}<br>
27
+ * {@example ../../examples/resources/renderer_default.properties 18}<br>
28
+ * <pre>
29
+ * DEBUG - Now comes the current MyClass object:
30
+ * DEBUG - Person::__set_state(array(
31
+ * 'firstName' => 'John',
32
+ * 'lastName' => 'Doe',
33
+ * ))
34
+ * </pre>
35
+ *
36
+ * @package log4php
37
+ * @subpackage renderers
38
+ * @since 0.3
39
+ */
40
+ class Ipagare_Log4php_Renderers_LoggerRendererDefault implements Ipagare_Log4php_Renderers_LoggerRendererObject {
41
+
42
+ /**
43
+ * Render objects by type casting
44
+ *
45
+ * @param mixed $o the object to render
46
+ * @return string
47
+ */
48
+ public function render($o) {
49
+ return var_export($o, true);
50
+ }
51
+ }
lib/Ipagare/Log4php/Renderers/LoggerRendererException.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Exception renderer
23
+ *
24
+ * @package log4php
25
+ * @subpackage renderers
26
+ * @since 2.1
27
+ */
28
+ class Ipagare_Log4php_Renderers_LoggerRendererException implements Ipagare_Log4php_Renderers_LoggerRendererObject {
29
+
30
+ public function render($o) {
31
+ $strRep = 'Throwable('.get_class($o).'): '.$o->getMessage().' in '.$o->getFile().' on line '.$o->getLine();
32
+ $strRep .= PHP_EOL.$o->getTraceAsString();
33
+
34
+ if (method_exists($o, 'getPrevious') && $o->getPrevious() !== null) {
35
+ $strRep .= PHP_EOL.'Caused by: '.$this->render($o->getPrevious());
36
+ }
37
+
38
+ return $strRep;
39
+ }
40
+ }
41
+ ?>
lib/Ipagare/Log4php/Renderers/LoggerRendererMap.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Log objects using customized renderers that implement {@link Ipagare_Log4php_Renderers_LoggerRendererObject}.
23
+ *
24
+ * Example:
25
+ * {@example ../../examples/php/renderer_map.php 19}<br>
26
+ * {@example ../../examples/resources/renderer_map.properties 18}<br>
27
+ * <pre>
28
+ * DEBUG - Now comes the current MyClass object:
29
+ * DEBUG - Doe, John
30
+ * </pre>
31
+ *
32
+ * @version $Revision: 1125335 $
33
+ * @package log4php
34
+ * @subpackage renderers
35
+ * @since 0.3
36
+ */
37
+ class Ipagare_Log4php_Renderers_LoggerRendererMap {
38
+
39
+ /**
40
+ * @var array
41
+ */
42
+ private $map;
43
+
44
+ /**
45
+ * @var LoggerDefaultRenderer
46
+ */
47
+ private $defaultRenderer;
48
+
49
+ /**
50
+ * Constructor
51
+ */
52
+ public function __construct() {
53
+ $this->map = array();
54
+ $this->defaultRenderer = new Ipagare_Log4php_Renderers_LoggerRendererDefault();
55
+ }
56
+
57
+ /**
58
+ * Add a renderer to a hierarchy passed as parameter.
59
+ * Note that hierarchy must implement getRendererMap() and setRenderer() methods.
60
+ *
61
+ * @param Ipagare_Log4php_LoggerHierarchy $repository a logger repository.
62
+ * @param string $renderedClassName
63
+ * @param string $renderingClassName
64
+ * @static
65
+ */
66
+ public function addRenderer($renderedClassName, $renderingClassName) {
67
+ $renderer = Ipagare_Log4php_LoggerReflectionUtils::createObject($renderingClassName);
68
+ if($renderer == null) {
69
+ return;
70
+ } else {
71
+ $this->put($renderedClassName, $renderer);
72
+ }
73
+ }
74
+
75
+
76
+ /**
77
+ * Find the appropriate renderer for the class type of the
78
+ * <var>o</var> parameter.
79
+ *
80
+ * This is accomplished by calling the {@link getByObject()}
81
+ * method if <var>o</var> is object or using {@link Ipagare_Log4php_Renderers_LoggerRendererDefault}.
82
+ * Once a renderer is found, it is applied on the object <var>o</var> and
83
+ * the result is returned as a string.
84
+ *
85
+ * @param mixed $o
86
+ * @return string
87
+ */
88
+ public function findAndRender($o) {
89
+ if($o == null) {
90
+ return null;
91
+ } else {
92
+ if(is_object($o)) {
93
+ $renderer = $this->getByObject($o);
94
+ if($renderer !== null) {
95
+ return $renderer->render($o);
96
+ } else {
97
+ return null;
98
+ }
99
+ } else {
100
+ $renderer = $this->defaultRenderer;
101
+ return $renderer->render($o);
102
+ }
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the
108
+ * class of the object parameter.
109
+ *
110
+ * @param mixed $o
111
+ * @return string
112
+ */
113
+ public function getByObject($o) {
114
+ return ($o == null) ? null : $this->getByClassName(get_class($o));
115
+ }
116
+
117
+
118
+ /**
119
+ * Search the parents of <var>clazz</var> for a renderer.
120
+ *
121
+ * The renderer closest in the hierarchy will be returned. If no
122
+ * renderers could be found, then the default renderer is returned.
123
+ *
124
+ * @param string $class
125
+ * @return Ipagare_Log4php_Renderers_LoggerRendererObject
126
+ */
127
+ public function getByClassName($class) {
128
+ $r = null;
129
+ for($c = $class; !empty($c); $c = get_parent_class($c)) {
130
+ $c = strtolower($c);
131
+ if(isset($this->map[$c])) {
132
+ return $this->map[$c];
133
+ }
134
+ }
135
+ return $this->defaultRenderer;
136
+ }
137
+
138
+ public function clear() {
139
+ $this->map = array();
140
+ }
141
+
142
+ /**
143
+ * Register a {@link Ipagare_Log4php_Renderers_LoggerRendererObject} for <var>clazz</var>.
144
+ * @param string $class
145
+ * @param Ipagare_Log4php_Renderers_LoggerRendererObject $or
146
+ */
147
+ private function put($class, $or) {
148
+ $this->map[strtolower($class)] = $or;
149
+ }
150
+ }
lib/Ipagare/Log4php/Renderers/LoggerRendererObject.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ * @package log4php
19
+ */
20
+
21
+ /**
22
+ * Implement this interface in order to render objects as strings using {@link Ipagare_Log4php_Renderers_LoggerRendererMap}.
23
+ *
24
+ * Implement this interface in order to render objects as strings using {@link Ipagare_Log4php_Renderers_LoggerRendererMap}.
25
+ *
26
+ * Example:
27
+ * {@example ../../examples/php/renderer_map.php 19}<br>
28
+ * {@example ../../examples/resources/renderer_map.properties 18}<br>
29
+ * <pre>
30
+ * DEBUG - Now comes the current MyClass object:
31
+ * DEBUG - Doe, John
32
+ * </pre>
33
+ *
34
+ * @version $Revision: 883108 $
35
+ * @package log4php
36
+ * @subpackage renderers
37
+ * @since 0.3
38
+ */
39
+ interface Ipagare_Log4php_Renderers_LoggerRendererObject {
40
+ /**
41
+ * Render the entity passed as parameter as a String.
42
+ * @param mixed $o entity to render
43
+ * @return string
44
+ */
45
+ public function render($o);
46
+ }
lib/Ipagare/Log4php/Xml/log4php.dtd ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <!--
3
+ Licensed to the Apache Software Foundation (ASF) under one or more
4
+ contributor license agreements. See the NOTICE file distributed with
5
+ this work for additional information regarding copyright ownership.
6
+ The ASF licenses this file to You under the Apache License, Version 2.0
7
+ (the "License"); you may not use this file except in compliance with
8
+ the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ -->
18
+ <!-- Authors: Chris Taylor, Ceki Gülcü. -->
19
+ <!-- Version: 1.2 -->
20
+
21
+ <!-- PHP Port Modifications Author: Marco Vassura -->
22
+ <!-- PHP dtd Version: $Revision: 823875 $ -->
23
+
24
+ <!-- A configuration element consists of optional renderer
25
+ elements,appender elements, categories and an optional root
26
+ element. -->
27
+ <!-- [log4php] -->
28
+ <!--
29
+ category instead of logger cannot be used. categoryFactory is not implemented in log4php.
30
+ -->
31
+ <!-- [/log4php] -->
32
+ <!ELEMENT log4php:configuration (renderer*, appender*,(logger)*,root?)>
33
+
34
+ <!-- The "threshold" attribute takes a level value such that all -->
35
+ <!-- logging statements with a level equal or below this value are -->
36
+ <!-- disabled. -->
37
+
38
+ <!-- Setting the "debug" enable the printing of internal log4j logging -->
39
+ <!-- statements. -->
40
+
41
+ <!-- By default, debug attribute is "null", meaning that we not do touch -->
42
+ <!-- internal log4j logging settings. The "null" value for the threshold -->
43
+ <!-- attribute can be misleading. The threshold field of a repository -->
44
+ <!-- cannot be set to null. The "null" value for the threshold attribute -->
45
+ <!-- simply means don't touch the threshold field, the threshold field -->
46
+ <!-- keeps its old value. -->
47
+
48
+ <!ATTLIST log4php:configuration
49
+ xmlns:log4php CDATA #FIXED "http://logging.apache.org/log4php"
50
+ threshold (all|debug|info|warn|error|fatal|off|null) "null"
51
+ >
52
+
53
+ <!-- renderer elements allow the user to customize the conversion of -->
54
+ <!-- message objects to String. -->
55
+ <!ELEMENT renderer EMPTY>
56
+ <!ATTLIST renderer
57
+ renderedClass CDATA #REQUIRED
58
+ renderingClass CDATA #REQUIRED
59
+ >
60
+
61
+ <!-- Appenders must have a name and a class. -->
62
+ <!-- Appenders may contain an error handler, a layout, optional parameters -->
63
+ <!-- and filters. They may also reference (or include) other appenders. -->
64
+ <!-- [log4php] -->
65
+ <!-- error handler tag has no effects since log4php does not handle errors. Defintion deleted. -->
66
+ <!-- [/log4php] -->
67
+ <!ELEMENT appender (param*, layout?, filter*, appender-ref*)>
68
+ <!ATTLIST appender
69
+ name ID #REQUIRED
70
+ class CDATA #REQUIRED
71
+ >
72
+
73
+ <!ELEMENT layout (param*)>
74
+ <!ATTLIST layout
75
+ class CDATA #REQUIRED
76
+ >
77
+
78
+ <!ELEMENT filter (param*)>
79
+ <!ATTLIST filter
80
+ class CDATA #REQUIRED
81
+ >
82
+
83
+
84
+ <!ELEMENT param EMPTY>
85
+ <!ATTLIST param
86
+ name CDATA #REQUIRED
87
+ value CDATA #REQUIRED
88
+ >
89
+
90
+ <!ELEMENT priority EMPTY>
91
+ <!ATTLIST priority
92
+ value CDATA #REQUIRED
93
+ >
94
+
95
+ <!ELEMENT level EMPTY>
96
+ <!ATTLIST level
97
+ value CDATA #REQUIRED
98
+ >
99
+
100
+ <!-- If no level element is specified, then the configurator MUST not -->
101
+ <!-- touch the level of the named logger. -->
102
+ <!ELEMENT logger (level?,appender-ref*)>
103
+ <!ATTLIST logger
104
+ name ID #REQUIRED
105
+ additivity (true|false) "true"
106
+ >
107
+
108
+ <!ELEMENT appender-ref EMPTY>
109
+ <!ATTLIST appender-ref
110
+ ref IDREF #REQUIRED
111
+ >
112
+
113
+ <!-- If no priority element is specified, then the configurator MUST not -->
114
+ <!-- touch the priority of root. -->
115
+ <!-- The root category always exists and cannot be subclassed. -->
116
+ <!ELEMENT root (param*, (priority|level)?, appender-ref*)>
117
+
118
+
119
+ <!-- ==================================================================== -->
120
+ <!-- A logging event -->
121
+ <!-- ==================================================================== -->
122
+ <!ELEMENT log4php:eventSet (log4php:event*)>
123
+ <!ATTLIST log4php:eventSet
124
+ xmlns:log4php CDATA #FIXED "http://www.vxr.it/log4php/"
125
+ version (0.2|0.3) "0.3"
126
+ includesLocationInfo (true|false) "true"
127
+ >
128
+
129
+ <!ELEMENT log4php:event (log4php:message, log4php:locationInfo?) >
130
+
131
+ <!-- The timestamp format is application dependent. -->
132
+ <!ATTLIST log4php:event
133
+ logger CDATA #REQUIRED
134
+ level CDATA #REQUIRED
135
+ thread CDATA #REQUIRED
136
+ timestamp CDATA #REQUIRED
137
+ >
138
+
139
+ <!ELEMENT log4php:message (#PCDATA)>
140
+ <!ELEMENT log4php:NDC (#PCDATA)>
141
+
142
+ <!ELEMENT log4php:locationInfo EMPTY>
143
+ <!ATTLIST log4php:locationInfo
144
+ class CDATA #REQUIRED
145
+ method CDATA #REQUIRED
146
+ file CDATA #REQUIRED
147
+ line CDATA #REQUIRED
148
+ >
lib/Ipagare/PagSeguroDireto/Config/Config.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /*
22
+ * Provides a means to retrieve configuration preferences.
23
+ * These preferences can come from the default config file (Ipagare_PagSeguroDireto_Library/config/Ipagare_PagSeguroDireto_Config_Config.php).
24
+ */
25
+
26
+ class Ipagare_PagSeguroDireto_Config_Config {
27
+
28
+ private static $config;
29
+ private static $data;
30
+
31
+ const VARNAME = 'PagSeguroDiretoConfig';
32
+
33
+ private function __construct() {
34
+ define('ALLOW_IPAGARE_PAGSEGURODIRETO_CONFIG', true);
35
+
36
+ require_once Ipagare_PagSeguroDireto_Library::getPath() .
37
+ DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "ConfigFile.php";
38
+ $varName = self::VARNAME;
39
+
40
+ if (isset($$varName)) {
41
+ self::$data = $$varName;
42
+ unset($$varName);
43
+ } else {
44
+ throw new Exception("Config is undefined.");
45
+ }
46
+ }
47
+
48
+ public static function init() {
49
+ if (self::$config == null) {
50
+ self::$config = new Ipagare_PagSeguroDireto_Config_Config();
51
+ }
52
+
53
+ return self::$config;
54
+ }
55
+
56
+ public static function getData($key1, $key2 = null) {
57
+ if ($key2 != null) {
58
+ if (isset(self::$data[$key1][$key2])) {
59
+ return self::$data[$key1][$key2];
60
+ } else {
61
+ throw new Exception("Config keys {$key1}, {$key2} not found.");
62
+ }
63
+ } else {
64
+ if (isset(self::$data[$key1])) {
65
+ return self::$data[$key1];
66
+ } else {
67
+ throw new Exception("Config key {$key1} not found.");
68
+ }
69
+ }
70
+ }
71
+
72
+ public static function setData($key1, $key2, $value) {
73
+ if (isset(self::$data[$key1][$key2])) {
74
+ self::$data[$key1][$key2] = $value;
75
+ } else {
76
+ throw new Exception("Config keys {$key1}, {$key2} not found.");
77
+ }
78
+ }
79
+
80
+ public static function getEnvironment() {
81
+ if (isset(self::$data['environment']) && isset(self::$data['environment']['environment'])) {
82
+ return self::$data['environment']['environment'];
83
+ } else {
84
+ throw new Exception("Environment not set.");
85
+ }
86
+ }
87
+
88
+ public static function getApplicationCharset() {
89
+ if (isset(self::$data['application']) && isset(self::$data['application']['charset'])) {
90
+ return self::$data['application']['charset'];
91
+ } else {
92
+ throw new Exception("Application charset not set.");
93
+ }
94
+ }
95
+
96
+ public static function setApplicationCharset($charset) {
97
+ self::setData('application', 'charset', $charset);
98
+ }
99
+
100
+ /**
101
+ * Validate if the requirements are enable for use correct of the Ipagare_PagSeguroDireto_
102
+ * @return array
103
+ */
104
+ public static function validateRequirements() {
105
+
106
+ $requirements = array(
107
+ 'version' => '',
108
+ 'spl' => '',
109
+ 'curl' => '',
110
+ 'dom' => ''
111
+ );
112
+
113
+ $version = str_replace('.', '', phpversion());
114
+
115
+ if ($version < 533) {
116
+ $requirements['version'] = 'Ipagare_PagSeguroDireto_Library: PHP version 5.3.3 or greater is required.';
117
+ }
118
+
119
+ if (!function_exists('spl_autoload_register')) {
120
+ $requirements['spl'] = 'Ipagare_PagSeguroDireto_Library: Standard PHP Library (SPL) is required.';
121
+ }
122
+
123
+ if (!function_exists('curl_init')) {
124
+ $requirements['curl'] = 'Ipagare_PagSeguroDireto_Library: cURL library is required.';
125
+ }
126
+
127
+ if (!class_exists('DOMDocument')) {
128
+ $requirements['dom'] = 'Ipagare_PagSeguroDireto_Library: DOM XML extension is required.';
129
+ }
130
+
131
+ return $requirements;
132
+ }
133
+
134
+ }
lib/Ipagare/PagSeguroDireto/Config/ConfigFile.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $PagSeguroDiretoConfig = array();
4
+
5
+ $PagSeguroDiretoConfig['environment'] = array();
6
+ $PagSeguroDiretoConfig['environment']['environment'] = "production";
7
+
8
+ $PagSeguroDiretoConfig['application'] = array();
9
+ $PagSeguroDiretoConfig['application']['charset'] = "UTF-8"; // UTF-8, ISO-8859-1
lib/Ipagare/PagSeguroDireto/Domain/AccountCredentials.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Identifies a Ipagare_PagSeguroDireto_ account
23
+ * /
24
+ */
25
+ class Ipagare_PagSeguroDireto_Domain_AccountCredentials extends Ipagare_PagSeguroDireto_Domain_Credentials {
26
+
27
+ /**
28
+ * Primary email associated with this account
29
+ */
30
+ private $email;
31
+
32
+ /**
33
+ * Ipagare_PagSeguroDireto_ token
34
+ */
35
+ private $token;
36
+
37
+ /**
38
+ * Initializes a new instance of the Ipagare_PagSeguroDireto_Domain_AccountCredentials class
39
+ *
40
+ * @throws Exception when credentials aren't provided.
41
+ *
42
+ * @param string $email
43
+ * @param string $token
44
+ */
45
+ public function __construct($email, $token) {
46
+ if ($email !== null && $token !== null) {
47
+ $this->email = $email;
48
+ $this->token = $token;
49
+ } else {
50
+ throw new Exception("Credentials not set.");
51
+ }
52
+ }
53
+
54
+ /**
55
+ * @return string the e-mail from this account credential object
56
+ */
57
+ public function getEmail() {
58
+ return $this->email;
59
+ }
60
+
61
+ /**
62
+ * Sets the e-mail from this account credential object
63
+ */
64
+ public function setEmail($email) {
65
+ $this->email = $email;
66
+ }
67
+
68
+ /**
69
+ * @return string the token from this account credential object
70
+ */
71
+ public function getToken() {
72
+ return $this->token;
73
+ }
74
+
75
+ /**
76
+ * Sets the token in this account credential object
77
+ */
78
+ public function setToken($token) {
79
+ $this->token = $token;
80
+ }
81
+
82
+ /**
83
+ * @return array a map of name value pairs that compose this set of credentials
84
+ */
85
+ public function getAttributesMap() {
86
+ return array(
87
+ 'email' => $this->email,
88
+ 'token' => $this->token
89
+ );
90
+ }
91
+
92
+ /**
93
+ * @return string a string that represents the current object
94
+ */
95
+ public function toString() {
96
+ $credentials = array();
97
+ $credentials['E-mail'] = $this->email;
98
+ $credentials['Token'] = $this->token;
99
+ return implode(' - ', $credentials);
100
+ }
101
+
102
+ }
lib/Ipagare/PagSeguroDireto/Domain/Address.php ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represents an address location, typically for shipping or charging purposes.
23
+ * @see Ipagare_PagSeguroDireto_Domain_Shipping
24
+ */
25
+ class Ipagare_PagSeguroDireto_Domain_Address {
26
+
27
+ private $postalCode;
28
+
29
+ /**
30
+ * Street name
31
+ */
32
+ private $street;
33
+
34
+ /**
35
+ * Number
36
+ */
37
+ private $number;
38
+
39
+ /**
40
+ * Apartment, suite number or any other qualifier after the street/number pair.
41
+ * Example: Apt 274, building A.
42
+ */
43
+ private $complement;
44
+
45
+ /**
46
+ * District, county or neighborhood, if applicable
47
+ */
48
+ private $district;
49
+
50
+ /**
51
+ * City
52
+ */
53
+ private $city;
54
+
55
+ /**
56
+ * State or province
57
+ */
58
+ private $state;
59
+
60
+ /**
61
+ * Country
62
+ */
63
+ private $country;
64
+
65
+ /**
66
+ * acronyms and states brazilian
67
+ * @var type
68
+ */
69
+ private static $acronyms = array('acre' => 'AC',
70
+ 'alagoas' => 'AL',
71
+ 'amapa' => 'AP',
72
+ 'amazonas' => 'AM',
73
+ 'bahia' => 'BA',
74
+ 'ceara' => 'CE',
75
+ 'espiritosanto' => 'ES',
76
+ 'goias' => 'GO',
77
+ 'maranhao' => 'MA',
78
+ 'matogrosso' => 'MT',
79
+ 'matogrossodosul' => 'MS',
80
+ 'matogrossosul' => 'MS',
81
+ 'minasgerais' => 'MG',
82
+ 'para' => 'PA',
83
+ 'paraiba' => 'PB',
84
+ 'parana' => 'PR',
85
+ 'pernambuco' => 'PE',
86
+ 'piaui' => 'PI',
87
+ 'riodejaneiro' => 'RJ',
88
+ 'riojaneiro' => 'RJ',
89
+ 'riograndedonorte' => 'RN',
90
+ 'riograndenorte' => 'RN',
91
+ 'riograndedosul' => 'RS',
92
+ 'riograndesul' => 'RS',
93
+ 'rondonia' => 'RO',
94
+ 'roraima' => 'RR',
95
+ 'santacatarina' => 'SC',
96
+ 'saopaulo' => 'SP',
97
+ 'sergipe' => 'SE',
98
+ 'tocantins' => 'TO',
99
+ 'distritofederal' => 'DF');
100
+
101
+ /**
102
+ * Initializes a new instance of the Address class
103
+ * @param array $data
104
+ */
105
+ public function __construct(array $data = null) {
106
+ if (isset($data['postalCode'])) {
107
+ $this->postalCode = $data['postalCode'];
108
+ }
109
+ if (isset($data['street'])) {
110
+ $this->street = $data['street'];
111
+ }
112
+ if (isset($data['number'])) {
113
+ $this->number = $data['number'];
114
+ }
115
+ if (isset($data['complement'])) {
116
+ $this->complement = $data['complement'];
117
+ }
118
+ if (isset($data['district'])) {
119
+ $this->district = $data['district'];
120
+ }
121
+ if (isset($data['city'])) {
122
+ $this->city = $data['city'];
123
+ }
124
+ if (isset($data['state'])) {
125
+ $this->state = $data['state'];
126
+ }
127
+ if (isset($data['country'])) {
128
+ $this->country = $data['country'];
129
+ }
130
+ }
131
+
132
+ /**
133
+ * @return string the street
134
+ */
135
+ public function getStreet() {
136
+ return $this->street;
137
+ }
138
+
139
+ /**
140
+ * @return string the number
141
+ */
142
+ public function getNumber() {
143
+ return $this->number;
144
+ }
145
+
146
+ /**
147
+ * @return string the complement
148
+ */
149
+ public function getComplement() {
150
+ return $this->complement;
151
+ }
152
+
153
+ /**
154
+ * @return string the distrcit
155
+ */
156
+ public function getDistrict() {
157
+ return $this->district;
158
+ }
159
+
160
+ /**
161
+ * @return string the city
162
+ */
163
+ public function getCity() {
164
+ return $this->city;
165
+ }
166
+
167
+ /**
168
+ * @return string the state
169
+ */
170
+ public function getState() {
171
+ return $this->state;
172
+ }
173
+
174
+ /**
175
+ * @return string the postal code
176
+ */
177
+ public function getPostalCode() {
178
+ return $this->postalCode;
179
+ }
180
+
181
+ /**
182
+ * @return string the country
183
+ */
184
+ public function getCountry() {
185
+ return $this->country;
186
+ }
187
+
188
+ /**
189
+ * Sets the country
190
+ * @param String $country
191
+ */
192
+ public function setCountry($country) {
193
+ $this->country = $country;
194
+ }
195
+
196
+ /**
197
+ * Sets the street
198
+ * @param String $street
199
+ */
200
+ public function setStreet($street) {
201
+ $this->street = $street;
202
+ }
203
+
204
+ /**
205
+ * sets the numbetr
206
+ * @param String $number
207
+ */
208
+ public function setNumber($number) {
209
+ $this->number = $number;
210
+ }
211
+
212
+ /**
213
+ * Sets the complement
214
+ * @param String $complement
215
+ */
216
+ public function setComplement($complement) {
217
+ $this->complement = $complement;
218
+ }
219
+
220
+ /**
221
+ * sets the district
222
+ * @param String $district
223
+ */
224
+ public function setDistrict($district) {
225
+ $this->district = $district;
226
+ }
227
+
228
+ /**
229
+ * Sets the city
230
+ * @param String $city
231
+ */
232
+ public function setCity($city) {
233
+ $this->city = $city;
234
+ }
235
+
236
+ /**
237
+ * Sets the state
238
+ * @param String $state
239
+ */
240
+ public function setState($state) {
241
+ $this->state = $this->treatState($state);
242
+ }
243
+
244
+ /**
245
+ * Sets the postal code
246
+ * @param String $postalCode
247
+ */
248
+ public function setPostalCode($postalCode) {
249
+ $this->postalCode = $postalCode;
250
+ }
251
+
252
+ /**
253
+ * Treat the state to pass in format waited of the Ipagare_PagSeguroDireto_
254
+ * @param type $defaultState
255
+ * @return string
256
+ */
257
+ private function treatState($defaultState) {
258
+
259
+ if (strlen($defaultState) == 2) {
260
+ foreach (self::$acronyms as $key => $val) {
261
+ if ($val == strtoupper($defaultState)) {
262
+ return strtoupper($defaultState);
263
+ }
264
+ }
265
+ return '';
266
+ }
267
+
268
+ $state = utf8_decode($defaultState);
269
+ $state = strtolower($state);
270
+
271
+ // Code ASCII of the vowel
272
+ $ascii['a'] = range(224, 230);
273
+ $ascii['e'] = range(232, 235);
274
+ $ascii['i'] = range(236, 239);
275
+ $ascii['o'] = array_merge(range(242, 246), array(240, 248));
276
+ $ascii['u'] = range(249, 252);
277
+
278
+ // Code ASCII of the others character
279
+ $ascii['b'] = array(223);
280
+ $ascii['c'] = array(231);
281
+ $ascii['d'] = array(208);
282
+ $ascii['n'] = array(241);
283
+ $ascii['y'] = array(253, 255);
284
+
285
+ foreach ($ascii as $key => $item) {
286
+ $accents = '';
287
+ foreach ($item as $code) {
288
+ $accents .= chr($code);
289
+ }
290
+ $change[$key] = '/[' . $accents . ']/i';
291
+ }
292
+
293
+ $state = preg_replace(array_values($change), array_keys($change), $state);
294
+
295
+ $state = preg_replace("/\s/", "", $state);
296
+
297
+ foreach (self::$acronyms as $key => $val) {
298
+ if ($key == $state) {
299
+ $acronym = $val;
300
+ return $acronym;
301
+ }
302
+ }
303
+
304
+ return '';
305
+ }
306
+
307
+ }
lib/Ipagare/PagSeguroDireto/Domain/Bank.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ipagare_PagSeguroDireto_Domain_Bank {
4
+
5
+ private $name;
6
+
7
+ public function getName() {
8
+ return $this->name;
9
+ }
10
+
11
+ public function setName($name) {
12
+ $this->name = $name;
13
+ }
14
+ }
lib/Ipagare/PagSeguroDireto/Domain/Billing.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shipping information
5
+ */
6
+ class Ipagare_PagSeguroDireto_Domain_Billing {
7
+
8
+ /**
9
+ * Shipping address
10
+ * @see Ipagare_PagSeguroDireto_Domain_Address
11
+ */
12
+ private $address;
13
+
14
+ /**
15
+ * Sets the shipping address
16
+ * @see Ipagare_PagSeguroDireto_Domain_Address
17
+ * @param Ipagare_PagSeguroDireto_Domain_Address $address
18
+ */
19
+ public function setAddress(Ipagare_PagSeguroDireto_Domain_Address $address) {
20
+ $this->address = $address;
21
+ }
22
+
23
+ /**
24
+ * @return Ipagare_PagSeguroDireto_Domain_Address the shipping Address
25
+ * @see PagSeguroAddress
26
+ */
27
+ public function getAddress() {
28
+ return $this->address;
29
+ }
30
+
31
+ }
lib/Ipagare/PagSeguroDireto/Domain/Credentials.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Abstract class that represents a Ipagare_PagSeguroDireto_ credential
23
+ */
24
+ abstract class Ipagare_PagSeguroDireto_Domain_Credentials {
25
+
26
+ /**
27
+ * @return array a map of name value pairs that compose this set of credentials
28
+ */
29
+ abstract public function getAttributesMap();
30
+
31
+ /**
32
+ * @return string a string that represents the current object
33
+ */
34
+ abstract public function toString();
35
+ }
lib/Ipagare/PagSeguroDireto/Domain/CreditCardHolder.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ipagare_PagSeguroDireto_Domain_CreditCardHolder {
4
+
5
+ /**
6
+ *
7
+ * @var type string
8
+ */
9
+ private $name;
10
+
11
+ /**
12
+ *
13
+ * @var type string
14
+ */
15
+ private $cpf;
16
+
17
+ /**
18
+ *
19
+ * @var type date (dd/mm/yyyy)
20
+ */
21
+ private $birthDate;
22
+
23
+ /**
24
+ *
25
+ * @var type string
26
+ */
27
+ private $areaCode;
28
+
29
+ /**
30
+ *
31
+ * @var type string
32
+ */
33
+ private $phone;
34
+
35
+ /**
36
+ * Initializes a new instance of the Address class
37
+ * @param array $data
38
+ */
39
+ public function __construct(array $data = null) {
40
+ if (isset($data['name'])) {
41
+ $this->name = $data['name'];
42
+ }
43
+ if (isset($data['cpf'])) {
44
+ $this->cpf = $data['cpf'];
45
+ }
46
+ if (isset($data['birthDate'])) {
47
+ $this->birthDate = $data['birthDate'];
48
+ }
49
+ if (isset($data['areaCode'])) {
50
+ $this->areaCode = $data['areaCode'];
51
+ }
52
+ if (isset($data['phone'])) {
53
+ $this->phone = $data['phone'];
54
+ }
55
+ }
56
+
57
+ public function getName() {
58
+ return $this->name;
59
+ }
60
+
61
+ public function getCpf() {
62
+ return $this->cpf;
63
+ }
64
+
65
+ public function getBirthDate() {
66
+ return $this->birthDate;
67
+ }
68
+
69
+ public function getAreaCode() {
70
+ return $this->areaCode;
71
+ }
72
+
73
+ public function getPhone() {
74
+ return $this->phone;
75
+ }
76
+
77
+ public function setName($name) {
78
+ $this->name = $name;
79
+ }
80
+
81
+ public function setCpf($cpf) {
82
+ $this->cpf = $cpf;
83
+ }
84
+
85
+ public function setBirthDate($birthDate) {
86
+ $this->birthDate = $birthDate;
87
+ }
88
+
89
+ public function setAreaCode($areaCode) {
90
+ $this->areaCode = $areaCode;
91
+ }
92
+
93
+ public function setPhone($phone) {
94
+ $this->phone = $phone;
95
+ }
96
+
97
+ }
lib/Ipagare/PagSeguroDireto/Domain/Currencies.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2013] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Class tha represents available currencies on Ipagare_PagSeguroDireto_
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_Currencies {
25
+
26
+ /**
27
+ * List of available currencies on Ipagare_PagSeguroDireto_ Transactions
28
+ * <code>
29
+ * key = currency name
30
+ * value = currency iso code 3
31
+ * </code>
32
+ * @var array
33
+ */
34
+ private static $currencies = array(
35
+ 'REAL' => 'BRL'
36
+ );
37
+
38
+ /**
39
+ * Check if currency is available by informed iso code for Ipagare_PagSeguroDireto_ transactions
40
+ * @param string $currency_iso_code
41
+ * @return boolean
42
+ */
43
+ public static function checkCurrencyAvailabilityByIsoCode($currency_iso_code) {
44
+ $available = false;
45
+ if (array_search(strtoupper($currency_iso_code), self::$currencies)) {
46
+ $available = true;
47
+ }
48
+ return $available;
49
+ }
50
+
51
+ /**
52
+ * Check if currency is available by informed currency name for Ipagare_PagSeguroDireto_ transactions
53
+ * @param string $name
54
+ * @return boolean
55
+ */
56
+ public static function checkCurrencyAvailabilityByName($name) {
57
+ $available = false;
58
+ if (array_key_exists(strtoupper($name), self::$currencies)) {
59
+ $available = true;
60
+ }
61
+ return $available;
62
+ }
63
+
64
+ /**
65
+ * Return currencies list
66
+ * @return array
67
+ */
68
+ public static function getCurrenciesList() {
69
+ return self::$currencies;
70
+ }
71
+
72
+ /**
73
+ * Return iso code by currency name
74
+ * Default return BRL (Brazilian Real) iso code
75
+ * @param string $name - the currency name
76
+ * @return string
77
+ */
78
+ public static function getIsoCodeByName($name) {
79
+ $name = strtoupper($name);
80
+ return (isset(self::$currencies[$name])) ? self::$currencies[$name] : self::$currencies['REAL'];
81
+ }
82
+
83
+ /**
84
+ * Return currency name by iso code
85
+ * @param string $iso_code
86
+ * @return string
87
+ */
88
+ public static function getCurrencyNameByIsoCode($iso_code) {
89
+ return array_search(strtoupper($iso_code), self::getCurrenciesList());
90
+ }
91
+
92
+ }
lib/Ipagare/PagSeguroDireto/Domain/Document.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represents document
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_Document {
25
+
26
+ private static $availableDocumentList = array(
27
+ 1 => 'CPF'
28
+ );
29
+
30
+ /**
31
+ * The type of document
32
+ * @var string
33
+ */
34
+ private $type;
35
+
36
+ /**
37
+ * The value of document
38
+ * @var string
39
+ */
40
+ private $value;
41
+
42
+ public function __construct(array $data = null) {
43
+ if ($data) {
44
+ if (isset($data['type']) && isset($data['value'])) {
45
+ $this->setType($data['type']);
46
+ $this->setValue(Ipagare_PagSeguroDireto_Helper_Helper::getOnlyNumbers($data['value']));
47
+ }
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Get document type
53
+ * @return String
54
+ */
55
+ public function getType() {
56
+ return $this->type;
57
+ }
58
+
59
+ /**
60
+ * Set document type
61
+ * @param String $type
62
+ */
63
+ public function setType($type) {
64
+ $this->type = strtoupper($type);
65
+ }
66
+
67
+ /**
68
+ * Get document value
69
+ * @return String
70
+ */
71
+ public function getValue() {
72
+ return $this->value;
73
+ }
74
+
75
+ /**
76
+ * Set document value
77
+ * @param String $value
78
+ */
79
+ public function setValue($value) {
80
+ $this->value = $value;
81
+ }
82
+
83
+ /**
84
+ * Check if document type is available for Ipagare_PagSeguroDireto_
85
+ * @param string $documentType
86
+ * @return array|boolean
87
+ */
88
+ public static function isDocumentTypeAvailable($documentType) {
89
+ return (array_search(strtoupper($documentType), self::$availableDocumentList));
90
+ }
91
+
92
+ }
lib/Ipagare/PagSeguroDireto/Domain/Documents.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represents available documents for Sender use in checkout transactions
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_Documents {
25
+
26
+ /**
27
+ * List of available documents for Sender use in Ipagare_PagSeguroDireto_ transactions
28
+ * @var array
29
+ */
30
+ private static $availableDocumentList = array(
31
+ 'CPF' => 'Cadastro de Pessoa Física'
32
+ );
33
+
34
+ /**
35
+ * Get available document list for Sender use in Ipagare_PagSeguroDireto_ transactions
36
+ * @return array
37
+ */
38
+ public static function getAvailableDocumentList() {
39
+ return self::$availableDocumentList;
40
+ }
41
+
42
+ /**
43
+ * Check if document type is available for Ipagare_PagSeguroDireto_
44
+ * @param string $documentType
45
+ * @return boolean
46
+ */
47
+ public static function isDocumentTypeAvailable($documentType) {
48
+ $documentType = strtoupper($documentType);
49
+ return (isset(self::$availableDocumentList[$documentType]));
50
+ }
51
+
52
+ /**
53
+ * Gets document description by type
54
+ * @param string
55
+ * @return string
56
+ */
57
+ public static function getDocumentByType($documentType) {
58
+ $documentType = strtoupper($documentType);
59
+ if (isset(self::$availableDocumentList[$documentType])) {
60
+ return self::$availableDocumentList[$documentType];
61
+ } else {
62
+ return false;
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Gets document type by description
68
+ * @param string $documentDescription
69
+ * @return string
70
+ */
71
+ public static function getDocumentByDescription($documentDescription) {
72
+ return array_search(strtolower($documentDescription), array_map('strtolower', self::$availableDocumentList));
73
+ }
74
+
75
+ }
lib/Ipagare/PagSeguroDireto/Domain/Error.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represents a Ipagare_PagSeguroDireto_ web service error
23
+ * @see Ipagare_PagSeguroDireto_Exception_ServiceException
24
+ */
25
+ class Ipagare_PagSeguroDireto_Domain_Error {
26
+
27
+ /**
28
+ * Error code
29
+ */
30
+ private $code;
31
+
32
+ /**
33
+ * Error description
34
+ */
35
+ private $message;
36
+
37
+ /**
38
+ * Initializes a new instance of the Ipagare_PagSeguroDireto_Domain_Error class
39
+ *
40
+ * @param String $code
41
+ * @param String $message
42
+ */
43
+ public function __construct($code, $message) {
44
+ $this->code = $code;
45
+ $this->message = $message;
46
+ }
47
+
48
+ /**
49
+ * @return integer|string the code
50
+ */
51
+ public function getCode() {
52
+ return $this->code;
53
+ }
54
+
55
+ /**
56
+ * Sets the code
57
+ * @param String $code
58
+ */
59
+ public function setCode($code) {
60
+ $this->code = $code;
61
+ }
62
+
63
+ /**
64
+ * @return String the error description
65
+ */
66
+ public function getMessage() {
67
+ return $this->message;
68
+ }
69
+
70
+ /**
71
+ * Sets the error description
72
+ * @param String $message
73
+ */
74
+ public function setMessage($message) {
75
+ $this->message = $message;
76
+ }
77
+
78
+ }
lib/Ipagare/PagSeguroDireto/Domain/HttpStatus.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * HTTP status that Ipagare_PagSeguroDireto_ web services can return.
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_HttpStatus {
25
+
26
+ /**
27
+ * @var array
28
+ */
29
+ private $typeList = array(
30
+ 200 => 'OK',
31
+ 400 => 'BAD_REQUEST',
32
+ 401 => 'UNAUTHORIZED',
33
+ 403 => 'FORBIDDEN',
34
+ 404 => 'NOT_FOUND',
35
+ 500 => 'INTERNAL_SERVER_ERROR',
36
+ 502 => 'BAD_GATEWAY'
37
+ );
38
+
39
+ /**
40
+ * @var int
41
+ */
42
+ private $status;
43
+
44
+ /**
45
+ * @var bool
46
+ */
47
+ private $type;
48
+
49
+ /**
50
+ * @param $status
51
+ */
52
+ public function __construct($status) {
53
+ if ($status) {
54
+ $this->status = (int) $status;
55
+ $this->type = $this->getTypeByStatus($this->status);
56
+ }
57
+ }
58
+
59
+ /**
60
+ * @return bool
61
+ */
62
+ public function getType() {
63
+ return $this->type;
64
+ }
65
+
66
+ /**
67
+ * @return int
68
+ */
69
+ public function getStatus() {
70
+ return $this->status;
71
+ }
72
+
73
+ /**
74
+ * @param $status
75
+ * @return bool
76
+ */
77
+ private function getTypeByStatus($status) {
78
+ if (isset($this->typeList[(int) $status])) {
79
+ return $this->typeList[(int) $status];
80
+ } else {
81
+ return false;
82
+ }
83
+ }
84
+
85
+ }
lib/Ipagare/PagSeguroDireto/Domain/Installment.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Represents the party on the transaction that is sending the money
5
+ */
6
+ class Ipagare_PagSeguroDireto_Domain_Installment {
7
+
8
+ /**
9
+ *
10
+ * @var type
11
+ */
12
+ private $quantity;
13
+
14
+ /**
15
+ *
16
+ * @var type
17
+ */
18
+ private $value;
19
+
20
+ /**
21
+ * Initializes a new instance of the Sender class
22
+ *
23
+ * @param array $data
24
+ */
25
+ public function __construct(array $data = null) {
26
+ if ($data) {
27
+ if (isset($data['quantity'])) {
28
+ $this->quantity = $data['quantity'];
29
+ }
30
+ if (isset($data['value'])) {
31
+ $this->value = $data['value'];
32
+ }
33
+ }
34
+ }
35
+
36
+ public function getQuantity() {
37
+ return $this->quantity;
38
+ }
39
+
40
+ public function getValue() {
41
+ return $this->value;
42
+ }
43
+
44
+ public function setQuantity($quantity) {
45
+ $this->quantity = $quantity;
46
+ }
47
+
48
+ public function setValue($value) {
49
+ $this->value = $value;
50
+ }
51
+
52
+ }
lib/Ipagare/PagSeguroDireto/Domain/Item.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represents a product/item in a transaction
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_Item {
25
+
26
+ /**
27
+ * Product identifier, such as SKU
28
+ */
29
+ private $id;
30
+
31
+ /**
32
+ * Product description
33
+ */
34
+ private $description;
35
+
36
+ /**
37
+ * Quantity
38
+ */
39
+ private $quantity;
40
+
41
+ /**
42
+ * Product unit price
43
+ */
44
+ private $amount;
45
+
46
+ /**
47
+ * Single unit weight, in grams
48
+ */
49
+ private $weight;
50
+
51
+ /**
52
+ * Single unit shipping cost
53
+ */
54
+ private $shippingCost;
55
+
56
+ /**
57
+ *
58
+ * Initializes a new instance of the Item class
59
+ * @param array $data
60
+ */
61
+ public function __construct(array $data = null) {
62
+ if ($data) {
63
+ if (isset($data['id'])) {
64
+ $this->id = $data['id'];
65
+ }
66
+ if (isset($data['description'])) {
67
+ $this->description = $data['description'];
68
+ }
69
+ if (isset($data['quantity'])) {
70
+ $this->quantity = $data['quantity'];
71
+ }
72
+ if (isset($data['amount'])) {
73
+ $this->amount = $data['amount'];
74
+ }
75
+ if (isset($data['weight'])) {
76
+ $this->weight = $data['weight'];
77
+ }
78
+ if (isset($data['shippingCost'])) {
79
+ $this->shippingCost = $data['shippingCost'];
80
+ }
81
+ }
82
+ }
83
+
84
+ /**
85
+ * @return integer the product identifier
86
+ */
87
+ public function getId() {
88
+ return $this->id;
89
+ }
90
+
91
+ /**
92
+ * Sets the product identifier
93
+ * @param String $id
94
+ */
95
+ public function setId($id) {
96
+ $this->id = $id;
97
+ }
98
+
99
+ /**
100
+ * @return String the product description
101
+ */
102
+ public function getDescription() {
103
+ return $this->description;
104
+ }
105
+
106
+ /**
107
+ * Sets the product description
108
+ * @param String $description
109
+ */
110
+ public function setDescription($description) {
111
+ $this->description = Ipagare_PagSeguroDireto_Helper_Helper::formatString($description, 255);
112
+ }
113
+
114
+ /**
115
+ * @return integer the quantity
116
+ */
117
+ public function getQuantity() {
118
+ return $this->quantity;
119
+ }
120
+
121
+ /**
122
+ * Sets the quantity
123
+ * @param String $quantity
124
+ */
125
+ public function setQuantity($quantity) {
126
+ $this->quantity = $quantity;
127
+ }
128
+
129
+ /**
130
+ * @return the unit amount for this item
131
+ */
132
+ public function getAmount() {
133
+ return $this->amount;
134
+ }
135
+
136
+ /**
137
+ * sets the unit amount fot this item
138
+ * @param String $amount
139
+ */
140
+ public function setAmount($amount) {
141
+ $this->amount = $amount;
142
+ }
143
+
144
+ /**
145
+ * @return float the weight
146
+ */
147
+ public function getWeight() {
148
+ return $this->weight;
149
+ }
150
+
151
+ /**
152
+ * Sets the single unit weight
153
+ * @param String $weight
154
+ */
155
+ public function setWeight($weight) {
156
+ $this->weight = $weight;
157
+ }
158
+
159
+ /**
160
+ * @return float the unit shipping cost for this item
161
+ */
162
+ public function getShippingCost() {
163
+ return $this->shippingCost;
164
+ }
165
+
166
+ /**
167
+ * Sets the unit shipping cost for this item
168
+ * @param String $shippingCost
169
+ */
170
+ public function setShippingCost($shippingCost) {
171
+ $this->shippingCost = $shippingCost;
172
+ }
173
+
174
+ }
lib/Ipagare/PagSeguroDireto/Domain/MetaData.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represent a metadata
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_MetaData {
25
+
26
+ /**
27
+ * @var array
28
+ */
29
+ private $items;
30
+
31
+ /**
32
+ * @param array $items
33
+ */
34
+ public function __construct(array $items = null) {
35
+ if (!is_null($items) && count($items) > 0) {
36
+ $this->setItems($items);
37
+ }
38
+ }
39
+
40
+ /**
41
+ * @param Ipagare_PagSeguroDireto_Domain_MetaDataItem $metaDataItem
42
+ */
43
+ public function addItem(Ipagare_PagSeguroDireto_Domain_MetaDataItem $metaDataItem) {
44
+ $this->items[] = $metaDataItem;
45
+ }
46
+
47
+ /**
48
+ * @param array $items
49
+ */
50
+ public function setItems(array $items) {
51
+ $this->items = $items;
52
+ }
53
+
54
+ /**
55
+ * @return array
56
+ */
57
+ public function getItems() {
58
+ if ($this->items == null) {
59
+ $this->items = array();
60
+ }
61
+ return $this->items;
62
+ }
63
+
64
+ }
lib/Ipagare/PagSeguroDireto/Domain/MetaDataItem.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represent a metadata item
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_MetaDataItem {
25
+
26
+ /**
27
+ * Allow add extra information to order
28
+ *
29
+ * @var string
30
+ */
31
+ private $key;
32
+
33
+ /**
34
+ * Value of corresponding key
35
+ *
36
+ * @var mixed
37
+ */
38
+ private $value;
39
+
40
+ /**
41
+ * Used for grouping values of metadata items
42
+ * @var mixed
43
+ */
44
+ private $group;
45
+
46
+ public function __construct($key = null, $value = null, $group = null) {
47
+
48
+ if (isset($key) && !Ipagare_PagSeguroDireto_Helper_Helper::isEmpty($key)) {
49
+ $this->setKey($key);
50
+ }
51
+ if (isset($value) && !Ipagare_PagSeguroDireto_Helper_Helper::isEmpty($value)) {
52
+ $this->setValue($value);
53
+ }
54
+ if (isset($group) && !Ipagare_PagSeguroDireto_Helper_Helper::isEmpty($group)) {
55
+ $this->setGroup($group);
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Gets the metadata item key
61
+ * @return string
62
+ */
63
+ public function getKey() {
64
+ return $this->key;
65
+ }
66
+
67
+ /**
68
+ * Sets the metadata item key
69
+ *
70
+ * @param string $key
71
+ */
72
+ public function setKey($key) {
73
+ $this->key = $key;
74
+ }
75
+
76
+ /**
77
+ * Gets metadata item value
78
+ * @return string
79
+ */
80
+ public function getValue() {
81
+ return $this->value;
82
+ }
83
+
84
+ /**
85
+ * Sets metadata item value
86
+ *
87
+ * @param string $value
88
+ */
89
+ public function setValue($value) {
90
+ $this->value = $this->_normalizeParameter($value);
91
+ }
92
+
93
+ /**
94
+ * Gets metadata item group
95
+ *
96
+ * @return int
97
+ */
98
+ public function getGroup() {
99
+ return $this->group;
100
+ }
101
+
102
+ /**
103
+ * Sets metadata item group
104
+ *
105
+ * @param int $group
106
+ */
107
+ public function setGroup($group) {
108
+ $this->group = (int) $group;
109
+ }
110
+
111
+ /**
112
+ * Normalize metadata item value
113
+ * @param string $parameterValue
114
+ * @return string
115
+ */
116
+ private function normalizeParameter($parameterValue) {
117
+
118
+ $parameterValue = Ipagare_PagSeguroDireto_Helper_Helper::formatString($parameterValue, 100, '');
119
+
120
+ switch ($this->getKey()) {
121
+ case Ipagare_PagSeguroDireto_Domain_MetaDataItemKeys::getItemKeyByDescription('CPF do passageiro'):
122
+ $parameterValue = Ipagare_PagSeguroDireto_Helper_Helper::getOnlyNumbers($parameterValue);
123
+ break;
124
+ case Ipagare_PagSeguroDireto_Domain_MetaDataItemKeys::getItemKeyByDescription('Tempo no jogo em dias'):
125
+ $parameterValue = Ipagare_PagSeguroDireto_Helper_Helper::getOnlyNumbers($parameterValue);
126
+ break;
127
+ case Ipagare_PagSeguroDireto_Domain_MetaDataItemKeys::getItemKeyByDescription('Celular de recarga'):
128
+ break;
129
+ default:
130
+ break;
131
+ }
132
+ return $parameterValue;
133
+ }
134
+
135
+ }
lib/Ipagare/PagSeguroDireto/Domain/MetaDataItemKeys.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represent available metadata item keys
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_MetaDataItemKeys {
25
+
26
+ private static $availableItemKeysList = array(
27
+ 'PASSENGER_CPF' => 'CPF do passageiro',
28
+ 'PASSENGER_PASSPORT' => 'Passaporte do passageiro',
29
+ 'ORIGIN_CITY' => 'Cidade de origem',
30
+ 'DESTINATION_CITY' => 'Cidade de destino',
31
+ 'ORIGIN_AIRPORT_CODE' => 'Código do aeroporto de origem',
32
+ 'DESTINATION_AIRPORT_CODE' => 'Código do aeroporto de destino',
33
+ 'GAME_NAME' => 'Nome do jogo',
34
+ 'PLAYER_ID' => 'Id do jogador',
35
+ 'TIME_IN_GAME_DAYS' => 'Tempo no jogo em dias',
36
+ 'MOBILE_NUMBER' => 'Celular de recarga',
37
+ 'PASSENGER_NAME' => 'Nome do passageiro'
38
+ );
39
+
40
+ /**
41
+ * Get available item key list for metadata use in Ipagare_PagSeguroDireto_ transactions
42
+ * @return array
43
+ */
44
+ public static function getAvailableItemKeysList() {
45
+ return self::$availableItemKeysList;
46
+ }
47
+
48
+ /**
49
+ * Check if item key is available for Ipagare_PagSeguroDireto_
50
+ * @param string $itemKey
51
+ * @return boolean
52
+ */
53
+ public static function isItemKeyAvailable($itemKey) {
54
+ $itemKey = strtoupper($itemKey);
55
+ return (isset(self::$availableItemKeysList[$itemKey]));
56
+ }
57
+
58
+ /**
59
+ * Gets item description by key
60
+ * @param string $itemKey
61
+ * @return string
62
+ */
63
+ public static function getItemDescriptionByKey($itemKey) {
64
+ $itemKey = strtoupper($itemKey);
65
+ if (isset(self::$availableItemKeysList[$itemKey])) {
66
+ return self::$availableItemKeysList[$itemKey];
67
+ } else {
68
+ return false;
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Gets item key type by description
74
+ * @param string $itemDescription
75
+ * @return string
76
+ */
77
+ public static function getItemKeyByDescription($itemDescription) {
78
+ return array_search(strtolower($itemDescription), array_map('strtolower', self::$availableItemKeysList));
79
+ }
80
+
81
+ }
lib/Ipagare/PagSeguroDireto/Domain/NotificationType.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Defines a list of known notification types.
23
+ * This class is not an enum to enable the introduction of new shipping types
24
+ * without breaking this version of the library.
25
+ */
26
+ class Ipagare_PagSeguroDireto_Domain_NotificationType {
27
+
28
+ private static $typeList = array(
29
+ 'TRANSACTION' => 'transaction'
30
+ );
31
+ private $value;
32
+
33
+ public function __construct($value = null) {
34
+ if ($value) {
35
+ $this->value = $value;
36
+ }
37
+ }
38
+
39
+ public function setValue($value) {
40
+ $this->value = $value;
41
+ }
42
+
43
+ public function setByType($type) {
44
+ if (isset(self::$typeList[$type])) {
45
+ $this->value = self::$typeList[$type];
46
+ } else {
47
+ throw new Exception("undefined index $type");
48
+ }
49
+ }
50
+
51
+ public function getValue() {
52
+ return $this->value;
53
+ }
54
+
55
+ /**
56
+ * @param value
57
+ * @return the Ipagare_PagSeguroDireto_Domain_NotificationType corresponding to the informed value
58
+ */
59
+ public function getTypeFromValue($value = null) {
60
+ $value = ($value == null ? $this->value : $value);
61
+ return array_search($this->value, self::$typeList);
62
+ }
63
+
64
+ }
lib/Ipagare/PagSeguroDireto/Domain/Parameter.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represent a parameter
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_Parameter {
25
+
26
+ private $items;
27
+
28
+ public function __construct(array $items = null) {
29
+ if (!is_null($items) && count($items) > 0) {
30
+ $this->setItems($items);
31
+ }
32
+ }
33
+
34
+ public function addItem(Ipagare_PagSeguroDireto_Domain_ParameterItem $parameterItem) {
35
+
36
+ if (!Ipagare_PagSeguroDireto_Helper_Helper::isEmpty($parameterItem->getKey())) {
37
+ if (!Ipagare_PagSeguroDireto_Helper_Helper::isEmpty($parameterItem->getValue())) {
38
+ $this->items[] = $parameterItem;
39
+ } else {
40
+ die('requered parameterValue.');
41
+ }
42
+ } else {
43
+ die('requered parameterKey.');
44
+ }
45
+ }
46
+
47
+ public function setItems(array $items) {
48
+ $this->items = $items;
49
+ }
50
+
51
+ public function getItems() {
52
+ if ($this->items == null) {
53
+ $this->items = array();
54
+ }
55
+ return $this->items;
56
+ }
57
+
58
+ }
lib/Ipagare/PagSeguroDireto/Domain/ParameterItem.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represent a parameter item
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_ParameterItem
25
+ {
26
+
27
+ /**
28
+ * Allow add extra information to order
29
+ *
30
+ * @var string
31
+ */
32
+ private $key;
33
+
34
+ /**
35
+ * Value of corresponding key
36
+ *
37
+ * @var mixed
38
+ */
39
+ private $value;
40
+
41
+ /**
42
+ * Used for grouping values of parameter items
43
+ * @var mixed
44
+ */
45
+ private $group;
46
+
47
+ public function __construct($key, $value, $group = null)
48
+ {
49
+ if (isset($key) && !Ipagare_PagSeguroDireto_Helper_Helper::isEmpty($key)) {
50
+ $this->setKey($key);
51
+ }
52
+ if (isset($value) && !Ipagare_PagSeguroDireto_Helper_Helper::isEmpty($value)) {
53
+ $this->setValue($value);
54
+ }
55
+ if (isset($group) && !Ipagare_PagSeguroDireto_Helper_Helper::isEmpty($group)) {
56
+ $this->setGroup($group);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Gets the parameter item key
62
+ * @return string
63
+ */
64
+ public function getKey()
65
+ {
66
+ return $this->key;
67
+ }
68
+
69
+ /**
70
+ * Sets the parameter item key
71
+ *
72
+ * @param string $key
73
+ */
74
+ public function setKey($key)
75
+ {
76
+ $this->key = $key;
77
+ }
78
+
79
+ /**
80
+ * Gets parameter item value
81
+ * @return string
82
+ */
83
+ public function getValue()
84
+ {
85
+ return $this->value;
86
+ }
87
+
88
+ /**
89
+ * Sets parameter item value
90
+ *
91
+ * @param string $value
92
+ */
93
+ public function setValue($value)
94
+ {
95
+ $this->value = $value;
96
+ }
97
+
98
+ /**
99
+ * Gets parameter item group
100
+ *
101
+ * @return int
102
+ */
103
+ public function getGroup()
104
+ {
105
+ return $this->group;
106
+ }
107
+
108
+ /**
109
+ * Sets parameter item group
110
+ *
111
+ * @param int $group
112
+ */
113
+ public function setGroup($group)
114
+ {
115
+ $this->group = (int) $group;
116
+ }
117
+ }
lib/Ipagare/PagSeguroDireto/Domain/PaymentMethod.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Payment method
23
+ *
24
+ */
25
+ class Ipagare_PagSeguroDireto_Domain_PaymentMethod {
26
+
27
+ /**
28
+ * Payment method type
29
+ */
30
+ private $type;
31
+
32
+ /**
33
+ * Payment method code
34
+ */
35
+ private $code;
36
+
37
+ /**
38
+ * Initializes a new instance of the PaymentMethod class
39
+ *
40
+ * @param Ipagare_PagSeguroDireto_Domain_PaymentMethodType $type
41
+ * @param Ipagare_PagSeguroDireto_Domain_PaymentMethodCode $code
42
+ */
43
+ public function __construct($type = null, $code = null) {
44
+ if ($type) {
45
+ $this->setType($type);
46
+ }
47
+ if ($code) {
48
+ $this->setCode($code);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * @return the payment method type
54
+ */
55
+ public function getType() {
56
+ return $this->type;
57
+ }
58
+
59
+ /**
60
+ * Sets the payment method type
61
+ * @param Ipagare_PagSeguroDireto_Domain_PaymentMethodType $type
62
+ */
63
+ public function setType($type) {
64
+ if ($type instanceof Ipagare_PagSeguroDireto_Domain_PaymentMethodType) {
65
+ $this->type = $type;
66
+ } else {
67
+ $this->type = new Ipagare_PagSeguroDireto_Domain_PaymentMethodType($type);
68
+ }
69
+ }
70
+
71
+ /**
72
+ * @return the code
73
+ */
74
+ public function getCode() {
75
+ return $this->code;
76
+ }
77
+
78
+ /**
79
+ * Sets the payment method code
80
+ * @param Ipagare_PagSeguroDireto_Domain_PaymentMethodCode $code
81
+ */
82
+ public function setCode($code) {
83
+ if ($code instanceof Ipagare_PagSeguroDireto_Domain_PaymentMethodCode) {
84
+ $this->code = $code;
85
+ } else {
86
+ $this->code = new Ipagare_PagSeguroDireto_Domain_PaymentMethodCode($code);
87
+ }
88
+ }
89
+
90
+ }
lib/Ipagare/PagSeguroDireto/Domain/PaymentMethodCode.php ADDED
@@ -0,0 +1,374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Defines a list of known payment method codes.
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_PaymentMethodCode {
25
+
26
+ const VISA_CREDIT_CARD = 101;
27
+ const MASTERCARD_CREDIT_CARD = 102;
28
+ const AMEX_CREDIT_CARD = 103;
29
+ const DINERS_CREDIT_CARD = 104;
30
+ const HIPERCARD_CREDIT_CARD = 105;
31
+ const AURA_CREDIT_CARD = 106;
32
+ const ELO_CREDIT_CARD = 107;
33
+ const PLENOCARD = 108;
34
+ const PERSONALCARD = 109;
35
+ const JCB_CREDIT_CARD = 110;
36
+ const DISCOVER_CREDIT_CARD = 111;
37
+ const BRASILCARD = 112;
38
+ const FORTBRASIL_CREDIT_CARD = 113;
39
+ const CARDBAN_CARD = 114;
40
+ const VALECARD_CARD = 115;
41
+ const CABAL_CARD = 116;
42
+ const MAIS_CARD = 117;
43
+ const AVISTA_CARD = 118;
44
+ const GRANDCARD_CARD = 119;
45
+ const SANTANDER_BOLETO = 202;
46
+ const BRADESCO_ONLINE_TRANSFER = 301;
47
+ const ITAU_ONLINE_TRANSFER = 302;
48
+ const BANCO_BRASIL_ONLINE_TRANSFER = 304;
49
+ const BANRISUL_ONLINE_TRANSFER = 306;
50
+ const HSBC_ONLINE_TRANSFER = 307;
51
+
52
+ private static $codeList = array('101' => array('codigo' => 101,
53
+ 'nome' => 'Visa',
54
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::VISA,
55
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
56
+
57
+ '102' => array('codigo' => 102,
58
+ 'nome' => 'Mastercard',
59
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::MASTERCARD,
60
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
61
+
62
+ '103' => array('codigo' => 103,
63
+ 'nome' => 'Amex',
64
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::AMERICAN_EXPRESS,
65
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
66
+
67
+ '104' => array('codigo' => 104,
68
+ 'nome' => 'Diners',
69
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::DINERS,
70
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
71
+
72
+ '105' => array('codigo' => 105,
73
+ 'nome' => 'Hipercard',
74
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::HIPERCARD,
75
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
76
+
77
+ '106' => array('codigo' => 106,
78
+ 'nome' => 'Aura',
79
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::AURA,
80
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
81
+
82
+ '107' => array('codigo' => 107,
83
+ 'nome' => 'Elo',
84
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::ELO,
85
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
86
+ '108' => array('codigo' => 108,
87
+ 'nome' => 'Plenocard',
88
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::PLENOCARD,
89
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
90
+ '109' => array('codigo' => 109,
91
+ 'nome' => 'Personalcard',
92
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::PERSONALCARD,
93
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
94
+ '110' => array('codigo' => 110,
95
+ 'nome' => 'Jcb',
96
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::JCB,
97
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
98
+ '111' => array('codigo' => 111,
99
+ 'nome' => 'Discover',
100
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::DISCOVER,
101
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
102
+ '112' => array('codigo' => 112,
103
+ 'nome' => 'BrasilCard',
104
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::BRASILCARD,
105
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
106
+ '113' => array('codigo' => 113,
107
+ 'nome' => 'Fortbrasil',
108
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::FORTBRASIL,
109
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
110
+
111
+ '114' => array('codigo' => 114,
112
+ 'nome' => 'CardBan',
113
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::CARDBAN,
114
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
115
+
116
+ '115' => array('codigo' => 115,
117
+ 'nome' => 'ValeCard',
118
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::VALECARD,
119
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
120
+
121
+ '116' => array('codigo' => 116,
122
+ 'nome' => 'Cabal',
123
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::CABAL,
124
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
125
+
126
+ '117' => array('codigo' => 117,
127
+ 'nome' => 'Mais!',
128
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::MAIS,
129
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
130
+
131
+ '118' => array('codigo' => 118,
132
+ 'nome' => 'AVista',
133
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::AVISTA,
134
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
135
+
136
+ '119' => array('codigo' => 119,
137
+ 'nome' => 'GrandCard',
138
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::GRANDCARD,
139
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD)),
140
+
141
+ '202' => array('codigo' => 202,
142
+ 'nome' => 'Santander - Boleto',
143
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::SANTANDER,
144
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::BOLETO)),
145
+
146
+ '301' => array('codigo' => 301,
147
+ 'nome' => 'Transferência - Bradesco',
148
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::BRADESCO,
149
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::ONLINE_TRANSFER)),
150
+
151
+ '302' => array('codigo' => 302,
152
+ 'nome' => 'Transferência - Itaú',
153
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::ITAU,
154
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::ONLINE_TRANSFER)),
155
+
156
+ '304' => array('codigo' => 304,
157
+ 'nome' => 'Transferência - Banco do Brasil',
158
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::BANCO_BRASIL,
159
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::ONLINE_TRANSFER)),
160
+
161
+ '306' => array('codigo' => 306,
162
+ 'nome' => 'Transferência - Banrisul',
163
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::BANRISUL,
164
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::ONLINE_TRANSFER)),
165
+ '307' => array('codigo' => 307,
166
+ 'nome' => 'Transferência - HSBC',
167
+ 'instituicao' => Ipagare_IpgPagSeguroDireto_Instituicao::HSBC,
168
+ 'tipo' => array(Ipagare_IpgPagSeguroDireto_TypePaymentType::ONLINE_TRANSFER))
169
+ );
170
+
171
+ /**
172
+ * Payment method code
173
+ * Example: 101
174
+ */
175
+ private $value;
176
+
177
+ private $nome;
178
+
179
+ private $instituicao;
180
+
181
+ private $tipo;
182
+
183
+ public function __construct($value = null) {
184
+ if (array_key_exists($value, self::$codeList)) {
185
+ $p = self::$codeList[$value];
186
+
187
+ $this->value = $p['codigo'];
188
+ $this->nome = $p['nome'];
189
+ $this->instituicao = $p['instituicao'];
190
+ $this->tipo = $p['tipo'];
191
+ } else {
192
+ throw new Ipagare_IpgPagSeguroDireto_RuntimeException("Chave não encontrada para meio de pagamento informado. Chave = " . $value);
193
+ }
194
+ }
195
+
196
+ public function setValue($value) {
197
+ $this->value = $value;
198
+ }
199
+
200
+ /**
201
+ * @return integer the payment method code value
202
+ * Example: 101
203
+ */
204
+ public function getValue() {
205
+ return $this->value;
206
+ }
207
+
208
+ public function isAmex() {
209
+ return $this->codigo == self::AMEX_CREDIT_CARD;
210
+ }
211
+
212
+ public function isDiners() {
213
+ return $this->codigo == self::DINERS_CREDIT_CARD;
214
+ }
215
+
216
+ public function isHipercard() {
217
+ return $this->codigo == self::HIPERCARD_CREDIT_CARD;
218
+ }
219
+
220
+ public function isMastercard() {
221
+ return $this->codigo == self::MASTERCARD_CREDIT_CARD;
222
+ }
223
+
224
+ public function isVisa() {
225
+ return $this->codigo == self::VISA_CREDIT_CARD;
226
+ }
227
+
228
+ public function isBbDebito() {
229
+ return $this->codigo == self::BANCO_BRASIL_ONLINE_TRANSFER;
230
+ }
231
+
232
+ public function isBanrisulDebito() {
233
+ return $this->codigo == self::BANRISUL_ONLINE_TRANSFER;
234
+ }
235
+
236
+ public function isBradescoDebito() {
237
+ return $this->codigo == self::BRADESCO_ONLINE_TRANSFER;
238
+ }
239
+
240
+ public function isItauDebito() {
241
+ return $this->codigo == self::ITAU_ONLINE_TRANSFER;
242
+ }
243
+
244
+ public function isHsbcDebito() {
245
+ return $this->codigo == self::HSBC_ONLINE_TRANSFER;
246
+ }
247
+
248
+ public function isSantanderBoleto() {
249
+ return $this->codigo == self::SANTANDER_BOLETO;
250
+ }
251
+
252
+ public function isAura() {
253
+ return $this->codigo == self::AURA_CREDIT_CARD;
254
+ }
255
+
256
+ public function isElo() {
257
+ return $this->codigo == self::ELO_CREDIT_CARD;
258
+ }
259
+
260
+ public function isCreditCard() {
261
+ if (!is_array($this->tipo)) {
262
+ return $this->tipo == Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD;
263
+ } else {
264
+ foreach ($this->tipo as $value) {
265
+ if ($value == Ipagare_IpgPagSeguroDireto_TypePaymentType::CREDIT_CARD) {
266
+ return true;
267
+ }
268
+ }
269
+ }
270
+ return false;
271
+ }
272
+
273
+ public function isBoleto() {
274
+ if (!is_array($this->tipo)) {
275
+ return $this->tipo == Ipagare_IpgPagSeguroDireto_TypePaymentType::BOLETO;
276
+ } else {
277
+ foreach ($this->tipo as $value) {
278
+ if ($value == Ipagare_IpgPagSeguroDireto_TypePaymentType::BOLETO) {
279
+ return true;
280
+ }
281
+ }
282
+ }
283
+ return false;
284
+ }
285
+
286
+ public function isDebitoBancario() {
287
+ if (!is_array($this->tipo)) {
288
+ return $this->tipo == Ipagare_IpgPagSeguroDireto_TypePaymentType::ONLINE_TRANSFER;
289
+ } else {
290
+ foreach ($this->tipo as $value) {
291
+ if ($value == Ipagare_IpgPagSeguroDireto_TypePaymentType::ONLINE_TRANSFER) {
292
+ return true;
293
+ }
294
+ }
295
+ }
296
+ return false;
297
+ }
298
+
299
+ public function isPlenoCard() {
300
+ return $this->codigo == self::PLENOCARD;
301
+ }
302
+
303
+ public function isPersonalCard() {
304
+ return $this->codigo == self::PERSONALCARD;
305
+ }
306
+
307
+ public function isJcbCreditCard() {
308
+ return $this->codigo == self::JCB_CREDIT_CARD;
309
+ }
310
+
311
+ public function isDiscoverCreditCard() {
312
+ return $this->codigo == self::DISCOVER_CREDIT_CARD;
313
+ }
314
+
315
+ public function isBrasilCard() {
316
+ return $this->codigo == self::BRASILCARD;
317
+ }
318
+
319
+ public function isFortBrasilCreditCard() {
320
+ return $this->codigo == self::FORTBRASIL_CREDIT_CARD;
321
+ }
322
+
323
+ public function isCardbanCard() {
324
+ return $this->codigo == self::CARDBAN_CARD;
325
+ }
326
+
327
+ public function isValecardCard() {
328
+ return $this->codigo == self::VALECARD_CARD;
329
+ }
330
+
331
+ public function isCabalCard() {
332
+ return $this->codigo == self::CABAL_CARD;
333
+ }
334
+
335
+ public function isMaisCard() {
336
+ return $this->codigo == self::MAIS_CARD;
337
+ }
338
+
339
+ public function isAvistaCard() {
340
+ return $this->codigo == self::AVISTA_CARD;
341
+ }
342
+
343
+ public function isGrandCardCard() {
344
+ return $this->codigo == self::GRANDCARD_CARD;
345
+ }
346
+
347
+ public function getInstituicao() {
348
+ return $this->instituicao;
349
+ }
350
+
351
+ public function setInstituicao($instituicao) {
352
+ $this->instituicao = $instituicao;
353
+ }
354
+
355
+ public function setNome($nome) {
356
+ $this->nome = $nome;
357
+ }
358
+
359
+ public function getNome() {
360
+ return $this->nome;
361
+ }
362
+
363
+ public function setTipo($tipo) {
364
+ $this->tipo = $tipo;
365
+ }
366
+
367
+ public function getTipo() {
368
+ return $this->tipo;
369
+ }
370
+
371
+ public function getBandeira() {
372
+ return strtolower($this->instituicao);
373
+ }
374
+ }
lib/Ipagare/PagSeguroDireto/Domain/PaymentMethodType.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Defines a list of known payment method types.
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_PaymentMethodType {
25
+
26
+ private static $typeList = array(
27
+ '1' => array('code' => 1, 'module' => 'creditCard', 'label' => 'Cartão de Crédito'),
28
+ '2' => array('code' => 2, 'module' => 'boleto', 'label' => 'Boleto Bancário'),
29
+ '3' => array('code' => 3, 'module' => 'etf', 'label' => 'Transferência On-line')
30
+ );
31
+ private $code;
32
+ private $module;
33
+ private $label;
34
+
35
+ /**
36
+ * @param null $code
37
+ */
38
+ public function __construct($code = null) {
39
+ if ($code) {
40
+ $this->code = $code;
41
+ $a = self::$typeList[$code];
42
+ $this->module = $a['module'];
43
+ $this->label = $a['label'];
44
+ }
45
+ }
46
+
47
+ public function setCode($code) {
48
+ $this->code = $code;
49
+ }
50
+
51
+ public function setByType($type) {
52
+ if (isset(self::$typeList[$type])) {
53
+ $this->code = self::$typeList[$type];
54
+ } else {
55
+ throw new Exception("undefined index $type");
56
+ }
57
+ }
58
+
59
+ /**
60
+ * @return integer payment method type value
61
+ * Example: 1
62
+ */
63
+ public function getCode() {
64
+ return $this->code;
65
+ }
66
+
67
+ /**
68
+ * @param value
69
+ * @return Ipagare_PagSeguroDireto_Domain_PaymentMethodType the corresponding to the informed value
70
+ */
71
+ public function getTypeFromCode($code = null) {
72
+ $code = ($code == null ? $this->code : $code);
73
+ return array_search($this->code, self::$typeList);
74
+ }
75
+
76
+ public static function getTypeList() {
77
+ return self::$typeList;
78
+ }
79
+
80
+ public function getModule() {
81
+ return $this->module;
82
+ }
83
+
84
+ public function getLabel() {
85
+ return $this->label;
86
+ }
87
+
88
+ public static function setTypeList($typeList) {
89
+ self::$typeList = $typeList;
90
+ }
91
+
92
+ public function setModule($module) {
93
+ $this->module = $module;
94
+ }
95
+
96
+ public function setLabel($label) {
97
+ $this->label = $label;
98
+ }
99
+
100
+ }
lib/Ipagare/PagSeguroDireto/Domain/PaymentRequest.php ADDED
@@ -0,0 +1,613 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represents a payment request
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_PaymentRequest {
25
+
26
+ /**
27
+ * Party that will be sending the money
28
+ * @var Ipagare_PagSeguroDireto_Domain_Sender
29
+ */
30
+ private $sender;
31
+
32
+ /**
33
+ * Payment currency
34
+ */
35
+ private $currency;
36
+
37
+ /**
38
+ * Products/items in this payment request
39
+ */
40
+ private $items;
41
+
42
+ /**
43
+ * Uri to where the Ipagare_PagSeguroDireto_ payment page should redirect the user after the payment information is processed.
44
+ * Typically this is a confirmation page on your web site.
45
+ * @var String
46
+ */
47
+ private $redirectURL;
48
+
49
+ /**
50
+ * Extra amount to be added to the transaction total
51
+ *
52
+ * This value can be used to add an extra charge to the transaction
53
+ * or provide a discount in the case ExtraAmount is a negative value.
54
+ * @var float
55
+ */
56
+ private $extraAmount;
57
+
58
+ /**
59
+ * Reference code
60
+ *
61
+ * Optional. You can use the reference code to store an identifier so you can
62
+ * associate the Ipagare_PagSeguroDireto_ transaction to a transaction in your system.
63
+ */
64
+ private $reference;
65
+
66
+ /**
67
+ * Shipping information associated with this payment request
68
+ */
69
+ private $shipping;
70
+
71
+ /**
72
+ * Billing information associated with this payment request
73
+ *
74
+ * @var PagSeguroBilling
75
+ */
76
+ private $billing;
77
+
78
+ /**
79
+ * Determines for which url Ipagare_PagSeguroDireto_ will send the order related notifications codes.
80
+ *
81
+ * Optional. Any change happens in the transaction status, a new notification request will be send
82
+ * to this url. You can use that for update the related order.
83
+ */
84
+ private $notificationURL;
85
+
86
+ /**
87
+ * Extra parameters that user can add to a Ipagare_PagSeguroDireto_ checkout request
88
+ *
89
+ * Optional
90
+ * @var Ipagare_PagSeguroDireto_Domain_Parameter
91
+ */
92
+ private $parameter;
93
+
94
+ /**
95
+ *
96
+ * @var Ipagare_PagSeguroDireto_Domain_CreditCardHolder
97
+ */
98
+ private $creditCardHolder;
99
+
100
+ /**
101
+ *
102
+ * @var Ipagare_PagSeguroDireto_Domain_Installment
103
+ */
104
+ private $installment;
105
+ private $creditCardToken;
106
+ private $receiverEmail;
107
+ private $paymentMethod;
108
+
109
+ /**
110
+ *
111
+ * @var Ipagare_PagSeguroDireto_Domain_Bank
112
+ */
113
+ private $bank;
114
+
115
+ /**
116
+ *
117
+ * @var String
118
+ */
119
+ private $paymentMode = 'default';
120
+
121
+ /**
122
+ * @return Ipagare_PagSeguroDireto_Domain_Sender the sender
123
+ *
124
+ * Party that will be sending the Uri to where the Ipagare_PagSeguroDireto_ payment page should redirect the
125
+ * user after the payment information is processed.
126
+ */
127
+ public function getSender() {
128
+ return $this->sender;
129
+ }
130
+
131
+ /**
132
+ * Sets the Sender, party that will be sending the money
133
+ * @param String $name
134
+ * @param String $email
135
+ * @param String $areaCode
136
+ * @param String $number
137
+ * @param String $documentType
138
+ * @param String $documentValue
139
+ */
140
+ public function setSender(
141
+ $name, $email = null, $areaCode = null, $number = null, $documentType = null, $documentValue = null
142
+ ) {
143
+ $param = $name;
144
+ if (is_array($param)) {
145
+ $this->sender = new Ipagare_PagSeguroDireto_Domain_Sender($param);
146
+ } elseif ($param instanceof Ipagare_PagSeguroDireto_Domain_Sender) {
147
+ $this->sender = $param;
148
+ } else {
149
+ $sender = new Ipagare_PagSeguroDireto_Domain_Sender();
150
+ $sender->setName($param);
151
+ $sender->setEmail($email);
152
+ $sender->setPhone(new Ipagare_PagSeguroDireto_Domain_Phone($areaCode, $number));
153
+ $sender->addDocument($documentType, $documentValue);
154
+ $this->sender = $sender;
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Sets the name of the sender, party that will be sending the money
160
+ * @param String $senderName
161
+ */
162
+ public function setSenderName($senderName) {
163
+ if ($this->sender == null) {
164
+ $this->sender = new Ipagare_PagSeguroDireto_Domain_Sender();
165
+ }
166
+ $this->sender->setName($senderName);
167
+ }
168
+
169
+ /**
170
+ * Sets the name of the sender, party that will be sending the money
171
+ * @param String $senderEmail
172
+ */
173
+ public function setSenderEmail($senderEmail) {
174
+ if ($this->sender == null) {
175
+ $this->sender = new Ipagare_PagSeguroDireto_Domain_Sender();
176
+ }
177
+ $this->sender->setEmail($senderEmail);
178
+ }
179
+
180
+ /**
181
+ * Sets the Sender phone number, phone of the party that will be sending the money
182
+ *
183
+ * @param areaCode
184
+ * @param number
185
+ */
186
+ public function setSenderPhone($areaCode, $number = null) {
187
+ $param = $areaCode;
188
+ if ($this->sender == null) {
189
+ $this->sender = new Ipagare_PagSeguroDireto_Domain_Sender();
190
+ }
191
+ if ($param instanceof Ipagare_PagSeguroDireto_Domain_Phone) {
192
+ $this->sender->setPhone($param);
193
+ } else {
194
+ $this->sender->setPhone(new Ipagare_PagSeguroDireto_Domain_Phone($param, $number));
195
+ }
196
+ }
197
+
198
+ /**
199
+ * @return String the currency
200
+ * Example: BRL
201
+ */
202
+ public function getCurrency() {
203
+ return $this->currency;
204
+ }
205
+
206
+ /**
207
+ * Sets the currency
208
+ * @param String $currency
209
+ */
210
+ public function setCurrency($currency) {
211
+ $this->currency = $currency;
212
+ }
213
+
214
+ /**
215
+ * @return array the items/products list in this payment request
216
+ */
217
+ public function getItems() {
218
+ return $this->items;
219
+ }
220
+
221
+ /**
222
+ * Sets the items/products list in this payment request
223
+ * @param array $items
224
+ */
225
+ public function setItems(array $items) {
226
+ if (is_array($items)) {
227
+ $i = array();
228
+ foreach ($items as $key => $item) {
229
+ if ($item instanceof Ipagare_PagSeguroDireto_Domain_Item) {
230
+ $i[$key] = $item;
231
+ } else {
232
+ if (is_array($item)) {
233
+ $i[$key] = new Ipagare_PagSeguroDireto_Domain_Item($item);
234
+ }
235
+ }
236
+ }
237
+ $this->items = $i;
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Adds a new product/item in this payment request
243
+ *
244
+ * @param String $id
245
+ * @param String $description
246
+ * @param String $quantity
247
+ * @param String $amount
248
+ * @param String $weight
249
+ * @param String $shippingCost
250
+ */
251
+ public function addItem(
252
+ $id, $description = null, $quantity = null, $amount = null, $weight = null, $shippingCost = null
253
+ ) {
254
+ $param = $id;
255
+ if ($this->items == null) {
256
+ $this->items = array();
257
+ }
258
+ if (is_array($param)) {
259
+ array_push($this->items, new Ipagare_PagSeguroDireto_Domain_Item($param));
260
+ } else {
261
+ if ($param instanceof Ipagare_PagSeguroDireto_Domain_Item) {
262
+ array_push($this->items, $param);
263
+ } else {
264
+ $item = new Ipagare_PagSeguroDireto_Domain_Item();
265
+ $item->setId($param);
266
+ $item->setDescription($description);
267
+ $item->setQuantity($quantity);
268
+ $item->setAmount($amount);
269
+ $item->setWeight($weight);
270
+ $item->setShippingCost($shippingCost);
271
+ array_push($this->items, $item);
272
+ }
273
+ }
274
+ }
275
+
276
+ public function addSenderDocument($type, $value) {
277
+ if ($this->getSender() instanceof Ipagare_PagSeguroDireto_Domain_Sender) {
278
+ $this->getSender()->addDocument($type, $value);
279
+ }
280
+ }
281
+
282
+ /**
283
+ * URI to where the Ipagare_PagSeguroDireto_ payment page should redirect the user after the payment information is processed.
284
+ * Typically this is a confirmation page on your web site.
285
+ *
286
+ * @return String the redirectURL
287
+ */
288
+ public function getRedirectURL() {
289
+ return $this->redirectURL;
290
+ }
291
+
292
+ /**
293
+ * Sets the redirect URL
294
+ *
295
+ * Uri to where the Ipagare_PagSeguroDireto_ payment page should redirect the user after the payment information is processed.
296
+ * Typically this is a confirmation page on your web site.
297
+ *
298
+ * @param String $redirectURL
299
+ */
300
+ public function setRedirectURL($redirectURL) {
301
+ $this->redirectURL = $this->verifyURLTest($redirectURL);
302
+ }
303
+
304
+ /**
305
+ * This value can be used to add an extra charge to the transaction
306
+ * or provide a discount in the case ExtraAmount is a negative value.
307
+ *
308
+ * @return float the extra amount
309
+ */
310
+ public function getExtraAmount() {
311
+ return $this->extraAmount;
312
+ }
313
+
314
+ /**
315
+ * Sets the extra amount
316
+ * This value can be used to add an extra charge to the transaction
317
+ * or provide a discount in the case <b>extraAmount</b> is a negative value.
318
+ *
319
+ * @param extraAmount
320
+ */
321
+ public function setExtraAmount($extraAmount) {
322
+ $this->extraAmount = $extraAmount;
323
+ }
324
+
325
+ /**
326
+ * @return mixed the reference of this payment request
327
+ */
328
+ public function getReference() {
329
+ return $this->reference;
330
+ }
331
+
332
+ /**
333
+ * Sets the reference of this payment request
334
+ * @param reference
335
+ */
336
+ public function setReference($reference) {
337
+ $this->reference = $reference;
338
+ }
339
+
340
+ /**
341
+ * @return Ipagare_PagSeguroDireto_Domain_Shipping the shipping information for this payment request
342
+ * @see Ipagare_PagSeguroDireto_Domain_Shipping
343
+ */
344
+ public function getShipping() {
345
+ return $this->shipping;
346
+ }
347
+
348
+ /**
349
+ * Sets the shipping information for this payment request
350
+ * @param Ipagare_PagSeguroDireto_Domain_Shipping $address
351
+ * @param Ipagare_PagSeguroDireto_Domain_ShippingType $type
352
+ */
353
+ public function setShipping($address, $type = null) {
354
+ $param = $address;
355
+ if ($param instanceof Ipagare_PagSeguroDireto_Domain_Shipping) {
356
+ $this->shipping = $param;
357
+ } else {
358
+ $shipping = new Ipagare_PagSeguroDireto_Domain_Shipping();
359
+ if (is_array($param)) {
360
+ $shipping->setAddress(new Ipagare_PagSeguroDireto_Domain_Address($param));
361
+ } else {
362
+ if ($param instanceof Ipagare_PagSeguroDireto_Domain_Address) {
363
+ $shipping->setAddress($param);
364
+ }
365
+ }
366
+ if ($type) {
367
+ if ($type instanceof Ipagare_PagSeguroDireto_Domain_ShippingType) {
368
+ $shipping->setType($type);
369
+ } else {
370
+ $shipping->setType(new Ipagare_PagSeguroDireto_Domain_ShippingType($type));
371
+ }
372
+ }
373
+ $this->shipping = $shipping;
374
+ }
375
+ }
376
+
377
+ /**
378
+ * Sets the shipping address for this payment request
379
+ * @param String $postalCode
380
+ * @param String $street
381
+ * @param String $number
382
+ * @param String $complement
383
+ * @param String $district
384
+ * @param String $city
385
+ * @param String $state
386
+ * @param String $country
387
+ */
388
+ public function setShippingAddress(
389
+ $postalCode = null, $street = null, $number = null, $complement = null, $district = null, $city = null, $state = null, $country = null
390
+ ) {
391
+ $param = $postalCode;
392
+ if ($this->shipping == null) {
393
+ $this->shipping = new Ipagare_PagSeguroDireto_Domain_Shipping();
394
+ }
395
+ if (is_array($param)) {
396
+ $this->shipping->setAddress(new Ipagare_PagSeguroDireto_Domain_Address($param));
397
+ } elseif ($param instanceof Ipagare_PagSeguroDireto_Domain_Address) {
398
+ $this->shipping->setAddress($param);
399
+ } else {
400
+ $address = new Ipagare_PagSeguroDireto_Domain_Address();
401
+ $address->setPostalCode($postalCode);
402
+ $address->setStreet($street);
403
+ $address->setNumber($number);
404
+ $address->setComplement($complement);
405
+ $address->setDistrict($district);
406
+ $address->setCity($city);
407
+ $address->setState($state);
408
+ $address->setCountry($country);
409
+ $this->shipping->setAddress($address);
410
+ }
411
+ }
412
+
413
+ /**
414
+ * Sets the shipping type for this payment request
415
+ * @param Ipagare_PagSeguroDireto_Domain_ShippingType $type
416
+ */
417
+ public function setShippingType($type) {
418
+ $param = $type;
419
+ if ($this->shipping == null) {
420
+ $this->shipping = new Ipagare_PagSeguroDireto_Domain_Shipping();
421
+ }
422
+ if ($param instanceof Ipagare_PagSeguroDireto_Domain_ShippingType) {
423
+ $this->shipping->setType($param);
424
+ } else {
425
+ $this->shipping->setType(new Ipagare_PagSeguroDireto_Domain_ShippingType($param));
426
+ }
427
+ }
428
+
429
+ /**
430
+ * Sets the shipping cost for this payment request
431
+ * @param float $shippingCost
432
+ */
433
+ public function setShippingCost($shippingCost) {
434
+ $param = $shippingCost;
435
+ if ($this->shipping == null) {
436
+ $this->shipping = new Ipagare_PagSeguroDireto_Domain_Shipping();
437
+ }
438
+
439
+ $this->shipping->setCost($param);
440
+ }
441
+
442
+ /**
443
+ * Get the notification status url
444
+ *
445
+ * @return String
446
+ */
447
+ public function getNotificationURL() {
448
+ return $this->notificationURL;
449
+ }
450
+
451
+ /**
452
+ * Sets the url that Ipagare_PagSeguroDireto_ will send the new notifications statuses
453
+ *
454
+ * @param String $notificationURL
455
+ */
456
+ public function setNotificationURL($notificationURL) {
457
+ $this->notificationURL = $this->verifyURLTest($notificationURL);
458
+ }
459
+
460
+ /**
461
+ * Sets parameter for Ipagare_PagSeguroDireto_ checkout requests
462
+ *
463
+ * @param Ipagare_PagSeguroDireto_Domain_Parameter $parameter
464
+ */
465
+ public function setParameter($parameter) {
466
+ $this->parameter = $parameter;
467
+ }
468
+
469
+ /**
470
+ * Gets parameter for Ipagare_PagSeguroDireto_ checkout requests
471
+ *
472
+ * @return Ipagare_PagSeguroDireto_Domain_Parameter
473
+ */
474
+ public function getParameter() {
475
+ if ($this->parameter == null) {
476
+ $this->parameter = new Ipagare_PagSeguroDireto_Domain_Parameter();
477
+ }
478
+ return $this->parameter;
479
+ }
480
+
481
+ /**
482
+ * add a parameter for Ipagare_PagSeguroDireto_ checkout request
483
+ *
484
+ * @param Ipagare_PagSeguroDireto_Domain_ParameterItem $parameterName key
485
+ * @param Ipagare_PagSeguroDireto_Domain_ParameterItem $parameterValue value
486
+ */
487
+ public function addParameter($parameterName, $parameterValue) {
488
+ $this->getParameter()->addItem(new Ipagare_PagSeguroDireto_Domain_ParameterItem($parameterName, $parameterValue));
489
+ }
490
+
491
+ public function register(Ipagare_PagSeguroDireto_Domain_Credentials $credentials) {
492
+ $paymentService = new Ipagare_PagSeguroDireto_Service_PaymentService();
493
+ return $paymentService->createTransaction($credentials, $this);
494
+ }
495
+
496
+ /**
497
+ * @return String a string that represents the current object
498
+ */
499
+ public function toString() {
500
+ $email = $this->sender ? $this->sender->getEmail() : "null";
501
+
502
+ $request = array();
503
+ $request['Reference'] = $this->reference;
504
+ $request['SenderEmail'] = $email;
505
+
506
+ return "Ipagare_PagSeguroDireto_Domain_PaymentRequest: " . var_export($request, true);
507
+ }
508
+
509
+ /**
510
+ * Verify if the adress of NotificationURL or RedirectURL is for tests and return empty
511
+ * @param type $url
512
+ * @return type
513
+ */
514
+ public function verifyURLTest($url) {
515
+ $adress = array(
516
+ 'localhost',
517
+ '127.0.0.1',
518
+ '::1'
519
+ );
520
+
521
+ $urlReturn;
522
+ foreach ($adress as $item) {
523
+ $find = strpos($url, $item);
524
+
525
+ if ($find) {
526
+ $urlReturn = '';
527
+ break;
528
+ } else {
529
+ $urlReturn = $url;
530
+ }
531
+ }
532
+
533
+ return $urlReturn;
534
+ }
535
+
536
+ public function getCreditCardHolder() {
537
+ return $this->creditCardHolder;
538
+ }
539
+
540
+ public function setCreditCardHolder($creditCardHolder) {
541
+ $this->creditCardHolder = $creditCardHolder;
542
+ }
543
+
544
+ public function getCreditCardToken() {
545
+ return $this->creditCardToken;
546
+ }
547
+
548
+ public function getReceiverEmail() {
549
+ return $this->receiverEmail;
550
+ }
551
+
552
+ public function getPaymentMethod() {
553
+ return $this->paymentMethod;
554
+ }
555
+
556
+ public function getPaymentMode() {
557
+ return $this->paymentMode;
558
+ }
559
+
560
+ public function setCreditCardToken($creditCardToken) {
561
+ $this->creditCardToken = $creditCardToken;
562
+ }
563
+
564
+ public function setReceiverEmail($receiverEmail) {
565
+ $this->receiverEmail = $receiverEmail;
566
+ }
567
+
568
+ public function setPaymentMethod($paymentMethod) {
569
+ $this->paymentMethod = $paymentMethod;
570
+ }
571
+
572
+ public function setPaymentMode($paymentMode) {
573
+ $this->paymentMode = $paymentMode;
574
+ }
575
+
576
+ public function getBilling() {
577
+ return $this->billing;
578
+ }
579
+
580
+ public function setBilling($address) {
581
+ $param = $address;
582
+ if ($param instanceof Ipagare_PagSeguroDireto_Domain_Billing) {
583
+ $this->billing = $param;
584
+ } else {
585
+ $billing = new Ipagare_PagSeguroDireto_Domain_Billing();
586
+ if (is_array($param)) {
587
+ $billing->setAddress(new Ipagare_PagSeguroDireto_Domain_Address($param));
588
+ } else {
589
+ if ($param instanceof Ipagare_PagSeguroDireto_Domain_Address) {
590
+ $billing->setAddress($param);
591
+ }
592
+ }
593
+ $this->billing = $billing;
594
+ }
595
+ }
596
+
597
+ public function getInstallment() {
598
+ return $this->installment;
599
+ }
600
+
601
+ public function setInstallment(Ipagare_PagSeguroDireto_Domain_Installment $installment) {
602
+ $this->installment = $installment;
603
+ }
604
+
605
+ public function getBank() {
606
+ return $this->bank;
607
+ }
608
+
609
+ public function setBank(Ipagare_PagSeguroDireto_Domain_Bank $bank) {
610
+ $this->bank = $bank;
611
+ }
612
+
613
+ }
lib/Ipagare/PagSeguroDireto/Domain/PaymentResponse.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ipagare_PagSeguroDireto_Domain_PaymentResponse {
4
+
5
+ /**
6
+ *
7
+ * @var array
8
+ */
9
+ public $dataSend;
10
+
11
+ /**
12
+ *
13
+ * @var Ipagare_PagSeguroDireto_Parser_PaymentParserData
14
+ */
15
+ public $paymentParserData;
16
+
17
+ /**
18
+ *
19
+ * @var array
20
+ */
21
+ public $errors = array();
22
+
23
+ public static function getInstance() {
24
+ return new Ipagare_PagSeguroDireto_Domain_PaymentResponse();
25
+ }
26
+
27
+ public function getDataSend() {
28
+ return $this->dataSend;
29
+ }
30
+
31
+ public function setDataSend($dataSend) {
32
+ $this->dataSend = $dataSend;
33
+ }
34
+
35
+ public function getPaymentParserData() {
36
+ return $this->paymentParserData;
37
+ }
38
+
39
+ public function setPaymentParserData(Ipagare_PagSeguroDireto_Parser_PaymentParserData $paymentParserData) {
40
+ $this->paymentParserData = $paymentParserData;
41
+ }
42
+
43
+ public function getErrors() {
44
+ return $this->errors;
45
+ }
46
+
47
+ public function setErrors($errors) {
48
+ $this->errors = $errors;
49
+ }
50
+
51
+ public function addFatalError($error) {
52
+ $this->errors['99999'] = $error;
53
+ }
54
+
55
+ public function hasErrors() {
56
+ return count($this->errors);
57
+ }
58
+
59
+ public function isSuccess() {
60
+ if ($this->hasErrors() || is_null($this->paymentParserData)) {
61
+ return false;
62
+ }
63
+
64
+ return $this->paymentParserData->isSuccess();
65
+ }
66
+
67
+ }
lib/Ipagare/PagSeguroDireto/Domain/Phone.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represents a phone number
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_Phone {
25
+
26
+ /**
27
+ * Area code
28
+ */
29
+ private $areaCode;
30
+
31
+ /**
32
+ * Phone number
33
+ */
34
+ private $number;
35
+
36
+ /**
37
+ * Initializes a new instance of the Ipagare_PagSeguroDireto_Domain_Phone class
38
+ *
39
+ * @param String $areaCode
40
+ * @param String $number
41
+ * @return Ipagare_PagSeguroDireto_Domain_Phone
42
+ */
43
+ public function __construct($areaCode = null, $number = null) {
44
+ $this->areaCode = ($areaCode == null ? null : $areaCode);
45
+ $this->number = ($number == null ? null : $number);
46
+ return $this;
47
+ }
48
+
49
+ /**
50
+ * @return int the area code
51
+ */
52
+ public function getAreaCode() {
53
+ return $this->areaCode;
54
+ }
55
+
56
+ /**
57
+ * @return int the number
58
+ */
59
+ public function getNumber() {
60
+ return $this->number;
61
+ }
62
+
63
+ /**
64
+ * Sets the area code
65
+ * @param String $areaCode
66
+ * @return Ipagare_PagSeguroDireto_Domain_Phone
67
+ */
68
+ public function setAreaCode($areaCode) {
69
+ $this->areaCode = $areaCode;
70
+ return $this;
71
+ }
72
+
73
+ /**
74
+ * Sets the number
75
+ * @param String $number
76
+ * @return Ipagare_PagSeguroDireto_Domain_Phone
77
+ */
78
+ public function setNumber($number) {
79
+ $this->number = $number;
80
+ return $this;
81
+ }
82
+
83
+ /**
84
+ * Sets the number from a formatted string
85
+ *
86
+ * @param $number String formatted string like <code>(99) [9]9999-9999</code>
87
+ * @return $this
88
+ */
89
+ public function setFullPhone($number) {
90
+ /* We clean the string that is coming. Can be formatted or not */
91
+ $number = str_replace(array('(', ')', '-', ' '), '', $number);
92
+ $number = explode('', $number);
93
+ $areaCode = array_shift($number[0]) . array_shift($number[1]);
94
+ $phone = implode('', $number);
95
+
96
+ $this->setAreaCode($areaCode);
97
+ $this->setNumber($phone);
98
+
99
+ return $this;
100
+ }
101
+
102
+ }
lib/Ipagare/PagSeguroDireto/Domain/Sender.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represents the party on the transaction that is sending the money
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_Sender {
25
+
26
+ /** Sender name */
27
+ private $name;
28
+
29
+ /** Sender email */
30
+ private $email;
31
+
32
+ /** Sender phone */
33
+ private $phone;
34
+
35
+ /** Hash */
36
+ private $hash;
37
+
38
+ /** Sender documents */
39
+ private $documents;
40
+
41
+ /**
42
+ * Initializes a new instance of the Sender class
43
+ *
44
+ * @param array $data
45
+ */
46
+ public function __construct(array $data = null) {
47
+ if ($data) {
48
+ if (isset($data['name'])) {
49
+ $this->name = $data['name'];
50
+ }
51
+ if (isset($data['email'])) {
52
+ $this->email = $data['email'];
53
+ }
54
+ if (isset($data['hash'])) {
55
+ $this->hash = $data['hash'];
56
+ }
57
+ if (isset($data['phone']) && $data['phone'] instanceof Ipagare_PagSeguroDireto_Domain_Phone) {
58
+ $this->phone = $data['phone'];
59
+ } else {
60
+ if (isset($data['areaCode']) && isset($data['number'])) {
61
+ $phone = new Ipagare_PagSeguroDireto_Domain_Phone($data['areaCode'], $data['number']);
62
+ $this->phone = $phone;
63
+ }
64
+ }
65
+ if (isset($data['documents']) && is_array($data['documents'])) {
66
+ $this->setDocuments($data['documents']);
67
+ }
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Sets the sender name
73
+ * @param String $name
74
+ */
75
+ public function setName($name) {
76
+ $this->name = Ipagare_PagSeguroDireto_Helper_Helper::formatString($name, 50, '');
77
+ }
78
+
79
+ /**
80
+ * @return String the sender name
81
+ */
82
+ public function getName() {
83
+ return $this->name;
84
+ }
85
+
86
+ /**
87
+ * Sets the Sender e-mail
88
+ * @param email
89
+ */
90
+ public function setEmail($email) {
91
+ $this->email = $email;
92
+ }
93
+
94
+ /**
95
+ * @return String the sender e-mail
96
+ */
97
+ public function getEmail() {
98
+ return $this->email;
99
+ }
100
+
101
+ /**
102
+ * Sets the sender phone
103
+ * @param String $areaCode
104
+ * @param String $number
105
+ */
106
+ public function setPhone($areaCode, $number = null) {
107
+ $param = $areaCode;
108
+ if ($param instanceof Ipagare_PagSeguroDireto_Domain_Phone) {
109
+ $this->phone = $param;
110
+ } elseif ($number) {
111
+ $phone = new Ipagare_PagSeguroDireto_Domain_Phone();
112
+ $phone->setAreaCode($areaCode);
113
+ $phone->setNumber($number);
114
+ $this->phone = $phone;
115
+ }
116
+ }
117
+
118
+ /**
119
+ * @return Ipagare_PagSeguroDireto_Domain_Phone the sender phone
120
+ * @see Ipagare_PagSeguroDireto_Domain_Phone
121
+ */
122
+ public function getPhone() {
123
+ return $this->phone;
124
+ }
125
+
126
+ /**
127
+ * Get Sender documents
128
+ * @return array Ipagare_PagSeguroDireto_Domain_Document List of Ipagare_PagSeguroDireto_Domain_Document
129
+ * @see Ipagare_PagSeguroDireto_Domain_Document
130
+ */
131
+ public function getDocuments() {
132
+ return $this->documents;
133
+ }
134
+
135
+ /**
136
+ * Set Ipagare_PagSeguroDireto_ documents
137
+ * @param array $documents
138
+ * @see Ipagare_PagSeguroDireto_Domain_Document
139
+ */
140
+ public function setDocuments(array $documents) {
141
+ if (count($documents) > 0) {
142
+ foreach ($documents as $document) {
143
+ if ($document instanceof Ipagare_PagSeguroDireto_Domain_SenderDocument) {
144
+ $this->documents[] = $document;
145
+ } else {
146
+ if (is_array($document)) {
147
+ $this->addDocument($document['type'], $document['value']);
148
+ }
149
+ }
150
+ }
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Add a document for Sender object
156
+ * @param String $type
157
+ * @param String $value
158
+ */
159
+ public function addDocument($type, $value) {
160
+ if ($type && $value) {
161
+ if (count($this->documents) == 0) {
162
+ $document = new Ipagare_PagSeguroDireto_Domain_SenderDocument($type, $value);
163
+ $this->documents[] = $document;
164
+ }
165
+ }
166
+ }
167
+
168
+ public function getHash() {
169
+ return $this->hash;
170
+ }
171
+
172
+ public function setHash($hash) {
173
+ $this->hash = $hash;
174
+ }
175
+ }
lib/Ipagare/PagSeguroDireto/Domain/SenderDocument.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class that represents a Sender Document
5
+ */
6
+ class Ipagare_PagSeguroDireto_Domain_SenderDocument {
7
+
8
+ /**
9
+ * The type of document
10
+ * @var string
11
+ */
12
+ private $type;
13
+
14
+ /**
15
+ * The value of document
16
+ * @var string
17
+ */
18
+ private $value;
19
+
20
+ /**
21
+ * @param $type
22
+ * @param $value
23
+ */
24
+ public function __construct($type, $value) {
25
+ if ($type && $value) {
26
+ $this->setType($type);
27
+ $this->setValue($value);
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Get document type
33
+ * @return string
34
+ */
35
+ public function getType() {
36
+ return $this->type;
37
+ }
38
+
39
+ /**
40
+ * Set document type
41
+ * @param string $type
42
+ */
43
+ public function setType($type) {
44
+ $this->type = strtoupper($type);
45
+ }
46
+
47
+ /**
48
+ * Get document value
49
+ * @return string
50
+ */
51
+ public function getValue() {
52
+ return $this->value;
53
+ }
54
+
55
+ /**
56
+ * Set document value
57
+ * @param string $value
58
+ */
59
+ public function setValue($value) {
60
+ $this->value = Ipagare_PagSeguroDireto_Helper_Helper::getOnlyNumbers($value);
61
+ }
62
+
63
+ /**
64
+ * Gets toString class
65
+ * @return string
66
+ */
67
+ public function toString() {
68
+ $document = array();
69
+ $document['type'] = $this->type;
70
+ $document['value'] = $this->value;
71
+
72
+ return "Ipagare_PagSeguroDireto_Domain_SenderDocument: " . var_export($document, true);
73
+ }
74
+
75
+ }
lib/Ipagare/PagSeguroDireto/Domain/Session.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Represents a phone number
5
+ */
6
+ class Ipagare_PagSeguroDireto_Domain_Session {
7
+
8
+ /**
9
+ * ID
10
+ */
11
+ private $id;
12
+
13
+ /**
14
+ * Initializes a new instance of the Ipagare_PagSeguroDireto_Domain_Session class
15
+ *
16
+ * @param String $areaCode
17
+ * @param String $number
18
+ * @return Ipagare_PagSeguroDireto_Domain_Phone
19
+ */
20
+ public function __construct($id = null) {
21
+ $this->id = ($id == null ? null : $id);
22
+ return $this;
23
+ }
24
+
25
+ public function getId() {
26
+ return $this->id;
27
+ }
28
+
29
+ public function setId($id) {
30
+ $this->id = $id;
31
+ }
32
+
33
+ }
lib/Ipagare/PagSeguroDireto/Domain/SessionResponse.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ipagare_PagSeguroDireto_Domain_SessionResponse {
4
+
5
+ /**
6
+ *
7
+ * @var Ipagare_PagSeguroDireto_Domain_Session
8
+ */
9
+ private $session;
10
+
11
+ /**
12
+ *
13
+ * @var array
14
+ */
15
+ public $errors = array();
16
+
17
+ public static function getInstance() {
18
+ return new Ipagare_PagSeguroDireto_Domain_SessionResponse();
19
+ }
20
+
21
+ public function getErrors() {
22
+ return $this->errors;
23
+ }
24
+
25
+ public function setErrors($errors) {
26
+ $this->errors = $errors;
27
+ }
28
+
29
+ public function addFatalError($error) {
30
+ $this->errors['99999'] = $error;
31
+ }
32
+
33
+ public function hasErrors() {
34
+ return count($this->errors);
35
+ }
36
+
37
+ public function isSuccess() {
38
+ if ($this->hasErrors() || is_null($this->session)) {
39
+ return false;
40
+ }
41
+
42
+ return true;
43
+ }
44
+
45
+ public function getSession() {
46
+ return $this->session;
47
+ }
48
+
49
+ public function setSession(Ipagare_PagSeguroDireto_Domain_Session $session) {
50
+ $this->session = $session;
51
+ }
52
+
53
+ }
lib/Ipagare/PagSeguroDireto/Domain/Shipping.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Shipping information
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_Shipping {
25
+
26
+ /**
27
+ * Shipping address
28
+ * @see Ipagare_PagSeguroDireto_Domain_Address
29
+ */
30
+ private $address;
31
+
32
+ /**
33
+ * Shipping type. See the Ipagare_PagSeguroDireto_Domain_ShippingType class for a list of known shipping types.
34
+ * @see Ipagare_PagSeguroDireto_Domain_ShippingType
35
+ */
36
+ private $type;
37
+
38
+ /**
39
+ * shipping cost.
40
+ */
41
+ private $cost;
42
+
43
+ /**
44
+ * Initializes a new instance of the Ipagare_PagSeguroDireto_Domain_Shipping class
45
+ * @param array $data
46
+ */
47
+ public function __construct(array $data = null) {
48
+ if ($data) {
49
+ if (isset($data['address']) && $data['address'] instanceof Ipagare_PagSeguroDireto_Domain_Address) {
50
+ $this->address = $data['address'];
51
+ }
52
+ if (isset($data['type']) && $data['type'] instanceof Ipagare_PagSeguroDireto_Domain_ShippingType) {
53
+ $this->type = $data['type'];
54
+ }
55
+ if (isset($data['cost'])) {
56
+ $this->cost = $data['cost'];
57
+ }
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Sets the shipping address
63
+ * @see Ipagare_PagSeguroDireto_Domain_Address
64
+ * @param Ipagare_PagSeguroDireto_Domain_Address $address
65
+ */
66
+ public function setAddress(Ipagare_PagSeguroDireto_Domain_Address $address) {
67
+ $this->address = $address;
68
+ }
69
+
70
+ /**
71
+ * @return Ipagare_PagSeguroDireto_Domain_Address the shipping Address
72
+ * @see Ipagare_PagSeguroDireto_Domain_Address
73
+ */
74
+ public function getAddress() {
75
+ return $this->address;
76
+ }
77
+
78
+ /**
79
+ * Sets the shipping type
80
+ * @param Ipagare_PagSeguroDireto_Domain_ShippingType $type
81
+ * @see Ipagare_PagSeguroDireto_Domain_ShippingType
82
+ */
83
+ public function setType(Ipagare_PagSeguroDireto_Domain_ShippingType $type) {
84
+ $this->type = $type;
85
+ }
86
+
87
+ /**
88
+ * @return Ipagare_PagSeguroDireto_Domain_ShippingType the shipping type
89
+ * @see Ipagare_PagSeguroDireto_Domain_ShippingType
90
+ */
91
+ public function getType() {
92
+ return $this->type;
93
+ }
94
+
95
+ /**
96
+ * @param $cost float
97
+ */
98
+ public function setCost($cost) {
99
+ $this->cost = $cost;
100
+ }
101
+
102
+ /**
103
+ * @return float the shipping cost
104
+ */
105
+ public function getCost() {
106
+ return $this->cost;
107
+ }
108
+
109
+ }
lib/Ipagare/PagSeguroDireto/Domain/ShippingType.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Defines a list of known shipping types.
23
+ * this class is not an enum to enable the introduction of new shipping types
24
+ * without breaking this version of the library.
25
+ */
26
+ class Ipagare_PagSeguroDireto_Domain_ShippingType {
27
+
28
+ /**
29
+ * @var array
30
+ */
31
+ private static $typeList = array(
32
+ 'PAC' => 1,
33
+ 'SEDEX' => 2,
34
+ 'NOT_SPECIFIED' => 3
35
+ );
36
+
37
+ /**
38
+ * the shipping type value
39
+ * Example: 1
40
+ */
41
+ private $value;
42
+
43
+ /**
44
+ * @param null $value
45
+ */
46
+ public function __construct($value = null) {
47
+ if ($value) {
48
+ $this->value = $value;
49
+ }
50
+ }
51
+
52
+ /**
53
+ * @param $value
54
+ */
55
+ public function setValue($value) {
56
+ $this->value = $value;
57
+ }
58
+
59
+ /**
60
+ * @param $type
61
+ * @throws Exception
62
+ */
63
+ public function setByType($type) {
64
+ if (isset(self::$typeList[$type])) {
65
+ $this->value = self::$typeList[$type];
66
+ } else {
67
+ throw new Exception("undefined index $type");
68
+ }
69
+ }
70
+
71
+ /**
72
+ * @return int the value of the shipping type
73
+ */
74
+ public function getValue() {
75
+ return $this->value;
76
+ }
77
+
78
+ /**
79
+ * @param value
80
+ * @return Ipagare_PagSeguroDireto_Domain_ShippingType the Ipagare_PagSeguroDireto_Domain_ShippingType corresponding to the informed value
81
+ */
82
+ public function getTypeFromValue($value = null) {
83
+ $value = ($value === null ? $this->value : $value);
84
+ return array_search($value, self::$typeList);
85
+ }
86
+
87
+ /**
88
+ * @param string
89
+ * @return integer the code corresponding to the informed shipping type
90
+ */
91
+ public static function getCodeByType($type) {
92
+ if (isset(self::$typeList[$type])) {
93
+ return self::$typeList[$type];
94
+ } else {
95
+ return false;
96
+ }
97
+ }
98
+
99
+ /**
100
+ * @param string $type
101
+ * @return Ipagare_PagSeguroDireto_Domain_ShippingType a Ipagare_PagSeguroDireto_Domain_ShippingType object corresponding to the informed type
102
+ */
103
+ public static function createByType($type) {
104
+ $ShippingType = new Ipagare_PagSeguroDireto_Domain_ShippingType();
105
+ $ShippingType->setByType($type);
106
+ return $ShippingType;
107
+ }
108
+
109
+ }
lib/Ipagare/PagSeguroDireto/Domain/Transaction.php ADDED
@@ -0,0 +1,415 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Class Ipagare_PagSeguroDireto_Domain_Transaction
23
+ * Represents a Ipagare_PagSeguroDireto_ transaction
24
+ *
25
+ * @property Ipagare_PagSeguroDireto_Domain_Sender $sender
26
+ *
27
+ */
28
+ class Ipagare_PagSeguroDireto_Domain_Transaction {
29
+
30
+ /**
31
+ * Transaction date
32
+ */
33
+ private $date;
34
+
35
+ /**
36
+ * Last event date
37
+ * Date the last notification about this transaction was sent
38
+ */
39
+ private $lastEventDate;
40
+
41
+ /**
42
+ * Transaction code
43
+ */
44
+ private $code;
45
+
46
+ /**
47
+ * Reference code
48
+ * You can use the reference code to store an identifier so you can
49
+ * associate the Ipagare_PagSeguroDireto_ transaction to a transaction in your system.
50
+ */
51
+ private $reference;
52
+
53
+ /**
54
+ * Transaction type
55
+ * @see Ipagare_PagSeguroDireto_Domain_TransactionType
56
+ * @var Ipagare_PagSeguroDireto_Domain_TransactionType
57
+ */
58
+ private $type;
59
+
60
+ /**
61
+ * Transaction Status
62
+ * @see Ipagare_PagSeguroDireto_Domain_TransactionStatus
63
+ * @var Ipagare_PagSeguroDireto_Domain_TransactionStatus
64
+ */
65
+ private $status;
66
+
67
+ /**
68
+ * Payment method
69
+ * @see Ipagare_PagSeguroDireto_Domain_PaymentMethod
70
+ * @var Ipagare_PagSeguroDireto_Domain_PaymentMethod
71
+ */
72
+ private $paymentMethod;
73
+
74
+ /**
75
+ * Gross amount of the transaction
76
+ */
77
+ private $grossAmount;
78
+
79
+ /**
80
+ * Discount amount
81
+ */
82
+ private $discountAmount;
83
+
84
+ /**
85
+ * Fee amount
86
+ */
87
+ private $feeAmount;
88
+
89
+ /**
90
+ * Net amount
91
+ */
92
+ private $netAmount;
93
+
94
+ /**
95
+ * Extra amount
96
+ */
97
+ private $extraAmount;
98
+
99
+ /**
100
+ * Installment count
101
+ */
102
+ private $installmentCount;
103
+
104
+ /**
105
+ * item/product list in this transaction
106
+ * @see Ipagare_PagSeguroDireto_Domain_Item
107
+ */
108
+ private $items;
109
+
110
+ /**
111
+ * Payer information, who is sending money
112
+ * @see Ipagare_PagSeguroDireto_Domain_Sender
113
+ * @var Ipagare_PagSeguroDireto_Domain_Sender
114
+ */
115
+ private $sender;
116
+
117
+ /**
118
+ * Shipping information
119
+ * @see Ipagare_PagSeguroDireto_Domain_Shipping
120
+ * @var Ipagare_PagSeguroDireto_Domain_Shipping
121
+ */
122
+ private $shipping;
123
+
124
+
125
+ private $cancellationSource;
126
+
127
+ /**
128
+ * Date the last notification about this transaction was sent
129
+ * @return datetime the last event date
130
+ */
131
+ public function getLastEventDate() {
132
+ return $this->lastEventDate;
133
+ }
134
+
135
+ /**
136
+ * Sets the last event date
137
+ *
138
+ * @param lastEventDate
139
+ */
140
+ public function setLastEventDate($lastEventDate) {
141
+ $this->lastEventDate = $lastEventDate;
142
+ }
143
+
144
+ /**
145
+ * @return datetime the transaction date
146
+ */
147
+ public function getDate() {
148
+ return $this->date;
149
+ }
150
+
151
+ /**
152
+ * Sets the transaction date
153
+ *
154
+ * @param string date
155
+ */
156
+ public function setDate($date) {
157
+ $this->date = $date;
158
+ }
159
+
160
+ /**
161
+ * @return string the transaction code
162
+ */
163
+ public function getCode() {
164
+ return $this->code;
165
+ }
166
+
167
+ /**
168
+ * Sets the transaction code
169
+ *
170
+ * @param code
171
+ */
172
+ public function setCode($code) {
173
+ $this->code = $code;
174
+ }
175
+
176
+ /**
177
+ * You can use the reference code to store an identifier so you can
178
+ * associate the Ipagare_PagSeguroDireto_ transaction to a transaction in your system.
179
+ *
180
+ * @return string the reference code
181
+ */
182
+ public function getReference() {
183
+ return $this->reference;
184
+ }
185
+
186
+ /**
187
+ * Sets the reference code
188
+ *
189
+ * @param reference
190
+ */
191
+ public function setReference($reference) {
192
+ $this->reference = $reference;
193
+ }
194
+
195
+ /**
196
+ * @return Ipagare_PagSeguroDireto_Domain_TransactionType the transaction type
197
+ * @see Ipagare_PagSeguroDireto_Domain_TransactionType
198
+ */
199
+ public function getType() {
200
+ return $this->type;
201
+ }
202
+
203
+ /**
204
+ * Sets the transaction type
205
+ * @param Ipagare_PagSeguroDireto_Domain_TransactionType $type
206
+ */
207
+ public function setType(Ipagare_PagSeguroDireto_Domain_TransactionType $type) {
208
+ $this->type = $type;
209
+ }
210
+
211
+ /**
212
+ * @return Ipagare_PagSeguroDireto_Domain_TransactionStatus the transaction status
213
+ * @see Ipagare_PagSeguroDireto_Domain_TransactionStatus
214
+ */
215
+ public function getStatus() {
216
+ return $this->status;
217
+ }
218
+
219
+ /**
220
+ * Sets the transaction status
221
+ * @param Ipagare_PagSeguroDireto_Domain_TransactionStatus $status
222
+ */
223
+ public function setStatus(Ipagare_PagSeguroDireto_Domain_TransactionStatus $status) {
224
+ $this->status = $status;
225
+ }
226
+
227
+ /**
228
+ * @return Ipagare_PagSeguroDireto_Domain_PaymentMethod the payment method used in this transaction
229
+ * @see Ipagare_PagSeguroDireto_Domain_PaymentMethod
230
+ */
231
+ public function getPaymentMethod() {
232
+ return $this->paymentMethod;
233
+ }
234
+
235
+ /**
236
+ * Sets the payment method used in this transaction
237
+ * @param Ipagare_PagSeguroDireto_Domain_PaymentMethod $paymentMethod
238
+ */
239
+ public function setPaymentMethod(Ipagare_PagSeguroDireto_Domain_PaymentMethod $paymentMethod) {
240
+ $this->paymentMethod = $paymentMethod;
241
+ }
242
+
243
+ /**
244
+ * @return float the transaction gross amount
245
+ */
246
+ public function getGrossAmount() {
247
+ return $this->grossAmount;
248
+ }
249
+
250
+ /**
251
+ * Sets the transaction gross amount
252
+ * @param float $totalValue
253
+ */
254
+ public function setGrossAmount($totalValue) {
255
+ $this->grossAmount = $totalValue;
256
+ }
257
+
258
+ /**
259
+ * @return float the transaction gross amount
260
+ */
261
+ public function getDiscountAmount() {
262
+ return $this->discountAmount;
263
+ }
264
+
265
+ /**
266
+ * Sets the transaction gross amount
267
+ * @param float $discountAmount
268
+ */
269
+ public function setDiscountAmount($discountAmount) {
270
+ $this->discountAmount = $discountAmount;
271
+ }
272
+
273
+ /**
274
+ * @return float the fee amount
275
+ */
276
+ public function getFeeAmount() {
277
+ return $this->feeAmount;
278
+ }
279
+
280
+ /**
281
+ * Sets the transaction fee amount
282
+ * @param float $feeAmount
283
+ */
284
+ public function setFeeAmount($feeAmount) {
285
+ $this->feeAmount = $feeAmount;
286
+ }
287
+
288
+ /**
289
+ * @return float the net amount
290
+ */
291
+ public function getNetAmount() {
292
+ return $this->netAmount;
293
+ }
294
+
295
+ /**
296
+ * Sets the net amount
297
+ * @param float $netAmount
298
+ */
299
+ public function setNetAmount($netAmount) {
300
+ $this->netAmount = $netAmount;
301
+ }
302
+
303
+ /**
304
+ * @return float the extra amount
305
+ */
306
+ public function getExtraAmount() {
307
+ return $this->extraAmount;
308
+ }
309
+
310
+ /**
311
+ * Sets the extra amount
312
+ * @param float $extraAmount
313
+ */
314
+ public function setExtraAmount($extraAmount) {
315
+ $this->extraAmount = $extraAmount;
316
+ }
317
+
318
+ /**
319
+ * @return integer the installment count
320
+ */
321
+ public function getInstallmentCount() {
322
+ return $this->installmentCount;
323
+ }
324
+
325
+ /**
326
+ * Sets the installment count
327
+ * @param integer $installmentCount
328
+ */
329
+ public function setInstallmentCount($installmentCount) {
330
+ $this->installmentCount = $installmentCount;
331
+ }
332
+
333
+ /**
334
+ * @return array Ipagare_PagSeguroDireto_Domain_Item the items/products list in this transaction
335
+ * @see Ipagare_PagSeguroDireto_Domain_Item
336
+ */
337
+ public function getItems() {
338
+ return $this->items;
339
+ }
340
+
341
+ /**
342
+ * Sets the list of items/products in this transaction
343
+ * @param array $items
344
+ * @see Ipagare_PagSeguroDireto_Domain_Item
345
+ */
346
+ public function setItems(array $items) {
347
+ $this->items = $items;
348
+ }
349
+
350
+ /**
351
+ * @return integer the items/products count in this transaction
352
+ */
353
+ public function getItemCount() {
354
+ return $this->items == null ? null : count($this->items);
355
+ }
356
+
357
+ /**
358
+ * @return Ipagare_PagSeguroDireto_Domain_Sender the sender information, who is sending money in this transaction
359
+ * @see Ipagare_PagSeguroDireto_Domain_Sender
360
+ */
361
+ public function getSender() {
362
+ return $this->sender;
363
+ }
364
+
365
+ /**
366
+ * Sets the sender information, who is sending money in this transaction
367
+ * @param Ipagare_PagSeguroDireto_Domain_Sender $sender
368
+ */
369
+ public function setSender(Ipagare_PagSeguroDireto_Domain_Sender $sender) {
370
+ $this->sender = $sender;
371
+ }
372
+
373
+ /**
374
+ * @return Ipagare_PagSeguroDireto_Domain_Shipping the shipping information
375
+ * @see Ipagare_PagSeguroDireto_Domain_Shipping
376
+ */
377
+ public function getShipping() {
378
+ return $this->shipping;
379
+ }
380
+
381
+ /**
382
+ * sets the shipping information for this transaction
383
+ * @param Ipagare_PagSeguroDireto_Domain_Shipping $shipping
384
+ */
385
+ public function setShipping(Ipagare_PagSeguroDireto_Domain_Shipping $shipping) {
386
+ $this->shipping = $shipping;
387
+ }
388
+
389
+ public function getCancellationSource() {
390
+ return $this->cancellationSource;
391
+ }
392
+
393
+ public function setCancellationSource($cancellationSource) {
394
+ $this->cancellationSource = $cancellationSource;
395
+ }
396
+
397
+ /**
398
+ * @return String a string that represents the current object
399
+ */
400
+ public function toString() {
401
+
402
+ $transaction = array();
403
+ $transaction['code'] = $this->code;
404
+ $transaction['email'] = $this->sender ? $this->sender->getEmail() : "null";
405
+ $transaction['date'] = $this->date;
406
+ $transaction['reference'] = $this->reference;
407
+ $transaction['status'] = $this->status ? $this->status->getValue() : "null";
408
+ $transaction['itemsCount'] = is_array($this->items) ? count($this->items) : "null";
409
+
410
+ $transaction = "Transaction: " . var_export($transaction, true);
411
+
412
+ return $transaction;
413
+ }
414
+
415
+ }
lib/Ipagare/PagSeguroDireto/Domain/TransactionCancellationSource.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ipagare_PagSeguroDireto_Domain_TransactionCancellationSource {
4
+
5
+ private static $sourceList = array(
6
+ 'INTERNAL' => 'PagSeguro',
7
+ 'EXTERNAL' => 'Instituições Financeiras'
8
+ );
9
+ private $value;
10
+
11
+ public function __construct($value = null) {
12
+ if ($value) {
13
+ $this->value = $value;
14
+ }
15
+ }
16
+
17
+ public function setValue($value) {
18
+ $this->value = $value;
19
+ }
20
+
21
+ public function setByType($type) {
22
+ if (isset(self::$sourceList[$type])) {
23
+ $this->value = self::$sourceList[$type];
24
+ } else {
25
+ throw new Exception("undefined index $type");
26
+ }
27
+ }
28
+
29
+ public function getValue() {
30
+ return $this->value;
31
+ }
32
+
33
+ /**
34
+ * @param string $value
35
+ * @return string the transaction type corresponding to the informed type value value
36
+ */
37
+ public function getTypeFromValue($value = null) {
38
+ $value = ($value == null ? $this->value : $value);
39
+ return array_search($value, self::$sourceList);
40
+ }
41
+
42
+ }
lib/Ipagare/PagSeguroDireto/Domain/TransactionSearchResponse.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Represents a page of transactions returned by the transaction search service
5
+ */
6
+ class Ipagare_PagSeguroDireto_Domain_TransactionSearchResponse {
7
+
8
+ /**
9
+ *
10
+ * @var Ipagare_PagSeguroDireto_Domain_Transaction
11
+ */
12
+ private $transaction;
13
+
14
+ /**
15
+ *
16
+ * @var array
17
+ */
18
+ public $errors = array();
19
+
20
+ public static function getInstance() {
21
+ return new Ipagare_PagSeguroDireto_Domain_TransactionSearchResponse();
22
+ }
23
+
24
+ public function getErrors() {
25
+ return $this->errors;
26
+ }
27
+
28
+ public function setErrors($errors) {
29
+ $this->errors = $errors;
30
+ }
31
+
32
+ public function hasErrors() {
33
+ return count($this->errors);
34
+ }
35
+
36
+ public function getTransaction() {
37
+ return $this->transaction;
38
+ }
39
+
40
+ public function setTransaction(Ipagare_PagSeguroDireto_Domain_Transaction $transaction) {
41
+ $this->transaction = $transaction;
42
+ }
43
+
44
+ }
lib/Ipagare/PagSeguroDireto/Domain/TransactionSearchResult.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represents a page of transactions returned by the transaction search service
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_TransactionSearchResult {
25
+
26
+ /**
27
+ * Date/time when this search was executed
28
+ */
29
+ private $date;
30
+
31
+ /**
32
+ * Transactions in the current page
33
+ */
34
+ private $resultsInThisPage;
35
+
36
+ /**
37
+ * Total number of pages
38
+ */
39
+ private $totalPages;
40
+
41
+ /**
42
+ * Current page.
43
+ */
44
+ private $currentPage;
45
+
46
+ /**
47
+ * Transaction summaries in this page
48
+ */
49
+ private $transactions;
50
+
51
+ /**
52
+ * @return the current page number
53
+ */
54
+ public function getCurrentPage() {
55
+ return $this->currentPage;
56
+ }
57
+
58
+ /**
59
+ * Sets the current page number
60
+ * @param integer $currentPage
61
+ */
62
+ public function setCurrentPage($currentPage) {
63
+ $this->currentPage = $currentPage;
64
+ }
65
+
66
+ /**
67
+ * @return the date/time when this search was executed
68
+ */
69
+ public function getDate() {
70
+ return $this->date;
71
+ }
72
+
73
+ /**
74
+ * Set the date/time when this search was executed
75
+ * @param date
76
+ */
77
+ public function setDate($date) {
78
+ $this->date = $date;
79
+ }
80
+
81
+ /**
82
+ * @return the number of transactions summaries in the current page
83
+ */
84
+ public function getResultsInThisPage() {
85
+ return $this->resultsInThisPage;
86
+ }
87
+
88
+ /**
89
+ * Sets the number of transaction summaries in the current page
90
+ *
91
+ * @param resultsInThisPage
92
+ */
93
+ public function setResultsInThisPage($resultsInThisPage) {
94
+ $this->resultsInThisPage = $resultsInThisPage;
95
+ }
96
+
97
+ /**
98
+ * @return the total number of pages
99
+ */
100
+ public function getTotalPages() {
101
+ return $this->totalPages;
102
+ }
103
+
104
+ /**
105
+ * Sets the total number of pages
106
+ *
107
+ * @param totalPages
108
+ */
109
+ public function setTotalPages($totalPages) {
110
+ $this->totalPages = $totalPages;
111
+ }
112
+
113
+ /**
114
+ * @return Ipagare_PagSeguroDireto_Domain_TransactionSummary the transaction summaries in this page
115
+ * @see Ipagare_PagSeguroDireto_Domain_TransactionSummary
116
+ */
117
+ public function getTransactions() {
118
+ return $this->transactions;
119
+ }
120
+
121
+ /**
122
+ * Sets the transaction summaries in this page
123
+ *
124
+ * @param array $transactions
125
+ */
126
+ public function setTransactions(array $transactions) {
127
+ $this->transactions = $transactions;
128
+ }
129
+
130
+ /**
131
+ * @return String a string that represents the current object
132
+ */
133
+ public function toString() {
134
+ $transaction = array();
135
+
136
+ $transaction['Date'] = $this->date;
137
+ $transaction['CurrentPage'] = $this->currentPage;
138
+ $transaction['TotalPages'] = $this->totalPages;
139
+ $transaction['Transactions in this page'] = $this->resultsInThisPage;
140
+
141
+ return "Ipagare_PagSeguroDireto_Domain_TransactionSearchResult: " . var_export($transaction, true);
142
+ }
143
+
144
+ }
lib/Ipagare/PagSeguroDireto/Domain/TransactionStatus.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Defines a list of known transaction statuses.
23
+ * This class is not an enum to enable the introduction of new shipping types
24
+ * without breaking this version of the library.
25
+ */
26
+ class Ipagare_PagSeguroDireto_Domain_TransactionStatus {
27
+
28
+ /**
29
+ * @var array
30
+ */
31
+ private static $statusList = array(
32
+ '1' => array('code' => 1,
33
+ 'module' => 'WAITING_PAYMENT',
34
+ 'client' => 'Aguardando pagamento',
35
+ 'message' => 'O comprador iniciou a transação, mas até o momento o PagSeguro não recebeu nenhuma informação sobre o pagamento.'),
36
+ '2' => array('code' => 2,
37
+ 'module' => 'IN_ANALYSIS',
38
+ 'client' => 'Em análise',
39
+ 'message' => 'O comprador optou por pagar com um cartão de crédito e o PagSeguro está analisando o risco da transação.'),
40
+ '3' => array('code' => 3,
41
+ 'module' => 'PAID',
42
+ 'client' => 'Paga',
43
+ 'message' => 'A transação foi paga pelo comprador e o PagSeguro já recebeu uma confirmação da instituição financeira responsável pelo processamento.'),
44
+ '4' => array('code' => 4,
45
+ 'module' => 'AVAILABLE',
46
+ 'client' => 'Disponível',
47
+ 'message' => 'A transação foi paga e chegou ao final de seu prazo de liberação sem ter sido retornada e sem que haja nenhuma disputa aberta.'),
48
+ '5' => array('code' => 5,
49
+ 'module' => 'IN_DISPUTE',
50
+ 'client' => 'Em disputa',
51
+ 'message' => 'O comprador, dentro do prazo de liberação da transação, abriu uma disputa.'),
52
+ '6' => array('code' => 6,
53
+ 'module' => 'REFUNDED',
54
+ 'client' => 'Devolvida',
55
+ 'message' => 'O valor da transação foi devolvido para o comprador.'),
56
+ '7' => array('code' => 7,
57
+ 'module' => 'CANCELED',
58
+ 'client' => 'Cancelada',
59
+ 'message' => 'A transação foi cancelada sem ter sido finalizada.'));
60
+
61
+ /**
62
+ *
63
+ * @var type
64
+ */
65
+ private $code;
66
+
67
+ /**
68
+ *
69
+ * @var type
70
+ */
71
+ private $module;
72
+ private $message;
73
+ private $clientMessage;
74
+
75
+ /**
76
+ * @param null $code
77
+ */
78
+ public function __construct($code = null) {
79
+ if ($code) {
80
+ $this->code = $code;
81
+ $a = self::$statusList[$code];
82
+ $this->module = $a['module'];
83
+ $this->message = $a['message'];
84
+ $this->clientMessage = $a['client'];
85
+ }
86
+ }
87
+
88
+ /**
89
+ * @param $code
90
+ */
91
+ public function setCode($code) {
92
+ $this->code = $code;
93
+ }
94
+
95
+ /**
96
+ * @return integer the status value.
97
+ */
98
+ public function getCode() {
99
+ return $this->code;
100
+ }
101
+
102
+ public function getTypeFromCode($code = null) {
103
+ $code = ($code == null ? $this->code : $code);
104
+ return array_search($this->code, self::$statusList);
105
+ }
106
+
107
+ /**
108
+ * Get status list
109
+ * @return array
110
+ */
111
+ public static function getStatusList() {
112
+ return self::$statusList;
113
+ }
114
+
115
+ public function getModule() {
116
+ return $this->module;
117
+ }
118
+
119
+ public function setModule($module) {
120
+ $this->module = $module;
121
+ }
122
+
123
+ public function isAguardandoPagamento() {
124
+ return (bool) ($this->code == '1');
125
+ }
126
+
127
+ public function isEmAnalise() {
128
+ return (bool) ($this->code == '2');
129
+ }
130
+
131
+ public function isPaga() {
132
+ return (bool) ($this->code == '3');
133
+ }
134
+
135
+ public function isDisponivel() {
136
+ return (bool) ($this->code == '4');
137
+ }
138
+
139
+ public function isEmDisputa() {
140
+ return (bool) ($this->code == '5');
141
+ }
142
+
143
+ public function isDevolvida() {
144
+ return (bool) ($this->code == '6');
145
+ }
146
+
147
+ public function isCancelada() {
148
+ return (bool) ($this->code == '7');
149
+ }
150
+
151
+ public function getMessage() {
152
+ return $this->message;
153
+ }
154
+
155
+ public function setMessage($message) {
156
+ $this->message = $message;
157
+ }
158
+
159
+ public function getClientMessage() {
160
+ return $this->clientMessage;
161
+ }
162
+
163
+ public function setClientMessage($clientMessage) {
164
+ $this->clientMessage = $clientMessage;
165
+ }
166
+ }
lib/Ipagare/PagSeguroDireto/Domain/TransactionSummary.php ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ ************************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ ************************************************************************
19
+ */
20
+
21
+ /**
22
+ * Represents a summary of a Ipagare_PagSeguroDireto_ transaction, typically returned by search services.
23
+ */
24
+ class Ipagare_PagSeguroDireto_Domain_TransactionSummary {
25
+
26
+ /**
27
+ * Transaction date
28
+ */
29
+ private $date;
30
+
31
+ /**
32
+ * Last event date
33
+ * Date the last notification about this transaction was sent
34
+ */
35
+ private $lastEventDate;
36
+
37
+ /**
38
+ * Transaction code
39
+ */
40
+ private $code;
41
+
42
+ /**
43
+ * Reference code
44
+ * You can use the reference code to store an identifier so you can
45
+ * associate the Ipagare_PagSeguroDireto_ transaction to a transaction in your system.
46
+ */
47
+ private $reference;
48
+
49
+ /**
50
+ * Groos amount of the transaction
51
+ */
52
+ private $grossAmount;
53
+
54
+ /**
55
+ * Transaction type
56
+ * @see Ipagare_PagSeguroDireto_Domain_TransactionType
57
+ */
58
+ private $type;
59
+
60
+ /**
61
+ * Transaction status
62
+ * @see Ipagare_PagSeguroDireto_Domain_TransactionStatus
63
+ */
64
+ private $status;
65
+
66
+ /**
67
+ * Net amount
68
+ */
69
+ private $netAmount;
70
+
71
+ /**
72
+ * Discount amount
73
+ */
74
+ private $discountAmount;
75
+
76
+ /**
77
+ * Fee amount
78
+ */
79
+ private $feeAmount;
80
+
81
+ /**
82
+ * Extra amount
83
+ */
84
+ private $extraAmount;
85
+
86
+ /**
87
+ * Payment method
88
+ * @see Ipagare_PagSeguroDireto_Domain_PaymentMethod
89
+ */
90
+ private $paymentMethod;
91
+
92
+ /**
93
+ * @return the transaction date
94
+ */
95
+ public function getDate()
96
+ {
97
+ return $this->date;
98
+ }
99
+
100
+ /**
101
+ * Sets the transaction date
102
+ * @param String $date
103
+ */
104
+ public function setDate($date)
105
+ {
106
+ $this->date = $date;
107
+ }
108
+
109
+ /**
110
+ * @return the transaction code
111
+ */
112
+ public function getCode()
113
+ {
114
+ return $this->code;
115
+ }
116
+
117
+ /**
118
+ * Sets transaction code
119
+ * @param String $code
120
+ */
121
+ public function setCode($code)
122
+ {
123
+ $this->code = $code;
124
+ }
125
+
126
+ /**
127
+ * You can use the reference code to store an identifier so you can
128
+ * associate the Ipagare_PagSeguroDireto_ transaction to a transaction in your system.
129
+ *
130
+ * @return the reference code
131
+ */
132
+ public function getReference()
133
+ {
134
+ return $this->reference;
135
+ }
136
+
137
+ /**
138
+ * Sets the reference code
139
+ *
140
+ * @param reference
141
+ */
142
+ public function setReference($reference)
143
+ {
144
+ $this->reference = $reference;
145
+ }
146
+
147
+ /**
148
+ * @return the transaction gross amount
149
+ */
150
+ public function getGrossAmount()
151
+ {
152
+ return $this->grossAmount;
153
+ }
154
+
155
+ /**
156
+ * Sets the gorss amount
157
+ * @param float $grossAmount
158
+ */
159
+ public function setGrossAmount($grossAmount)
160
+ {
161
+ $this->grossAmount = $grossAmount;
162
+ }
163
+
164
+ /**
165
+ * @return the transaction type
166
+ * @see Ipagare_PagSeguroDireto_Domain_TransactionType
167
+ */
168
+ public function getType()
169
+ {
170
+ return $this->type;
171
+ }
172
+
173
+ /**
174
+ * Sets the transaction sype
175
+ * @param Ipagare_PagSeguroDireto_Domain_TransactionType $type
176
+ */
177
+ public function setType(Ipagare_PagSeguroDireto_Domain_TransactionType $type)
178
+ {
179
+ $this->type = $type;
180
+ }
181
+
182
+ /**
183
+ * Date the last notification about this transaction was sent
184
+ * @return the last event date
185
+ */
186
+ public function getLastEventDate()
187
+ {
188
+ return $this->lastEventDate;
189
+ }
190
+
191
+ /**
192
+ * Sets the last event date
193
+ * @param String $lastEventDate
194
+ */
195
+ public function setLastEventDate($lastEventDate)
196
+ {
197
+ $this->lastEventDate = $lastEventDate;
198
+ }
199
+
200
+ /**
201
+ * @return the transaction status
202
+ * @see Ipagare_PagSeguroDireto_Domain_TransactionStatus
203
+ */
204
+ public function getStatus()
205
+ {
206
+ return $this->status;
207
+ }
208
+
209
+ /**
210
+ * Sets the transaction status
211
+ * @param Ipagare_PagSeguroDireto_Domain_TransactionStatus $status
212
+ */
213
+ public function setStatus(Ipagare_PagSeguroDireto_Domain_TransactionStatus $status)
214
+ {
215
+ $this->status = $status;
216
+ }
217
+
218
+ /**
219
+ * @return the net amount
220
+ */
221
+ public function getNetAmount()
222
+ {
223
+ return $this->netAmount;
224
+ }
225
+
226
+ /**
227
+ * Sets the net amount
228
+ * @param float $netAmount
229
+ */
230
+ public function setNetAmount($netAmount)
231
+ {
232
+ $this->netAmount = $netAmount;
233
+ }
234
+
235
+ /**
236
+ * @return the discount amount
237
+ */
238
+ public function getDiscountAmount()
239
+ {
240
+ return $this->discountAmount;
241
+ }
242
+
243
+ /**
244
+ * Sets the discount amount
245
+ * @param float $discountAmount
246
+ */
247
+ public function setDiscountAmount($discountAmount)
248
+ {
249
+ $this->discountAmount = $discountAmount;
250
+ }
251
+
252
+ /**
253
+ * @return the fee amount
254
+ */
255
+ public function getFeeAmount()
256
+ {
257
+ return $this->feeAmount;
258
+ }
259
+
260
+ /**
261
+ * Sets the fee amount
262
+ * @param float $feeAmount
263
+ */
264
+ public function setFeeAmount($feeAmount)
265
+ {
266
+ $this->feeAmount = $feeAmount;
267
+ }
268
+
269
+ /**
270
+ * @return the extra amount
271
+ */
272
+ public function getExtraAmount()
273
+ {
274
+ return $this->extraAmount;
275
+ }
276
+
277
+ /**
278
+ * Sets the extra amount
279
+ * @param float $extraAmount
280
+ */
281
+ public function setExtraAmount($extraAmount)
282
+ {
283
+ $this->extraAmount = $extraAmount;
284
+ }
285
+
286
+ /**
287
+ * Sets the payment method
288
+ * @param Ipagare_PagSeguroDireto_Domain_PaymentMethod $paymentMethod
289
+ */
290
+ public function setPaymentMethod(Ipagare_PagSeguroDireto_Domain_PaymentMethod $paymentMethod)
291
+ {
292
+ $this->paymentMethod = $paymentMethod;
293
+ }
294
+
295
+ /**
296
+ * @return the payment method
297
+ * @see Ipagare_PagSeguroDireto_Domain_PaymentMethod
298
+ */
299
+ public function getPaymentMethod()
300
+ {
301
+ return $this->paymentMethod;
302
+ }
303
+ }
lib/Ipagare/PagSeguroDireto/Domain/TransactionType.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Defines a list of known transaction types.
23
+ * This class is not an enum to enable the introduction of new shipping types
24
+ * without breaking this version of the library.
25
+ */
26
+ class Ipagare_PagSeguroDireto_Domain_TransactionType {
27
+
28
+ private static $typeList = array(
29
+ 'PAYMENT' => 1,
30
+ 'TRANSFER' => 2,
31
+ 'FUND_ADDITION' => 3,
32
+ 'WITHDRAW' => 4,
33
+ 'CHARGE' => 5,
34
+ 'DONATION' => 6,
35
+ 'BONUS' => 7,
36
+ 'BONUS_REPASS' => 8,
37
+ 'OPERATIONAL' => 9,
38
+ 'POLITICAL_DONATION' => 10
39
+ );
40
+ private $value;
41
+
42
+ public function __construct($value = null) {
43
+ if ($value) {
44
+ $this->value = $value;
45
+ }
46
+ }
47
+
48
+ public function setValue($value) {
49
+ $this->value = $value;
50
+ }
51
+
52
+ public function setByType($type) {
53
+ if (isset(self::$typeList[$type])) {
54
+ $this->value = self::$typeList[$type];
55
+ } else {
56
+ throw new Exception("undefined index $type");
57
+ }
58
+ }
59
+
60
+ public function getValue() {
61
+ return $this->value;
62
+ }
63
+
64
+ /**
65
+ * @param integer|string $value
66
+ * @return string|integer the transaction type corresponding to the informed type value value
67
+ */
68
+ public function getTypeFromValue($value = null) {
69
+ $value = ($value == null ? $this->value : $value);
70
+ return array_search($value, self::$typeList);
71
+ }
72
+
73
+ }
lib/Ipagare/PagSeguroDireto/Exception/ServiceException.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /*
22
+ * Represents a exception behavior
23
+ * */
24
+
25
+ /**
26
+ * Class Ipagare_PagSeguroDireto_Exception_ServiceException
27
+ */
28
+ class Ipagare_PagSeguroDireto_Exception_ServiceException extends Exception {
29
+
30
+ /**
31
+ * @var Ipagare_PagSeguroDireto_Domain_HttpStatus
32
+ */
33
+ private $httpStatus;
34
+
35
+ /**
36
+ * @var
37
+ */
38
+ private $httpMessage;
39
+
40
+ /**
41
+ * @var array
42
+ */
43
+ private $errors = array();
44
+
45
+ /**
46
+ * @param Ipagare_PagSeguroDireto_Domain_HttpStatus $httpStatus
47
+ * @param array $errors
48
+ */
49
+ public function __construct(Ipagare_PagSeguroDireto_Domain_HttpStatus $httpStatus, array $errors = null) {
50
+ $this->httpStatus = $httpStatus;
51
+ if ($errors) {
52
+ $this->errors = $errors;
53
+ }
54
+ $this->httpMessage = $this->getFormattedMessage();
55
+ }
56
+
57
+ /**
58
+ * @return array
59
+ */
60
+ public function getErrors() {
61
+ return $this->errors;
62
+ }
63
+
64
+ /**
65
+ * @param array $errors
66
+ */
67
+ public function setErrors(array $errors) {
68
+ $this->errors = $errors;
69
+ }
70
+
71
+ /**
72
+ * @return Ipagare_PagSeguroDireto_Domain_HttpStatus
73
+ */
74
+ public function getHttpStatus() {
75
+ return $this->httpStatus;
76
+ }
77
+
78
+ /**
79
+ * @param Ipagare_PagSeguroDireto_Domain_HttpStatus $httpStatus
80
+ */
81
+ public function setHttpStatus(Ipagare_PagSeguroDireto_Domain_HttpStatus $httpStatus) {
82
+ $this->httpStatus = $httpStatus;
83
+ }
84
+
85
+ /**
86
+ * @return string
87
+ */
88
+ private function getHttpMessage() {
89
+ switch ($this->httpStatus->getType()) {
90
+
91
+ case 'BAD_REQUEST':
92
+ $message = "BAD_REQUEST";
93
+ break;
94
+
95
+ case 'UNAUTHORIZED':
96
+ $message = "UNAUTHORIZED";
97
+ break;
98
+
99
+ case 'FORBIDDEN':
100
+ $message = "FORBIDDEN";
101
+ break;
102
+
103
+ case 'NOT_FOUND':
104
+ $message = "NOT_FOUND";
105
+ break;
106
+
107
+ case 'INTERNAL_SERVER_ERROR':
108
+ $message = "INTERNAL_SERVER_ERROR";
109
+ break;
110
+
111
+ case 'BAD_GATEWAY':
112
+ $message = "BAD_GATEWAY";
113
+ break;
114
+
115
+ default:
116
+ $message = "UNDEFINED";
117
+ break;
118
+ }
119
+ return $message;
120
+ }
121
+
122
+ /**
123
+ * @return string
124
+ */
125
+ public function getFormattedMessage() {
126
+ $message = "";
127
+ $message .= "[HTTP " . $this->httpStatus->getStatus() . "] - " . $this->getHttpMessage() . "\n";
128
+ foreach ($this->errors as $key => $value) {
129
+ if ($value instanceof Ipagare_PagSeguroDireto_Domain_Error) {
130
+ $message .= "$key [" . $value->getCode() . "] - " . $value->getMessage();
131
+ }
132
+ }
133
+ return $message;
134
+ }
135
+
136
+ /**
137
+ * @return mixed
138
+ */
139
+ public function getOneLineMessage() {
140
+ return str_replace("\n", " ", $this->getFormattedMessage());
141
+ }
142
+
143
+ }
lib/Ipagare/PagSeguroDireto/Helper/Helper.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Helper functions
23
+ */
24
+ class Ipagare_PagSeguroDireto_Helper_Helper {
25
+
26
+ /**
27
+ * @param $date
28
+ * @return bool|string
29
+ */
30
+ public static function formatDate($date)
31
+ {
32
+ $format = DateTime::ATOM;
33
+ if ($date instanceof DateTime) {
34
+ $d = $date->format($format);
35
+ } elseif (is_numeric($date)) {
36
+ $d = date($format, $date);
37
+ } else {
38
+ $d = (string) $date;
39
+ }
40
+ return $d;
41
+ }
42
+
43
+ /**
44
+ * @param $numeric
45
+ * @return string
46
+ */
47
+ public static function decimalFormat($numeric)
48
+ {
49
+ if (is_float($numeric)) {
50
+ $numeric = (float) $numeric;
51
+ $numeric = (string) number_format($numeric, 2, '.', '');
52
+ }
53
+ return $numeric;
54
+ }
55
+
56
+ /**
57
+ * @param $date
58
+ * @param $days
59
+ * @return bool|string
60
+ */
61
+ public static function subDays($date, $days)
62
+ {
63
+ $d = self::formatDate($date);
64
+ $d = date_parse($d);
65
+ $d = mktime($d['hour'], $d['minute'], $d['second'], $d['month'], $d['day'] - $days, $d['year']);
66
+ return self::formatDate($d);
67
+ }
68
+
69
+ /**
70
+ * @param $var
71
+ * @param null $dump
72
+ */
73
+ public static function printError($var, $dump = null)
74
+ {
75
+ if (is_array($var) || is_object($var)) {
76
+ echo "<pre>";
77
+ if ($dump) {
78
+ var_dump($var);
79
+ } else {
80
+ print_r($var);
81
+ }
82
+ echo "</pre>";
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Remove left, right and inside extra spaces in string
88
+ * @param string $string
89
+ * @return string
90
+ */
91
+ public static function removeStringExtraSpaces($string)
92
+ {
93
+ return trim(preg_replace("/( +)/", " ", $string));
94
+ }
95
+
96
+ /**
97
+ * Perform truncate of string value
98
+ * @param string $string
99
+ * @param int $limit
100
+ * @param mixed $endchars
101
+ * @return string
102
+ */
103
+ public static function truncateValue($string, $limit, $endchars = '...')
104
+ {
105
+
106
+ if (!is_array($string) && !is_object($string)) {
107
+
108
+ $stringLength = strlen($string);
109
+ $endcharsLength = strlen($endchars);
110
+
111
+ if ($stringLength > (int) $limit) {
112
+ $cut = (int) ($limit - $endcharsLength);
113
+ $string = substr($string, 0, $cut) . $endchars;
114
+ }
115
+ }
116
+ return $string;
117
+ }
118
+
119
+ /**
120
+ * Return formatted string to send in Ipagare_PagSeguroDireto_ request
121
+ * @param string $string
122
+ * @param int $limit
123
+ * @param mixed $endchars
124
+ * @return string
125
+ */
126
+ public static function formatString($string, $limit, $endchars = '...')
127
+ {
128
+ $string = Ipagare_PagSeguroDireto_Helper_Helper::removeStringExtraSpaces($string);
129
+ return Ipagare_PagSeguroDireto_Helper_Helper::truncateValue($string, $limit, $endchars);
130
+ }
131
+
132
+ /**
133
+ * Check if var is empty
134
+ * @param string $value
135
+ * @return boolean
136
+ */
137
+ public static function isEmpty($value)
138
+ {
139
+ return (!isset($value) || trim($value) == "");
140
+ }
141
+
142
+ /**
143
+ * Check if notification post is empty
144
+ * @param array $notification_data
145
+ * @return boolean
146
+ */
147
+ public static function isNotificationEmpty(array $notification_data)
148
+ {
149
+ $isEmpty = true;
150
+
151
+ if (isset($notification_data['notificationCode']) && isset($notification_data['notificationType'])) {
152
+ $isEmpty = (Ipagare_PagSeguroDireto_Helper_Helper::isEmpty($notification_data['notificationCode']) ||
153
+ Ipagare_PagSeguroDireto_Helper_Helper::isEmpty($notification_data['notificationType'])
154
+ );
155
+ }
156
+
157
+ return $isEmpty;
158
+ }
159
+
160
+ /**
161
+ * Remove all non digit character from string
162
+ * @param string $value
163
+ * @return string
164
+ */
165
+ public static function getOnlyNumbers($value)
166
+ {
167
+ return preg_replace('/\D/', '', $value);
168
+ }
169
+ }
lib/Ipagare/PagSeguroDireto/Library.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ class Ipagare_PagSeguroDireto_Library {
22
+
23
+ const VERSION = '1.1.3';
24
+
25
+ public static $resources;
26
+ public static $config;
27
+ private static $path;
28
+ private static $library;
29
+ private static $php_version;
30
+
31
+ private function __construct() {
32
+ self::$path = (dirname(__FILE__));
33
+ //Ipagare_PagSeguroDireto_Loader_Autoloader::init();
34
+ self::$resources = Ipagare_PagSeguroDireto_Resources_Resources::init();
35
+ self::$config = Ipagare_PagSeguroDireto_Config_Config::init();
36
+ }
37
+
38
+ public static function init() {
39
+ //require_once "Loader" . DIRECTORY_SEPARATOR . "Ipagare/AutoLoader.php";
40
+ self::verifyDependencies();
41
+ if (self::$library == null) {
42
+ self::$library = new Ipagare_PagSeguroDireto_Library();
43
+ }
44
+ return self::$library;
45
+ }
46
+
47
+ private static function verifyDependencies() {
48
+ $dependencies = true;
49
+
50
+ try {
51
+ if (!function_exists('spl_autoload_register')) {
52
+ $dependencies = false;
53
+ throw new Exception("Ipagare_PagSeguroDireto_Library: Standard PHP Library (SPL) is required.");
54
+ }
55
+
56
+ if (!function_exists('curl_init')) {
57
+ $dependencies = false;
58
+ throw new Exception('Ipagare_PagSeguroDireto_Library: cURL library is required.');
59
+ }
60
+
61
+ if (!class_exists('DOMDocument')) {
62
+ $dependencies = false;
63
+ throw new Exception('Ipagare_PagSeguroDireto_Library: DOM XML extension is required.');
64
+ }
65
+ } catch (Exception $e) {
66
+ return $dependencies;
67
+ }
68
+
69
+ return $dependencies;
70
+ }
71
+
72
+ final public static function getVersion() {
73
+ return self::VERSION;
74
+ }
75
+
76
+ final public static function getPath() {
77
+ return self::$path;
78
+ }
79
+
80
+ final public static function getModuleVersion() {
81
+ return 'ipagare:1.1.3';
82
+ }
83
+
84
+ final public static function getPHPVersion() {
85
+ return self::$php_version = phpversion();
86
+ }
87
+
88
+ final public static function setPHPVersion($version) {
89
+ self::$php_version = $version;
90
+ }
91
+
92
+ final public static function getCMSVersion() {
93
+ return 'magento:' . Mage::getVersion();
94
+ }
95
+
96
+ }
97
+
98
+ Ipagare_PagSeguroDireto_Library::init();
lib/Ipagare/PagSeguroDireto/Loader/AutoLoader.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /*
22
+ * Library autoloader - spl_autoload_register
23
+ */
24
+
25
+ class Ipagare_PagSeguroDireto_Loader_Autoloader {
26
+
27
+ public static $loader;
28
+ private static $dirs = array(
29
+ 'config',
30
+ 'resources',
31
+ 'domain',
32
+ 'exception',
33
+ 'parser',
34
+ 'service',
35
+ 'utils',
36
+ 'helper'
37
+ );
38
+
39
+ private function __construct() {
40
+ if (function_exists('__autoload')) {
41
+ spl_autoload_register('__autoload');
42
+ }
43
+ spl_autoload_register(array($this, 'addClass'));
44
+ }
45
+
46
+ public static function init() {
47
+ if (!function_exists('spl_autoload_register')) {
48
+ throw new Exception("Ipagare_PagSeguroDireto_Library: Standard PHP Library (SPL) is required.");
49
+ }
50
+ if (self::$loader == null) {
51
+ self::$loader = new Ipagare_PagSeguroDireto_Loader_Autoloader();
52
+ }
53
+ return self::$loader;
54
+ }
55
+
56
+ private function addClass($class) {
57
+ foreach (self::$dirs as $key => $dir) {
58
+ $file = Ipagare_PagSeguroDireto_Library::getPath() . DIRECTORY_SEPARATOR .
59
+ $dir . DIRECTORY_SEPARATOR . $class . '.class.php';
60
+ if (file_exists($file) && is_file($file)) {
61
+ require_once $file;
62
+ }
63
+ }
64
+ }
65
+
66
+ }
lib/Ipagare/PagSeguroDireto/Parser/PaymentParser.php ADDED
@@ -0,0 +1,287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Class Ipagare_PagSeguroDireto_Parser_PaymentParser
23
+ */
24
+ class Ipagare_PagSeguroDireto_Parser_PaymentParser extends Ipagare_PagSeguroDireto_Parser_ServiceParser {
25
+
26
+ /**
27
+ * @param $payment Ipagare_PagSeguroDireto_Domain_PaymentRequest
28
+ * @return mixed
29
+ */
30
+ public static function getData(Ipagare_PagSeguroDireto_Domain_PaymentRequest $payment) {
31
+ $data = null;
32
+
33
+ // reference
34
+ if ($payment->getReference() != null) {
35
+ $data["reference"] = $payment->getReference();
36
+ }
37
+
38
+ // paymentMode
39
+ if ($payment->getPaymentMode() != null) {
40
+ $data["paymentMode"] = $payment->getPaymentMode();
41
+ }
42
+
43
+ // paymentMethod
44
+ if ($payment->getPaymentMethod() != null) {
45
+ $data["paymentMethod"] = $payment->getPaymentMethod();
46
+ }
47
+
48
+ // receiverEmail
49
+ if ($payment->getReceiverEmail() != null) {
50
+ $data["receiverEmail"] = $payment->getReceiverEmail();
51
+ }
52
+
53
+ // currency
54
+ if ($payment->getCurrency() != null) {
55
+ $data['currency'] = $payment->getCurrency();
56
+ }
57
+
58
+ // creditCardToken
59
+ if ($payment->getCreditCardToken() != null) {
60
+ $data["creditCardToken"] = $payment->getCreditCardToken();
61
+ }
62
+
63
+ // installment
64
+ if ($payment->getInstallment() != null) {
65
+ if ($payment->getInstallment()->getQuantity() != null) {
66
+ $data["installmentQuantity"] = $payment->getInstallment()->getQuantity();
67
+ }
68
+
69
+ if ($payment->getInstallment()->getValue() != null) {
70
+ $data["installmentValue"] = $payment->getInstallment()->getValue();
71
+ }
72
+ }
73
+
74
+ // bank
75
+ $bank = $payment->getBank();
76
+ if ($bank != null) {
77
+ if ($bank->getName() != null) {
78
+ $data['bankName'] = $bank->getName();
79
+ }
80
+ }
81
+
82
+ // creditCardHolder
83
+ $creditCardHolder = $payment->getCreditCardHolder();
84
+ if ($creditCardHolder != null) {
85
+ if ($creditCardHolder->getName() != null) {
86
+ $data['creditCardHolderName'] = $creditCardHolder->getName();
87
+ }
88
+ if ($creditCardHolder->getCpf() != null) {
89
+ $data['creditCardHolderCPF'] = $creditCardHolder->getCpf();
90
+ }
91
+ if ($creditCardHolder->getBirthDate() != null) {
92
+ $data['creditCardHolderBirthDate'] = $creditCardHolder->getBirthDate();
93
+ }
94
+ if ($creditCardHolder->getAreaCode() != null) {
95
+ $data['creditCardHolderAreaCode'] = $creditCardHolder->getAreaCode();
96
+ }
97
+ if ($creditCardHolder->getPhone() != null) {
98
+ $data['creditCardHolderPhone'] = $creditCardHolder->getPhone();
99
+ }
100
+ }
101
+
102
+ // sender
103
+ if ($payment->getSender() != null) {
104
+ if ($payment->getSender()->getName() != null) {
105
+ $data['senderName'] = $payment->getSender()->getName();
106
+ }
107
+ if ($payment->getSender()->getEmail() != null) {
108
+ $data['senderEmail'] = $payment->getSender()->getEmail();
109
+ }
110
+ // senderHash
111
+ if ($payment->getSender()->getHash() != null) {
112
+ $data['senderHash'] = $payment->getSender()->getHash();
113
+ }
114
+
115
+ // phone
116
+ if ($payment->getSender()->getPhone() != null) {
117
+ if ($payment->getSender()->getPhone()->getAreaCode() != null) {
118
+ $data['senderAreaCode'] = $payment->getSender()->getPhone()->getAreaCode();
119
+ }
120
+ if ($payment->getSender()->getPhone()->getNumber() != null) {
121
+ $data['senderPhone'] = $payment->getSender()->getPhone()->getNumber();
122
+ }
123
+ }
124
+
125
+ // documents
126
+ /** @var $document Ipagare_PagSeguroDireto_Domain_Document */
127
+ if ($payment->getSender()->getDocuments() != null) {
128
+ $documents = $payment->getSender()->getDocuments();
129
+ if (is_array($documents) && count($documents) == 1) {
130
+ foreach ($documents as $document) {
131
+ if (!is_null($document)) {
132
+
133
+ if ($document->getType() == 'CNPJ') {
134
+ $data['senderCNPJ'] = $document->getValue();
135
+ } else {
136
+ $data['senderCPF'] = $document->getValue();
137
+ }
138
+ }
139
+ }
140
+ }
141
+ }
142
+ }
143
+
144
+ // items
145
+ $items = $payment->getItems();
146
+ if (count($items) > 0) {
147
+ $i = 0;
148
+
149
+ foreach ($items as $key => $value) {
150
+ $i++;
151
+ if ($items[$key]->getId() != null) {
152
+ $data["itemId$i"] = $items[$key]->getId();
153
+ }
154
+ if ($items[$key]->getDescription() != null) {
155
+ $data["itemDescription$i"] = $items[$key]->getDescription();
156
+ }
157
+ if ($items[$key]->getQuantity() != null) {
158
+ $data["itemQuantity$i"] = $items[$key]->getQuantity();
159
+ }
160
+ if ($items[$key]->getAmount() != null) {
161
+ $amount = Ipagare_PagSeguroDireto_Helper_Helper::decimalFormat($items[$key]->getAmount());
162
+ $data["itemAmount$i"] = $amount;
163
+ }
164
+ if ($items[$key]->getWeight() != null) {
165
+ $data["itemWeight$i"] = $items[$key]->getWeight();
166
+ }
167
+ if ($items[$key]->getShippingCost() != null) {
168
+ $data["itemShippingCost$i"] = Ipagare_PagSeguroDireto_Helper_Helper::decimalFormat($items[$key]->getShippingCost());
169
+ }
170
+ }
171
+ }
172
+
173
+ // extraAmount
174
+ if ($payment->getExtraAmount() != null) {
175
+ $data['extraAmount'] = Ipagare_PagSeguroDireto_Helper_Helper::decimalFormat($payment->getExtraAmount());
176
+ }
177
+
178
+ // shipping
179
+ if ($payment->getShipping() != null) {
180
+ if ($payment->getShipping()->getType() != null && $payment->getShipping()->getType()->getValue() != null) {
181
+ $data['shippingType'] = $payment->getShipping()->getType()->getValue();
182
+ }
183
+
184
+ if ($payment->getShipping()->getCost() != null && $payment->getShipping()->getCost() != null) {
185
+ $data['shippingCost'] = $payment->getShipping()->getCost();
186
+ }
187
+
188
+ // shipping address
189
+ $shippingAddress = $payment->getShipping()->getAddress();
190
+ if ($shippingAddress != null) {
191
+ if ($shippingAddress->getStreet() != null) {
192
+ $data['shippingAddressStreet'] = $shippingAddress->getStreet();
193
+ }
194
+ if ($shippingAddress->getNumber() != null) {
195
+ $data['shippingAddressNumber'] = $shippingAddress->getNumber();
196
+ }
197
+ if ($shippingAddress->getComplement() != null) {
198
+ $data['shippingAddressComplement'] = $shippingAddress->getComplement();
199
+ }
200
+ if ($shippingAddress->getCity() != null) {
201
+ $data['shippingAddressCity'] = $shippingAddress->getCity();
202
+ }
203
+ if ($shippingAddress->getState() != null) {
204
+ $data['shippingAddressState'] = $shippingAddress->getState();
205
+ }
206
+ if ($shippingAddress->getDistrict() != null) {
207
+ $data['shippingAddressDistrict'] = $shippingAddress->getDistrict();
208
+ }
209
+ if ($shippingAddress->getPostalCode() != null) {
210
+ $data['shippingAddressPostalCode'] = $shippingAddress->getPostalCode();
211
+ }
212
+ if ($shippingAddress->getCountry() != null) {
213
+ $data['shippingAddressCountry'] = $shippingAddress->getCountry();
214
+ }
215
+ }
216
+
217
+ // billing address
218
+ $billingAddress = $payment->getBilling()->getAddress();
219
+ if ($billingAddress != null) {
220
+ if ($billingAddress->getStreet() != null) {
221
+ $data['billingAddressStreet'] = $billingAddress->getStreet();
222
+ }
223
+ if ($billingAddress->getNumber() != null) {
224
+ $data['billingAddressNumber'] = $billingAddress->getNumber();
225
+ }
226
+ if ($billingAddress->getComplement() != null) {
227
+ $data['billingAddressComplement'] = $billingAddress->getComplement();
228
+ }
229
+ if ($billingAddress->getCity() != null) {
230
+ $data['billingAddressCity'] = $billingAddress->getCity();
231
+ }
232
+ if ($billingAddress->getState() != null) {
233
+ $data['billingAddressState'] = $billingAddress->getState();
234
+ }
235
+ if ($billingAddress->getDistrict() != null) {
236
+ $data['billingAddressDistrict'] = $billingAddress->getDistrict();
237
+ }
238
+ if ($billingAddress->getPostalCode() != null) {
239
+ $data['billingAddressPostalCode'] = $billingAddress->getPostalCode();
240
+ }
241
+ if ($billingAddress->getCountry() != null) {
242
+ $data['billingAddressCountry'] = $billingAddress->getCountry();
243
+ }
244
+ }
245
+ }
246
+
247
+ // redirectURL
248
+ if ($payment->getRedirectURL() != null) {
249
+ $data['redirectURL'] = $payment->getRedirectURL();
250
+ }
251
+
252
+ // notificationURL
253
+ if ($payment->getNotificationURL() != null) {
254
+ $data['notificationURL'] = $payment->getNotificationURL();
255
+ }
256
+
257
+ // parameter
258
+ if (count($payment->getParameter()->getItems()) > 0) {
259
+ foreach ($payment->getParameter()->getItems() as $item) {
260
+ if ($item instanceof Ipagare_PagSeguroDireto_Domain_ParameterItem) {
261
+ if (!Ipagare_PagSeguroDireto_Helper_Helper::isEmpty($item->getKey()) && !Ipagare_PagSeguroDireto_Helper_Helper::isEmpty($item->getValue())) {
262
+ if (!Ipagare_PagSeguroDireto_Helper_Helper::isEmpty($item->getGroup())) {
263
+ $data[$item->getKey() . '' . $item->getGroup()] = $item->getValue();
264
+ } else {
265
+ $data[$item->getKey()] = $item->getValue();
266
+ }
267
+ }
268
+ }
269
+ }
270
+ }
271
+
272
+ return $data;
273
+ }
274
+
275
+ /**
276
+ * @param $str_xml
277
+ * @return Ipagare_PagSeguroDireto_Parser_PaymentParserData
278
+ */
279
+ public static function readSuccessXml($str_xml) {
280
+ $parser = new Ipagare_PagSeguroDireto_Utils_XmlParser($str_xml);
281
+ $paymentData = Ipagare_PagSeguroDireto_Parser_PaymentParserData::getInstance($parser->getResult('transaction'));
282
+ $paymentData->setXmlReturn($str_xml);
283
+
284
+ return $paymentData;
285
+ }
286
+
287
+ }
lib/Ipagare/PagSeguroDireto/Parser/PaymentParserData.php ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Class Ipagare_PagSeguroDireto_Parser_PaymentParserData
23
+ */
24
+ class Ipagare_PagSeguroDireto_Parser_PaymentParserData {
25
+
26
+ /**
27
+ *
28
+ * @var string
29
+ */
30
+ public $date;
31
+
32
+ /**
33
+ *
34
+ * @var string
35
+ */
36
+ public $lastEventDate;
37
+
38
+ /**
39
+ *
40
+ * @var string
41
+ */
42
+ public $code;
43
+
44
+ /**
45
+ *
46
+ * @var string
47
+ */
48
+ private $reference;
49
+
50
+ /**
51
+ *
52
+ * @var Ipagare_PagSeguroDireto_Domain_TransactionType
53
+ */
54
+ private $type;
55
+
56
+ /**
57
+ *
58
+ * @var Ipagare_PagSeguroDireto_Domain_TransactionStatus
59
+ */
60
+ private $status;
61
+
62
+ /**
63
+ *
64
+ * @var Ipagare_PagSeguroDireto_Domain_TransactionCancellationSource
65
+ */
66
+ private $cancellationSource;
67
+
68
+ /**
69
+ *
70
+ * @var Ipagare_PagSeguroDireto_Domain_PaymentMethod
71
+ */
72
+ private $paymentMethod;
73
+
74
+ /**
75
+ *
76
+ * @var string
77
+ */
78
+ private $paymentLink;
79
+
80
+ /**
81
+ *
82
+ * @var float
83
+ */
84
+ private $grossAmount;
85
+
86
+ /**
87
+ *
88
+ * @var float
89
+ */
90
+ private $discountAmount;
91
+
92
+ /**
93
+ *
94
+ * @var float
95
+ */
96
+ private $feeAmount;
97
+
98
+ /**
99
+ *
100
+ * @var float
101
+ */
102
+ private $netAmount;
103
+
104
+ /**
105
+ *
106
+ * @var float
107
+ */
108
+ private $extraAmount;
109
+
110
+ /**
111
+ *
112
+ * @var string
113
+ */
114
+ private $escrowEndDate;
115
+
116
+ /**
117
+ *
118
+ * @var int
119
+ */
120
+ private $installmentCount;
121
+
122
+ /**
123
+ *
124
+ * @var string
125
+ */
126
+ private $xmlReturn;
127
+
128
+ /**
129
+ *
130
+ * @param array $data
131
+ */
132
+ public static function getInstance($data) {
133
+ $payment = new Ipagare_PagSeguroDireto_Parser_PaymentParserData();
134
+ $payment->setDate($data['date']);
135
+ $payment->setLastEventDate($data['lastEventDate']);
136
+ $payment->setCode($data['code']);
137
+ $payment->setReference($data['reference']);
138
+ $payment->setType(new Ipagare_PagSeguroDireto_Domain_TransactionType($data['type']));
139
+ $payment->setStatus(new Ipagare_PagSeguroDireto_Domain_TransactionStatus($data['status']));
140
+
141
+ // payment method
142
+ $type = $data['paymentMethod']['type'];
143
+ $code = $data['paymentMethod']['code'];
144
+ $paymentMethod = new Ipagare_PagSeguroDireto_Domain_PaymentMethod($type, $code);
145
+ $payment->setPaymentMethod($paymentMethod);
146
+
147
+ if (isset($data['paymentLink'])) {
148
+ $payment->setPaymentLink($data['paymentLink']);
149
+ }
150
+ $payment->setGrossAmount($data['grossAmount']);
151
+ $payment->setDiscountAmount($data['discountAmount']);
152
+ $payment->setFeeAmount($data['feeAmount']);
153
+ $payment->setNetAmount($data['netAmount']);
154
+ $payment->setExtraAmount($data['extraAmount']);
155
+ $payment->setInstallmentCount($data['installmentCount']);
156
+
157
+ // cancellationSource
158
+ if (isset($data['cancellationSource'])) {
159
+ $payment->setCancellationSource($data['cancellationSource']);
160
+ }
161
+
162
+ return $payment;
163
+ }
164
+
165
+ public function getDate() {
166
+ return $this->date;
167
+ }
168
+
169
+ public function getLastEventDate() {
170
+ return $this->lastEventDate;
171
+ }
172
+
173
+ public function getCode() {
174
+ return $this->code;
175
+ }
176
+
177
+ public function getReference() {
178
+ return $this->reference;
179
+ }
180
+
181
+ public function getType() {
182
+ return $this->type;
183
+ }
184
+
185
+ public function getStatus() {
186
+ return $this->status;
187
+ }
188
+
189
+ public function getCancellationSource() {
190
+ return $this->cancellationSource;
191
+ }
192
+
193
+ public function getPaymentMethod() {
194
+ return $this->paymentMethod;
195
+ }
196
+
197
+ public function getPaymentLink() {
198
+ return $this->paymentLink;
199
+ }
200
+
201
+ public function getGrossAmount() {
202
+ return $this->grossAmount;
203
+ }
204
+
205
+ public function getDiscountAmount() {
206
+ return $this->discountAmount;
207
+ }
208
+
209
+ public function getFeeAmount() {
210
+ return $this->feeAmount;
211
+ }
212
+
213
+ public function getNetAmount() {
214
+ return $this->netAmount;
215
+ }
216
+
217
+ public function getExtraAmount() {
218
+ return $this->extraAmount;
219
+ }
220
+
221
+ public function getEscrowEndDate() {
222
+ return $this->escrowEndDate;
223
+ }
224
+
225
+ public function getInstallmentCount() {
226
+ return $this->installmentCount;
227
+ }
228
+
229
+ public function setDate($date) {
230
+ $this->date = $date;
231
+ }
232
+
233
+ public function setLastEventDate($lastEventDate) {
234
+ $this->lastEventDate = $lastEventDate;
235
+ }
236
+
237
+ public function setCode($code) {
238
+ $this->code = $code;
239
+ }
240
+
241
+ public function setReference($reference) {
242
+ $this->reference = $reference;
243
+ }
244
+
245
+ public function setType(Ipagare_PagSeguroDireto_Domain_TransactionType $type) {
246
+ $this->type = $type;
247
+ }
248
+
249
+ public function setStatus(Ipagare_PagSeguroDireto_Domain_TransactionStatus $status) {
250
+ $this->status = $status;
251
+ }
252
+
253
+ public function setCancellationSource(Ipagare_PagSeguroDireto_Domain_TransactionCancellationSource $cancellationSource) {
254
+ $this->cancellationSource = $cancellationSource;
255
+ }
256
+
257
+ public function setPaymentMethod(Ipagare_PagSeguroDireto_Domain_PaymentMethod $paymentMethod) {
258
+ $this->paymentMethod = $paymentMethod;
259
+ }
260
+
261
+ public function setPaymentLink($paymentLink) {
262
+ $this->paymentLink = $paymentLink;
263
+ }
264
+
265
+ public function setGrossAmount($grossAmount) {
266
+ $this->grossAmount = $grossAmount;
267
+ }
268
+
269
+ public function setDiscountAmount($discountAmount) {
270
+ $this->discountAmount = $discountAmount;
271
+ }
272
+
273
+ public function setFeeAmount($feeAmount) {
274
+ $this->feeAmount = $feeAmount;
275
+ }
276
+
277
+ public function setNetAmount($netAmount) {
278
+ $this->netAmount = $netAmount;
279
+ }
280
+
281
+ public function setExtraAmount($extraAmount) {
282
+ $this->extraAmount = $extraAmount;
283
+ }
284
+
285
+ public function setEscrowEndDate($escrowEndDate) {
286
+ $this->escrowEndDate = $escrowEndDate;
287
+ }
288
+
289
+ public function setInstallmentCount($installmentCount) {
290
+ $this->installmentCount = $installmentCount;
291
+ }
292
+
293
+ public function getXmlReturn() {
294
+ return $this->xmlReturn;
295
+ }
296
+
297
+ public function setXmlReturn($xmlReturn) {
298
+ $this->xmlReturn = $xmlReturn;
299
+ }
300
+
301
+ public function isSuccess() {
302
+ if (!is_null($this->code)) {
303
+ return true;
304
+ }
305
+ }
306
+
307
+ }
lib/Ipagare/PagSeguroDireto/Parser/ServiceParser.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Class Ipagare_PagSeguroDireto_Parser_ServiceParser
23
+ */
24
+ class Ipagare_PagSeguroDireto_Parser_ServiceParser {
25
+
26
+ /**
27
+ * @param $str_xml
28
+ * @return array
29
+ */
30
+ public static function readErrors($str_xml) {
31
+ $parser = new Ipagare_PagSeguroDireto_Utils_XmlParser($str_xml);
32
+ $data = $parser->getResult('errors');
33
+
34
+ $errors = array();
35
+ if (isset($data['error']) && is_array($data['error'])) {
36
+ if (isset($data['error']['code']) && isset($data['error']['message'])) {
37
+ array_push($errors, new Ipagare_IpgPagSeguroDireto_ErrorMessages($data['error']['code']));
38
+ } else {
39
+ foreach ($data['error'] as $key => $value) {
40
+ if (isset($value['code']) && isset($value['message'])) {
41
+ array_push($errors, new Ipagare_IpgPagSeguroDireto_ErrorMessages($value['code']));
42
+ }
43
+ }
44
+ }
45
+ }
46
+ return $errors;
47
+ }
48
+
49
+ }
lib/Ipagare/PagSeguroDireto/Parser/SessionParser.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Ipagare_PagSeguroDireto_Parser_SessionParser
5
+ */
6
+ class Ipagare_PagSeguroDireto_Parser_SessionParser extends Ipagare_PagSeguroDireto_Parser_ServiceParser {
7
+
8
+ /**
9
+ * @param $str_xml
10
+ * @return Ipagare_PagSeguroDireto_Domain_Session
11
+ */
12
+ public static function readXml($str_xml) {
13
+ $parser = new Ipagare_PagSeguroDireto_Utils_XmlParser($str_xml);
14
+ $data = $parser->getResult('session');
15
+
16
+ return new Ipagare_PagSeguroDireto_Domain_Session($data['id']);
17
+ }
18
+
19
+ }
lib/Ipagare/PagSeguroDireto/Parser/TransactionParser.php ADDED
@@ -0,0 +1,378 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Ipagare_PagSeguroDireto_Parser_TransactionParser
5
+ */
6
+ class Ipagare_PagSeguroDireto_Parser_TransactionParser extends Ipagare_PagSeguroDireto_Parser_ServiceParser {
7
+
8
+ /**
9
+ * @param $str_xml
10
+ * @return Ipagare_PagSeguroDireto_Domain_TransactionSearchResult
11
+ */
12
+ public static function readSearchResult($str_xml) {
13
+
14
+ $parser = new Ipagare_PagSeguroDireto_Utils_XmlParser($str_xml);
15
+ $data = $parser->getResult('transactionSearchResult');
16
+
17
+ $searchResutlt = new Ipagare_PagSeguroDireto_Domain_TransactionSearchResult();
18
+
19
+ if (isset($data['totalPages'])) {
20
+ $searchResutlt->setTotalPages($data['totalPages']);
21
+ }
22
+
23
+ if (isset($data['date'])) {
24
+ $searchResutlt->setDate($data['date']);
25
+ }
26
+
27
+ if (isset($data['resultsInThisPage'])) {
28
+ $searchResutlt->setResultsInThisPage($data['resultsInThisPage']);
29
+ }
30
+
31
+ if (isset($data['currentPage'])) {
32
+ $searchResutlt->setCurrentPage($data['currentPage']);
33
+ }
34
+
35
+ if (isset($data['transactions']) && is_array($data['transactions'])) {
36
+ $transactions = array();
37
+ if (isset($data['transactions']['transaction'][0])) {
38
+ $i = 0;
39
+ foreach ($data['transactions']['transaction'] as $key => $value) {
40
+ $transactions[$i++] = self::parseTransactionSummary($value);
41
+ }
42
+ } else {
43
+ $transactions[0] = self::parseTransactionSummary($data['transactions']['transaction']);
44
+ }
45
+ $searchResutlt->setTransactions($transactions);
46
+ }
47
+
48
+ return $searchResutlt;
49
+ }
50
+
51
+ /**
52
+ * @param $str_xml
53
+ * @return Ipagare_PagSeguroDireto_Domain_Transaction
54
+ */
55
+ public static function readTransaction($str_xml) {
56
+ // Parser
57
+ $parser = new Ipagare_PagSeguroDireto_Utils_XmlParser($str_xml);
58
+
59
+ // <transaction>
60
+ $data = $parser->getResult('transaction');
61
+
62
+ $transaction = new Ipagare_PagSeguroDireto_Domain_Transaction();
63
+
64
+ // <transaction> <lastEventDate>
65
+ if (isset($data["lastEventDate"])) {
66
+ $transaction->setLastEventDate($data["lastEventDate"]);
67
+ }
68
+
69
+ // <transaction> <date>
70
+ if (isset($data["date"])) {
71
+ $transaction->setDate($data["date"]);
72
+ }
73
+
74
+ // <transaction> <code>
75
+ if (isset($data["code"])) {
76
+ $transaction->setCode($data["code"]);
77
+ }
78
+
79
+ // <transaction> <reference>
80
+ if (isset($data["reference"])) {
81
+ $transaction->setReference($data["reference"]);
82
+ }
83
+
84
+ // <transaction> <type>
85
+ if (isset($data["type"])) {
86
+ $transaction->setType(new Ipagare_PagSeguroDireto_Domain_TransactionType($data["type"]));
87
+ }
88
+
89
+ // <transaction> <status>
90
+ if (isset($data["status"])) {
91
+ $transaction->setStatus(new Ipagare_PagSeguroDireto_Domain_TransactionStatus($data["status"]));
92
+ }
93
+
94
+ // <transaction> <cancellationSource>
95
+ if (isset($data["cancellationSource"])) {
96
+ $transaction->setCancellationSource($data["cancellationSource"]);
97
+ }
98
+
99
+ if (isset($data["paymentMethod"]) && is_array($data["paymentMethod"])) {
100
+
101
+ // <transaction> <paymentMethod>
102
+ $paymentMethod = new Ipagare_PagSeguroDireto_Domain_PaymentMethod();
103
+
104
+ // <transaction> <paymentMethod> <type>
105
+ if (isset($data["paymentMethod"]['type'])) {
106
+ $paymentMethod->setType(new Ipagare_PagSeguroDireto_Domain_PaymentMethodType($data["paymentMethod"]['type']));
107
+ }
108
+
109
+ // <transaction> <paymentMethod> <code>
110
+ if (isset($data["paymentMethod"]['code'])) {
111
+ $paymentMethod->setCode(new Ipagare_PagSeguroDireto_Domain_PaymentMethodCode($data["paymentMethod"]['code']));
112
+ }
113
+
114
+ $transaction->setPaymentMethod($paymentMethod);
115
+ }
116
+
117
+ // <transaction> <grossAmount>
118
+ if (isset($data["grossAmount"])) {
119
+ $transaction->setGrossAmount($data["grossAmount"]);
120
+ }
121
+
122
+ // <transaction> <discountAmount>
123
+ if (isset($data["discountAmount"])) {
124
+ $transaction->setDiscountAmount($data["discountAmount"]);
125
+ }
126
+
127
+ // <transaction> <feeAmount>
128
+ if (isset($data["feeAmount"])) {
129
+ $transaction->setFeeAmount($data["feeAmount"]);
130
+ }
131
+
132
+ // <transaction> <netAmount>
133
+ if (isset($data["netAmount"])) {
134
+ $transaction->setNetAmount($data["netAmount"]);
135
+ }
136
+
137
+ // <transaction> <extraAmount>
138
+ if (isset($data["extraAmount"])) {
139
+ $transaction->setExtraAmount($data["extraAmount"]);
140
+ }
141
+
142
+ // <transaction> <installmentCount>
143
+ if (isset($data["installmentCount"])) {
144
+ $transaction->setInstallmentCount($data["installmentCount"]);
145
+ }
146
+
147
+ if (isset($data["items"]['item']) && is_array($data["items"]['item'])) {
148
+
149
+ $items = array();
150
+ $i = 0;
151
+
152
+ if (isset($data["items"]['item'][0])) {
153
+ foreach ($data["items"]['item'] as $key => $value) {
154
+ $item = self::parseTransactionItem($value);
155
+ $items[$i] = $item;
156
+ $i++;
157
+ }
158
+ } else {
159
+ $items[0] = self::parseTransactionItem($data["items"]['item']);
160
+ }
161
+
162
+ // <transaction> <items>
163
+ $transaction->setItems($items);
164
+ }
165
+
166
+ if (isset($data["sender"])) {
167
+
168
+ // <transaction> <sender>
169
+ $sender = new Ipagare_PagSeguroDireto_Domain_Sender();
170
+
171
+ // <transaction> <sender> <name>
172
+ if (isset($data["sender"]["name"])) {
173
+ $sender->setName($data["sender"]["name"]);
174
+ }
175
+
176
+ // <transaction> <sender> <email>
177
+ if (isset($data["sender"]["email"])) {
178
+ $sender->setEmail($data["sender"]["email"]);
179
+ }
180
+
181
+ if (isset($data["sender"]["phone"])) {
182
+
183
+ // <transaction> <sender> <phone>
184
+ $phone = new Ipagare_PagSeguroDireto_Domain_Phone();
185
+
186
+ // <transaction> <sender> <phone> <areaCode>
187
+ if (isset($data["sender"]["phone"]["areaCode"])) {
188
+ $phone->setAreaCode($data["sender"]["phone"]["areaCode"]);
189
+ }
190
+
191
+ // <transaction> <sender> <phone> <number>
192
+ if (isset($data["sender"]["phone"]["number"])) {
193
+ $phone->setNumber($data["sender"]["phone"]["number"]);
194
+ }
195
+
196
+ $sender->setPhone($phone);
197
+ }
198
+
199
+ // <transaction><sender><documents>
200
+ if (isset($data['sender']['documents']) && is_array($data['sender']['documents'])) {
201
+
202
+ $documents = $data['sender']['documents'];
203
+ if (count($documents) > 0) {
204
+ foreach ($documents as $document) {
205
+ $sender->addDocument($document['type'], $document['value']);
206
+ }
207
+ }
208
+ }
209
+
210
+ $transaction->setSender($sender);
211
+ }
212
+
213
+ if (isset($data["shipping"]) && is_array($data["shipping"])) {
214
+
215
+ // <transaction> <shipping>
216
+ $shipping = new Ipagare_PagSeguroDireto_Domain_Shipping();
217
+
218
+ // <transaction> <shipping> <type>
219
+ if (isset($data["shipping"]["type"])) {
220
+ $shipping->setType(new Ipagare_PagSeguroDireto_Domain_ShippingType($data["shipping"]["type"]));
221
+ }
222
+
223
+ // <transaction> <shipping> <cost>
224
+ if (isset($data["shipping"]["cost"])) {
225
+ $shipping->setCost($data["shipping"]["cost"]);
226
+ }
227
+
228
+ if (isset($data["shipping"]["address"]) && is_array($data["shipping"]["address"])) {
229
+
230
+ // <transaction> <shipping> <address>
231
+ $address = new Ipagare_PagSeguroDireto_Domain_Address();
232
+
233
+ // <transaction> <shipping> <address> <street>
234
+ if (isset($data["shipping"]["address"]["street"])) {
235
+ $address->setStreet($data["shipping"]["address"]["street"]);
236
+ }
237
+
238
+ // <transaction> <shipping> <address> <number>
239
+ if (isset($data["shipping"]["address"]["number"])) {
240
+ $address->setNumber($data["shipping"]["address"]["number"]);
241
+ }
242
+
243
+ // <transaction> <shipping> <address> <complement>
244
+ if (isset($data["shipping"]["address"]["complement"])) {
245
+ $address->setComplement($data["shipping"]["address"]["complement"]);
246
+ }
247
+
248
+ // <transaction> <shipping> <address> <city>
249
+ if (isset($data["shipping"]["address"]["city"])) {
250
+ $address->setCity($data["shipping"]["address"]["city"]);
251
+ }
252
+
253
+ // <transaction> <shipping> <address> <state>
254
+ if (isset($data["shipping"]["address"]["state"])) {
255
+ $address->setState($data["shipping"]["address"]["state"]);
256
+ }
257
+
258
+ // <transaction> <shipping> <address> <district>
259
+ if (isset($data["shipping"]["address"]["district"])) {
260
+ $address->setDistrict($data["shipping"]["address"]["district"]);
261
+ }
262
+
263
+ // <transaction> <shipping> <address> <postalCode>
264
+ if (isset($data["shipping"]["address"]["postalCode"])) {
265
+ $address->setPostalCode($data["shipping"]["address"]["postalCode"]);
266
+ }
267
+
268
+ // <transaction> <shipping> <address> <country>
269
+ if (isset($data["shipping"]["address"]["country"])) {
270
+ $address->setCountry($data["shipping"]["address"]["country"]);
271
+ }
272
+
273
+ $shipping->setAddress($address);
274
+ }
275
+
276
+ // <transaction> <shipping>
277
+ $transaction->setShipping($shipping);
278
+ }
279
+
280
+ return $transaction;
281
+ }
282
+
283
+ /**
284
+ * @param $data
285
+ * @return Ipagare_PagSeguroDireto_Domain_Item
286
+ */
287
+ private static function parseTransactionItem($data) {
288
+
289
+ // <transaction> <items> <item>
290
+ $item = new Ipagare_PagSeguroDireto_Domain_Item();
291
+
292
+ // <transaction> <items> <item> <id>
293
+ if (isset($data["id"])) {
294
+ $item->setId($data["id"]);
295
+ }
296
+
297
+ // <transaction> <items> <item> <description>
298
+ if (isset($data["description"])) {
299
+ $item->setDescription($data["description"]);
300
+ }
301
+
302
+ // <transaction> <items> <item> <quantity>
303
+ if (isset($data["quantity"])) {
304
+ $item->setQuantity($data["quantity"]);
305
+ }
306
+
307
+ // <transaction> <items> <item> <amount>
308
+ if (isset($data["amount"])) {
309
+ $item->setAmount($data["amount"]);
310
+ }
311
+
312
+ // <transaction> <items> <item> <weight>
313
+ if (isset($data["weight"])) {
314
+ $item->setWeight($data["weight"]);
315
+ }
316
+
317
+ return $item;
318
+ }
319
+
320
+ /**
321
+ * @param $data
322
+ * @return Ipagare_PagSeguroDireto_Domain_TransactionSummary
323
+ */
324
+ private static function parseTransactionSummary($data) {
325
+
326
+ $transactionSummary = new Ipagare_PagSeguroDireto_Domain_TransactionSummary();
327
+
328
+ if (isset($data['type'])) {
329
+ $transactionSummary->setType(new Ipagare_PagSeguroDireto_Domain_TransactionType($data['type']));
330
+ }
331
+ if (isset($data['code'])) {
332
+ $transactionSummary->setCode($data['code']);
333
+ }
334
+ if (isset($data['reference'])) {
335
+ $transactionSummary->setReference($data['reference']);
336
+ }
337
+ if (isset($data['date'])) {
338
+ $transactionSummary->setDate($data['date']);
339
+ }
340
+ if (isset($data['lastEventDate'])) {
341
+ $transactionSummary->setLastEventDate($data['lastEventDate']);
342
+ }
343
+ if (isset($data['grossAmount'])) {
344
+ $transactionSummary->setGrossAmount($data['grossAmount']);
345
+ }
346
+ if (isset($data['status'])) {
347
+ $transactionSummary->setStatus(new Ipagare_PagSeguroDireto_Domain_TransactionStatus($data['status']));
348
+ }
349
+ if (isset($data['netAmount'])) {
350
+ $transactionSummary->setNetAmount($data['netAmount']);
351
+ }
352
+ if (isset($data['discountAmount'])) {
353
+ $transactionSummary->setDiscountAmount($data['discountAmount']);
354
+ }
355
+ if (isset($data['feeAmount'])) {
356
+ $transactionSummary->setFeeAmount($data['feeAmount']);
357
+ }
358
+ if (isset($data['extraAmount'])) {
359
+ $transactionSummary->setExtraAmount($data['extraAmount']);
360
+ }
361
+ if (isset($data['lastEvent'])) {
362
+ $transactionSummary->setLastEventDate($data['lastEvent']);
363
+ }
364
+ if (isset($data['paymentMethod'])) {
365
+ $paymentMethod = new Ipagare_PagSeguroDireto_Domain_PaymentMethod();
366
+ if (isset($data['paymentMethod']['type'])) {
367
+ $paymentMethod->setType(new Ipagare_PagSeguroDireto_Domain_PaymentMethodType($data['paymentMethod']['type']));
368
+ }
369
+ if (isset($data['paymentMethod']['code'])) {
370
+ $paymentMethod->setCode(new Ipagare_PagSeguroDireto_Domain_PaymentMethodCode($data['paymentMethod']['code']));
371
+ }
372
+ $transactionSummary->setPaymentMethod($paymentMethod);
373
+ }
374
+
375
+ return $transactionSummary;
376
+ }
377
+
378
+ }
lib/Ipagare/PagSeguroDireto/Resources/Resources.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ class Ipagare_PagSeguroDireto_Resources_Resources {
22
+
23
+ private static $resources;
24
+ private static $data;
25
+
26
+ const VAR_NAME = 'PagSeguroDiretoResources';
27
+
28
+ private function __construct() {
29
+ define('ALLOW_PAGSEGURO_RESOURCES', true);
30
+ require_once Ipagare_PagSeguroDireto_Library::getPath() . DIRECTORY_SEPARATOR . "Resources" . DIRECTORY_SEPARATOR .
31
+ "ResourcesFile.php";
32
+ $varName = self::VAR_NAME;
33
+ if (isset($$varName)) {
34
+ self::$data = $$varName;
35
+ unset($$varName);
36
+ } else {
37
+ throw new Exception("Resources is undefined.");
38
+ }
39
+ }
40
+
41
+ public static function init() {
42
+ if (self::$resources == null) {
43
+ self::$resources = new Ipagare_PagSeguroDireto_Resources_Resources();
44
+ }
45
+ return self::$resources;
46
+ }
47
+
48
+ public static function getData($key1, $key2 = null) {
49
+ if ($key2 != null) {
50
+ if (isset(self::$data[$key1][$key2])) {
51
+ return self::$data[$key1][$key2];
52
+ } else {
53
+ throw new Exception("Resources keys {$key1}, {$key2} not found.");
54
+ }
55
+ } else {
56
+ if (isset(self::$data[$key1])) {
57
+ return self::$data[$key1];
58
+ } else {
59
+ throw new Exception("Resources key {$key1} not found.");
60
+ }
61
+ }
62
+ }
63
+
64
+ public static function setData($key1, $key2, $value) {
65
+ if (isset(self::$data[$key1][$key2])) {
66
+ self::$data[$key1][$key2] = $value;
67
+ } else {
68
+ throw new Exception("Resources keys {$key1}, {$key2} not found.");
69
+ }
70
+ }
71
+
72
+ public static function getWebserviceUrl($environment) {
73
+ if (isset(self::$data['environment']) && isset(self::$data['environment'][$environment]) &&
74
+ isset(self::$data['environment'][$environment]['webserviceUrl'])
75
+ ) {
76
+ return self::$data['environment'][$environment]['webserviceUrl'];
77
+ } else {
78
+ throw new Exception("WebService URL not set for $environment environment.");
79
+ }
80
+ }
81
+
82
+ public static function getTransactionUrl($environment) {
83
+ if (isset(self::$data['environment']) && isset(self::$data['environment'][$environment]) &&
84
+ isset(self::$data['environment'][$environment]['transactionUrl'])
85
+ ) {
86
+ return self::$data['environment'][$environment]['transactionUrl'];
87
+ } else {
88
+ throw new Exception("TransactionUrl URL not set for $environment environment.");
89
+ }
90
+ }
91
+
92
+ }
lib/Ipagare/PagSeguroDireto/Resources/ResourcesFile.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // URLs
4
+ $PagSeguroDiretoResources['environment'] = array();
5
+ $PagSeguroDiretoResources['environment']['production'] = array('webserviceUrl' => 'https://ws.pagseguro.uol.com.br',
6
+ 'transactionUrl' => 'https://stc.pagseguro.uol.com.br');
7
+
8
+ $PagSeguroDiretoResources['environment']['sandbox'] = array('webserviceUrl' => 'https://ws.sandbox.pagseguro.uol.com.br',
9
+ 'transactionUrl' => 'https://stc.sandbox.pagseguro.uol.com.br');
10
+
11
+ // Session service
12
+ $PagSeguroDiretoResources['sessionService'] = array();
13
+ $PagSeguroDiretoResources['sessionService']['servicePath'] = "/v2/sessions";
14
+ $PagSeguroDiretoResources['sessionService']['serviceTimeout'] = 20;
15
+
16
+ // Payment service
17
+ $PagSeguroDiretoResources['paymentService'] = array();
18
+ $PagSeguroDiretoResources['paymentService']['servicePath'] = "/v2/transactions";
19
+ $PagSeguroDiretoResources['paymentService']['serviceTimeout'] = 20;
20
+
21
+ // Notification service
22
+ $PagSeguroDiretoResources['notificationService'] = array();
23
+ $PagSeguroDiretoResources['notificationService']['servicePath'] = "/v2/transactions/notifications";
24
+ $PagSeguroDiretoResources['notificationService']['serviceTimeout'] = 20;
25
+
26
+ // Transaction search service
27
+ $PagSeguroDiretoResources['transactionSearchService'] = array();
28
+ $PagSeguroDiretoResources['transactionSearchService']['servicePath'] = "/v2/transactions";
29
+ $PagSeguroDiretoResources['transactionSearchService']['serviceTimeout'] = 20;
lib/Ipagare/PagSeguroDireto/Service/ConnectionData.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ipagare_PagSeguroDireto_Service_ConnectionData {
4
+
5
+ /**
6
+ * @var
7
+ */
8
+ private $serviceName;
9
+
10
+ /**
11
+ * @var Ipagare_PagSeguroDireto_Domain_Credentials
12
+ */
13
+ private $credentials;
14
+
15
+ /**
16
+ * @var
17
+ */
18
+ private $resources;
19
+
20
+ /**
21
+ * @var
22
+ */
23
+ private $environment;
24
+
25
+ /**
26
+ * @var
27
+ */
28
+ private $webserviceUrl;
29
+
30
+ /**
31
+ * @var
32
+ */
33
+ private $transactionUrl;
34
+
35
+ /**
36
+ * @var
37
+ */
38
+ private $servicePath;
39
+
40
+ /**
41
+ * @var
42
+ */
43
+ private $serviceTimeout;
44
+
45
+ /**
46
+ * @var
47
+ */
48
+ private $charset;
49
+
50
+ /**
51
+ * @param Ipagare_PagSeguroDireto_Domain_Credentials $credentials
52
+ * @param $serviceName
53
+ */
54
+ public function __construct(Ipagare_PagSeguroDireto_Domain_Credentials $credentials, $serviceName) {
55
+ $this->credentials = $credentials;
56
+ $this->serviceName = $serviceName;
57
+
58
+ $this->setEnvironment(Ipagare_PagSeguroDireto_Config_Config::getEnvironment());
59
+ $this->setTransactionUrl(Ipagare_PagSeguroDireto_Resources_Resources::getTransactionUrl($this->getEnvironment()));
60
+ $this->setWebserviceUrl(Ipagare_PagSeguroDireto_Resources_Resources::getWebserviceUrl($this->getEnvironment()));
61
+ $this->setCharset(Ipagare_PagSeguroDireto_Config_Config::getApplicationCharset());
62
+
63
+ $this->resources = Ipagare_PagSeguroDireto_Resources_Resources::getData($this->serviceName);
64
+ if (isset($this->resources['servicePath'])) {
65
+ $this->setServicePath($this->resources['servicePath']);
66
+ }
67
+ if (isset($this->resources['serviceTimeout'])) {
68
+ $this->setServiceTimeout($this->resources['serviceTimeout']);
69
+ }
70
+ }
71
+
72
+ /**
73
+ * @return Ipagare_PagSeguroDireto_Domain_Credentials
74
+ */
75
+ public function getCredentials() {
76
+ return $this->credentials;
77
+ }
78
+
79
+ /**
80
+ * @param Ipagare_PagSeguroDireto_Domain_Credentials $credentials
81
+ */
82
+ public function setCredentials(Ipagare_PagSeguroDireto_Domain_Credentials $credentials) {
83
+ $this->credentials = $credentials;
84
+ }
85
+
86
+ /**
87
+ * @return string
88
+ */
89
+ public function getCredentialsUrlQuery() {
90
+ return http_build_query($this->credentials->getAttributesMap(), '', '&');
91
+ }
92
+
93
+ /**
94
+ * @return mixed
95
+ */
96
+ public function getEnvironment() {
97
+ return $this->environment;
98
+ }
99
+
100
+ /**
101
+ * @param $environment
102
+ */
103
+ public function setEnvironment($environment) {
104
+ $this->environment = $environment;
105
+ }
106
+
107
+ /**
108
+ * @return mixed
109
+ */
110
+ public function getWebserviceUrl() {
111
+ return $this->webserviceUrl;
112
+ }
113
+
114
+ /**
115
+ * @param $webserviceUrl
116
+ */
117
+ public function setWebserviceUrl($webserviceUrl) {
118
+ $this->webserviceUrl = $webserviceUrl;
119
+ }
120
+
121
+ /**
122
+ * @return mixed
123
+ */
124
+ public function getServicePath() {
125
+ return $this->servicePath;
126
+ }
127
+
128
+ /**
129
+ * @param $servicePath
130
+ */
131
+ public function setServicePath($servicePath) {
132
+ $this->servicePath = $servicePath;
133
+ }
134
+
135
+ /**
136
+ * @return mixed
137
+ */
138
+ public function getServiceTimeout() {
139
+ return $this->serviceTimeout;
140
+ }
141
+
142
+ /**
143
+ * @param $serviceTimeout
144
+ */
145
+ public function setServiceTimeout($serviceTimeout) {
146
+ $this->serviceTimeout = $serviceTimeout;
147
+ }
148
+
149
+ /**
150
+ * @return string
151
+ */
152
+ public function getServiceUrl() {
153
+ return $this->getWebserviceUrl() . $this->getServicePath();
154
+ }
155
+
156
+ /**
157
+ * @param $resource
158
+ * @return mixed
159
+ */
160
+ public function getResource($resource) {
161
+ return $this->resources[$resource];
162
+ }
163
+
164
+ /**
165
+ * @return mixed
166
+ */
167
+ public function getCharset() {
168
+ return $this->charset;
169
+ }
170
+
171
+ /**
172
+ * @param $charset
173
+ */
174
+ public function setCharset($charset) {
175
+ $this->charset = $charset;
176
+ }
177
+
178
+ public function getTransactionUrl() {
179
+ return $this->transactionUrl;
180
+ }
181
+
182
+ public function setTransactionUrl($transactionUrl) {
183
+ $this->transactionUrl = $transactionUrl;
184
+ }
185
+
186
+ }
lib/Ipagare/PagSeguroDireto/Service/NotificationService.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Encapsulates web service calls regarding Ipagare_PagSeguroDireto_ notifications
23
+ */
24
+ class Ipagare_PagSeguroDireto_Service_NotificationService {
25
+
26
+ /**
27
+ *
28
+ */
29
+ const SERVICE_NAME = 'notificationService';
30
+
31
+ private $logger;
32
+
33
+ public function __construct() {
34
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
35
+ }
36
+
37
+ /**
38
+ * @param Ipagare_PagSeguroDireto_Service_ConnectionData $connectionData
39
+ * @param $notificationCode
40
+ * @return string
41
+ */
42
+ private function buildTransactionNotificationUrl(Ipagare_PagSeguroDireto_Service_ConnectionData $connectionData, $notificationCode) {
43
+ $url = $connectionData->getServiceUrl();
44
+ return "{$url}/{$notificationCode}/?" . $connectionData->getCredentialsUrlQuery();
45
+ }
46
+
47
+ /**
48
+ * Returns a transaction from a notification code
49
+ *
50
+ * @param Ipagare_PagSeguroDireto_Domain_Credentials $credentials
51
+ * @param String $notificationCode
52
+ * @throws Ipagare_PagSeguroDireto_Exception_ServiceException
53
+ * @throws Exception
54
+ * @return Ipagare_PagSeguroDireto_Domain_Transaction
55
+ * @see Ipagare_PagSeguroDireto_Domain_Transaction
56
+ */
57
+ public function checkTransaction(Ipagare_PagSeguroDireto_Domain_Credentials $credentials, $notificationCode) {
58
+ $connectionData = new Ipagare_PagSeguroDireto_Service_ConnectionData($credentials, self::SERVICE_NAME);
59
+
60
+ $transactionSearchResponse = Ipagare_PagSeguroDireto_Domain_TransactionSearchResponse::getInstance();
61
+
62
+ $this->logger->info('Parametros enviados[NOTIFICATION]: ' . $notificationCode);
63
+
64
+ try {
65
+ $connection = new Ipagare_PagSeguroDireto_Utils_HttpConnection();
66
+ $connection->get(
67
+ self::buildTransactionNotificationUrl($connectionData, $notificationCode), $connectionData->getServiceTimeout(), $connectionData->getCharset()
68
+ );
69
+
70
+ $httpStatus = new Ipagare_PagSeguroDireto_Domain_HttpStatus($connection->getStatus());
71
+
72
+ switch ($httpStatus->getType()) {
73
+ case 'OK':
74
+ $this->logger->info('Parametros recebidos[NOTIFICATION]: ' . $connection->getResponse());
75
+ $transaction = Ipagare_PagSeguroDireto_Parser_TransactionParser::readTransaction($connection->getResponse());
76
+ $transactionSearchResponse->setTransaction($transaction);
77
+ break;
78
+
79
+ case 'BAD_REQUEST':
80
+ $errors = Ipagare_PagSeguroDireto_Parser_TransactionParser::readErrors($connection->getResponse());
81
+ $transactionSearchResponse->setErrors($errors);
82
+ break;
83
+
84
+ default:
85
+ $e = new Ipagare_PagSeguroDireto_Exception_ServiceException($httpStatus);
86
+ $transactionSearchResponse->setErrors(array(new Ipagare_PagSeguroDireto_Domain_Error('99999', $e->getFormattedMessage())));
87
+ break;
88
+ }
89
+ } catch (Ipagare_PagSeguroDireto_Exception_ServiceException $e) {
90
+
91
+ } catch (Exception $e) {
92
+
93
+ }
94
+
95
+ return $transactionSearchResponse;
96
+ }
97
+
98
+ }
lib/Ipagare/PagSeguroDireto/Service/PaymentService.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Encapsulates web service calls regarding Ipagare_PagSeguroDireto_ payment requests
23
+ */
24
+ class Ipagare_PagSeguroDireto_Service_PaymentService {
25
+
26
+ /**
27
+ *
28
+ */
29
+ const SERVICE_NAME = 'paymentService';
30
+
31
+ private $logger;
32
+
33
+ public function __construct() {
34
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
35
+ }
36
+
37
+ /**
38
+ * @param Ipagare_PagSeguroDireto_Service_ConnectionData $connectionData
39
+ * @return string
40
+ */
41
+ private function buildCheckoutRequestUrl(Ipagare_PagSeguroDireto_Service_ConnectionData $connectionData) {
42
+ return $connectionData->getServiceUrl() . '/?' . $connectionData->getCredentialsUrlQuery();
43
+ }
44
+
45
+ /**
46
+ *
47
+ * @param Ipagare_PagSeguroDireto_Domain_Credentials $credentials
48
+ * @param Ipagare_PagSeguroDireto_Domain_PaymentRequest $paymentRequest
49
+ * @return Ipagare_PagSeguroDireto_Domain_PaymentResponse
50
+ */
51
+ public function createTransaction(
52
+ Ipagare_PagSeguroDireto_Domain_Credentials $credentials, Ipagare_PagSeguroDireto_Domain_PaymentRequest $paymentRequest) {
53
+ $connectionData = new Ipagare_PagSeguroDireto_Service_ConnectionData($credentials, self::SERVICE_NAME);
54
+
55
+ try {
56
+ $data = Ipagare_PagSeguroDireto_Parser_PaymentParser::getData($paymentRequest);
57
+
58
+ $paymentResponse = Ipagare_PagSeguroDireto_Domain_PaymentResponse::getInstance();
59
+ $paymentResponse->setDataSend($data);
60
+
61
+ $this->logger->info('Parametros enviados[PAGAMENTO]: ' . Mage::helper('ipgpagsegurodireto')->buildParametersForLog($data));
62
+
63
+ $connection = new Ipagare_PagSeguroDireto_Utils_HttpConnection();
64
+ $connection->post(
65
+ $this->buildCheckoutRequestUrl($connectionData), $data, $connectionData->getServiceTimeout(), $connectionData->getCharset()
66
+ );
67
+ $this->logger->info('Parametros recebidos[PAGAMENTO]: ' . $connection->getResponse());
68
+
69
+ $httpStatus = new Ipagare_PagSeguroDireto_Domain_HttpStatus($connection->getStatus());
70
+ switch ($httpStatus->getType()) {
71
+ case 'OK':
72
+ //$this->logger->info('Parametros recebidos[PAGAMENTO]: ' . $connection->getResponse());
73
+ $paymentParserData = Ipagare_PagSeguroDireto_Parser_PaymentParser::readSuccessXml($connection->getResponse());
74
+ $paymentResponse->setPaymentParserData($paymentParserData);
75
+ break;
76
+
77
+ case 'BAD_REQUEST':
78
+ $errors = Ipagare_PagSeguroDireto_Parser_PaymentParser::readErrors($connection->getResponse());
79
+ $paymentResponse->setErrors($errors);
80
+ break;
81
+
82
+ default:
83
+ $e = new Ipagare_PagSeguroDireto_Exception_ServiceException($httpStatus);
84
+ $paymentResponse->addFatalError($e->getOneLineMessage());
85
+ break;
86
+ }
87
+ } catch (Ipagare_PagSeguroDireto_Exception_ServiceException $e) {
88
+
89
+ } catch (Exception $e) {
90
+
91
+ }
92
+
93
+ return $paymentResponse;
94
+ }
95
+
96
+ }
lib/Ipagare/PagSeguroDireto/Service/SessionService.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ipagare_PagSeguroDireto_Service_SessionService {
4
+
5
+ /**
6
+ *
7
+ */
8
+ const SERVICE_NAME = 'sessionService';
9
+
10
+ /**
11
+ * @param Ipagare_PagSeguroDireto_Service_ConnectionData $connectionData
12
+ * @return string
13
+ */
14
+ private static function buildSessionUrl(Ipagare_PagSeguroDireto_Service_ConnectionData $connectionData) {
15
+ return $connectionData->getServiceUrl() . '/?' . $connectionData->getCredentialsUrlQuery();
16
+ }
17
+
18
+ /**
19
+ * Returns a transaction from a notification code
20
+ *
21
+ * @param Ipagare_PagSeguroDireto_Domain_Credentials $credentials
22
+ * @param String $notificationCode
23
+ * @throws Ipagare_PagSeguroDireto_Exception_ServiceException
24
+ * @throws Exception
25
+ * @return Ipagare_PagSeguroDireto_Domain_Session
26
+ * @see Ipagare_PagSeguroDireto_Domain_Transaction
27
+ */
28
+ public static function createSession(Ipagare_PagSeguroDireto_Domain_Credentials $credentials) {
29
+ $connectionData = new Ipagare_PagSeguroDireto_Service_ConnectionData($credentials, self::SERVICE_NAME);
30
+
31
+ try {
32
+ $connection = new Ipagare_PagSeguroDireto_Utils_HttpConnection();
33
+ $connection->post(self::buildSessionUrl($connectionData), array(), $connectionData->getServiceTimeout(), $connectionData->getCharset());
34
+
35
+ $httpStatus = new Ipagare_PagSeguroDireto_Domain_HttpStatus($connection->getStatus());
36
+ $sessionResponse = new Ipagare_PagSeguroDireto_Domain_SessionResponse();
37
+
38
+ switch ($httpStatus->getType()) {
39
+ case 'OK':
40
+ $session = Ipagare_PagSeguroDireto_Parser_SessionParser::readXml($connection->getResponse());
41
+ $sessionResponse->setSession($session);
42
+ break;
43
+
44
+ case 'BAD_REQUEST':
45
+ $errors = Ipagare_PagSeguroDireto_Parser_SessionParser::readErrors($connection->getResponse());
46
+ $sessionResponse->setErrors($errors);
47
+ break;
48
+
49
+ case 'UNAUTHORIZED':
50
+ $errors = array(new Ipagare_IpgPagSeguroDireto_ErrorMessages('UNAUTHORIZED'));
51
+ $sessionResponse->setErrors($errors);
52
+ break;
53
+
54
+ default:
55
+ $e = new Ipagare_PagSeguroDireto_Exception_ServiceException($httpStatus);
56
+ $sessionResponse->addFatalError($e->getOneLineMessage());
57
+ break;
58
+ }
59
+ } catch (Ipagare_PagSeguroDireto_Exception_ServiceException $e) {
60
+
61
+ } catch (Exception $e) {
62
+
63
+ }
64
+
65
+ return $sessionResponse;
66
+ }
67
+
68
+ }
lib/Ipagare/PagSeguroDireto/Service/TransactionSearchService.php ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * Encapsulates web service calls to search for Ipagare_PagSeguroDireto_ transactions
23
+ */
24
+ class Ipagare_PagSeguroDireto_Service_TransactionSearchService {
25
+
26
+ const SERVICE_NAME = 'transactionSearchService';
27
+
28
+ private $logger;
29
+
30
+ public function __construct() {
31
+ $this->logger = Ipagare_IpgBase_Logger::getLogger(__CLASS__);
32
+ }
33
+
34
+ private function buildSearchUrlByCode(Ipagare_PagSeguroDireto_Service_ConnectionData $connectionData, $transactionCode) {
35
+ $url = $connectionData->getServiceUrl();
36
+ return "{$url}/{$transactionCode}/?" . $connectionData->getCredentialsUrlQuery();
37
+ }
38
+
39
+ private function buildSearchUrlByDate(Ipagare_PagSeguroDireto_Service_ConnectionData $connectionData, array $searchParams) {
40
+ $url = $connectionData->getServiceUrl();
41
+ $initialDate = $searchParams['initialDate'] != null ? $searchParams['initialDate'] : "";
42
+ $finalDate = $searchParams['finalDate'] != null ? ("&finalDate=" . $searchParams['finalDate']) : "";
43
+ if ($searchParams['pageNumber'] != null) {
44
+ $page = "&page=" . $searchParams['pageNumber'];
45
+ }
46
+ if ($searchParams['maxPageResults'] != null) {
47
+ $maxPageResults = "&maxPageResults=" . $searchParams['maxPageResults'];
48
+ }
49
+ return "{$url}/?" . $connectionData->getCredentialsUrlQuery() .
50
+ "&initialDate={$initialDate}{$finalDate}{$page}{$maxPageResults}";
51
+ }
52
+
53
+ private function buildSearchUrlAbandoned(Ipagare_PagSeguroDireto_Service_ConnectionData $connectionData, array $searchParams) {
54
+ $url = $connectionData->getServiceUrl();
55
+ $initialDate = $searchParams['initialDate'] != null ? $searchParams['initialDate'] : "";
56
+ $finalDate = $searchParams['finalDate'] != null ? ("&finalDate=" . $searchParams['finalDate']) : "";
57
+ if ($searchParams['pageNumber'] != null) {
58
+ $page = "&page=" . $searchParams['pageNumber'];
59
+ }
60
+ if ($searchParams['maxPageResults'] != null) {
61
+ $maxPageResults = "&maxPageResults=" . $searchParams['maxPageResults'];
62
+ }
63
+ return "{$url}/abandoned/?" . $connectionData->getCredentialsUrlQuery() .
64
+ "&initialDate={$initialDate}&finalDate={$finalDate}{$page}{$maxPageResults}";
65
+ }
66
+
67
+ /**
68
+ * Finds a transaction with a matching transaction code
69
+ *
70
+ * @param Ipagare_PagSeguroDireto_Domain_Credentials $credentials
71
+ * @param String $transactionCode
72
+ * @return Ipagare_PagSeguroDireto_Domain_Transaction a transaction object
73
+ * @see Ipagare_PagSeguroDireto_Domain_TransactionSearchResponse
74
+ * @throws Ipagare_PagSeguroDireto_Exception_ServiceException
75
+ * @throws Exception
76
+ */
77
+ public function searchByCode(Ipagare_PagSeguroDireto_Domain_Credentials $credentials, $transactionCode) {
78
+ $this->logger->info('Parametros enviados[TRANSACTION]: ' . $transactionCode);
79
+
80
+ $connectionData = new Ipagare_PagSeguroDireto_Service_ConnectionData($credentials, self::SERVICE_NAME);
81
+
82
+ $transactionSearchResponse = Ipagare_PagSeguroDireto_Domain_TransactionSearchResponse::getInstance();
83
+
84
+ try {
85
+ $connection = new Ipagare_PagSeguroDireto_Utils_HttpConnection();
86
+ $connection->get(
87
+ $this->buildSearchUrlByCode($connectionData, $transactionCode), $connectionData->getServiceTimeout(), $connectionData->getCharset()
88
+ );
89
+ $httpStatus = new Ipagare_PagSeguroDireto_Domain_HttpStatus($connection->getStatus());
90
+
91
+ switch ($httpStatus->getType()) {
92
+ case 'OK':
93
+ $this->logger->info('Parametros recebidos[TRANSACTION]: ' . $connection->getResponse());
94
+ $transaction = Ipagare_PagSeguroDireto_Parser_TransactionParser::readTransaction($connection->getResponse());
95
+ $transactionSearchResponse->setTransaction($transaction);
96
+ break;
97
+
98
+ case 'BAD_REQUEST':
99
+ $errors = Ipagare_PagSeguroDireto_Parser_TransactionParser::readErrors($connection->getResponse());
100
+ $transactionSearchResponse->setErrors($errors);
101
+ break;
102
+
103
+ default:
104
+ $e = new Ipagare_PagSeguroDireto_Exception_ServiceException($httpStatus);
105
+ $transactionSearchResponse->setErrors(array(new Ipagare_PagSeguroDireto_Domain_Error('99999', $e->getFormattedMessage())));
106
+ break;
107
+ }
108
+ } catch (Ipagare_PagSeguroDireto_Exception_ServiceException $e) {
109
+
110
+ } catch (Exception $e) {
111
+
112
+ }
113
+
114
+ return $transactionSearchResponse;
115
+ }
116
+
117
+ /**
118
+ * Search transactions associated with this set of credentials within a date range
119
+ *
120
+ * @param Ipagare_PagSeguroDireto_Domain_Credentials $credentials
121
+ * @param integer $pageNumber
122
+ * @param integer $maxPageResults
123
+ * @param String $initialDate
124
+ * @param String $finalDate
125
+ * @return a object of Ipagare_PagSeguroDireto_TransactionSerachResult class
126
+ * @see Ipagare_PagSeguroDireto_Domain_TransactionSearchResult
127
+ * @throws Ipagare_PagSeguroDireto_Exception_ServiceException
128
+ * @throws Exception
129
+ */
130
+ public function searchByDate(
131
+ Ipagare_PagSeguroDireto_Domain_Credentials $credentials, $pageNumber, $maxPageResults, $initialDate, $finalDate = null
132
+ ) {
133
+ $connectionData = new Ipagare_PagSeguroDireto_Service_ConnectionData($credentials, self::SERVICE_NAME);
134
+
135
+ $searchParams = array(
136
+ 'initialDate' => Ipagare_PagSeguroDireto_Helper_Helper::formatDate($initialDate),
137
+ 'pageNumber' => $pageNumber,
138
+ 'maxPageResults' => $maxPageResults
139
+ );
140
+
141
+ $searchParams['finalDate'] = $finalDate ? Ipagare_PagSeguroDireto_Helper_Helper::formatDate($finalDate) : null;
142
+
143
+ try {
144
+ $connection = new Ipagare_PagSeguroDireto_Utils_HttpConnection();
145
+ $connection->get(
146
+ $this->buildSearchUrlByDate($connectionData, $searchParams), $connectionData->getServiceTimeout(), $connectionData->getCharset()
147
+ );
148
+
149
+ $httpStatus = new Ipagare_PagSeguroDireto_Domain_HttpStatus($connection->getStatus());
150
+
151
+ switch ($httpStatus->getType()) {
152
+
153
+ case 'OK':
154
+ $searchResult = Ipagare_PagSeguroDireto_Parser_TransactionParser::readSearchResult($connection->getResponse());
155
+ break;
156
+
157
+ case 'BAD_REQUEST':
158
+ $errors = Ipagare_PagSeguroDireto_Parser_TransactionParser::readErrors($connection->getResponse());
159
+ $e = new Ipagare_PagSeguroDireto_Exception_ServiceException($httpStatus, $errors);
160
+ throw $e;
161
+ break;
162
+
163
+ default:
164
+ $e = new Ipagare_PagSeguroDireto_Exception_ServiceException($httpStatus);
165
+ throw $e;
166
+ break;
167
+ }
168
+
169
+ return isset($searchResult) ? $searchResult : false;
170
+ } catch (Ipagare_PagSeguroDireto_Exception_ServiceException $e) {
171
+ throw $e;
172
+ } catch (Exception $e) {
173
+ throw $e;
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Search transactions abandoned associated with this set of credentials within a date range
179
+ *
180
+ * @param Ipagare_PagSeguroDireto_Domain_Credentials $credentials
181
+ * @param String $initialDate
182
+ * @param String $finalDate
183
+ * @param integer $pageNumber
184
+ * @param integer $maxPageResults
185
+ * @return Ipagare_PagSeguroDireto_Domain_TransactionSearchResult a object of Ipagare_PagSeguroDireto_Domain_TransactionSearchResult class
186
+ * @see Ipagare_PagSeguroDireto_Domain_TransactionSearchResult
187
+ * @throws Ipagare_PagSeguroDireto_Exception_ServiceException
188
+ * @throws Exception
189
+ */
190
+ public function searchAbandoned(
191
+ Ipagare_PagSeguroDireto_Domain_Credentials $credentials, $pageNumber, $maxPageResults, $initialDate, $finalDate = null
192
+ ) {
193
+ $connectionData = new Ipagare_PagSeguroDireto_Service_ConnectionData($credentials, self::SERVICE_NAME);
194
+ $searchParams = array(
195
+ 'initialDate' => Ipagare_PagSeguroDireto_Helper_Helper::formatDate($initialDate),
196
+ 'pageNumber' => $pageNumber,
197
+ 'maxPageResults' => $maxPageResults
198
+ );
199
+
200
+ $searchParams['finalDate'] = $finalDate ? Ipagare_PagSeguroDireto_Helper_Helper::formatDate($finalDate) : null;
201
+
202
+ try {
203
+ $connection = new Ipagare_PagSeguroDireto_Utils_HttpConnection();
204
+ $connection->get(
205
+ $this->buildSearchUrlAbandoned($connectionData, $searchParams), $connectionData->getServiceTimeout(), $connectionData->getCharset()
206
+ );
207
+
208
+ $httpStatus = new Ipagare_PagSeguroDireto_Domain_HttpStatus($connection->getStatus());
209
+
210
+ switch ($httpStatus->getType()) {
211
+ case 'OK':
212
+ $searchResult = Ipagare_PagSeguroDireto_Parser_TransactionParser::readSearchResult($connection->getResponse());
213
+ break;
214
+
215
+ case 'BAD_REQUEST':
216
+ $errors = Ipagare_PagSeguroDireto_Parser_TransactionParser::readErrors($connection->getResponse());
217
+ $e = new Ipagare_PagSeguroDireto_Exception_ServiceException($httpStatus, $errors);
218
+ throw $e;
219
+ break;
220
+
221
+ default:
222
+ $e = new Ipagare_PagSeguroDireto_Exception_ServiceException($httpStatus);
223
+ throw $e;
224
+ break;
225
+ }
226
+
227
+ return isset($searchResult) ? $searchResult : false;
228
+ } catch (Ipagare_PagSeguroDireto_Exception_ServiceException $e) {
229
+ throw $e;
230
+ } catch (Exception $e) {
231
+ throw $e;
232
+ }
233
+ }
234
+
235
+ }
lib/Ipagare/PagSeguroDireto/Utils/HttpConnection.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ /**
22
+ * HTTP Connection Class - used in API calls (cURL library is required)
23
+ */
24
+ class Ipagare_PagSeguroDireto_Utils_HttpConnection {
25
+
26
+ private $status;
27
+ private $response;
28
+
29
+ public function __construct() {
30
+ if (!function_exists('curl_init')) {
31
+ throw new Exception('Ipagare_PagSeguroDireto_Library: cURL library is required.');
32
+ }
33
+ }
34
+
35
+ public function getStatus() {
36
+ return $this->status;
37
+ }
38
+
39
+ public function setStatus($status) {
40
+ $this->status = $status;
41
+ }
42
+
43
+ public function getResponse() {
44
+ return $this->response;
45
+ }
46
+
47
+ public function setResponse($response) {
48
+ $this->response = $response;
49
+ }
50
+
51
+ public function post($url, array $data, $timeout = 40, $charset = 'ISO-8859-1') {
52
+ return $this->curlConnection('POST', $url, $timeout, $charset, $data);
53
+ }
54
+
55
+ public function get($url, $timeout = 40, $charset = 'ISO-8859-1') {
56
+ return $this->curlConnection('GET', $url, $timeout, $charset, null);
57
+ }
58
+
59
+ private function curlConnection($method, $url, $timeout, $charset, array $data = null) {
60
+ if (strtoupper($method) === 'POST') {
61
+ $postFields = ($data ? http_build_query($data, '', '&') : "");
62
+ $contentLength = "Content-length: " . strlen($postFields);
63
+ $methodOptions = array(
64
+ CURLOPT_POST => true,
65
+ CURLOPT_POSTFIELDS => $postFields,
66
+ );
67
+ } else {
68
+ $contentLength = null;
69
+ $methodOptions = array(
70
+ CURLOPT_HTTPGET => true
71
+ );
72
+ }
73
+
74
+ $options = array(
75
+ CURLOPT_HTTPHEADER => array(
76
+ "Content-Type: application/x-www-form-urlencoded; charset=" . $charset,
77
+ $contentLength,
78
+ 'lib-description: php:' . Ipagare_PagSeguroDireto_Library::getVersion(),
79
+ 'language-engine-description: php:' . Ipagare_PagSeguroDireto_Library::getPHPVersion()
80
+ ),
81
+ CURLOPT_URL => $url,
82
+ CURLOPT_RETURNTRANSFER => true,
83
+ CURLOPT_HEADER => false,
84
+ CURLOPT_SSL_VERIFYPEER => false,
85
+ CURLOPT_CONNECTTIMEOUT => $timeout,
86
+ //CURLOPT_TIMEOUT => $timeout
87
+ );
88
+
89
+ if (!is_null(Ipagare_PagSeguroDireto_Library::getModuleVersion())) {
90
+ array_push($options[CURLOPT_HTTPHEADER], 'module-description: ' . Ipagare_PagSeguroDireto_Library::getModuleVersion());
91
+ }
92
+
93
+ if (!is_null(Ipagare_PagSeguroDireto_Library::getCMSVersion())) {
94
+ array_push($options[CURLOPT_HTTPHEADER], 'cms-description: ' . Ipagare_PagSeguroDireto_Library::getCMSVersion());
95
+ }
96
+
97
+ $options = ($options + $methodOptions);
98
+ $curl = curl_init();
99
+ curl_setopt_array($curl, $options);
100
+ $resp = curl_exec($curl);
101
+ $info = curl_getinfo($curl);
102
+ $error = curl_errno($curl);
103
+ $errorMessage = curl_error($curl);
104
+ curl_close($curl);
105
+ $this->setStatus((int) $info['http_code']);
106
+ $this->setResponse((String) $resp);
107
+ if ($error) {
108
+ throw new Exception("CURL can't connect: $errorMessage");
109
+ } else {
110
+ return true;
111
+ }
112
+ }
113
+
114
+ }
lib/Ipagare/PagSeguroDireto/Utils/XmlParser.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * ***********************************************************************
5
+ Copyright [2011] [Ipagare_PagSeguroDireto_ Internet Ltda.]
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ * ***********************************************************************
19
+ */
20
+
21
+ class Ipagare_PagSeguroDireto_Utils_XmlParser {
22
+
23
+ private $dom;
24
+
25
+ public function __construct($xml) {
26
+ $xml = mb_convert_encoding($xml, "UTF-8", "UTF-8,ISO-8859-1");
27
+ $parser = xml_parser_create();
28
+ if (!xml_parse($parser, $xml)) {
29
+ throw new Exception(
30
+ "Ipagare_PagSeguroDireto_Library XML parsing error: (" . xml_get_error_code($parser) .
31
+ ") " . xml_error_string(xml_get_error_code($parser))
32
+ );
33
+ } else {
34
+ $this->dom = new DOMDocument();
35
+ $this->dom->loadXml($xml);
36
+ }
37
+ }
38
+
39
+ public function getResult($node = null) {
40
+ $result = $this->toArray($this->dom);
41
+ if ($node) {
42
+ if (isset($result[$node])) {
43
+ return $result[$node];
44
+ } else {
45
+ throw new Exception("Ipagare_PagSeguroDireto_Library XML parsing error: undefined index [$node]");
46
+ }
47
+ } else {
48
+ return $result;
49
+ }
50
+ }
51
+
52
+ private function toArray($node) {
53
+ $occurrence = array();
54
+ $result = null;
55
+ /** @var $node DOMNode */
56
+ if ($node->hasChildNodes()) {
57
+ foreach ($node->childNodes as $child) {
58
+ if (!isset($occurrence[$child->nodeName])) {
59
+ $occurrence[$child->nodeName] = null;
60
+ }
61
+ $occurrence[$child->nodeName] ++;
62
+ }
63
+ }
64
+ if (isset($child)) {
65
+ if ($child->nodeName == '#text') {
66
+ $result = html_entity_decode(
67
+ htmlentities($node->nodeValue, ENT_COMPAT, 'UTF-8'), ENT_COMPAT, 'ISO-8859-15'
68
+ );
69
+ } else {
70
+ if ($node->hasChildNodes()) {
71
+ $children = $node->childNodes;
72
+ for ($i = 0; $i < $children->length; $i++) {
73
+ $child = $children->item($i);
74
+ if ($child->nodeName != '#text') {
75
+ if ($occurrence[$child->nodeName] > 1) {
76
+ $result[$child->nodeName][] = $this->toArray($child);
77
+ } else {
78
+ $result[$child->nodeName] = $this->toArray($child);
79
+ }
80
+ } else {
81
+ if ($child->nodeName == '0') {
82
+ $text = $this->toArray($child);
83
+ if (trim($text) != '') {
84
+ $result[$child->nodeName] = $this->toArray($child);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ if ($node->hasAttributes()) {
91
+ $attributes = $node->attributes;
92
+ if (!is_null($attributes)) {
93
+ foreach ($attributes as $key => $attr) {
94
+ $result["@" . $attr->name] = $attr->value;
95
+ }
96
+ }
97
+ }
98
+ }
99
+ return $result;
100
+ } else {
101
+ return null;
102
+ }
103
+ }
104
+
105
+ }
media/ipagare/ipgbase/images/imprimir_boleto.png ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/101/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/101/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/101/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/101/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/101/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/101/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/101/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/101/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/101/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/101/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/101/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/101/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/102/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/102/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/102/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/102/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/102/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/102/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/102/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/102/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/102/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/102/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/102/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/102/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/13x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/14x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/15x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/103/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/104/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/104/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/104/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/104/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/104/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/104/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/104/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/104/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/104/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/104/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/104/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/104/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/105/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/105/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/105/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/105/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/105/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/105/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/105/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/105/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/105/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/105/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/105/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/105/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/13x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/14x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/15x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/16x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/17x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/18x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/106/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/107/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/107/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/107/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/107/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/107/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/107/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/107/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/107/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/107/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/107/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/107/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/107/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/108/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/108/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/108/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/108/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/108/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/108/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/108/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/108/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/108/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/108/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/108/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/108/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/109/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/109/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/109/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/109/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/109/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/109/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/109/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/109/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/109/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/109/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/109/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/109/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/110/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/110/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/110/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/110/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/110/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/110/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/110/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/110/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/110/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/110/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/110/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/110/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/111/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/111/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/111/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/111/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/111/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/111/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/111/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/111/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/111/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/111/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/111/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/111/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/112/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/112/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/112/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/112/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/112/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/112/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/112/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/112/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/112/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/112/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/112/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/112/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/113/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/113/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/113/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/113/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/113/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/113/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/113/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/113/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/113/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/113/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/113/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/113/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/114/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/114/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/114/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/114/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/114/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/114/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/114/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/114/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/114/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/114/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/114/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/114/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/115/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/115/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/115/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/116/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/116/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/116/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/116/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/116/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/116/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/116/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/116/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/116/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/116/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/116/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/116/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/117/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/117/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/117/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/117/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/117/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/117/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/117/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/117/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/117/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/117/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/117/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/117/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/118/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/118/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/118/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/118/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/118/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/118/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/119/10x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/119/11x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/119/12x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/119/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/119/2x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/119/3x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/119/4x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/119/5x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/119/6x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/119/7x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/119/8x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/119/9x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/202/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/301/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/302/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/304/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/306/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/bandeiras/307/1x.gif ADDED
Binary file
media/ipagare/ipgpagsegurodireto/images/logo_pagseguro.png ADDED
Binary file
media/ipagare/ipgpagsegurodireto/images/logo_pagseguro_.png ADDED
Binary file
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>IPG_PagSeguro_Transparente</name>
4
+ <version>1.1.3</version>
5
+ <stability>stable</stability>
6
+ <license>GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>M&#xF3;dulo PagSeguro Transparente para Magento.</summary>
10
+ <description>M&#xF3;dulo PagSeguro Transparente para Magento.</description>
11
+ <notes>- Pequenas corre&#xE7;&#xF5;es;</notes>
12
+ <authors><author><name>iPAGARE</name><user>ipagare</user><email>magento@ideatecnologia.com</email></author></authors>
13
+ <date>2016-06-30</date>
14
+ <time>21:38:43</time>
15
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="ipagare"><file name="ipgbase.xml" hash="811beded4d17f5f1a5d1ab312c7530aa"/><file name="ipgpagsegurodireto.xml" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="pt_BR"><file name="Ipagare_IpgBase.csv" hash="6f386bf28f0a68c28085bb00dce2ea3b"/><file name="Ipagare_IpgPagSeguroDireto.csv" hash="7fc99c7f40344c20f457e7190b989a58"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ipagare_IpgBase.xml" hash="99054ea890bedfa9e57b72a451023cfe"/><file name="Ipagare_IpgPagSeguroDireto.xml" hash="4e615cb6a2fb3a5a7b0281eaed76f47c"/></dir></target><target name="magelocal"><dir name="Ipagare"><dir name="IpgBase"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Invoice"><file name="Totals.php" hash="ce7c4906f42c2af3727666a07db878f8"/></dir><file name="Totals.php" hash="2f2fc2d0fadb9d3d50d939656398ca0d"/></dir></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Licenca.php" hash="dbaf0d44442f7392f39b36d34e93f682"/></dir><dir name="Form"><dir name="Field"><file name="Date.php" hash="95a37d4a918ee99cdb47b821561704bc"/><file name="NeedHelp.php" hash="fecadbb4a157192d70dcafd44994cd62"/></dir></dir></dir></dir></dir><dir name="Checkout"><dir name="Onepage"><file name="Success.php" hash="de7b3e5583f34787b0850d4e773e31ef"/></dir></dir><dir name="Sales"><dir name="Order"><dir name="Invoice"><file name="Totals.php" hash="a61a9f295567a3c26d40bfaf05520dd2"/></dir><file name="Totals.php" hash="ee0c1dcf451ace956d781f8dcde3f99f"/></dir></dir></dir><file name="Config.php" hash="74d6b400e1681e2f8e698e8f1d62073f"/><file name="ConfiguracoesSystem.php" hash="b7929c9971639e2ecad0627633e9ea03"/><file name="Date.php" hash="b445635367b601f96611895968a664e7"/><dir name="Helper"><file name="Boleto.php" hash="47536864c117dd25d7d32eeccb48bea0"/><file name="Data.php" hash="4d5b24e21f77f55a3c62f38dc3d4799f"/><file name="Date.php" hash="34f78df55b3876d0cdfed44e62c74161"/><file name="LogUtils.php" hash="602693e1a9934eb9cdda8795cc470841"/><file name="Math.php" hash="9c19c8a5953ca6196c27d9e24fc126d3"/><file name="Module.php" hash="ee3f95dd3f1d25879c02a45492d8c0df"/><file name="OneStepCheckout.php" hash="8d3d1937239a4791e03b75023f5e5d27"/><file name="Session.php" hash="6b7d135ff3cbe5375d28c27e192077a9"/><file name="StringUtils.php" hash="6d3c0aa0491b2ede75ab9c1d77769b3e"/><file name="TokenProcessor.php" hash="49d432d805c458d20312baf19e4c1ad7"/><file name="Url.php" hash="98cdbc75e9e34da474dcee0f7aea21ee"/></dir><file name="Logger.php" hash="dc858d5ccdd1e24685a749058ad31a36"/><dir name="Model"><file name="EmailService.php" hash="12b850a75433f530612c010b63766cc9"/><file name="ExpiraPedido.php" hash="9fe34b596ad91efa538e3a64e25c6581"/><file name="HttpResponse.php" hash="bb5ee60c7f81152f59757a69a1956135"/><file name="Observer.php" hash="9f9b1e653a0e8f2ec4bb66318daaf544"/><file name="Session.php" hash="ed8ba7f2e5663d69c0646fa1ae58013a"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Dias.php" hash="6b2da109b02935d8dbf2df4a97b9b03e"/><file name="Horas.php" hash="c80cab52d714cab0e5703e18bd9da5b4"/><file name="Minutos.php" hash="f3e5cb50fcf06cce33b1cffaae13eaa6"/></dir></dir></dir></dir><file name="PaymentDiscount.php" hash="aa373063a1af11ff8adc60ef262199b1"/><dir name="controllers"><dir name="Adminhtml"><file name="ConfigController.php" hash="d290b89972e0b859e2f17cbf2574d99a"/></dir><file name="BoletoController.php" hash="303c86e55eb4f70ffbc2f6a10e762ad9"/><file name="CronController.php" hash="99b2b0a50dddc98ac6f4b797b647c296"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f28b99cd9f53ea06ce186c46408519c5"/><file name="config.xml" hash="b432bc464f23135829cb13b1f91e1bf5"/><file name="system.xml" hash="9108ca94f066f1f670f20b160b94b5c0"/></dir><dir name="sql"><dir name="ipgbase_setup"><file name="mysql4-install-1.0.0.php" hash="9f26fda45b2018bbfdc10af227daf057"/><file name="mysql4-upgrade-1.6.0-1.6.2.php" hash="9f26fda45b2018bbfdc10af227daf057"/><file name="mysql4-upgrade-1.6.1-1.6.2.php" hash="9f26fda45b2018bbfdc10af227daf057"/><file name="oldinstall.php" hash="041662b5c18b851f39b33f43143790e6"/></dir></dir></dir><dir name="IpgPagSeguroDireto"><dir name="Block"><dir name="Checkout"><dir name="Onepage"><file name="Success.php" hash="0274901ba7e9648780b72f710770ae20"/></dir></dir><dir name="Payment"><file name="Info.php" hash="a794e4aac1e13a68822992f5fa96d8d1"/><file name="Transferencia.php" hash="0ed375de2b70b7265fdb91c2682600e9"/></dir><dir name="Standard"><file name="Form.php" hash="e34c6bef87932c77ded10a1868ac6f9d"/></dir></dir><file name="Config.php" hash="655f77bd1631145c4af468f4d3b3450e"/><file name="ConfiguracoesSystem.php" hash="7f59641233af13e04be9f70f24fd7531"/><file name="ErrorMessages.php" hash="6fdb580780b6e80a2461590f6e875a37"/><dir name="Helper"><file name="Data.php" hash="ff061c9c9fd867805ac3b298758a9e80"/><file name="Math.php" hash="fe74fff13008878c27eb348c8a76a9e7"/><file name="Module.php" hash="0e5f994d98f6b3d486334b9001c97095"/><file name="Session.php" hash="80522a0bd1bf95ba3afb28cbd54dd859"/><file name="Validator.php" hash="36f9b40b0dfcea07ae257084dd6f61de"/></dir><file name="Instituicao.php" hash="3c5bb95ed02a0bf7c7653f700d2be3aa"/><dir name="Model"><file name="Credential.php" hash="c87539fd6da21fff2debb615ed461440"/><file name="Discount.php" hash="8a1fcffdb9e02c1522d26b8d45000f7b"/><dir name="Entity"><file name="Erro.php" hash="e300f8d08ac667f822362b2293fe67f0"/><file name="Payment.php" hash="1c790f608f7d76d7363355596588925a"/><file name="Sonda.php" hash="315ccc8e3beecb40b19cb2622c9f1ded"/></dir><file name="ExpiraPedido.php" hash="6d865bafcceaa5c0ccf292e582b03965"/><file name="IpgPagSeguroDireto.php" hash="3c75f285a46bb8943beb175faaa88bcb"/><dir name="Mysql4"><dir name="Entity"><dir name="Erro"><file name="Collection.php" hash="0a4ed47195a3edbcc58216378fdec781"/></dir><file name="Erro.php" hash="01ab9fdfca19f6393a90f54e5170bad7"/><dir name="Payment"><file name="Collection.php" hash="76dd9a7ded3c61d2b9d0c349984b3db9"/></dir><file name="Payment.php" hash="6e2bca7801e4a06b649ce715ac359ef1"/><dir name="Sonda"><file name="Collection.php" hash="127d63e742a6a1dcbd35a26109399116"/></dir><file name="Sonda.php" hash="0c62edf0d0434e53de4b6a55bca5ee5d"/></dir></dir><file name="Notification.php" hash="eb4cd561c36c7982370b954072762660"/><file name="Observer.php" hash="fbbc7cb56b02127a55ab2bb3d17687d6"/><file name="Payment.php" hash="d5f5acc81961d8239f4c8c5bc82b07a5"/><file name="PaymentMath.php" hash="fee02c75fafaba8309499ac7edd778a9"/><file name="PaymentType.php" hash="02febba3065d7532ff904a053381d3b9"/><dir name="Sales"><dir name="Order"><dir name="Invoice"><dir name="Total"><file name="Discount.php" hash="22d8e39d06bed4c3ac621a6f2ffdd00d"/></dir></dir></dir><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Discount.php" hash="a4d70e5400dfbf203f59bead9975065e"/></dir></dir></dir></dir><file name="ShopPayment.php" hash="05ec7f9e9f48e13570657112b8ae28a8"/><file name="Sonda.php" hash="e49b0d7994558a6c4ac3cf0b7c07c7e3"/><dir name="System"><dir name="Config"><dir name="Source"><file name="AllBoletoMethods.php" hash="6f1c8e07736a48f9f67e202ea581a3b7"/><file name="AllCardMethods.php" hash="ba77a82b2670c96b2cba9ad47fb97ea1"/><file name="AllDebitMethods.php" hash="ca292cf215445f6e01d9872439893070"/></dir></dir></dir></dir><file name="PaymentMode.php" hash="f9582422ec99b86ce30a5254d5d23de8"/><file name="PaymentModeOption.php" hash="b29fb665bf32a0ebc3602e02f28fe309"/><file name="PaymentTypeOption.php" hash="404d6025a5c5c239ba0a63931c0dac03"/><file name="PaymentTypeOptions.php" hash="7ecd40b6c73f9c172d21179d94627c20"/><file name="RuntimeException.php" hash="33bdee50173fed6e9afb192e9644bbe1"/><file name="ShopPayment.php" hash="f221c54377abea43bb6edbfaea7cbd53"/><file name="TypePaymentType.php" hash="436b7dc23ea05eddea6d2b820a43fa41"/><dir name="controllers"><file name="NotificationController.php" hash="5a294f3fccf87f763afb898565a5aaa3"/><file name="PaymentController.php" hash="b63f91168797ddb45276b723f67b391b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f484829cb4a8c7c6fe26cd3c7fcf3c56"/><file name="config.xml" hash="faa7ed470150e0f5c8d7964165131c89"/><file name="system.xml" hash="175ea6b05548b73ed73ce62e2dc8d6ef"/></dir><dir name="sql"><dir name="ipgpagsegurodireto_setup"><file name="mysql4-install-1.0.0.php" hash="948a5325d45c8bbdf71d8845be1e19ac"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="ipagare"><dir name="ipgbase"><dir name="adminhtml"><file name="index.js" hash="e904def09bc449a238ee8569c3dbdef0"/></dir><dir name="frontend"><file name="front.js" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir><dir name="ipgpagsegurodireto"><dir name="adminhtml"><file name="index.js" hash="d41d8cd98f00b204e9800998ecf8427e"/><dir name="sales"><dir name="order"><file name="view.js" hash="5974b72a0ed7113a714e1e9a7c3fbd1f"/></dir></dir></dir><dir name="frontend"><dir name="payment"><file name="pagseguro.directpayment.js" hash="3906d4e849cef663d2febb49b93bfc56"/><dir name="transferencia"><file name="index.js" hash="b47b4ec4bf75295460aac301684f24d5"/></dir></dir></dir></dir><dir name="lib"><file name="checkout.js" hash="c74d2232f703725abca4d053c774b5f4"/><file name="ipagare.js" hash="57611eb8b2f713c3239e7e5bb22cba4e"/><file name="json2.js" hash="708bbfa8d653ed0729fafed243c882ce"/><dir name="prototype"><file name="maskedinput.js" hash="0d3c58da91a93c62401c5d0a41bba5c6"/></dir></dir></dir></dir></target><target name="magelib"><dir name="Ipagare"><dir name="Log4php"><dir name="Appenders"><file name="LoggerAppenderAdodb.php" hash="b31121293d41f6843ca1c6ad01901d44"/><file name="LoggerAppenderConsole.php" hash="2792477e7338029e8cda53481cf98ab1"/><file name="LoggerAppenderDailyFile.php" hash="2b3d418de7e48b21771341f3364cf1c8"/><file name="LoggerAppenderEcho.php" hash="7f45c042382466a154d88fcd491176b1"/><file name="LoggerAppenderFile.php" hash="98a80507f99e14f97c4793fda3abd485"/><file name="LoggerAppenderMail.php" hash="917bd9b6fe510d6c253b6e1e3aaf7138"/><file name="LoggerAppenderMailEvent.php" hash="4342ab5ac479211504ec009644bd05ac"/><file name="LoggerAppenderMongoDB.php" hash="2dde79d71de5e8a1f523bef6ecc72599"/><file name="LoggerAppenderNull.php" hash="e38ebd40974eabae0eb0e762f49cd653"/><file name="LoggerAppenderPDO.php" hash="0f02596bdef5945b53ce5c72f3b95799"/><file name="LoggerAppenderPhp.php" hash="e2aacbc2a1d55fb36f1b711143b6cb9e"/><file name="LoggerAppenderRollingFile.php" hash="464c3b306d7149fc246ac1ad839a195b"/><file name="LoggerAppenderSocket.php" hash="8a025ed5613dea942d9d9d3cab64537a"/><file name="LoggerAppenderSyslog.php" hash="183341424b76299b3fb62d5d5373d786"/></dir><dir name="Configurators"><file name="LoggerConfiguratorBasic.php" hash="5dda01f3426881c4cbe99fbd41504940"/><file name="LoggerConfiguratorIni.php" hash="1161e5ff28324d64815b19598804f0f6"/><file name="LoggerConfiguratorPhp.php" hash="8a65513bb7cc76c0fdd1ac6b5fd1cdd1"/><file name="LoggerConfiguratorXml.php" hash="31c696227cb22fef992af71cd07bacea"/></dir><dir name="Filters"><file name="LoggerFilterDenyAll.php" hash="67ac2b4d1a82d53045e7ec940504d567"/><file name="LoggerFilterLevelMatch.php" hash="3d83fba7c6dc7b606dc72f582e3e75d1"/><file name="LoggerFilterLevelRange.php" hash="a1fbd796594269a9f56b0138f4e8b9e3"/><file name="LoggerFilterStringMatch.php" hash="49b47ffbf483ab1982efdf1ae36c364c"/></dir><dir name="Helpers"><file name="LoggerBasicPatternConverter.php" hash="cb8afd945b3b7b8ee6fbb6bc6682c6ef"/><file name="LoggerCategoryPatternConverter.php" hash="07df9aa9b861a94b0f2bef77d8195f72"/><file name="LoggerClassNamePatternConverter.php" hash="46fcf7e0525c978210959b4c8f99a9c5"/><file name="LoggerDatePatternConverter.php" hash="7879be01afaa81bdada923c694010bad"/><file name="LoggerFormattingInfo.php" hash="7fc68cd37a568bf040240f8d2f5452fe"/><file name="LoggerLiteralPatternConverter.php" hash="7e5f241006afd3726bbec5d42316e800"/><file name="LoggerLocationPatternConverter.php" hash="4ea94ff8e325b9b05700f5f4940324d9"/><file name="LoggerMDCPatternConverter.php" hash="a9faf52d09a9e385776131ee117086a4"/><file name="LoggerNamedPatternConverter.php" hash="780660488d166aaf047b6e765b2851d6"/><file name="LoggerOptionConverter.php" hash="9d8f4ebafbf4bab6ffc5c6f1da19da52"/><file name="LoggerPatternConverter.php" hash="5bd9ff7988942b1aaacebb991541a874"/><file name="LoggerPatternParser.php" hash="79afa5d4659028f856dac3e3546e9887"/></dir><dir name="Layouts"><file name="LoggerLayoutHtml.php" hash="b9dd5e069f47891ae80b4aac718c225d"/><file name="LoggerLayoutPattern.php" hash="531092855338182c1cdc5162579d4900"/><file name="LoggerLayoutSimple.php" hash="e90777249b3d648b948f47349af98a55"/><file name="LoggerLayoutTTCC.php" hash="90b1b1e2ccf178605d3fc10f0ccd45e5"/><file name="LoggerLayoutXml.php" hash="723de37428e27d090320b0265b08cd55"/></dir><file name="Logger.php" hash="cf27a8bdea9ab35d5ed804bb069ec621"/><file name="LoggerAppender.php" hash="1ae439bd84b9b433216b0dfc79e96c99"/><file name="LoggerAppenderPool.php" hash="e02f1242feec0f95cb3239707341825b"/><file name="LoggerConfigurator.php" hash="8813ec1d59384a7943a013cbf5b21637"/><file name="LoggerException.php" hash="8a9b3b2531834d4447a84b36f416258e"/><file name="LoggerFilter.php" hash="a8f7e6a19e5eb91495725ac9707592cd"/><file name="LoggerHierarchy.php" hash="60d36c0e5fc5ef51d233255c065ee338"/><file name="LoggerLayout.php" hash="acf9e61845a5a15ea5f0d108df1cf7d1"/><file name="LoggerLevel.php" hash="4c03c22532dde42ff380db07417c53ca"/><file name="LoggerLocationInfo.php" hash="d4583a76a6099c9ca543ccbed6cfd032"/><file name="LoggerLoggingEvent.php" hash="ac94bf4f76cbc3b432559d0e6da7b030"/><file name="LoggerMDC.php" hash="3834179417c2b0ce3e51a170fda6b155"/><file name="LoggerNDC.php" hash="97fbdaa1ced0f4f0f378a3486b36c0d1"/><file name="LoggerReflectionUtils.php" hash="5eddfb23215addb2c3dc5f80b1da26d1"/><file name="LoggerRoot.php" hash="7c9a9c821d1e0e1d966743138790f0c4"/><file name="LoggerThrowableInformation.php" hash="19df6cdd8568ffb448dbae5b855fb805"/><dir name="Renderers"><file name="LoggerRendererDefault.php" hash="bfaf9fd683fb746f673d462f858f19c0"/><file name="LoggerRendererException.php" hash="3339690dcb0c07af4b871b3c6a3b74b3"/><file name="LoggerRendererMap.php" hash="fbbb4c2bdd727db290c845f70390ca2a"/><file name="LoggerRendererObject.php" hash="b3f4d59f0239b11be7e21729c32ce537"/></dir><dir name="Xml"><file name="log4php.dtd" hash="fb7e60edf02964352b7ddee1f26d8924"/></dir></dir><dir name="PagSeguroDireto"><dir name="Config"><file name="Config.php" hash="2d67c29e984fbee45fc60131ad6e3e3c"/><file name="ConfigFile.php" hash="482a57ef37ca6f5495df68c6e40fdbe8"/></dir><dir name="Domain"><file name="AccountCredentials.php" hash="50d345ffe0dd84b81d84fdbc0e340524"/><file name="Address.php" hash="c9825d7716345dead087f7162a1ae56c"/><file name="Bank.php" hash="d2424594b68a3aabf797b504e8ceeaa9"/><file name="Billing.php" hash="c738d627ee596150ebcddb9afe703939"/><file name="Credentials.php" hash="98f0cb5aaa0d6f1a9aeebb29aeaf223a"/><file name="CreditCardHolder.php" hash="24be41d411bc03cd4b8a1c9490acff20"/><file name="Currencies.php" hash="b98adec3ad0f67225640fcfce5d3667a"/><file name="Document.php" hash="51cab7aa56cc302a7c3be4fc357a53f3"/><file name="Documents.php" hash="a2913d8ef4ad6de3d2158c41609ceb80"/><file name="Error.php" hash="548f8f13ff626606dd5ac2dda8835689"/><file name="HttpStatus.php" hash="a5802f2aceb319e74e015b16ea0d2f89"/><file name="Installment.php" hash="937c9a26ed960fbcdf8da0fd39d95369"/><file name="Item.php" hash="9c01399378937a54d8a04611891d8baf"/><file name="MetaData.php" hash="b2e3f4e022f18790582e414ad48fd091"/><file name="MetaDataItem.php" hash="a3089e56130ca86b6c8df2be1f761d99"/><file name="MetaDataItemKeys.php" hash="3bc1fadb932ca66c7596ee22f5750339"/><file name="NotificationType.php" hash="0609359c301d369dde01cd72954c2fd5"/><file name="Parameter.php" hash="83f3d8f0a855fe0256614968a89adeda"/><file name="ParameterItem.php" hash="042c62c14888640a3c5f874be695b498"/><file name="PaymentMethod.php" hash="922d043b2e5ba863150705c13dc4b589"/><file name="PaymentMethodCode.php" hash="7edda95ffc55fa23dc9c382e823833c2"/><file name="PaymentMethodType.php" hash="a5abb5b93433f10e16d811f25953ce3c"/><file name="PaymentRequest.php" hash="7b5693df62f02369391c74ec9c17b2af"/><file name="PaymentResponse.php" hash="bbdf29cdd577790b0188bd35367527bf"/><file name="Phone.php" hash="20897c7fd7e6cc2370471f2952597dea"/><file name="Sender.php" hash="d96623153d440c35e2a09492f62d0523"/><file name="SenderDocument.php" hash="7418593ca9bbe6e0a2e77c91a640fe11"/><file name="Session.php" hash="b1b6e3656de23af484d0ca7248ad3e2f"/><file name="SessionResponse.php" hash="2641e9dbbc2aaeb6bd309888e78ca9e0"/><file name="Shipping.php" hash="dd005c1fc3ebab16952aaef8d6b8c62a"/><file name="ShippingType.php" hash="5a73a81fa4b9ce225af7a7351074717c"/><file name="Transaction.php" hash="b0923ff9614cbfc170051f24fa373dca"/><file name="TransactionCancellationSource.php" hash="a333c636dfd3418d9b76e470950c8d28"/><file name="TransactionSearchResponse.php" hash="7dc92626c502a33ccc1f3ed6a9d08a77"/><file name="TransactionSearchResult.php" hash="fc75610c4573511433cde926609bb463"/><file name="TransactionStatus.php" hash="efe1e72becf197e4bd8b503594e43ef5"/><file name="TransactionSummary.php" hash="1ffb7de34fa29b35a0255319d032592b"/><file name="TransactionType.php" hash="8557855a5f728aa0b026cd285bfe6b71"/></dir><dir name="Exception"><file name="ServiceException.php" hash="daef1c54c6fd65279fb8c8a44a466580"/></dir><dir name="Helper"><file name="Helper.php" hash="045dc42d8c8257530daa5c399f1923b4"/></dir><file name="Library.php" hash="8ce1afba07bc2b8657ffecc33f4b6ff9"/><dir name="Loader"><file name="AutoLoader.php" hash="7a04b2b246fb6be1f9eb526e9b7ce590"/></dir><dir name="Parser"><file name="PaymentParser.php" hash="531afbb624bea82ea44fee24310d2881"/><file name="PaymentParserData.php" hash="32cbe48ef53496a7082e2e8cfcd8a462"/><file name="ServiceParser.php" hash="7de7d0a3946d7867e7f18b37804c1129"/><file name="SessionParser.php" hash="3aa9d4b781131ae7ca62f97fba1d10f4"/><file name="TransactionParser.php" hash="49cab1482a17b5044f1fa2f980901f46"/></dir><dir name="Resources"><file name="Resources.php" hash="22add0d4ea4b812954fe2bab25998ad1"/><file name="ResourcesFile.php" hash="64f9ecd86948668bafe03993f0e1fed1"/></dir><dir name="Service"><file name="ConnectionData.php" hash="3826872e3fd15473512b268b049c9578"/><file name="NotificationService.php" hash="bc43e2cc0b744e88e6f6b61974cc0aba"/><file name="PaymentService.php" hash="2dac4bdc6f010ac0bd1f46fcb7fa9c9b"/><file name="SessionService.php" hash="90adbe0e5421182cf03dd3ef6c4c318c"/><file name="TransactionSearchService.php" hash="1602f565ba5c155019d67a2ddae69b13"/></dir><dir name="Utils"><file name="HttpConnection.php" hash="f3310fb12e172b8d6c9d30ec3da13386"/><file name="XmlParser.php" hash="7dbbb7a77add0e57816f53b4e6bfd652"/></dir></dir></dir></target><target name="magemedia"><dir name="ipagare"><dir name="ipgbase"><dir name="images"><file name="imprimir_boleto.png" hash="8936fa0871a0d2b62f4efc522e1504e3"/></dir></dir><dir name="ipgpagsegurodireto"><dir name="bandeiras"><dir name="101"><file name="10x.gif" hash="4a55ee1bf3afbbf86877e6db4587fdc1"/><file name="11x.gif" hash="5520afac3745af1afac2c48b0b401638"/><file name="12x.gif" hash="be3fa56848763d1a2cde6358674872d4"/><file name="1x.gif" hash="c5c0ff6368122c177335f862f9bedf6c"/><file name="2x.gif" hash="7e557dabe2080890f6053426be87d956"/><file name="3x.gif" hash="42451c7680825e87f74ef4ee5eff76db"/><file name="4x.gif" hash="d22cdd50884e8ebb2deaf26ea267bcdb"/><file name="5x.gif" hash="08758844e3dbe3ba29f7026ea83d77e4"/><file name="6x.gif" hash="14fbaeb0032f2711e7cf9582f50448a0"/><file name="7x.gif" hash="74423a7a5147c8b71055e70ac55c8d1a"/><file name="8x.gif" hash="83869f8ea5a893dafd9587ed4da39580"/><file name="9x.gif" hash="70dfbd10cd17c2dab2dba4894346ee9e"/></dir><dir name="102"><file name="10x.gif" hash="19bccb8d0fa48ec5937ecb1a0b8f6640"/><file name="11x.gif" hash="8a75bc6e6f5655dd0b48818e72b4c712"/><file name="12x.gif" hash="59890c5e572f6ad22142ce4966e35789"/><file name="1x.gif" hash="2f88255a1115f54ff49ca16b975f04b7"/><file name="2x.gif" hash="49e00e9419cf2938eb499c705c3ee9f6"/><file name="3x.gif" hash="4c7972ee6c3060847790844b611ca000"/><file name="4x.gif" hash="983fc72685e10267042ffdb371507814"/><file name="5x.gif" hash="5dd1457d491797f3b7df79b520ed8ab7"/><file name="6x.gif" hash="df3d279dc56bd2660d65e39169a0cc8c"/><file name="7x.gif" hash="90367aaa1665bdcafde8f62fce42ad7c"/><file name="8x.gif" hash="d83ffff382049265218394f86e38f675"/><file name="9x.gif" hash="9ad51c1fee98c44e10182dcea2a2ecb5"/></dir><dir name="103"><file name="10x.gif" hash="59ff1f8555c4c560296cb95e2966c8ed"/><file name="11x.gif" hash="76e8ded47cce82b1aa3ba102e8dcfadb"/><file name="12x.gif" hash="298e11d0383a51d4bac4ce985e9dd3c9"/><file name="13x.gif" hash="fbcea53d5a947b6650709867639b1a24"/><file name="14x.gif" hash="cf2324c3ee974f52999f53ff3dab1da0"/><file name="15x.gif" hash="ae4bfe2d705c5c07af949d4fed44a0e7"/><file name="1x.gif" hash="709b03a6b2f9be75340d333023e769ab"/><file name="2x.gif" hash="206624b949c47bb12b5a8cdc39ba61ce"/><file name="3x.gif" hash="7c0c93b4c4a964150fca6bf55b256424"/><file name="4x.gif" hash="a6a38febfdfe79d26994435a501b59bf"/><file name="5x.gif" hash="d5cf7cafaed90a576943ce4ef77539f1"/><file name="6x.gif" hash="2ecf07e99ce028332bb01aab2c03006c"/><file name="7x.gif" hash="7f9339559c680fa624b8d268f8e9dac2"/><file name="8x.gif" hash="a1e8ca9ac0c1862f4e5e70933374757f"/><file name="9x.gif" hash="8ab11eb6a5fc51b1d542f5815e588025"/></dir><dir name="104"><file name="10x.gif" hash="29f045c1880865c8c7b0077eac12df9c"/><file name="11x.gif" hash="acd550840a00ca856f1cba278c6da8fc"/><file name="12x.gif" hash="37a8f20918e522a3b45ae8a2d77f0749"/><file name="1x.gif" hash="6a8d41031c5913512387776e5dd1b7dd"/><file name="2x.gif" hash="2ed918382deece4b1d00351179143491"/><file name="3x.gif" hash="ff3e844f8bcefe47efee512bbf1a21d5"/><file name="4x.gif" hash="dd41efb9a3672e2d5f9f977f51328242"/><file name="5x.gif" hash="fd8c0e2be926fd6179a9ea2e57abaffe"/><file name="6x.gif" hash="5a960d3aa0be054c240a2910a4b5281a"/><file name="7x.gif" hash="61493b39eca1a607c315b09b37ab870a"/><file name="8x.gif" hash="38b53c64eb0d66484e9b03544b1e5e04"/><file name="9x.gif" hash="6c5cbdbcbbb070b2fbd3c9f289f50a69"/></dir><dir name="105"><file name="10x.gif" hash="8e4db22b31a32514e33bd4700f559e1a"/><file name="11x.gif" hash="1212d4ba1a7367055aad009ee3cc686e"/><file name="12x.gif" hash="da3ecd1c88aaddfffdaf5d1a4db84654"/><file name="1x.gif" hash="2ad6d1df9bf66b830c9750103c798043"/><file name="2x.gif" hash="43a4f5941a3a6a176149fa5877add2d2"/><file name="3x.gif" hash="9577a96941f96cfe6d9c3145f6ded0fb"/><file name="4x.gif" hash="3f31ef5194e3ff90e71be0c4e2a9243a"/><file name="5x.gif" hash="1aae0a4acd331a35e6233c5eeafada72"/><file name="6x.gif" hash="2fc9a55a96a4c68caf21dc9938c4d6f3"/><file name="7x.gif" hash="b9737e8f76795cd57e4f66c3f8382c44"/><file name="8x.gif" hash="236d05bdf07fec69951789abdb1fd876"/><file name="9x.gif" hash="032680d27205555b186c18e7a43ef163"/></dir><dir name="106"><file name="10x.gif" hash="420e04abec83946ecf9274098a280b0b"/><file name="11x.gif" hash="2c677142e20148cc7bab3a38b61a25c5"/><file name="12x.gif" hash="d2357ca986409a6cadd9309796b26a87"/><file name="13x.gif" hash="34cae59a3a80aef42f3ce3c89d2853f1"/><file name="14x.gif" hash="bf81e6e640401067ea6310c0a120e489"/><file name="15x.gif" hash="07676277749dfa4b68431e2c9b7abe9d"/><file name="16x.gif" hash="2806876fdb82c0b5e2d1b3932738a575"/><file name="17x.gif" hash="660b480066354c427ae4873c194b67cf"/><file name="18x.gif" hash="69683207398c3358e66efb60c9b4739f"/><file name="1x.gif" hash="d1c3d9370fbc0adb9cedd3c835566748"/><file name="2x.gif" hash="35df30ef065194029712ef2ae946d8d9"/><file name="3x.gif" hash="5afcdb8abf8ba8f9042db37d3df1560e"/><file name="4x.gif" hash="000ee5bf97aec9e8faf7c05af694fdb8"/><file name="5x.gif" hash="956b0ea766647e90e2182532aa177528"/><file name="6x.gif" hash="c52f9e2e723bf87773f9275a17553bf1"/><file name="7x.gif" hash="3e222ec179cc12e84eca242413137ec9"/><file name="8x.gif" hash="b8508ac2137f353da778ef08a62a1126"/><file name="9x.gif" hash="87796b31bca3a82ad7ec157a9d89b135"/></dir><dir name="107"><file name="10x.gif" hash="e16c1f55a33529ec4dd175860c4f6338"/><file name="11x.gif" hash="d4559737c6bc6af60e5fe91fb8d31c4d"/><file name="12x.gif" hash="ad4573e93be74fb8416e1affd5a729e7"/><file name="1x.gif" hash="332549954dee04569ea4577a2220d24f"/><file name="2x.gif" hash="7cdefb9f0c24d4895f960cc328ba8504"/><file name="3x.gif" hash="3d4e2001a00acbee7973437e190fe5a7"/><file name="4x.gif" hash="d1f5d76c7565f55eeab4d25bcd0f826e"/><file name="5x.gif" hash="8bac322e17535f5a02516c3a9b8add3a"/><file name="6x.gif" hash="38cd876b372a12ad4059328cc4123523"/><file name="7x.gif" hash="a24a91ae6175d16f1517fcff821e1ec8"/><file name="8x.gif" hash="48f39ffb0a5295917f9d3581045d4296"/><file name="9x.gif" hash="45963f41deb37ed7ba9116f5a53328f8"/></dir><dir name="108"><file name="10x.gif" hash="2138de6dbf95059632ce0b58f0ed2084"/><file name="11x.gif" hash="9535bfbc62013599ecc5cd42702a632f"/><file name="12x.gif" hash="b8f95f59209950208ae3e5b32985a5a3"/><file name="1x.gif" hash="f72a78109c746f0fb7364b57706ad3d0"/><file name="2x.gif" hash="5f4476382b35572baac19d74008e0555"/><file name="3x.gif" hash="293fa94977e7b8b9f969d5a8ba831bb3"/><file name="4x.gif" hash="bfbbe55eb0082c097b0e21656603990b"/><file name="5x.gif" hash="4eea2441dceb6cfbf79a5eee33eccde8"/><file name="6x.gif" hash="30bd668b490be8d164af6f4553620e5d"/><file name="7x.gif" hash="208919abcb116d52373e0f171468a5ab"/><file name="8x.gif" hash="d3c98e0e6f5c086b003543893677ba94"/><file name="9x.gif" hash="8aec644baf163b8f661d6d5ae0d02fce"/></dir><dir name="109"><file name="10x.gif" hash="f7e44949748b22e5d28bb9e0d12dfb57"/><file name="11x.gif" hash="278b5dac10ba228f7751922ec4a1cb4a"/><file name="12x.gif" hash="bbd92898ce39e3a70a1373c7370210cb"/><file name="1x.gif" hash="6997f0bd017aafdbfd8e05ac2a91d0d3"/><file name="2x.gif" hash="4c995c76b4f2886087c1a90e5a282e71"/><file name="3x.gif" hash="082ea40638d99e7c863ab8daad2c7edc"/><file name="4x.gif" hash="949ab5e13a3f443073a39f5a12e5634b"/><file name="5x.gif" hash="6f15cf163cc2430099168a369a0eef7c"/><file name="6x.gif" hash="7f758876fd04ef050229707ef0f640da"/><file name="7x.gif" hash="e2965e9a11acf711da88e1dbe49cf95a"/><file name="8x.gif" hash="8d25dbed06a16801fa859bc5dc06efe6"/><file name="9x.gif" hash="d97e73212de7ea3c6139f88428b51225"/></dir><dir name="110"><file name="10x.gif" hash="64094c8751c82fed9e3e96c74c984911"/><file name="11x.gif" hash="a2a0e930f893afc612959e2044965a93"/><file name="12x.gif" hash="c7727dd4938575bb8d62ec6440ee893e"/><file name="1x.gif" hash="745e605a964b7fa0211ae350e5dda8d7"/><file name="2x.gif" hash="af4980bc29f336ee08f5cdbaad846be2"/><file name="3x.gif" hash="2a1af54bd8a0b83271495265cde4a31e"/><file name="4x.gif" hash="81f047b79389d1c90c4dbaaa9b1ae47b"/><file name="5x.gif" hash="8deae8c778dbb57218f823c9181ce3d8"/><file name="6x.gif" hash="d5de238b8c43580f44194d7dbddf1679"/><file name="7x.gif" hash="bd87aee2798ab59edade92286c6ec178"/><file name="8x.gif" hash="cccdb843316b3635e1abb405e062ec2e"/><file name="9x.gif" hash="26f649edd6401aceace857453b9767cf"/></dir><dir name="111"><file name="10x.gif" hash="60e9805557f5011ecebbccbff9ae6ca9"/><file name="11x.gif" hash="0c05c409b809c366780863ebb3868048"/><file name="12x.gif" hash="db8c015828f68146b47740a9ef1ed6c1"/><file name="1x.gif" hash="e81b4492a6867ea8fb9c91052d533973"/><file name="2x.gif" hash="4735c01a28b6112264f0bd0a732296dc"/><file name="3x.gif" hash="cf5eb35d623c2f0436162eb140336c02"/><file name="4x.gif" hash="2b409b591e8b6c6228ad1a37d932fcf3"/><file name="5x.gif" hash="75d16ba244560661ed1ca0d1fafd682d"/><file name="6x.gif" hash="6a87720368b08dc3915bfbec5919980e"/><file name="7x.gif" hash="7af1499bc7e2ad68d3154a3172828148"/><file name="8x.gif" hash="5f17c4f3dcffeb2e22c02514e5f7847d"/><file name="9x.gif" hash="1ddf17a2b8b377c4c0eeae87824a855e"/></dir><dir name="112"><file name="10x.gif" hash="cbdeb934626284d6397f67cded17291c"/><file name="11x.gif" hash="cd219544bfd9f854e9f52f4fdb4c95d3"/><file name="12x.gif" hash="eb5bfe89b8f4815428e4fc8e97ff5b21"/><file name="1x.gif" hash="2a89cc173675ee3a907d7c35f24469b3"/><file name="2x.gif" hash="0e30496e56ad8282d6d9f9a21c850c69"/><file name="3x.gif" hash="be5676bdc1d01ca11a571c76da422940"/><file name="4x.gif" hash="6f5af9555eb4634326b9bbdbd8401484"/><file name="5x.gif" hash="1deb41ce24d8558569ba704afa9cf1f9"/><file name="6x.gif" hash="e2951307912c939e5516965a1baff1dc"/><file name="7x.gif" hash="3af1077a9f1a56237c555eeee80ae80a"/><file name="8x.gif" hash="cb234a96f2b03a0fb1566d966c4f5daa"/><file name="9x.gif" hash="533d695670b8dd8bca7ad049d05525b6"/></dir><dir name="113"><file name="10x.gif" hash="200d31ad1dc1bdc0b2fa6127e5c59b5c"/><file name="11x.gif" hash="79277d891e5bd45ee74446280af32b56"/><file name="12x.gif" hash="2ae388d024b586bea264ae1a90c53735"/><file name="1x.gif" hash="ebc1787bb30dd005ca9634d23b3b5080"/><file name="2x.gif" hash="7daff19f0323e4f9cda19c879496c952"/><file name="3x.gif" hash="38752b476cdf7b452a32df37071c9776"/><file name="4x.gif" hash="f97f8db04756ea534ca3ec00e1212241"/><file name="5x.gif" hash="7ba28706c80512dbd99fd0e7b0d2136e"/><file name="6x.gif" hash="ed6b0c9945fa6c75151d868330090ff0"/><file name="7x.gif" hash="fbc8d61b57a24b14c904b5867ba6a1fc"/><file name="8x.gif" hash="caed87f745d6a43812529ff630a808bb"/><file name="9x.gif" hash="5ba0166bdad7b47ed44c547499ab826d"/></dir><dir name="114"><file name="10x.gif" hash="a366c82e3217f0a326943f56617a8aef"/><file name="11x.gif" hash="c9f2532e008108cb722baa17059021f3"/><file name="12x.gif" hash="494c83118f467839572252e2073e7bf5"/><file name="1x.gif" hash="d321337c74805e74648f2f2d7e01e2bf"/><file name="2x.gif" hash="b8d2021e42d9a40cd058b0c1fa6c19c2"/><file name="3x.gif" hash="941b1d22b2a978e0fdf12b382c0864c2"/><file name="4x.gif" hash="5a1f55104aad8d5a17ef2458db13a5cc"/><file name="5x.gif" hash="e89510054be6e00acba9117871269815"/><file name="6x.gif" hash="a2f24186dfe55ee2bdcc50e5f393327f"/><file name="7x.gif" hash="d49c8fbf3142d7fe0b1df3ffe18b5ba0"/><file name="8x.gif" hash="7576060a368fccb643a8b0905e9b61a3"/><file name="9x.gif" hash="8c5af3cd070903e1b76740d458ef5a4e"/></dir><dir name="115"><file name="1x.gif" hash="04fa63c67caad86494393209d28ac923"/><file name="2x.gif" hash="3c524fa472f7709ad5508f45c47f7f56"/><file name="3x.gif" hash="cffeb44639fb3bc2ceddb5f54766e38b"/></dir><dir name="116"><file name="10x.gif" hash="9c402b6dbd31a380b2c3588eba9a9a66"/><file name="11x.gif" hash="281208ec6a979441bdc928c52dd65b55"/><file name="12x.gif" hash="0fcae55b2d02ac3ea533a9c545648375"/><file name="1x.gif" hash="c69cc955eb768c91ecf6b6084b44740e"/><file name="2x.gif" hash="0fa13f4551fbea7a015f9dfc43b7fb17"/><file name="3x.gif" hash="a0b1fc1700c4797feb1e5c87d7cd2053"/><file name="4x.gif" hash="f83935899bd6b52f01674b677151a78e"/><file name="5x.gif" hash="889270be485eac5d7caa272708651694"/><file name="6x.gif" hash="937144d56773dacef4961277f3004f5c"/><file name="7x.gif" hash="78054c2966272923d25b27e8c0e945ed"/><file name="8x.gif" hash="de996a62976834da191250fa990295c4"/><file name="9x.gif" hash="f54a6f7faeb02bd9a6123610beba0824"/></dir><dir name="117"><file name="10x.gif" hash="443be829514c7e6e7518888677615f41"/><file name="11x.gif" hash="001deb7ea075caccb5cdf8fc4e8fa6b1"/><file name="12x.gif" hash="d4599dd49b386e3a74730bcb21e3929c"/><file name="1x.gif" hash="d0265b00ada4928b8a3c3bc4b97d4676"/><file name="2x.gif" hash="4829bd3c0ce9db1deba3b6c808a201b4"/><file name="3x.gif" hash="df7bca14f403791c148b087a77fa3596"/><file name="4x.gif" hash="26345d22a1d07268a243842f4f0f4cb3"/><file name="5x.gif" hash="43ad89d3b7ac910187f746539e5c3c56"/><file name="6x.gif" hash="3b3838700e3d8fcb95c8bdef4bfc9a89"/><file name="7x.gif" hash="181cdc54a453e4b05991a145fd536480"/><file name="8x.gif" hash="e18e686d624251c88ba9b56e9a7fe709"/><file name="9x.gif" hash="e7e4985001269bbfd622c5238aaba996"/></dir><dir name="118"><file name="1x.gif" hash="f55227222ca8e47eb1679c4afb2ba680"/><file name="2x.gif" hash="90223b8794f6874c291880dfdf530135"/><file name="3x.gif" hash="795b4271728eed5b43281f746d2a3255"/><file name="4x.gif" hash="1d4ec9b9d3feba9268dafc1d822b6034"/><file name="5x.gif" hash="800dace856d7f61082793fbf3dfc3b7f"/><file name="6x.gif" hash="90bcacb3e0e0fffa08bfe4703ffd6136"/></dir><dir name="119"><file name="10x.gif" hash="053c0ab6930a26f25ddb13c5f617d0b1"/><file name="11x.gif" hash="8844e8ab115b6e144a699b0a7a51364b"/><file name="12x.gif" hash="cbdedfb1faddd7fc298577865555db76"/><file name="1x.gif" hash="a46c11d4a1aa59ba3757f851b46e1c8d"/><file name="2x.gif" hash="0fdbc41482038ce7a2e913f96ab394e9"/><file name="3x.gif" hash="eb5d05eb95d66515a9dd815898224c4a"/><file name="4x.gif" hash="97369c1d24851a298effcab4ece21ac8"/><file name="5x.gif" hash="ee660e427087741daaba6d465433cc33"/><file name="6x.gif" hash="2fe2c7cb4313ae7b636cf7d481a773a0"/><file name="7x.gif" hash="07ad79ff61400357720824edad77e192"/><file name="8x.gif" hash="cd1cea43cb0a4c1faa5e45e5d5c93656"/><file name="9x.gif" hash="478345790146f4014d7aaa3e0b8018e6"/></dir><dir name="202"><file name="1x.gif" hash="9c9d9237fd11ce7768b63014e588d1e6"/></dir><dir name="301"><file name="1x.gif" hash="2f2781a5859a71d8591852fc3f87e05d"/></dir><dir name="302"><file name="1x.gif" hash="f5a345bce7660baa7120d37e7a3f135c"/></dir><dir name="304"><file name="1x.gif" hash="b0c7a90a2062595916ff50f1d7ce041f"/></dir><dir name="306"><file name="1x.gif" hash="8e22d13bfdd55a19f534148507655f53"/></dir><dir name="307"><file name="1x.gif" hash="9e34ca3a26163dcf1c7877ac01e8b51b"/></dir></dir><dir name="images"><file name="logo_pagseguro.png" hash="152171c2f59670f4b0dfbd7e8166cec6"/><file name="logo_pagseguro_.png" hash="d8dc8c1cdbaed742bb6f5d0bb65d9ab6"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="ipgbase"><dir name="css"><dir name="images"><dir name="francybox"><file name="blank.gif" hash="325472601571f31e1bf00674c368d335"/><file name="fancy_close.png" hash="6e2879a324a76e9972ebc98201aae1d8"/><file name="fancy_loading.png" hash="b1d54c240cf06e7f41e372d56919b738"/><file name="fancy_nav_left.png" hash="3f3e406102152cd8236383568a40ba35"/><file name="fancy_nav_right.png" hash="216e4bde5bddeeaa60dc3d692890a68e"/><file name="fancy_shadow_e.png" hash="fd4f491080d29fade5080877f1ba4c8b"/><file name="fancy_shadow_n.png" hash="18cde16379b2ceadef714d9b346d09ec"/><file name="fancy_shadow_ne.png" hash="63adf788acf193d4e4f3642d7d793125"/><file name="fancy_shadow_nw.png" hash="c820c878aedb7a7f9ebd7135a58e7c65"/><file name="fancy_shadow_s.png" hash="9b9e5c888028aaef40fe5b6a363f1e29"/><file name="fancy_shadow_se.png" hash="a8afd5a008884380ee712d177105268f"/><file name="fancy_shadow_sw.png" hash="f81cc0fee5581d76ad3cebe47e7e791b"/><file name="fancy_shadow_w.png" hash="59b0e63eb059e58d932cfd53da4d87e6"/><file name="fancy_title_left.png" hash="1582ac2d3bef6a6445bf02ceca2741cd"/><file name="fancy_title_main.png" hash="38dad6c1ed4bdc81c0bec721b2deb8c2"/><file name="fancy_title_over.png" hash="b886fd165d4b7ac77d41fb52d87ffc60"/><file name="fancy_title_right.png" hash="6cbe0c935511e7f9a2555ccb6a7324c4"/><file name="fancybox-x.png" hash="168696d8a694214090ef90e029cdf393"/><file name="fancybox-y.png" hash="36a58859beb9a6b19322a37466b9f78e"/><file name="fancybox.png" hash="11e57e492ee0311540967cc7a1e6e3e2"/></dir></dir><file name="styles.css" hash="2a9cd4aa3ec3134806bf70a6edd568e6"/></dir><dir name="images"><file name="help.png" hash="cc45e0c10b3bc12f6c2c4b8d89ddfd2d"/><file name="logo-ipagare-menu.png" hash="e5b2d6404f5c6819c581505e3d86b9f9"/><file name="logo-ipagare.png" hash="14907bbc308c30264409f6d12cce01f6"/></dir></dir><dir name="ipgpagsegurodireto"><dir name="css"><file name="styles.css" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="ipgbase"><dir name="css"><dir name="checkout"><file name="osc.css" hash="5a6d9a58763b85c51a98584bbc5ce128"/></dir><file name="styles.css" hash="18051a9cb1bd7459e397aa4345fd7a87"/></dir><dir name="images"><file name="ajax-loader-tr.gif" hash="1ae32bc8232ff2527c627e5b38eb319a"/><file name="bkg_btn-close.gif" hash="df3f2332f0bad01e031deb22b81f630c"/><file name="bkg_btn-close2.gif" hash="822457d78fb3c21dc12e9777d83eb4f1"/><file name="boleto.png" hash="5fb45044bd1c9136f8711e28c49f8108"/></dir></dir><dir name="ipgpagsegurodireto"><dir name="css"><file name="cvm.css" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="opc.css" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="styles-ie7.css" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="styles.css" hash="68f9d805bfdd1cdd89e984e6064b6eaa"/></dir><dir name="images"><file name="boleto.png" hash="5fb45044bd1c9136f8711e28c49f8108"/><file name="bubble.png" hash="633d5cc5048f0f7996f037c19ce44a83"/><file name="codigo_bin_1.png" hash="8f74e05f4868275b2aa4aba7f5830a1c"/><file name="codigo_bin_2.png" hash="56aae6868f83a53131226803d3ecebe3"/><file name="cvv.gif" hash="9a9eccd9f0f137c13323816b92b43d22"/><file name="padlock_clean.png" hash="f8358258d72e3b8f9ef29bfd68fa4fbb"/><file name="padlock_closed.png" hash="b42020410a6e2d992790b35cc97e1db1"/><file name="pagseguro.png" hash="fa319cc6d61fda11ba06f8f5499b1dcb"/><file name="pagseguro.pxm" hash="4a78a49f87dfd787ff8e80843100b5e7"/><file name="pagseguro.pxm.sb-cd4c37b0-h3WR13" hash="2548c76ac14a4e385fdb632e3b1aa928"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>5.6.0</max></php></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/ipgbase/css/images/francybox/blank.gif ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_close.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_loading.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_nav_left.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_nav_right.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_e.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_n.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_ne.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_nw.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_s.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_se.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_sw.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_shadow_w.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_title_left.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_title_main.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_title_over.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancy_title_right.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancybox-x.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancybox-y.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/images/francybox/fancybox.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/css/styles.css ADDED
@@ -0,0 +1 @@
 
1
+ #ipagare_ipagare #topo_ipagare{background-image:url("../images/logo-ipagare.png");background-repeat:no-repeat;background-position:right}ul.tabs a.ipgcore-section,ul.tabs a.ipgcore-section:hover{background:url("../../images/tabs_span_bg.gif") repeat-x scroll 0 100% transparent;border-bottom:medium none;padding:.3em .8em .28em 1.5em}ul.tabs a.ipgcore-section:hover{background-color:#d8e6e6}ul.tabs a.ipgcore-section.active,ul.tabs a.ipgcore-section.active:hover{background-color:#fff}ul.tabs a.ipgcore-section span,ul.tabs a.ipgcore-section:hover span{background:url("../images/logo-ipagare-menu.png") no-repeat scroll 0 0 transparent;height:0;overflow:hidden;padding:20px 0 0 0;width:200px}div.box a.link_ipagare{background:url("../images/btn_bg.gif") repeat-x scroll 0 100% #ffac47;border-color:#ed6502 #a04300 #a04300 #ed6502;border-style:solid;border-width:1px;color:#fff;cursor:pointer;font:bold 12px arial,helvetica,sans-serif;padding:1px 5px 1px 5px;text-align:center!important;white-space:nowrap;text-decoration:none;margin-right:5px}div.box a:hover,p.box a.link_ipagare_debug_log:hover,p.box a.link_ipagare_debug:hover{background:url("../images/btn_over_bg.gif") repeat-x scroll 0 0 #f77c16}div.box a:active,p.box a.link_ipagare_debug_log:active,p.box a.link_ipagare_debug:active{background:url("../images/btn_on_bg.gif") repeat-x scroll 0 0 #f77c16}.entry-edit-head-ipagare{background:no-repeat scroll 5px 5px #fcfac9;padding:5px 5px 1px 60px;border:1px solid #d7c699!important;height:20px;font-weight:bold}.entry-edit-head-ipagare #opcoes{padding-right:5px;text-decoration:underline;color:#000}img.bandeira_ipagare{float:right}.opcoes-ipagare-captura{background:url("../../images/btn_bg.gif") repeat-x scroll 0 100% #ffac47;border-color:#ed6502 #a04300 #a04300 #ed6502;border-style:solid;border-width:1px;float:left;color:#fff;cursor:pointer;font:bold 12px arial,helvetica,sans-serif;text-align:center!important;white-space:nowrap;text-decoration:none;margin-right:5px;width:130px;font-size:11px;height:17px;padding:2px 0 0 0}.opcoes-ipagare-cancela{background:url("../../images/btn_back_bg.gif") repeat scroll 0 100% #ccc;border-color:#ccc #aaa #aaa #ccc;border-style:solid;border-width:1px;float:left;color:#fff;cursor:pointer;font:bold 12px arial,helvetica,sans-serif;text-align:center!important;white-space:nowrap;text-decoration:none;margin-right:5px;width:160px;height:18px;padding:2px 0 0 0}.entry-edit-head-ipagare a:hover#opcoes{text-decoration:none}.opcoes-ipagare-captura a.link_ipagare,.opcoes-ipagare-captura a.link_boleto{text-decoration:none;color:#fff}.opcoes-ipagare-cancela a.link_ipagare{text-decoration:none;color:#000}span.ipagare_captura{background:url("../../images/save_btn_icon.gif") no-repeat;padding:0 0 0 20px}span.ipagare_cancela{background:url("../../images/cancel_icon.gif") no-repeat;padding:0 0 0 20px}.div_escore_clear_sale{border:2px solid #d6d6d6;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;float:right;width:60px;height:36px;text-align:center;padding:2px}.escore_clear_sale{font-size:16px;font-weight:bold}.bandeira_clearsale_status{float:left;margin-right:10px}
skin/adminhtml/default/default/ipgbase/images/help.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/images/logo-ipagare-menu.png ADDED
Binary file
skin/adminhtml/default/default/ipgbase/images/logo-ipagare.png ADDED
Binary file
skin/adminhtml/default/default/ipgpagsegurodireto/css/styles.css ADDED
File without changes
skin/frontend/base/default/ipgbase/css/checkout/osc.css ADDED
@@ -0,0 +1 @@
 
1
+ .checkoutcontainer input{height:25px;margin-bottom:5px;font-size:12px}.checkoutcontainer select{padding:5px;overflow:hidden;height:30px;padding-top:5px;width:250px}.checkoutcontainer option,.checkoutcontainer select{font:1.1em/1 "FuturaStdMedium",Futura,Helvetica,Arial,sans-serif;padding-left:5px;outline:0 none}.checkoutcontainer option{background-color:#fff;border-bottom:1px solid #999;padding:5px;outline:0 none;border:1px solid #e0e0e0}
skin/frontend/base/default/ipgbase/css/styles.css ADDED
@@ -0,0 +1 @@
 
1
+ div.ipagare .cvv-o-que-e-isso{float:left;text-align:center;width:auto;height:30px;line-height:30px;margin-left:10px}div.ipagare .cvv-o-que-e-isso a{cursor:help;font-size:11px}.onestepcheckout-totals total{border-collapse:collapse}table.onestepcheckout-totals tr.total td{font-weight:bold}#ipagare a.boleto-link{background-image:url('../images/boleto.png');background-repeat:no-repeat;display:inline-block;height:25px;width:130px}#message-popup-window-mask{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;z-index:980;background-color:#efefef;opacity:.5;-ms-filter:"alpha(opacity=50)"}.message-popup{position:absolute;z-index:990;width:407px;top:-9999em;left:50%;margin:0 0 0 -203px;background:#f3bf8f;padding:0 4px 4px}.message-popup.show{top:280px}.message-popup .message-popup-head{padding:1px 0}.message-popup .message-popup-head h2{padding:0 10px;margin:0;font:bold 12px/19px Arial,Helvetica,sans-serif;color:#644f3b}.message-popup .message-popup-head a{float:right;border:1px solid #ea7601;padding:0 12px 0 7px;background:url(../images/bkg_btn-close.gif) 0 50% repeat-x!important;font:normal 12px/17px Arial,Helvetica,sans-serif;color:#fff;text-decoration:none!important;cursor:pointer}.message-popup .message-popup-head a span{float:left;background:url(../images/bkg_btn-close2.gif) 0 50% no-repeat;padding-left:19px}.message-popup .message-popup-content{background:#fdf4eb;padding:21px 21px 10px}.message-popup .message-popup-content .message-icon{float:left;width:50px;padding:47px 0 0;background-position:50% 0;background-repeat:no-repeat;font-size:10px;line-height:12px;text-transform:uppercase;text-align:center;overflow:hidden}.message-popup .message-popup-content .message-critical{background-image:url(../images/severity_critical.gif);color:#e41101}.message-popup .message-popup-content .message-major{color:#f55600}.message-popup .message-popup-content .message-minor{color:#ff9e22}.message-popup .message-popup-content .message-notice{color:#659601}.message-popup .message-popup-content .message-text{float:right;width:295px;min-height:4.5em;overflow:hidden;color:#644f3b}.message-popup .message-popup-content .read-more{margin:7px 0 0;text-align:right}.message-popup .message-popup-content .read-more a{background:url(../images/more_arrow.gif) 0 50% no-repeat;padding-left:14px;text-decoration:underline}.message-popup .message-popup-content .read-more a:hover{text-decoration:none}.message-popup .message-popup-head:after,.message-popup .message-popup-content .message:after{display:block;clear:both;content:".";font-size:0;line-height:0;height:0;overflow:hidden}#ipagare-loading-mask{color:#d85909;font-size:1.1em;font-weight:bold;opacity:.8;position:absolute;text-align:center;z-index:500}#ipagare-loading-mask .loader{background:none repeat scroll 0 0 #fff4e9;border:2px solid #f1af73;color:#d85909;font-weight:bold;left:50%;margin-left:-105px;padding:15px 30px;position:fixed;text-align:center;top:45%;width:150px;z-index:1000}
skin/frontend/base/default/ipgbase/images/ajax-loader-tr.gif ADDED
Binary file
skin/frontend/base/default/ipgbase/images/bkg_btn-close.gif ADDED
Binary file
skin/frontend/base/default/ipgbase/images/bkg_btn-close2.gif ADDED
Binary file
skin/frontend/base/default/ipgbase/images/boleto.png ADDED
Binary file
skin/frontend/base/default/ipgpagsegurodireto/css/cvm.css ADDED
File without changes
skin/frontend/base/default/ipgpagsegurodireto/css/opc.css ADDED
File without changes
skin/frontend/base/default/ipgpagsegurodireto/css/styles-ie7.css ADDED
File without changes
skin/frontend/base/default/ipgpagsegurodireto/css/styles.css ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .ipagare .form-list .fields {margin: 0 0 10px 0;width: 100%;}
2
+ .form-list input.input-text,
3
+ .form-list select {
4
+ height: 35px;
5
+ border-radius: 3px;
6
+ padding: 0;
7
+ width: 100%;
8
+ display: inline-block;
9
+ text-indent: 5px;
10
+ }
11
+ .form-list select {
12
+ text-indent: 0;
13
+ }
14
+
15
+ fieldset .form-list p{
16
+ margin: 0 0 0.5em 0;
17
+ padding: 0;
18
+ }
19
+ ul#payment_form_ipgpagsegurodireto{
20
+ width: 100%;
21
+ overflow: visible;
22
+ }
23
+ #payment_form_ipgpagsegurodireto .img-container-pagsegurodireto {
24
+ cursor: pointer;
25
+ display: inline-block;
26
+ padding: 3px;
27
+ width: 55px;
28
+ height: 55px;
29
+ text-align: center;
30
+ position: relative;
31
+ border: 1px solid transparent;
32
+ }
33
+ #payment_form_ipgpagsegurodireto .img-container-pagsegurodireto.hot,
34
+ #payment_form_ipgpagsegurodireto .img-container-pagsegurodireto.select {
35
+ background-color: #F0F0F0;
36
+ border: 1px solid #CCC;
37
+ -webkit-border-radius: 5px;
38
+ -moz-border-radius: 5px;
39
+ border-radius: 5px;
40
+ }
41
+ #payment_form_ipgpagsegurodireto .imgMP {
42
+ cursor: pointer;
43
+ vertical-align: baseline;
44
+ position: absolute;
45
+ bottom: 5px;
46
+ left: 7px;
47
+ }
48
+ #payment_form_ipgpagsegurodireto h4.titulo{
49
+ margin: 1em 0 0.3em;
50
+ border-width: 0;
51
+ font-size: 12px;
52
+ }
53
+ .divPagForm .ipagare-validade-cartao {
54
+ float: left;
55
+ margin-right: 1%;
56
+ width: 49%;
57
+ }
58
+ .divPagForm .ipagare-validade-cartao span {padding: 0 3%;}
59
+
60
+ #payment_form_ipgpagsegurodireto label{
61
+ clear: both;
62
+ float: inherit;
63
+ }
64
+ #payment_form_ipgpagsegurodireto div.titular-cartao em {
65
+ color: #F00;
66
+ }
67
+ #payment_form_ipgpagsegurodireto option, #payment_form_ipgpagsegurodireto select{
68
+ outline: 0 none;
69
+ clear: both;
70
+ float: left;
71
+ }
72
+ #payment_form_ipgpagsegurodireto option{
73
+ color: #666666;
74
+ background-color: #fff;
75
+ border-bottom: 1px solid #999;
76
+ padding: 5px;
77
+ outline: 0 none;
78
+ border: 1px solid #E0E0E0;
79
+ }
80
+
81
+ #payment_form_ipgpagsegurodireto .ipgpagseguro-cvv {
82
+ float: left;
83
+ }
84
+ #payment_form_ipgpagsegurodireto .divPagForm .cvv{
85
+ width: 50px;
86
+ float: left;
87
+ }
88
+ #payment_form_ipgpagsegurodireto .divPagForm .bin{
89
+ width: 75px;
90
+ height:30px;
91
+ }
92
+ div.ipagare .bin-como-funciona a {
93
+ cursor: help;
94
+ font-size: 1em;
95
+ }
96
+ div.ipagare .bin-como-funciona {
97
+ float: left;
98
+ height: 30px;
99
+ margin-left: 10px;
100
+ width: auto;
101
+ padding-top: 3px;
102
+ }
103
+ #payment_form_ipgpagsegurodireto .divPagForm input.validate-cc-number{
104
+ background: url("../images/padlock_clean.png") no-repeat scroll 100% #FFFFFF;
105
+ }
106
+ #payment_form_ipgpagsegurodireto placeholder {
107
+ color:#666666 !important;
108
+ font-weight: normal;
109
+ font-size: 12px;
110
+ }
111
+ #payment_form_ipgpagsegurodireto input:-moz-placeholder {
112
+ color:#999999 !important;
113
+ font-weight: normal;
114
+ font-size: 12px;
115
+ }
116
+ #payment_form_ipgpagsegurodireto .divPagForm input.validate-cc-number:focus{
117
+ background: url("../images/padlock_closed.png") no-repeat scroll 100% #FFFFFF;
118
+ }
119
+ #payment_form_ipgpagsegurodireto .divPagForm input.month {
120
+ clear: both;
121
+ float: left;
122
+ }
123
+ .divPagForm input.month,
124
+ .divPagForm input.year{
125
+ width:40%;
126
+ text-align: center;
127
+ text-indent: 0;
128
+ }
129
+ #payment_form_ipgpagsegurodireto .form-list label {
130
+ text-align: left;
131
+ }
132
+ #payment_form_ipgpagsegurodireto .ipagare-parcelas {
133
+ float: left;
134
+ width: 100%;
135
+ margin-bottom: 10px;
136
+ }
137
+ #payment_form_ipgpagsegurodireto .ipagare-parcelas p{
138
+ clear: both;
139
+ position: relative;
140
+ }
141
+ #payment_form_ipgpagsegurodireto .ipagare-parcelas input{
142
+ float: left;
143
+ clear:both;
144
+ }
145
+ #payment_form_ipgpagsegurodireto p.titulo{
146
+ font-weight: 500;
147
+ padding: 5px 0;
148
+ }
149
+ #payment_form_ipgpagsegurodireto .ipagare-alert {
150
+ float: left;
151
+ width:100%;
152
+ padding-bottom: 20px;
153
+ }
154
+ .divPagForm input.areacode {
155
+ width: 25%;
156
+ clear: both;
157
+ float: left;
158
+ text-indent: 0;
159
+ text-align: center;
160
+ }
161
+ .divPagForm input.fonenumber {
162
+ width: 70%;
163
+ float: right;
164
+ }
165
+
166
+ #ipagare a.boleto-link {
167
+ background-image: url('../images/boleto.png');
168
+ background-repeat: no-repeat;
169
+ display: inline-block;
170
+ height: 30px;
171
+ width: 130px;
172
+ }
173
+ #ipagare.banco h1 {
174
+ margin-bottom: 15px;
175
+ }
176
+
177
+ #ipagare.banco ol {
178
+ list-style-position: outside;
179
+ list-style-type: decimal;
180
+ margin-bottom: 20px;
181
+ margin-left: 18px;
182
+ }
183
+
184
+ #ipagare.banco ol li {
185
+ margin-bottom: 5px;
186
+ }
187
+
188
+ #ipagare.banco p.desc {
189
+ background-color: #F0F0F0;
190
+ border: 1px solid #E0E0E0;
191
+ padding: 15px;
192
+ }
193
+
194
+ #ipagare.banco p.btn {
195
+ margin-top: 50px;
196
+ text-align: center;
197
+ }
198
+ #co-payment-form p.pagsegurodireto {
199
+ margin-top: 20px;
200
+ font-size: 10px;
201
+ }
202
+ #co-payment-form p.pagsegurodireto span.aviso {
203
+ padding-top: 5px;
204
+ display: inline-block;
205
+ width: 155px;
206
+ padding-left: 5px;
207
+ }
208
+
209
+ #payment_form_ipgpagsegurodireto div.titular-cartao {
210
+ padding-top: 20px;
211
+ display: inline-block;
212
+ }
213
+ #payment_form_ipgpagsegurodireto div.titular-cartao h4 {
214
+ text-align: center;
215
+ text-transform: uppercase;
216
+ font-weight: normal;
217
+ }
218
+ p.msg-pagseguro {
219
+ background: url("../images/pagseguro.png") no-repeat scroll 100% transparent;
220
+ height: 60px;
221
+ border: 1px solid #b6b6b6;
222
+ border-radius: 3px;
223
+ display: inline-block;
224
+ width: 100%;
225
+ opacity: 0.7;
226
+ margin: 10px 0;
227
+ }
228
+ p.msg-pagseguro span {
229
+ margin: 10px;
230
+ display: inline-block;
231
+ }
skin/frontend/base/default/ipgpagsegurodireto/images/boleto.png ADDED
Binary file
skin/frontend/base/default/ipgpagsegurodireto/images/bubble.png ADDED
Binary file
skin/frontend/base/default/ipgpagsegurodireto/images/codigo_bin_1.png ADDED
Binary file
skin/frontend/base/default/ipgpagsegurodireto/images/codigo_bin_2.png ADDED
Binary file
skin/frontend/base/default/ipgpagsegurodireto/images/cvv.gif ADDED
Binary file
skin/frontend/base/default/ipgpagsegurodireto/images/padlock_clean.png ADDED
Binary file
skin/frontend/base/default/ipgpagsegurodireto/images/padlock_closed.png ADDED
Binary file
skin/frontend/base/default/ipgpagsegurodireto/images/pagseguro.png ADDED
Binary file
skin/frontend/base/default/ipgpagsegurodireto/images/pagseguro.pxm ADDED
Binary file
skin/frontend/base/default/ipgpagsegurodireto/images/pagseguro.pxm.sb-cd4c37b0-h3WR13 ADDED
Binary file