idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
52,600
public static function insert ( $ sqlstatement , array $ data = [ ] ) { static :: verifyConnection ( ) ; if ( ! preg_match ( "/^insert\s+into\s+[\w\d_-`]+\s?(\(.+\))?\s+(values\s?(\(.+\),?)+|\s?set\s+(.+)+);?$/i" , $ sqlstatement ) ) { throw new DatabaseException ( 'Syntax Error on the Request' , E_USER_ERROR ) ; } if ...
Execute an insert query
52,601
public static function statement ( $ sqlstatement ) { static :: verifyConnection ( ) ; if ( ! preg_match ( "/^((drop|alter|create)\s+(?:(?:temp|temporary)\s+)?table|truncate|call)(\s+)?(.+?);?$/i" , $ sqlstatement ) ) { throw new DatabaseException ( 'Syntax Error on the Request' , E_USER_ERROR ) ; } return static :: $ ...
Executes a request of type DROP | CREATE TABLE | TRAUNCATE | ALTER Builder
52,602
public static function delete ( $ sqlstatement , array $ data = [ ] ) { static :: verifyConnection ( ) ; if ( ! preg_match ( "/^delete\sfrom\s[\w\d_`]+\swhere\s.+;?$/i" , $ sqlstatement ) ) { throw new DatabaseException ( 'Syntax Error on the Request' , E_USER_ERROR ) ; } return static :: executePrepareQuery ( $ sqlsta...
Execute a delete request
52,603
public static function table ( $ table ) { static :: verifyConnection ( ) ; $ table = static :: $ adapter -> getTablePrefix ( ) . $ table ; return new QueryBuilder ( $ table , static :: $ adapter -> getConnection ( ) ) ; }
Load the query builder factory on table name
52,604
public static function startTransaction ( callable $ callback = null ) { static :: verifyConnection ( ) ; if ( ! static :: $ adapter -> getConnection ( ) -> inTransaction ( ) ) { static :: $ adapter -> getConnection ( ) -> beginTransaction ( ) ; } if ( is_callable ( $ callback ) ) { try { call_user_func_array ( $ callb...
Starting the start of a transaction
52,605
private static function executePrepareQuery ( $ sqlstatement , array $ data = [ ] ) { $ pdostatement = static :: $ adapter -> getConnection ( ) -> prepare ( $ sqlstatement ) ; static :: $ adapter -> bind ( $ pdostatement , Sanitize :: make ( $ data , true ) ) ; $ pdostatement -> execute ( ) ; $ r = $ pdostatement -> ro...
Execute the request of type delete insert update
52,606
public static function make ( Request $ request , Response $ response ) { if ( is_null ( static :: $ instance ) ) { static :: $ instance = new static ( $ request , $ response ) ; } return static :: $ instance ; }
Build the application
52,607
public function prefix ( $ prefix , callable $ cb ) { $ prefix = rtrim ( $ prefix , '/' ) ; if ( ! preg_match ( '@^/@' , $ prefix ) ) { $ prefix = '/' . $ prefix ; } if ( $ this -> prefix !== null ) { $ this -> prefix .= $ prefix ; } else { $ this -> prefix = $ prefix ; } call_user_func_array ( $ cb , [ $ this ] ) ; $ ...
Add a prefix on the roads
52,608
public function middleware ( $ middlewares ) { $ middlewares = ( array ) $ middlewares ; $ this -> middlewares = [ ] ; foreach ( $ middlewares as $ middleware ) { if ( is_callable ( $ middleware ) ) { $ this -> middlewares [ ] = $ middleware ; } elseif ( class_exists ( $ middleware , true ) ) { $ this -> middlewares [ ...
Allows to associate a global middleware on an route
52,609
public function any ( $ path , $ cb ) { foreach ( [ 'options' , 'patch' , 'post' , 'delete' , 'put' , 'get' ] as $ method ) { $ this -> $ method ( $ path , $ cb ) ; } return $ this ; }
Add a route for
52,610
public function post ( $ path , $ cb ) { $ input = $ this -> request ; if ( ! $ input -> has ( '_method' ) ) { return $ this -> routeLoader ( 'POST' , $ path , $ cb ) ; } $ method = strtoupper ( $ input -> get ( '_method' ) ) ; if ( in_array ( $ method , [ 'DELETE' , 'PUT' ] ) ) { $ this -> special_method = $ method ; ...
Add a POST route
52,611
public function match ( array $ methods , $ path , $ cb ) { foreach ( $ methods as $ method ) { if ( $ this -> request -> method ( ) === strtoupper ( $ method ) ) { $ this -> pushHttpVerbe ( strtoupper ( $ method ) , $ path , $ cb ) ; } } return $ this ; }
Match route de tout type de method
52,612
private function routeLoader ( $ method , $ path , $ cb ) { $ path = $ this -> config [ 'app.root' ] . $ this -> prefix . $ path ; $ this -> current = [ 'path' => $ path , 'method' => $ method ] ; $ route = new Route ( $ path , $ cb ) ; $ route -> middleware ( $ this -> middlewares ) ; $ this -> routes [ $ method ] [ ]...
Start loading a route .
52,613
public function send ( ) { if ( php_sapi_name ( ) == 'cli' ) { return true ; } if ( ! $ this -> disable_x_powered_by ) { $ this -> response -> addHeader ( 'X-Powered-By' , 'Bow Framework' ) ; } $ this -> prefix = '' ; $ method = $ this -> request -> method ( ) ; if ( $ method == 'POST' ) { if ( $ this -> special_method...
Launcher of the application
52,614
private function sendResponse ( $ response ) { if ( $ response instanceof ResponseInterface ) { $ response -> sendContent ( ) ; } else { echo $ this -> response -> send ( $ response ) ; } }
Send the answer to the customer
52,615
public function rest ( $ url , $ controller_name , array $ where = [ ] ) { if ( ! is_string ( $ controller_name ) && ! is_array ( $ controller_name ) ) { throw new ApplicationException ( 'The first parameter must be an array or a string' , E_ERROR ) ; } $ ignore_method = [ ] ; $ controller = $ controller_name ; if ( is...
REST API Maker .
52,616
public function makeWith ( $ key , $ parameters = [ ] ) { $ this -> parameters = $ parameters ; $ this -> resolve ( $ key ) ; $ this -> parameters = [ ] ; return $ invalide ; }
Compilation with parameter
52,617
public function bind ( $ key , $ value ) { $ this -> key [ $ key ] = true ; $ this [ $ key ] = $ value ; }
Add to register
52,618
private function resolve ( $ key ) { $ reflection = new \ ReflectionClass ( $ key ) ; if ( ! $ reflection -> isInstantiable ( ) ) { return $ key ; } $ constructor = $ reflection -> getConstructor ( ) ; if ( ! $ constructor ) { return $ reflection -> newInstance ( ) ; } $ parameters = $ constructor -> getParameters ( ) ...
Instantiate a class by its key
52,619
public function run ( ) { if ( $ this -> booted ) { return ; } $ this -> kernel -> withoutSession ( ) ; $ this -> kernel -> boot ( ) ; $ this -> booted = true ; foreach ( $ this -> setting -> getBootstrap ( ) as $ item ) { require $ item ; } $ command = $ this -> arg -> getParameter ( 'command' ) ; if ( array_key_exist...
Launch Bow task runner
52,620
private function call ( $ command ) { if ( ! in_array ( $ command , static :: COMMAND ) ) { $ this -> throwFailsCommand ( "The command '$command' not exists." , 'help' ) ; } if ( ! $ this -> arg -> getParameter ( 'action' ) ) { if ( $ this -> arg -> getParameter ( 'target' ) == 'help' ) { $ this -> help ( $ command ) ;...
Calls a command
52,621
private function generate ( ) { $ action = $ this -> arg -> getParameter ( 'action' ) ; if ( ! in_array ( $ action , [ 'key' , 'resource' , 'session' ] ) ) { $ this -> throwFailsAction ( 'This action is not exists' , 'help generate' ) ; } $ this -> command -> call ( 'generate' , $ action , $ this -> arg -> getParameter...
Allows generate a resource on a controller
52,622
public function open ( $ save_path , $ name ) { if ( ! is_dir ( $ this -> save_path ) ) { mkdir ( $ this -> save_path , 0777 ) ; } return true ; }
When the session start
52,623
private static function format ( $ str , array $ values = [ ] ) { foreach ( $ values as $ key => $ value ) { $ str = preg_replace ( '/{\s*' . $ key . '\s*\}/' , $ value , $ str ) ; } return $ str ; }
Permet de formater
52,624
final public function drop ( $ table ) { $ table = $ this -> getTablePrefixed ( $ table ) ; $ sql = sprintf ( 'DROP TABLE `%s`;' , $ table ) ; return $ this -> executeSqlQuery ( $ sql ) ; }
Drop table action
52,625
final public function dropIfExists ( $ table ) { $ table = $ this -> getTablePrefixed ( $ table ) ; $ sql = sprintf ( 'DROP TABLE IF EXISTS `%s`;' , $ table ) ; return $ this -> executeSqlQuery ( $ sql ) ; }
Drop table if he exists action
52,626
final public function create ( $ table , callable $ cb ) { $ table = $ this -> getTablePrefixed ( $ table ) ; $ generator = new SQLGenerator ( $ table , $ this -> adapter -> getName ( ) ) ; call_user_func_array ( $ cb , [ $ generator ] ) ; if ( $ this -> adapter -> getName ( ) == 'mysql' ) { $ engine = sprintf ( 'ENGIN...
Function of creation of a new table in the database .
52,627
final public function alter ( $ table , callable $ cb ) { $ table = $ this -> getTablePrefixed ( $ table ) ; call_user_func_array ( $ cb , [ $ generator = new SQLGenerator ( $ table , $ this -> adapter -> getName ( ) , 'alter' ) ] ) ; $ sql = sprintf ( 'ALTER TABLE `%s` %s;' , $ table , $ generator -> make ( ) ) ; retu...
Alter table action .
52,628
final public function renameTable ( $ table , $ to ) { if ( $ this -> adapter -> getName ( ) == 'mysql' ) { $ command = 'RENAME' ; } else { $ command = 'ALTER TABLE' ; } $ sql = sprintf ( '%s %s TO %s' , $ command , $ table , $ to ) ; return $ this -> executeSqlQuery ( $ sql ) ; }
Add SQL query
52,629
public static function getInstallments ( PagSeguroCredentials $ credentials , $ amount , $ cardBrand = null , $ maxInstallmentNoInterest = null ) { $ amount = PagSeguroHelper :: decimalFormat ( $ amount ) ; LogPagSeguro :: info ( "PagSeguroInstallmentService.getInstallments(" . $ amount . ") - begin" ) ; self :: $ conn...
Get from webservice installments for direct payment .
52,630
public static function checkAuthorization ( PagSeguroCredentials $ credentials , $ notificationCode ) { LogPagSeguro :: info ( "PagSeguroNotificationService.CheckAuthorization(notificationCode=$notificationCode) - begin" ) ; $ connectionData = new PagSeguroConnectionData ( $ credentials , self :: SERVICE_NAME ) ; try {...
Returns a authorization from a notification code
52,631
public function createPaymentRequest ( ) { try { $ this -> currency ( ) ; $ this -> reference ( ) ; $ this -> discounts ( ) ; $ this -> shipping ( ) ; $ this -> sender ( ) ; $ this -> urls ( ) ; $ this -> items ( ) ; $ this -> config ( ) ; $ this -> setShoppingCartRecovery ( ) ; return $ this -> register ( ) ; } catch ...
Create a new pagseguro direct payment request
52,632
private function config ( ) { $ this -> _library -> setEnvironment ( ) ; $ this -> _library -> setCharset ( ) ; $ this -> _library -> setLog ( ) ; }
Set configuration for payment
52,633
private function urls ( ) { $ this -> _paymentRequest -> setRedirectUrl ( $ this -> getRedirectUrl ( ) ) ; $ this -> _paymentRequest -> setNotificationUrl ( $ this -> getNotificationUrl ( ) ) ; }
Set redirect and notification url s
52,634
private function shipping ( ) { if ( $ this -> _order -> getIsVirtual ( ) ) { $ this -> _paymentRequest -> setShipping ( ) -> setAddressRequired ( ) -> withParameters ( 'false' ) ; } else { $ this -> _paymentRequest -> setShipping ( ) -> setAddressRequired ( ) -> withParameters ( 'true' ) ; $ this -> setShippingInforma...
Set shipping for payment
52,635
private function setSenderDocument ( ) { $ this -> _paymentRequest -> setSender ( ) -> setDocument ( ) -> withParameters ( $ this -> _data [ 'sender_document' ] [ 'type' ] , $ this -> _data [ 'sender_document' ] [ 'number' ] ) ; }
Set sender document
52,636
private function guest ( ) { $ address = $ this -> getBillingAddress ( ) ; $ this -> _paymentRequest -> setSender ( ) -> setName ( $ address -> getFirstname ( ) . ' ' . $ address -> getLastname ( ) ) ; }
Set guest info
52,637
private function setSenderPhone ( ) { $ addressData = ( $ this -> getBillingAddress ( ) ) ? $ this -> getBillingAddress ( ) : $ this -> _order -> getShippingAddress ( ) ; if ( ! empty ( $ addressData [ 'telephone' ] ) ) { $ phone = \ UOL \ PagSeguro \ Helper \ Data :: formatPhone ( $ addressData [ 'telephone' ] ) ; $ t...
Set the sender phone if it exist
52,638
private function getShippingAddress ( $ address , $ shipping = null ) { if ( ! is_null ( $ address ) or ! empty ( $ adress ) ) return $ address ; if ( $ shipping ) return \ UOL \ PagSeguro \ Helper \ Data :: addressConfig ( $ shipping [ 'street' ] ) ; return null ; }
Get shipping address
52,639
private function getOrderStoreReference ( ) { return \ UOL \ PagSeguro \ Helper \ Data :: getOrderStoreReference ( $ this -> _scopeConfig -> getValue ( 'pagseguro/store/reference' ) , $ this -> _order -> getEntityId ( ) ) ; }
Get store reference from magento core_config_data
52,640
private function getRegionAbbreviation ( $ shipping ) { if ( strlen ( $ shipping -> getRegionCode ( ) ) == 2 ) { return $ shipping -> getRegionCode ( ) ; } $ regionAbbreviation = new \ PagSeguro \ Enum \ Address ( ) ; return ( is_string ( $ regionAbbreviation -> getType ( $ shipping -> getRegion ( ) ) ) ) ? $ regionAbb...
Get a brazilian region name and return the abbreviation if it exists
52,641
private function setShoppingCartRecovery ( ) { if ( $ this -> _scopeConfig -> getValue ( 'payment/pagseguro/shopping_cart_recovery' ) == true ) { $ this -> _paymentRequest -> addParameter ( ) -> withParameters ( 'enableRecovery' , 'true' ) ; } else { $ this -> _paymentRequest -> addParameter ( ) -> withParameters ( 'en...
Set PagSeguro recovery shopping cart value
52,642
public function getPagSeguroCredentials ( ) { $ email = $ this -> _scopeConfig -> getValue ( 'payment/pagseguro/email' ) ; $ token = $ this -> _scopeConfig -> getValue ( 'payment/pagseguro/token' ) ; \ PagSeguro \ Configuration \ Configure :: setAccountCredentials ( $ email , $ token ) ; return \ PagSeguro \ Configurat...
Get the access credential
52,643
private function loader ( ) { $ objectManager = \ Magento \ Framework \ App \ ObjectManager :: getInstance ( ) ; $ productMetadata = $ objectManager -> get ( 'Magento\Framework\App\ProductMetadataInterface' ) ; $ timezone = $ objectManager -> create ( '\Magento\Framework\Stdlib\DateTime\TimezoneInterface' ) ; date_defa...
Load library vendor
52,644
public function setLog ( ) { \ PagSeguro \ Configuration \ Configure :: setLog ( $ this -> _scopeConfig -> getValue ( 'payment/pagseguro/log' ) , $ this -> _scopeConfig -> getValue ( 'payment/pagseguro/log_file' ) ) ; }
Set the log and log location configured in the PagSeguro module
52,645
public function getImageUrl ( $ imageModulePath ) { $ objectManager = \ Magento \ Framework \ App \ ObjectManager :: getInstance ( ) ; $ viewRepository = $ objectManager -> get ( '\Magento\Framework\View\Asset\Repository' ) ; return $ viewRepository -> getUrl ( $ imageModulePath ) ; }
Get image full frontend url
52,646
public function execute ( \ Magento \ Framework \ Event \ Observer $ observer ) { $ order = $ observer -> getEvent ( ) -> getOrder ( ) ; if ( $ order -> getStatus ( ) == 'pagseguro_iniciado' ) { $ orderId = $ order -> getId ( ) ; $ environment = $ this -> _scopeConfig -> getValue ( 'payment/pagseguro/environment' ) ; $...
checkout_submit_all_after event handler to store pagseguro order info
52,647
private function saveOrderAndEnvironment ( $ orderId , $ environment ) { $ this -> _ordersFactory -> create ( ) -> setData ( [ 'order_id' => $ orderId , 'environment' => $ environment ] ) -> save ( ) ; }
Create the order in the pagseguro_orders table saving the order id and the environment
52,648
private function updateSalesOrderGridEnvironment ( $ orderId , $ environment ) { $ environmentName = $ this -> getEnvironmentName ( $ environment ) ; $ resource = $ this -> _objectManager -> create ( 'Magento\Framework\App\ResourceConnection' ) ; $ connection = $ resource -> getConnection ( ) ; $ tableName = $ resource...
Update environment in sales_order_grid table
52,649
private function whenError ( $ message ) { return $ this -> result -> setData ( [ 'success' => false , 'payload' => [ 'error' => $ message , 'redirect' => sprintf ( '%s%s' , $ this -> baseUrl ( ) , 'pagseguro/payment/failure' ) ] ] ) ; }
Return when fails
52,650
private function lastRealOrderId ( ) { $ lastRealOrderId = $ this -> _objectManager -> create ( '\Magento\Checkout\Model\Session' ) -> getLastRealOrder ( ) -> getId ( ) ; if ( is_null ( $ lastRealOrderId ) ) { throw new \ Exception ( "There is no order associated with this session." ) ; } return $ lastRealOrderId ; }
Get last real order id
52,651
public function request ( ) { $ transactions = $ this -> searchTransactions ( ) ; if ( count ( $ transactions ) > 0 ) { foreach ( $ transactions as $ transaction ) { $ this -> _arrayTransactions [ ] = array ( 'date' => $ this -> formatDate ( $ transaction [ 'created_at' ] ) , 'magento_id' => $ transaction [ 'increment_...
Get all transactions and return formatted data
52,652
public function execute ( $ data ) { $ this -> getDetailsTransaction ( str_replace ( '-' , '' , $ data ) ) ; if ( ! empty ( $ this -> _detailsTransactionByCode ) && $ this -> _needConciliate ) { throw new \ Exception ( 'need to conciliate' ) ; } if ( empty ( $ this -> _detailsTransactionByCode ) ) { throw new \ Excepti...
Get details transactions
52,653
public function request ( ) { $ this -> getPagSeguroAbandoned ( ) ; if ( $ this -> _PagSeguroPaymentList -> getTransactions ( ) ) { foreach ( $ this -> _PagSeguroPaymentList -> getTransactions ( ) as $ payment ) { date_default_timezone_set ( 'UTC' ) ; $ order = \ UOL \ PagSeguro \ Helper \ Data :: getReferenceDecryptOr...
Get all transactions and orders and return builded data
52,654
private function sendEmail ( $ order , $ recoveryCode ) { $ sender = [ 'email' => $ this -> _scopeConfig -> getValue ( 'trans_email/ident_general/email' , ScopeInterface :: SCOPE_STORE ) , 'name' => $ this -> _scopeConfig -> getValue ( 'trans_email/ident_general/name' , ScopeInterface :: SCOPE_STORE ) ] ; $ receiver = ...
Send email with abandoned template
52,655
protected function requestPagSeguroAbandoned ( $ page ) { $ date = $ this -> getDates ( ) ; $ options = [ 'initial_date' => $ date [ 'initial' ] , 'final_date' => $ date [ 'final' ] , 'page' => $ page , 'max_per_page' => 1000 , ] ; try { $ this -> _library -> setEnvironment ( ) ; $ this -> _library -> setCharset ( ) ; ...
Request all PagSeguroTransaction in this _date interval
52,656
private function getSent ( $ orderId ) { $ connection = $ this -> _resource -> getConnection ( ) ; $ tableName = $ this -> _resource -> getTableName ( 'pagseguro_orders' ) ; $ mapsDeleteQuery = "SELECT sent FROM {$tableName} WHERE order_id={$orderId}" ; return $ connection -> query ( $ mapsDeleteQuery ) -> fetch ( ) ; ...
Get quantity of email was sent
52,657
private function setSent ( $ orderId , $ sent ) { $ connection = $ this -> _resource -> getConnection ( ) ; $ tableName = $ this -> _resource -> getTableName ( 'pagseguro_orders' ) ; $ mapsDeleteQuery = "UPDATE {$tableName} SET sent={$sent} WHERE order_id={$orderId}" ; $ connection -> query ( $ mapsDeleteQuery ) ; }
Increments a sent for a order in pagseguro_orders table .
52,658
private function output ( $ installments , $ maxInstallment ) { return ( $ maxInstallment ) ? $ this -> formatOutput ( $ this -> getMaxInstallment ( $ installments ) ) : $ this -> formatOutput ( $ installments ) ; }
Return a formated output of installments
52,659
private function formatOutput ( $ installments ) { $ response = $ this -> getOptions ( ) ; foreach ( $ installments as $ installment ) { $ response [ 'installments' ] [ ] = $ this -> formatInstallments ( $ installment ) ; } return $ response ; }
Format the installment to the be show in the view
52,660
private function formatInstallments ( $ installment ) { return [ 'quantity' => $ installment -> getQuantity ( ) , 'amount' => $ installment -> getAmount ( ) , 'totalAmount' => round ( $ installment -> getTotalAmount ( ) , 2 ) , 'text' => str_replace ( '.' , ',' , $ this -> getInstallmentText ( $ installment ) ) ] ; }
Format a installment for output
52,661
private function getInstallmentText ( $ installment ) { return sprintf ( "%s x de R$ %.2f %s juros" , $ installment -> getQuantity ( ) , $ installment -> getAmount ( ) , $ this -> getInterestFreeText ( $ installment -> getInterestFree ( ) ) ) ; }
Mount the text message of the installment
52,662
private function getMaxInstallment ( $ installments ) { $ final = $ current = [ 'brand' => '' , 'start' => 0 , 'final' => 0 , 'quantity' => 0 ] ; foreach ( $ installments as $ key => $ installment ) { if ( $ current [ 'brand' ] !== $ installment -> getCardBrand ( ) ) { $ current [ 'brand' ] = $ installment -> getCardBr...
Get the bigger installments list in the installments
52,663
public function isLightboxCheckoutType ( ) { if ( $ this -> getConfigData ( 'checkout' ) == \ UOL \ PagSeguro \ Model \ System \ Config \ Checkout :: LIGHTBOX ) { return true ; } return false ; }
Check if checkout type is lightbox
52,664
public function execute ( ) { try { $ this -> order = $ this -> loadOrder ( ) ; $ installments = new InstallmentsMethod ( $ this -> _objectManager -> create ( 'Magento\Framework\App\Config\ScopeConfigInterface' ) , $ this -> _objectManager -> create ( 'Magento\Framework\Module\ModuleList' ) , $ this -> order , $ this -...
Returns the installments
52,665
private static function sortData ( $ text ) { if ( preg_match ( '/[-,\\n]/' , $ text ) ) { $ broken = preg_split ( '/[-,\\n]/' , $ text ) ; for ( $ i = 0 ; $ i < strlen ( $ broken [ 0 ] ) ; $ i ++ ) { if ( is_numeric ( substr ( $ broken [ 0 ] , $ i , 1 ) ) ) { return array ( substr ( $ broken [ 0 ] , 0 , $ i ) , substr...
Sort the data reported
52,666
public static function getStatusFromKey ( $ key ) { if ( array_key_exists ( $ key , self :: $ statusList ) ) { return self :: $ statusList [ $ key ] ; } return false ; }
Get the name of payment status
52,667
public static function formatPhone ( $ phone ) { $ ddd = '' ; $ phone = self :: keepOnlyNumbers ( $ phone ) ; if ( substr ( $ phone , 0 , 1 ) == 0 ) { $ phone = substr ( $ phone , 1 ) ; } if ( strlen ( $ phone ) > 9 ) { if ( strlen ( $ phone ) > 11 ) { $ phone = substr ( $ phone , 2 ) ; } $ ddd = substr ( $ phone , 0 ,...
Format string phone number
52,668
private function makeSession ( $ response ) { $ this -> session ( ) -> setData ( [ 'pagseguro_payment' => [ 'payment_link' => $ response -> getPaymentLink ( ) , 'payment_type' => strtolower ( Boleto :: class ) , 'order_id' => $ this -> lastRealOrderId ( ) , ] ] ) ; }
Create new pogseguro payment session data
52,669
public function getProduct ( ) { if ( ! $ this -> hasData ( 'product' ) ) { $ this -> setData ( 'product' , $ this -> _coreRegistry -> registry ( 'product' ) ) ; } return $ this -> getData ( 'product' ) ; }
Retrieve currently viewed product object
52,670
public function getInstallment ( $ value ) { $ installments = $ this -> _installmentFactory -> create ( ) ; $ output = $ installments -> create ( round ( $ value , 2 ) , true ) ; return $ output [ 'installments' ] ; }
Get the bigger installment list for the value passed
52,671
public function isEnabled ( ) { $ status = $ this -> _scopeConfig -> getValue ( 'payment/pagseguro/installments' ) ; return ( ! is_null ( $ status ) && $ status == 1 ) ? true : false ; }
Validate if the PagSeguro installments list in the product view is enabled
52,672
private function addPayment ( $ order , $ payment ) { if ( $ this -> compareStore ( $ payment ) && $ this -> hasOrder ( $ order ) && $ this -> compareStatus ( $ order , $ payment ) ) { array_push ( $ this -> _arrayPayments , $ this -> build ( $ payment , $ order ) ) ; return true ; } return false ; }
Add a needle conciliate payment to a list
52,673
public function execute ( $ data ) { try { $ config = $ this -> sanitizeConfig ( $ data ) ; $ this -> isConciliate ( $ config ) ; if ( ! $ this -> doCancel ( $ config ) ) throw new \ Exception ( 'impossible to cancel.' ) ; $ this -> doUpdates ( $ config ) ; return true ; } catch ( \ Exception $ exception ) { throw $ ex...
Cancels one transaction
52,674
private function checkConciliation ( $ payment , $ order ) { if ( $ order -> getStatus ( ) == $ this -> getStatusFromPaymentKey ( $ payment -> getStatus ( ) ) ) return true ; return false ; }
Check for conciliation
52,675
private function compareStatus ( $ order , $ payment ) { if ( ! ( in_array ( $ order -> getStatus ( ) , [ $ this -> getStatusFromPaymentKey ( 1 ) , $ this -> getStatusFromPaymentKey ( 2 ) ] ) || in_array ( $ payment -> getStatus ( ) , [ 1 , 2 ] ) ) ) { return false ; } return true ; }
Compare between magento status and PagSeguro transaction status
52,676
public function checkoutUrl ( $ code , $ serviceName ) { $ connectionData = new \ PagSeguro \ Resources \ Connection \ Data ( $ this -> _library -> getPagSeguroCredentials ( ) ) ; return $ connectionData -> buildPaymentResponseUrl ( ) . "?code=$code" ; }
Get checkout url
52,677
private function getOrderStoreReference ( ) { return \ UOL \ PagSeguro \ Helper \ Data :: getOrderStoreReference ( $ this -> _scopeConfig -> getValue ( 'pagseguro/store/reference' ) , $ this -> _checkoutSession -> getLastRealOrder ( ) -> getEntityId ( ) ) ; }
Get store reference from magento core_config_data table
52,678
private function setPagSeguroDiscountsByPaymentMethod ( ) { $ storeId = \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE ; if ( $ this -> _scopeConfig -> getValue ( 'payment/pagseguro_default_lightbox/discount_credit_card' , $ storeId ) == 1 ) { $ creditCard = ( double ) $ this -> _scopeConfig -> getValue ( 'p...
Get the discount configuration for PagSeguro store configurarion and set in the payment request the discount amount for every payment method configured
52,679
public function execute ( $ data , $ value = null ) { try { $ config = $ this -> sanitizeConfig ( $ data ) ; if ( $ value != null ) $ config -> value = number_format ( floatval ( $ value ) , 2 , '.' , '' ) ; $ this -> isConciliate ( $ config ) ; if ( ! $ this -> doRefund ( $ config ) ) throw new \ Exception ( 'impossib...
Refund one transaction
52,680
private function whenSuccess ( $ response , $ method ) { $ this -> makeSession ( $ response , $ method ) ; return $ this -> result -> setData ( [ 'success' => true , 'payload' => [ 'redirect' => sprintf ( '%s%s' , $ this -> baseUrl ( ) , 'pagseguro/direct/success' ) ] ] ) ; }
Return when success
52,681
private function makeSession ( $ response , $ method ) { if ( $ method === 'pagseguro_credit_card' ) { $ this -> session ( ) -> setData ( [ 'pagseguro_payment' => [ 'payment_type' => $ method , 'order_id' => $ this -> orderId , ] ] ) ; } else { $ this -> session ( ) -> setData ( [ 'pagseguro_payment' => [ 'payment_link...
Create new pagseguro payment session data
52,682
public function execute ( ) { $ this -> _orderFactory = $ this -> _objectManager -> get ( '\Magento\Sales\Model\OrderFactory' ) ; $ this -> _checkoutSession = $ this -> _objectManager -> get ( '\Magento\Checkout\Model\Session' ) ; $ order = $ this -> _objectManager -> create ( '\Magento\Sales\Model\Order' ) -> load ( $...
Show cancel page
52,683
public function execute ( ) { try { $ nofitication = new \ UOL \ PagSeguro \ Model \ NotificationMethod ( $ this -> _objectManager -> create ( '\Magento\Framework\App\Config\ScopeConfigInterface' ) , $ this -> _objectManager -> create ( '\Magento\Sales\Api\OrderRepositoryInterface' ) , $ this -> _objectManager -> creat...
Update a order
52,684
protected function prepareBlockData ( ) { $ order = $ this -> _checkoutSession -> getLastRealOrder ( ) ; $ this -> addData ( [ 'can_view_order' => $ this -> canViewOrder ( $ order ) , 'view_order_url' => $ this -> getUrl ( 'sales/order/view/' , [ 'order_id' => $ order -> getEntityId ( ) ] ) , 'print_url' => $ this -> g...
Prepares block data
52,685
protected function canViewOrder ( Order $ order ) { return $ this -> httpContext -> getValue ( Context :: CONTEXT_AUTH ) && $ this -> isVisible ( $ order ) ; }
Can view order
52,686
private function createPagSeguroOrdersTable ( $ setup ) { $ tableName = $ setup -> getTable ( self :: PAGSEGURO_ORDERS ) ; if ( $ setup -> getConnection ( ) -> isTableExists ( $ tableName ) != true ) { $ table = $ setup -> getConnection ( ) -> newTable ( $ tableName ) -> addColumn ( 'entity_id' , Table :: TYPE_INTEGER ...
Create the pagseguro_orders table in the DB
52,687
private function integratePagSeguroAndOrdersGrid ( $ setup ) { $ setup -> getConnection ( ) -> addColumn ( $ setup -> getTable ( 'sales_order_grid' ) , 'transaction_code' , [ 'type' => Table :: TYPE_TEXT , 'length' => 80 , 'comment' => 'PagSeguro Transaction Code' ] ) ; $ setup -> getConnection ( ) -> addColumn ( $ set...
Add PagSeguro columns to magento sales_order_grid table
52,688
protected function getTransactions ( $ page = null ) { if ( is_null ( $ page ) ) $ page = 1 ; try { if ( is_null ( $ this -> _PagSeguroPaymentList ) ) { $ this -> _PagSeguroPaymentList = $ this -> requestPagSeguroPayments ( $ page ) ; } else { $ response = $ this -> requestPagSeguroPayments ( $ page ) ; $ this -> _PagS...
Get PagSeguro payments
52,689
public function searchTransactions ( ) { try { $ connection = $ this -> getConnection ( ) ; $ select = $ connection -> select ( ) -> from ( [ 'order' => 'sales_order' ] , [ 'status' , 'created_at' , 'increment_id' , 'store_id' , 'entity_id' ] ) -> join ( [ 'ps' => 'pagseguro_orders' ] , 'order.entity_id = ps.order_id' ...
Get all transactions where there is a pagseguro transaction code
52,690
public function getDetailsTransaction ( $ transactionCode ) { $ this -> _detailsTransactionByCode = $ this -> getTransactionsByCode ( $ transactionCode ) ; if ( ! empty ( $ this -> _detailsTransactionByCode ) ) { $ order = $ this -> decryptOrderById ( $ this -> _detailsTransactionByCode ) ; if ( $ this -> getStoreRefer...
Get and formats transaction details
52,691
protected function getDates ( ) { $ date = new \ DateTime ( "now" ) ; $ date -> setTimezone ( new \ DateTimeZone ( "America/Sao_Paulo" ) ) ; $ final = $ date -> format ( "Y-m-d\TH:i:s" ) ; $ dateInterval = "P" . ( string ) $ this -> _days . "D" ; $ date -> sub ( new \ DateInterval ( $ dateInterval ) ) ; $ date -> setTi...
Get date interval from days qty .
52,692
protected function getPartiallyRefundedOrders ( ) { $ pagseguroOrdersIdArray = array ( ) ; $ connection = $ this -> getConnection ( ) ; $ select = $ connection -> select ( ) -> from ( [ 'ps' => $ this -> getPrefixTableName ( 'pagseguro_orders' ) ] , [ 'order_id' ] ) -> where ( 'ps.partially_refunded = ?' , '1' ) ; if (...
Get all pagseguro partially refunded orders id
52,693
public function buildDetailsTransaction ( ) { return array ( 'date' => $ this -> formatDate ( $ this -> _detailsTransactionByCode -> getDate ( ) ) , 'code' => $ this -> _detailsTransactionByCode -> getCode ( ) , 'reference' => $ this -> _detailsTransactionByCode -> getReference ( ) , 'type' => \ UOL \ PagSeguro \ Helpe...
Build and format the transaction data for the listing
52,694
private function prepareCreditorFees ( ) { $ creditorFees = "" ; if ( ! empty ( $ this -> _detailsTransactionByCode -> getCreditorFees ( ) ) ) { $ creditorFees = array ( 'intermediationRateAmount' => $ this -> _detailsTransactionByCode -> getCreditorFees ( ) -> getIntermediationRateAmount ( ) , 'intermediationFeeAmount...
Format transaction CreditorFees
52,695
private function prepareItems ( ) { $ itens = array ( ) ; if ( $ this -> _detailsTransactionByCode -> getItemCount ( ) > 0 ) { foreach ( $ this -> _detailsTransactionByCode -> getItems ( ) as $ item ) { $ itens [ ] = array ( 'id' => $ item -> getId ( ) , 'description' => $ item -> getDescription ( ) , 'quantity' => $ i...
Format transaction Items
52,696
private function preparePaymentMethod ( ) { $ paymentMethod = "" ; if ( ! empty ( $ this -> _detailsTransactionByCode -> getPaymentMethod ( ) ) ) { $ paymentMethod = array ( 'code' => $ this -> _detailsTransactionByCode -> getPaymentMethod ( ) -> getCode ( ) , 'type' => $ this -> _detailsTransactionByCode -> getPayment...
Format transaction PaymentMethod
52,697
private function prepareSender ( ) { $ documents = array ( ) ; if ( count ( $ this -> _detailsTransactionByCode -> getSender ( ) -> getDocuments ( ) ) > 0 ) { foreach ( $ this -> _detailsTransactionByCode -> getSender ( ) -> getDocuments ( ) as $ doc ) { $ documents [ ] = array ( 'type' => $ doc -> getType ( ) , 'ident...
Format transaction Sender
52,698
private function prepareShipping ( ) { $ shipping = array ( ) ; if ( ! empty ( $ this -> _detailsTransactionByCode -> getShipping ( ) ) ) { $ shipping = array ( 'addres' => array ( 'street' => $ this -> _detailsTransactionByCode -> getShipping ( ) -> getAddress ( ) -> getStreet ( ) , 'number' => $ this -> _detailsTrans...
Format transaction Shipping
52,699
private function hasEmail ( ) { $ email = $ this -> _scopeConfig -> getValue ( 'payment/pagseguro/email' ) ; if ( ! isset ( $ email ) ) return false ; if ( $ this -> isValidEmail ( $ email ) ) return true ; return false ; }
Check if has a valid e - mail