idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
16,700 | public function video ( $ video ) { $ oldSource = $ this -> source ; $ this -> source = $ video ; $ parsedURL = parse_url ( $ video ) ; if ( count ( $ parsedURL ) === 1 ) { $ this -> type = static :: TYPE_VIDEO ; $ this -> id = $ parsedURL [ 'path' ] ; return $ this ; } if ( strtolower ( $ parsedURL [ 'host' ] ) == 'yo... | Set Player Video Does not validate whether or not YouTube video exists . |
16,701 | public function playlist ( $ playlist ) { $ oldSource = $ this -> source ; $ this -> source = $ playlist ; $ parsedURL = parse_url ( $ playlist ) ; if ( count ( $ parsedURL ) === 1 ) { $ this -> type = static :: TYPE_PLAYLIST ; $ this -> id = $ parsedURL [ 'path' ] ; return $ this -> cookies ( ) -> theme ( static :: TH... | Set Player Playlist Does not validate whether or not YouTube playlist exists . |
16,702 | public function size ( $ size ) { if ( ! $ this -> isValidSize ( $ size ) ) { throw new AudioPlayerException ( 'Invalid Size' ) ; } $ this -> size = $ size ; if ( $ size == static :: SIZE_TINY || $ size == static :: SIZE_INVISIBLE ) { $ this -> progressBar ( false ) -> timeCode ( false ) ; } else { $ this -> progressBa... | Set Player Size . |
16,703 | public function theme ( $ theme ) { if ( $ this -> isPlaylist ( ) && $ theme == static :: THEME_DARK ) { throw new AudioPlayerException ( 'Playlists can not use the Dark Theme. YouTube limitation.' ) ; } if ( $ theme != static :: THEME_LIGHT && $ theme != static :: THEME_DARK ) { throw new AudioPlayerException ( 'Inva... | Set Player Theme . |
16,704 | public function hd ( $ useHD = true ) { if ( $ useHD ) { $ this -> hd = true ; } else { $ this -> hd = false ; } return $ this ; } | Set HD Choose whether or not to force the player into HD . |
16,705 | public function autoplay ( $ autoplay = true ) { if ( $ autoplay ) { $ this -> autoplay = true ; } else { $ this -> autoplay = false ; } return $ this ; } | Set Autoplay Choose whether or not to automatically play the video when it loads Please don t use this . You ll make me sad . |
16,706 | public function jsAPI ( $ useJSAPI = true ) { if ( $ useJSAPI ) { $ this -> jsapi = true ; } else { $ this -> jsapi = false ; } return $ this ; } | Set JSApi Choose whether or not to allow access via the YouTube JavaScript API . |
16,707 | public function progressBar ( $ useProgressBar = true ) { if ( $ useProgressBar ) { $ this -> progressbar = true ; } else { $ this -> progressbar = false ; } if ( $ useProgressBar && $ this -> getSize ( ) == static :: SIZE_TINY ) { $ this -> size ( static :: SIZE_SMALL ) ; } return $ this ; } | Set Progress Bar Choose whether or not to display the progress bar . |
16,708 | public function timeCode ( $ useTimeCode = true ) { if ( $ useTimeCode ) { $ this -> progressBar ( ) ; $ this -> timecode = true ; } else { $ this -> timecode = false ; } if ( $ this -> progressbar && $ this -> getSize ( ) == static :: SIZE_TINY ) { $ this -> size ( static :: SIZE_SMALL ) ; } return $ this ; } | Set Time Code Choose whether or not to display the time code . Requires Progress Bar . |
16,709 | public function cookies ( $ useCookies = true ) { if ( ! $ useCookies && $ this -> getType ( ) == static :: TYPE_PLAYLIST ) { throw new AudioPlayerException ( 'Can not disable cookies with playlists. YouTube limitation.' ) ; } if ( $ useCookies ) { $ this -> cookies = true ; } else { $ this -> cookies = false ; } retu... | Set Cookies Choose whether or not to allow YouTube to collect cookies . |
16,710 | public function https ( $ useHTTPS = true ) { if ( $ useHTTPS ) { $ this -> https = true ; } else { $ this -> https = false ; } return $ this ; } | Set HTTPS Choose whether to use HTTPs or HTTP . |
16,711 | public function getEmbedURL ( $ encode = true ) { $ url = '' ; if ( $ this -> getHTTPS ( ) ) { $ url .= 'https://' ; } else { $ url .= 'http://' ; } if ( $ this -> getCookies ( ) ) { $ url .= 'www.youtube.com' ; } else { $ url .= 'www.youtube-nocookie.com' ; } if ( $ this -> isVideo ( ) ) { $ url .= '/v/' ; } else { $ ... | Get Embed URL . |
16,712 | public function render ( $ return = false ) { $ html = '<object type="application/x-shockwave-flash"' ; $ html .= ' width="' . $ this -> getWidth ( ) . '"' ; $ html .= ' height="' . $ this -> getHeight ( ) . '"' ; $ html .= ' data="' . $ this -> getEmbedURL ( ) . '"' ; if ( $ this -> isInvisible ( ) ) { $ html .= ' sty... | Render valid XHTML . |
16,713 | public function getService ( Payment $ payment , $ intent ) { $ method = 'create' . ucfirst ( $ intent ) . 'Service' ; $ values = $ this -> extend ( $ method , $ payment ) ; if ( count ( $ values ) > 1 ) { throw new InvalidConfigurationException ( "Multiple extensions are trying to create a service for '$intent'" ) ; }... | Create a service for the given payment and intent . |
16,714 | protected function createPaymentService ( Payment $ payment ) { return $ this -> getService ( $ payment , GatewayInfo :: shouldUseAuthorize ( $ payment -> Gateway ) ? ServiceFactory :: INTENT_AUTHORIZE : ServiceFactory :: INTENT_PURCHASE ) ; } | Create a payment service . This will either return an AuthorizeService or PurchaseService depending on the gateway config . |
16,715 | public function cancel ( ) { if ( ! $ this -> payment -> IsComplete ( ) ) { $ this -> payment -> Status = 'Void' ; $ this -> payment -> write ( ) ; ErrorHandling :: safeExtend ( $ this -> payment , 'onCancelled' ) ; } return $ this -> generateServiceResponse ( ServiceResponse :: SERVICE_CANCELLED ) ; } | Cancel a payment |
16,716 | public function oGateway ( ) { $ gatewayName = $ this -> payment -> Gateway ; $ gateway = $ this -> getGatewayFactory ( ) -> create ( $ gatewayName ) ; $ parameters = GatewayInfo :: getParameters ( $ gatewayName ) ; if ( is_array ( $ parameters ) ) { $ gateway -> initialize ( $ parameters ) ; } return $ gateway ; } | Get the omnipay gateway associated with this payment with configuration applied . |
16,717 | public function handleNotification ( ) { $ gateway = $ this -> oGateway ( ) ; if ( ! $ gateway -> supportsAcceptNotification ( ) ) { throw new InvalidConfigurationException ( sprintf ( 'The gateway "%s" doesn\'t support "acceptNotification"' , $ this -> payment -> Gateway ) ) ; } $ notification = null ; try { $ notific... | Handle a notification via gateway - > acceptNotification . |
16,718 | protected function gatherGatewayData ( $ data = array ( ) , $ includeCardOrToken = true ) { if ( ! isset ( $ data [ 'clientIp' ] ) ) { $ data [ 'clientIp' ] = Controller :: curr ( ) -> getRequest ( ) -> getIP ( ) ; } $ gatewaydata = array_merge ( $ data , array ( 'amount' => ( float ) $ this -> payment -> MoneyAmount ,... | Collect common data parameters to pass to the gateway . This method should merge in common data that is required by all services . |
16,719 | protected function wrapOmnipayResponse ( ResponseInterface $ omnipayResponse , $ isNotification = false ) { if ( $ isNotification ) { $ flags = ServiceResponse :: SERVICE_NOTIFICATION ; if ( ! $ omnipayResponse -> isSuccessful ( ) ) { $ flags |= ServiceResponse :: SERVICE_ERROR ; } return $ this -> generateServiceRespo... | Get a service response from the given Omnipay response |
16,720 | protected function markCompleted ( $ endStatus , ServiceResponse $ serviceResponse , $ gatewayMessage ) { $ this -> payment -> Status = $ endStatus ; if ( $ gatewayMessage && ( $ reference = $ gatewayMessage -> getTransactionReference ( ) ) ) { $ this -> payment -> TransactionReference = $ reference ; } $ this -> payme... | Mark this payment process as completed . This sets the desired end - status on the payment sets the transaction reference and writes the payment . |
16,721 | protected function createPartialPayment ( $ amount , $ status , $ write = true ) { $ payment = Payment :: create ( array ( 'Gateway' => $ this -> payment -> Gateway , 'TransactionReference' => $ this -> payment -> TransactionReference , 'SuccessUrl' => $ this -> payment -> SuccessUrl , 'FailureUrl' => $ this -> payment... | Create a partial payment that will be based on the current payment . This new payment will inherit the Gateway TransactionReference SuccessUrl and FailureUrl of the initial payment . |
16,722 | protected function generateServiceResponse ( $ flags , $ omnipayData = null ) { $ response = new ServiceResponse ( $ this -> payment , $ flags ) ; if ( $ omnipayData ) { $ response -> setOmnipayResponse ( $ omnipayData ) ; } if ( ! $ response -> isNotification ( ) && ! $ response -> isRedirect ( ) ) { $ response -> set... | Generate a service response |
16,723 | protected function createMessage ( $ type , $ data = null ) { $ output = array ( ) ; if ( is_string ( $ data ) ) { $ output = [ 'Message' => $ data ] ; } elseif ( is_array ( $ data ) ) { $ output = $ data ; } elseif ( $ data instanceof \ Exception ) { $ output = [ 'Message' => $ data -> getMessage ( ) , 'Code' => $ dat... | Record a transaction on this for this payment . |
16,724 | protected function logToFile ( $ data , $ type = '' ) { $ this -> logger -> log ( is_subclass_of ( $ type , GatewayErrorMessage :: class ) ? 'error' : 'info' , sprintf ( '%s (%s)' , $ type , $ this -> payment -> Gateway ) , Logging :: prepareForLogging ( $ data ) ) ; } | Helper function for logging gateway requests |
16,725 | public static function subtract ( $ amountA , $ amountB ) { $ precision = ( int ) self :: config ( ) -> get ( 'precision' ) ; if ( function_exists ( 'bcsub' ) && self :: config ( ) -> get ( 'useBcMath' ) ) { return bcsub ( $ amountA , $ amountB , $ precision ) ; } return self :: formatFloat ( ( double ) $ amountA - ( d... | Subtract two numbers that are represented as a string . Numbers will not be rounded but floored instead! So 10 . 0 - 0 . 1 with a precision of 0 will result in 9! |
16,726 | public static function add ( $ amountA , $ amountB ) { $ precision = ( int ) self :: config ( ) -> get ( 'precision' ) ; if ( function_exists ( 'bcadd' ) && self :: config ( ) -> get ( 'useBcMath' ) ) { return bcadd ( $ amountA , $ amountB , $ precision ) ; } return self :: formatFloat ( ( double ) $ amountA + ( double... | Add two numbers that are represented as a string Numbers will not be rounded but floored instead! So 0 . 22 + 0 . 27 with a precision of 1 will result in 0 . 4! |
16,727 | public static function compare ( $ amountA , $ amountB ) { $ precision = ( int ) self :: config ( ) -> get ( 'precision' ) ; if ( function_exists ( 'bccomp' ) && self :: config ( ) -> get ( 'useBcMath' ) ) { return bccomp ( $ amountA , $ amountB , $ precision ) ; } $ scale = pow ( 10 , max ( 0 , $ precision ) ) ; $ a =... | Compare two numbers that are represented as a string |
16,728 | private static function formatFloat ( $ f , $ precision ) { $ scale = pow ( 10 , max ( 0 , $ precision ) ) ; $ i = ( int ) ( $ f * $ scale ) / $ scale ; return number_format ( $ i , $ precision , '.' , '' ) ; } | Format a float to string |
16,729 | public function initiate ( $ data = array ( ) ) { if ( $ this -> payment -> Status !== 'Created' ) { throw new InvalidStateException ( 'Cannot create a card for this payment. Status is not "Created"' ) ; } if ( ! $ this -> payment -> isInDB ( ) ) { $ this -> payment -> write ( ) ; } $ gateway = $ this -> oGateway ( ) ;... | Start a createcard request |
16,730 | private function addTransactionReference ( array & $ gatewayData , $ isAuthorize = false ) { $ payment = $ this -> owner -> getPayment ( ) ; if ( $ payment -> Gateway == 'SagePay_Server' ) { $ type = ( $ isAuthorize ) ? Message \ AuthorizeRedirectResponse :: class : Message \ PurchaseRedirectResponse :: class ; $ messa... | Grabs the transactionReference from the previous received message and adds it to the gateway data so that it can be sent back to SagePay as clarification |
16,731 | private function addDescription ( array & $ gatewayData ) { $ payment = $ this -> owner -> getPayment ( ) ; if ( $ payment -> Gateway == 'SagePay_Direct' || $ payment -> Gateway == 'SagePay_Server' ) { $ gatewayData [ 'description' ] = sprintf ( 'Payment made on %s' , date ( 'D j M Y' ) ) ; } } | Description for SagePay must be < 100 characters |
16,732 | private function respondToNotification ( ServiceResponse $ response , Payment $ payment ) { $ omnipayResponse = $ response -> getOmnipayResponse ( ) ; if ( $ omnipayResponse !== null && $ omnipayResponse -> isSuccessful ( ) && $ response -> isNotification ( ) && ! $ response -> isError ( ) ) { $ msg = [ 'Status=' . Ser... | Used to respond to the SagePay notification |
16,733 | public function getCardTypes ( ) { $ card = new CreditCard ( ) ; $ brands = $ card -> getSupportedBrands ( ) ; foreach ( $ brands as $ brand => $ x ) { $ brands [ $ brand ] = _t ( 'CreditCard.' . strtoupper ( $ brand ) , $ brand ) ; } return $ brands ; } | Get a list of supported credit - card brands . |
16,734 | public function getBillingFields ( ) { $ fields = array ( 'billingAddress1' => TextField :: create ( $ this -> getFieldName ( 'billingAddress1' ) , _t ( 'SilverStripe\Omnipay\PaymentForm.BillingAddress1' , 'Address' ) ) , 'billingAddress2' => TextField :: create ( $ this -> getFieldName ( 'billingAddress2' ) , _t ( 'Si... | Get billing address fields |
16,735 | public function getEmailFields ( ) { $ fields = array ( 'email' => EmailField :: create ( $ this -> getFieldName ( 'email' ) , _t ( 'SilverStripe\Omnipay\PaymentForm.Email' , 'Email' ) ) ) ; $ this -> cullForGateway ( $ fields ) ; return FieldList :: create ( $ fields ) ; } | Get email fields . |
16,736 | public function getCompanyFields ( ) { $ fields = array ( 'company' => TextField :: create ( $ this -> getFieldName ( 'company' ) , _t ( 'SilverStripe\Omnipay\PaymentForm.Company' , 'Company' ) ) ) ; $ this -> cullForGateway ( $ fields ) ; return FieldList :: create ( $ fields ) ; } | Get company fields |
16,737 | protected function cullForGateway ( & $ fields , $ defaults = array ( ) ) { if ( ! $ this -> gateway ) { return ; } $ selected = array_merge ( $ defaults , GatewayInfo :: requiredFields ( $ this -> gateway ) ) ; foreach ( $ fields as $ name => $ field ) { if ( ! in_array ( $ name , $ selected ) ) { unset ( $ fields [ $... | Clear all fields that are not required by the gateway . Does nothing if gateway is null |
16,738 | private function getGlobalFieldName ( $ defaultName ) { $ renameMap = $ this -> config ( ) -> rename ; if ( is_array ( $ renameMap ) && array_key_exists ( $ defaultName , $ renameMap ) ) { return $ renameMap [ $ defaultName ] ; } return false ; } | Fetches custom name from the rename map or returns false |
16,739 | private function getGatewayFieldName ( $ defaultName , $ gateway = null ) { if ( ! $ gateway ) { if ( ! $ this -> gateway ) { return false ; } return $ this -> getGatewayFieldName ( $ defaultName , $ this -> gateway ) ; } $ renameMap = $ this -> config ( ) -> rename ; if ( is_array ( $ renameMap ) && array_key_exists (... | Fetches custom name for a gateway field from the rename map or returns false |
16,740 | protected function notificationFailure ( $ serviceResponse ) { $ omnipayResponse = $ serviceResponse -> getOmnipayResponse ( ) ; if ( ! $ omnipayResponse ) { return ; } $ pending = $ this -> payment -> getPartialPayments ( ) -> filter ( 'Status' , $ this -> pendingState ) ; foreach ( $ pending as $ payment ) { $ paymen... | Method to handle notification failures . Here we have to check if the gateway actually reported a failure and then update the payment status accordingly! |
16,741 | public function setOmnipayResponse ( $ response ) { $ this -> omnipayResponse = $ response ; if ( $ this -> isRedirect ( ) ) { $ redirectResponse = $ this -> omnipayResponse -> getRedirectResponse ( ) ; if ( $ redirectResponse instanceof \ Symfony \ Component \ HttpFoundation \ RedirectResponse ) { $ this -> targetUrl ... | Set the response from Omnipay |
16,742 | public function redirectOrRespond ( ) { if ( $ this -> isRedirect ( ) ) { $ redirectResponse = $ this -> omnipayResponse -> getRedirectResponse ( ) ; if ( $ redirectResponse instanceof \ Symfony \ Component \ HttpFoundation \ RedirectResponse ) { $ this -> targetUrl = $ redirectResponse -> getTargetUrl ( ) ; return Con... | Create a redirect or a response . This should be called when the application is ready to redirect! |
16,743 | public function initiate ( $ data = array ( ) ) { if ( $ this -> payment -> Status !== 'Created' ) { throw new InvalidStateException ( 'Cannot authorize this payment. Status is not "Created"' ) ; } if ( ! $ this -> payment -> isInDB ( ) ) { $ this -> payment -> write ( ) ; } $ gateway = $ this -> oGateway ( ) ; if ( ! ... | Start an authorization request |
16,744 | public static function getEndpointUrl ( $ action , $ identifier ) { $ url = Controller :: join_links ( 'paymentendpoint' , $ identifier , $ action ) ; return Director :: absoluteURL ( $ url ) ; } | Generate an absolute url for gateways to return to or send requests to . |
16,745 | protected function getPaymentIntent ( $ payment ) { $ intent = null ; switch ( $ payment -> Status ) { case 'PendingAuthorization' : case 'Authorized' : $ intent = ServiceFactory :: INTENT_AUTHORIZE ; break ; case 'PendingCreateCard' : case 'CardCreated' : $ intent = ServiceFactory :: INTENT_CREATECARD ; break ; case '... | Find the intent of the current payment |
16,746 | protected function createPaymentResponse ( $ payment ) { if ( ! $ payment ) { return $ this -> httpError ( 404 , _t ( 'SilverStripe\Omnipay\Model\Payment.NotFound' , 'Payment could not be found.' ) ) ; } $ intent = $ this -> getPaymentIntent ( $ payment ) ; if ( ! $ intent ) { return $ this -> httpError ( 403 , _t ( 'S... | Create the appropriate HTTP response for the given payment . |
16,747 | protected function getPaymentFromRequest ( HTTPRequest $ request , $ gateway = null ) { $ identifier = $ request -> param ( 'Identifier' ) ; $ results = $ this -> extend ( 'updatePaymentFromRequest' , $ request , $ gateway ) ; foreach ( $ results as $ result ) { if ( $ result instanceof Payment ) { return $ result ; } ... | Get the the payment according to the identifier given in the url |
16,748 | public function TotalPaid ( ) { $ paid = 0 ; if ( $ payments = $ this -> owner -> Payments ( ) ) { foreach ( $ payments as $ payment ) { if ( $ payment -> Status == 'Captured' ) { $ paid += $ payment -> Amount ; } } } return $ paid ; } | Get the total captured amount |
16,749 | public function TotalPaidOrAuthorized ( ) { $ paid = 0 ; if ( $ payments = $ this -> owner -> Payments ( ) ) { foreach ( $ payments as $ payment ) { $ captured = $ payment -> Status == 'Captured' ; $ authorized = $ payment -> Status == 'Authorized' && ! GatewayInfo :: isManual ( $ payment -> Gateway ) ; if ( $ captured... | Get the total captured or authorized amount excluding Manual payments . |
16,750 | public function initiate ( $ data = array ( ) ) { if ( $ this -> payment -> Status !== 'Created' ) { throw new InvalidStateException ( 'Cannot initiate a purchase with this payment. Status is not "Created"' ) ; } if ( ! $ this -> payment -> isInDB ( ) ) { $ this -> payment -> write ( ) ; } $ gateway = $ this -> oGatewa... | Attempt to make a payment . |
16,751 | public function complete ( $ data = array ( ) , $ isNotification = false ) { $ flags = $ isNotification ? ServiceResponse :: SERVICE_NOTIFICATION : 0 ; if ( $ this -> payment -> Status === 'Captured' ) { return $ this -> generateServiceResponse ( $ flags ) ; } if ( $ this -> payment -> Status !== 'PendingPurchase' ) { ... | Finalise this payment after off - site external processing . This is usually only called by PaymentGatewayController . |
16,752 | private function PaymentTypes ( ) { $ factory = Omnipay :: getFactory ( ) ; $ gateways = array_unique ( array_merge ( $ factory -> all ( ) , array_keys ( GatewayInfo :: getSupportedGateways ( false ) ) ) ) ; $ supportedGateways = array ( ) ; array_walk ( $ gateways , function ( $ name , $ index ) use ( & $ supportedGat... | Get all available payment types |
16,753 | public function getDefaultSearchContext ( ) { $ context = parent :: getDefaultSearchContext ( ) ; $ fields = $ context -> getSearchFields ( ) ; $ fields -> removeByName ( 'Gateway' ) ; $ fields -> removeByName ( 'Created' ) ; $ fields -> insertAfter ( 'Money' , DropdownField :: create ( 'Gateway' , $ this -> fieldLabel... | Change search context to use a dropdown for list of gateways . |
16,754 | public function init ( $ gateway , $ amount , $ currency ) { $ this -> setGateway ( $ gateway ) ; $ this -> setAmount ( $ amount ) ; $ this -> setCurrency ( $ currency ) ; return $ this ; } | Set gateway amount and currency in one function . |
16,755 | public function getTitle ( ) { return strftime ( _t ( 'SilverStripe\Omnipay\Model\Payment.TitleTemplate' , '{Gateway} {Money} %d/%m/%Y' , 'A template for the payment title' , str_replace ( '%' , '%%' , array ( 'Gateway' => $ this -> getGatewayTitle ( ) , 'Money' => $ this -> dbObject ( 'Money' ) -> Nice ( ) ) ) ) , str... | Locale aware title for a payment . Consists of Gateway - Name Money and Currency Created date . |
16,756 | public function getPaymentStatus ( ) { if ( $ this -> Status ) { return _t ( 'SilverStripe\Omnipay\Model\Payment.STATUS_' . strtoupper ( $ this -> Status ) , $ this -> Status ) ; } return null ; } | Get the payment status . This will return a localized value if available . |
16,757 | public function setAmount ( $ amount ) { if ( $ amount instanceof DBMoney ) { $ this -> setField ( 'Money' , $ amount ) ; } elseif ( $ this -> Status == 'Created' && is_numeric ( $ amount ) ) { $ this -> MoneyAmount = $ amount ; } return $ this ; } | Set the payment amount but only when the status is Created . |
16,758 | public function getPartialPayments ( ) { if ( ! $ this -> isInDB ( ) ) { return null ; } return Payment :: get ( ) -> filter ( 'InitialPaymentID' , $ this -> ID ) -> sort ( array ( 'Created' => 'DESC' , 'ID' => 'DESC' ) ) ; } | Get partial payments that have this payment as initial payment . The list will be sorted from newest to oldest |
16,759 | public function getMaxCaptureAmount ( ) { if ( $ this -> Status !== 'Authorized' ) { return 0 ; } $ percent = GatewayInfo :: maxExcessCapturePercent ( $ this -> Gateway ) ; $ fixedAmount = GatewayInfo :: maxExcessCaptureAmount ( $ this -> Gateway , $ this -> getCurrency ( ) ) ; if ( $ percent === - 1 ) { return Payment... | Calculate the max amount that can be captured for this payment . If the Status of the payment isn t Authorized this will return 0 |
16,760 | public function canCapture ( $ member = null , $ partial = false ) { if ( ! ( $ this -> Status === 'Authorized' && ( $ partial ? GatewayInfo :: allowPartialCapture ( $ this -> Gateway ) : GatewayInfo :: allowCapture ( $ this -> Gateway ) ) ) ) { return false ; } if ( $ this -> isInDB ( ) ) { $ hasPartials = $ this -> g... | Whether or not this payment can be captured |
16,761 | public function canVoid ( $ member = null ) { if ( ! ( $ this -> Status == 'Authorized' && GatewayInfo :: allowVoid ( $ this -> Gateway ) ) ) { return false ; } $ extended = $ this -> extendedCan ( 'canVoid' , $ member ) ; if ( $ extended !== null ) { return $ extended ; } return Permission :: check ( 'VOID_PAYMENTS' ,... | Whether or not this payment can be voided |
16,762 | public function canRefund ( $ member = null , $ partial = false ) { if ( ! ( $ this -> Status == 'Captured' && ( $ partial ? GatewayInfo :: allowPartialRefund ( $ this -> Gateway ) : GatewayInfo :: allowRefund ( $ this -> Gateway ) ) ) ) { return false ; } if ( $ this -> isInDB ( ) ) { $ hasPartials = $ this -> getPart... | Whether or not this payment can be refunded |
16,763 | protected function generateUniquePaymentIdentifier ( $ gateway = null ) { $ gateway = $ gateway ? : $ this -> Gateway ; $ length = GatewayInfo :: getConfigSetting ( $ gateway , 'payment_identifier_length' ) ? : static :: config ( ) -> get ( 'payment_identifier_length' ) ; $ generator = Injector :: inst ( ) -> get ( Ran... | Generate an internally unique string that identifies a payment and can be used in URLs . |
16,764 | protected function getStatusValues ( ) { $ values = array ( ) ; foreach ( $ this -> dbObject ( 'Status' ) -> enumValues ( ) as $ value ) { $ values [ $ value ] = _t ( 'SilverStripe\Omnipay\Model\Payment.STATUS_' . strtoupper ( $ value ) , $ value ) ; } return $ values ; } | Get an array of status enum value to translated string . Can be used for dropdowns |
16,765 | public static function prepareForLogging ( $ data ) { if ( empty ( $ data ) ) { return [ ] ; } if ( ! is_array ( $ data ) ) { return [ $ data ] ; } if ( self :: config ( ) -> logStyle == self :: LOGSTYLE_SIMPLE ) { return array_filter ( [ isset ( $ data [ 'Message' ] ) ? $ data [ 'Message' ] : null , isset ( $ data [ '... | Prepare data for logging by cleaning up the data or simplify it . |
16,766 | private static function sanitize ( array & $ data ) { $ blackList = array_combine ( self :: config ( ) -> loggingBlacklist , self :: config ( ) -> loggingBlacklist ) ; array_walk_recursive ( $ data , function ( & $ value , $ key ) use ( $ blackList ) { if ( isset ( $ blackList [ $ key ] ) ) { $ value = '(sanitized)' ; ... | Clean out sensitive data such as credit - card numbers |
16,767 | public static function getSupportedGateways ( $ nice = true ) { $ allowed = Payment :: config ( ) -> allowed_gateways ; if ( ! is_array ( $ allowed ) || empty ( $ allowed ) ) { throw new InvalidConfigurationException ( 'No allowed gateways configured. Use SilverStripe\Omnipay\Model\Payment.allowed_gateways config.' ) ;... | Get the available configured payment types optionally with i18n readable names . |
16,768 | public static function niceTitle ( $ name ) { if ( empty ( $ name ) ) { return '' ; } $ gateway = null ; try { $ factory = new GatewayFactory ( ) ; $ gateway = $ factory -> create ( $ name ) ; } catch ( \ Exception $ e ) { } $ title = _t ( 'Gateway.' . $ name , $ gateway ? $ gateway -> getName ( ) : $ name ) ; return (... | Get a locale aware title for the given gateway . |
16,769 | public static function isOffsite ( $ gateway ) { $ configValue = self :: getConfigSetting ( $ gateway , 'is_offsite' ) ; if ( is_bool ( $ configValue ) ) { return $ configValue ; } $ factory = new GatewayFactory ( ) ; $ gateway = $ factory -> create ( $ gateway ) ; if ( method_exists ( $ gateway , 'isOffsite' ) ) { ret... | Checks if the given gateway name is an off - site gateway . |
16,770 | public static function shouldUseAuthorize ( $ gateway ) { if ( self :: isManual ( $ gateway ) ) { return true ; } return self :: getConfigSetting ( $ gateway , 'use_authorize' ) == true ; } | Check if the given gateway should use authorize payments |
16,771 | public static function shouldUseAsyncNotifications ( $ gateway ) { if ( self :: isManual ( $ gateway ) ) { return false ; } return self :: getConfigSetting ( $ gateway , 'use_async_notification' ) == true ; } | Check if the given gateway should use asynchronous notifications |
16,772 | public static function allowVoid ( $ gateway ) { $ setting = self :: getConfigSetting ( $ gateway , 'can_void' ) ; return ( $ setting === null || ! ( $ setting == false || $ setting === 'off' || $ setting === 'false' ) ) ; } | Whether or not the given gateway should allow voiding of payments |
16,773 | public static function allowPartialCapture ( $ gateway ) { return ( self :: configToConstant ( $ gateway , 'can_capture' ) === self :: PARTIAL || self :: configToConstant ( $ gateway , 'can_capture' ) === self :: MULTIPLE ) ; } | Whether or not the given gateway should allow partial capturing of payments |
16,774 | public static function maxExcessCapturePercent ( $ gateway ) { $ setting = self :: getConfigSetting ( $ gateway , 'max_capture' ) ; if ( ! $ setting ) { return 0 ; } $ pattern = '/^(\d+)%$/' ; if ( ! is_array ( $ setting ) ) { if ( preg_match ( $ pattern , $ setting , $ match ) ) { return $ match [ 1 ] ; } if ( is_nume... | Get the max excess capture percentage for the given gateway . |
16,775 | public static function maxExcessCaptureAmount ( $ gateway , $ currency = null ) { $ setting = self :: getConfigSetting ( $ gateway , 'max_capture' ) ; if ( ! $ setting ) { return 0 ; } if ( ! is_array ( $ setting ) ) { if ( preg_match ( '/^\d+%$/' , $ setting ) ) { return - 1 ; } if ( is_numeric ( $ setting ) ) { retur... | Get the max excess capture amount for the given gateway and an optional currency . |
16,776 | public static function allowPartialRefund ( $ gateway ) { return ( self :: configToConstant ( $ gateway , 'can_refund' ) === self :: PARTIAL || self :: configToConstant ( $ gateway , 'can_refund' ) === self :: MULTIPLE ) ; } | Whether or not the given gateway should allow partial refunding of payments |
16,777 | public static function requiredFields ( $ gateway ) { $ fields = array ( ) ; $ requiredFields = self :: getConfigSetting ( $ gateway , 'required_fields' ) ; if ( is_array ( $ requiredFields ) ) { $ fields = $ requiredFields ; } if ( ! self :: isOffsite ( $ gateway ) && ! self :: isManual ( $ gateway ) ) { $ fields = ar... | Get the required parameters for a given gateway |
16,778 | public static function getParameters ( $ gateway ) { $ params = self :: getConfigSetting ( $ gateway , 'parameters' ) ; return is_array ( $ params ) ? $ params : null ; } | Get the gateway config - parameters . |
16,779 | public static function getConfigSetting ( $ gateway , $ key ) { $ config = self :: config ( ) -> get ( $ gateway ) ; if ( ! is_array ( $ config ) ) { return null ; } return isset ( $ config [ $ key ] ) ? $ config [ $ key ] : null ; } | Get a single config setting for a gateway |
16,780 | public function allow ( Request $ request ) { foreach ( $ this -> patterns as $ regex ) if ( preg_match ( sprintf ( "#^%s$#i" , $ regex ) , $ request -> getUri ( ) -> getPath ( ) ) ) return false ; return true ; } | The default allow rule set allows all connections through unless otherwise stated |
16,781 | public function browserAction ( ) { if ( false === $ this -> admin -> isGranted ( 'LIST' ) ) { throw new AccessDeniedException ( ) ; } $ datagrid = $ this -> admin -> getDatagrid ( ) ; $ datagrid -> setValue ( 'context' , null , $ this -> admin -> getPersistentParameter ( 'context' ) ) ; $ datagrid -> setValue ( 'provi... | Returns the response object associated with the browser action . |
16,782 | public function uploadAction ( ) { if ( false === $ this -> admin -> isGranted ( 'CREATE' ) ) { throw new AccessDeniedException ( ) ; } $ mediaManager = $ this -> get ( 'sonata.media.manager.media' ) ; $ request = $ this -> getRequest ( ) ; $ provider = $ request -> get ( 'provider' ) ; $ file = $ request -> files -> g... | Returns the response object associated with the upload action . |
16,783 | public function isValid ( $ value , $ checkExistence = false ) { if ( null === $ value || '' === $ value ) { return false ; } $ countryCode = substr ( $ value , 0 , 2 ) ; $ vatin = substr ( $ value , 2 ) ; if ( false === $ this -> isValidCountryCode ( $ countryCode ) ) { return false ; } if ( 0 === preg_match ( '/^(?:'... | Returns true if value is a valid VAT identification number false otherwise |
16,784 | private function getSoapClient ( ) { if ( null === $ this -> soapClient ) { $ this -> soapClient = new \ SoapClient ( $ this -> wsdl , array ( 'classmap' => $ this -> classmap , 'user_agent' => 'Mozilla' , 'exceptions' => true , ) ) ; } return $ this -> soapClient ; } | Get SOAP client |
16,785 | public function getEvents ( $ app , $ subscribeAll = false ) { $ uri = 'events' ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri , [ 'form_params' => [ 'app' => $ app , 'subscribeAll' => $ subscribeAll , ] ] ) ; $ events = [ ] ; foreach ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) as $ ev... | WebSocket connection for events . |
16,786 | protected function doRequest ( $ type , $ endpoint , $ params = [ ] ) { $ base = ( $ this -> useSSL ) ? "https" : "http" ; $ url = $ base . "://" . $ this -> host . ":" . $ this -> port . $ this -> plugin . $ endpoint ; if ( $ this -> useBasicAuth ) $ auth = 'Basic ' . base64_encode ( $ this -> basicUser . ':' . $ this... | Make the request and analyze the result |
16,787 | public function stop ( ) { foreach ( array_reverse ( $ this -> getArrayCopy ( ) ) as $ playback ) { try { $ this -> phparia -> playbacks ( ) -> stopPlayback ( $ playback -> getId ( ) ) ; } catch ( \ Exception $ ignore ) { } } } | Stop all the playbacks |
16,788 | public function getMailboxes ( ) { $ uri = 'mailboxes' ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; $ mailboxes = [ ] ; foreach ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) as $ mailbox ) { $ mailboxes [ ] = new Mailbox ( $ mailbox ) ; } return $ mailboxes ; } | List all mailboxes . |
16,789 | public function getMailbox ( $ mailboxName ) { $ uri = "mailboxes/$mailboxName" ; try { $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } return new Mailbox ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) ) ; } | Retrieve the current state of a mailbox . |
16,790 | public function deleteMailbox ( $ mailboxName ) { $ uri = "mailboxes/$mailboxName" ; try { $ this -> client -> getEndpoint ( ) -> delete ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } } | Destroy a mailbox . |
16,791 | public function getApplications ( ) { $ uri = 'applications' ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; $ applications = [ ] ; foreach ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) as $ application ) { $ applications [ ] = new Application ( $ this -> client , $ application ) ; } ... | List all getApplications . |
16,792 | public function getApplication ( $ applicationName ) { $ uri = "applications/$applicationName" ; try { $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } return new Application ( $ this -> client , \ GuzzleHttp \ json_deco... | Get details of an application . |
16,793 | public function subscribe ( $ applicationName , $ eventSource ) { $ uri = "applications/$applicationName/subscription" ; try { $ response = $ this -> client -> getEndpoint ( ) -> post ( $ uri , [ 'form_params' => [ 'eventSource' => $ eventSource , ] ] ) ; } catch ( RequestException $ e ) { $ this -> processRequestExcep... | Subscribe an application to a event source . Returns the state of the application after the subscriptions have changed |
16,794 | public function unsubscribe ( $ applicationName , $ eventSource ) { $ uri = "applications/$applicationName/subscription?eventSource=" . \ GuzzleHttp \ json_encode ( $ eventSource ) ; try { $ response = $ this -> client -> getEndpoint ( ) -> delete ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestE... | Unsubscribe an application from an event source . Returns the state of the application after the subscriptions have changed |
16,795 | public function getRecordings ( ) { $ uri = 'recordings/stored' ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; $ recordings = [ ] ; foreach ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) as $ recording ) { $ recordings [ ] = new StoredRecording ( $ recording ) ; } return $ recordings ... | List recordings that are complete . |
16,796 | public function getRecording ( $ recordingName ) { $ uri = "recordings/stored/$recordingName" ; try { $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } return new StoredRecording ( \ GuzzleHttp \ json_decode ( $ response ... | Get a stored recording s details . |
16,797 | public function deleteRecording ( $ recordingName ) { $ uri = "recordings/stored/$recordingName" ; try { $ this -> client -> getEndpoint ( ) -> delete ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } } | Delete a stored recording . |
16,798 | public function copyRecording ( $ recordingName , $ destinationRecordingName ) { $ uri = "recordings/stored/$recordingName/copy" ; try { $ response = $ this -> client -> getEndpoint ( ) -> post ( $ uri , [ 'form_params' => [ 'destinationRecordingName' => $ destinationRecordingName , ] ] ) ; } catch ( RequestException $... | Copy a stored recording . |
16,799 | public function getLiveRecording ( $ recordingName ) { $ uri = "recordings/live/$recordingName" ; try { $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } return new LiveRecording ( $ this -> client , \ GuzzleHttp \ json_d... | Get live recording |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.