src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerPayPal.class.php
protected function CallPayPalExpressCheckout($sMessageConsumer)
    {
        $oGlobal = TGlobal::instance();

        $sReturnURLBase = $this->getActivePageService()->getActivePage()->GetRealURLPlain(array(), true);
        if ('.html' == substr($sReturnURLBase, -5)) {
            $sReturnURLBase = substr($sReturnURLBase, 0, -5);
        }
        if ('/' != substr($sReturnURLBase, -1)) {
            $sReturnURLBase .= '/';
        }
        $sSuccessURL = $sReturnURLBase.self::URL_IDENTIFIER.'success/spot_'.$oGlobal->GetExecutingModulePointer()->sModuleSpotName;
        $sCancelURL = $sReturnURLBase.self::URL_IDENTIFIER.'cancel/spot_'.$oGlobal->GetExecutingModulePointer()->sModuleSpotName;

        $oBasket = TShopBasket::GetInstance();

        $aParameter = array();
        $aParameter['PAYMENTREQUEST_0_AMT'] = number_format($oBasket->dCostTotal, 2); // the total value to charge (use US-Format (1000.00)
        $aParameter['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->GetCurrencyIdentifier();
        $aParameter['RETURNURL'] = $sSuccessURL; // go to the checkout complete page
        $aParameter['CANCELURL'] = $sCancelURL; //urldecode(str_replace('&amp;','&',$oActivePage->GetRealURL(array('paypalreturn'=>'1'),$aExcludes,true))); // return to the cancel page

        // styling
        $aParameter['HDRIMG'] = ''; // - : specify an image to appear at the top left of the payment page
        $aParameter['HDRBORDERCOLOR'] = ''; // - : set the border color around the header of the payment page
        $aParameter['HDRBACKCOLOR'] = ''; // - : set the background color for the background of the header of the payment page
        $aParameter['PAYFLOWCOLOR'] = ''; // - : set the background color for the payment page

        //$aParameter['notify_url'] = $this->GetInstantPaymentNotificationListenerURL(); // instant payment notification url

        $logger = $this->getPaypalLogger();

        $logger->info('Parameters sent to the PayPal API', $aParameter);
        $aResponse = $this->ExecutePayPalCall('SetExpressCheckout', $aParameter);

        $sSuccess = false;
        // store relevant data in session - and redirect to paypal
        if (array_key_exists('ACK', $aResponse)) {
            $sAckResponse = strtoupper($aResponse['ACK']);
            if ('SUCCESS' == $sAckResponse) {
                $this->sPayPalToken = urldecode($aResponse['TOKEN']);
                $payPalURL = $this->GetConfigParameter('url').'?cmd=_express-checkout&token='.$this->sPayPalToken;
                $this->getRedirect()->redirect($payPalURL);
                $sSuccess = true;
            }
        }
        if (!$sSuccess) {
            $sResponse = self::GetPayPalErrorMessage($aResponse);
            $logger->critical('PayPal payment could not be initiated.', array($sResponse));

            $oMsgManager = TCMSMessageManager::GetInstance();
            $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-PAYMENT-ERROR', array('errorMsg' => 'Error Number: '.$aResponse['L_ERRORCODE0']));
        }

        return $sSuccess;
    }
protected function CallPayPalExpressCheckout($sMessageConsumer)
    {
        $oGlobal = TGlobal::instance();

        $sReturnURLBase = $this->getActivePageService()->getActivePage()->GetRealURLPlain(array(), true);
        if ('.html' == substr($sReturnURLBase, -5)) {
            $sReturnURLBase = substr($sReturnURLBase, 0, -5);
        }
        if ('/' != substr($sReturnURLBase, -1)) {
            $sReturnURLBase .= '/';
        }
        $sSuccessURL = $sReturnURLBase.self::URL_IDENTIFIER.'success/spot_'.$oGlobal->GetExecutingModulePointer()->sModuleSpotName;
        $sCancelURL = $sReturnURLBase.self::URL_IDENTIFIER.'cancel/spot_'.$oGlobal->GetExecutingModulePointer()->sModuleSpotName;

        $oBasket = TShopBasket::GetInstance();

        $aParameter = array();
        $aParameter['PAYMENTREQUEST_0_AMT'] = number_format($oBasket->dCostTotal, 2); // the total value to charge (use US-Format (1000.00)
        $aParameter['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->GetCurrencyIdentifier();
        $aParameter['RETURNURL'] = $sSuccessURL; // go to the checkout complete page
        $aParameter['CANCELURL'] = $sCancelURL; //urldecode(str_replace('&amp;','&',$oActivePage->GetRealURL(array('paypalreturn'=>'1'),$aExcludes,true))); // return to the cancel page

        // styling
        $aParameter['HDRIMG'] = ''; // - : specify an image to appear at the top left of the payment page
        $aParameter['HDRBORDERCOLOR'] = ''; // - : set the border color around the header of the payment page
        $aParameter['HDRBACKCOLOR'] = ''; // - : set the background color for the background of the header of the payment page
        $aParameter['PAYFLOWCOLOR'] = ''; // - : set the background color for the payment page

        //$aParameter['notify_url'] = $this->GetInstantPaymentNotificationListenerURL(); // instant payment notification url

        $logger = $this->getPaypalLogger();

        $logger->info('Parameters sent to the PayPal API', $aParameter);
        $aResponse = $this->ExecutePayPalCall('SetExpressCheckout', $aParameter);

        $sSuccess = false;
        // store relevant data in session - and redirect to paypal
        if (array_key_exists('ACK', $aResponse)) {
            $sAckResponse = strtoupper($aResponse['ACK']);
            if ('SUCCESS' == $sAckResponse) {
                $this->sPayPalToken = urldecode($aResponse['TOKEN']);
                $payPalURL = $this->GetConfigParameter('url').'?cmd=_express-checkout&token='.$this->sPayPalToken;
                $this->getRedirect()->redirect($payPalURL);
                $sSuccess = true;
            }
        }
        if (!$sSuccess) {
            $sResponse = self::GetPayPalErrorMessage($aResponse);
            $logger->critical('PayPal payment could not be initiated.', array($sResponse));

            $oMsgManager = TCMSMessageManager::GetInstance();
            $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-PAYMENT-ERROR', array('errorMsg' => 'Error Number: '.$aResponse['L_ERRORCODE0']));
        }

        return $sSuccess;
    }
protected function CallPayPalExpressCheckout ( $ sMessageConsumer ) { $ oGlobal = TGlobal :: instance ( ) ; $ sReturnURLBase = $ this -> getActivePageService ( ) -> getActivePage ( ) -> GetRealURLPlain ( array ( ) , true ) ; if ( '.html' == substr ( $ sReturnURLBase , - 5 ) ) { $ sReturnURLBase = substr ( $ sReturnURLBase , 0 , - 5 ) ; } if ( '/' != substr ( $ sReturnURLBase , - 1 ) ) { $ sReturnURLBase .= '/' ; } $ sSuccessURL = $ sReturnURLBase . self :: URL_IDENTIFIER . 'success/spot_' . $ oGlobal -> GetExecutingModulePointer ( ) -> sModuleSpotName ; $ sCancelURL = $ sReturnURLBase . self :: URL_IDENTIFIER . 'cancel/spot_' . $ oGlobal -> GetExecutingModulePointer ( ) -> sModuleSpotName ; $ oBasket = TShopBasket :: GetInstance ( ) ; $ aParameter = array ( ) ; $ aParameter [ 'PAYMENTREQUEST_0_AMT' ] = number_format ( $ oBasket -> dCostTotal , 2 ) ; // the total value to charge (use US-Format (1000.00) $ aParameter [ 'PAYMENTREQUEST_0_CURRENCYCODE' ] = $ this -> GetCurrencyIdentifier ( ) ; $ aParameter [ 'RETURNURL' ] = $ sSuccessURL ; // go to the checkout complete page $ aParameter [ 'CANCELURL' ] = $ sCancelURL ; //urldecode(str_replace('&amp;','&',$oActivePage->GetRealURL(array('paypalreturn'=>'1'),$aExcludes,true))); // return to the cancel page // styling $ aParameter [ 'HDRIMG' ] = '' ; // - : specify an image to appear at the top left of the payment page $ aParameter [ 'HDRBORDERCOLOR' ] = '' ; // - : set the border color around the header of the payment page $ aParameter [ 'HDRBACKCOLOR' ] = '' ; // - : set the background color for the background of the header of the payment page $ aParameter [ 'PAYFLOWCOLOR' ] = '' ; // - : set the background color for the payment page //$aParameter['notify_url'] = $this->GetInstantPaymentNotificationListenerURL(); // instant payment notification url $ logger = $ this -> getPaypalLogger ( ) ; $ logger -> info ( 'Parameters sent to the PayPal API' , $ aParameter ) ; $ aResponse = $ this -> ExecutePayPalCall ( 'SetExpressCheckout' , $ aParameter ) ; $ sSuccess = false ; // store relevant data in session - and redirect to paypal if ( array_key_exists ( 'ACK' , $ aResponse ) ) { $ sAckResponse = strtoupper ( $ aResponse [ 'ACK' ] ) ; if ( 'SUCCESS' == $ sAckResponse ) { $ this -> sPayPalToken = urldecode ( $ aResponse [ 'TOKEN' ] ) ; $ payPalURL = $ this -> GetConfigParameter ( 'url' ) . '?cmd=_express-checkout&token=' . $ this -> sPayPalToken ; $ this -> getRedirect ( ) -> redirect ( $ payPalURL ) ; $ sSuccess = true ; } } if ( ! $ sSuccess ) { $ sResponse = self :: GetPayPalErrorMessage ( $ aResponse ) ; $ logger -> critical ( 'PayPal payment could not be initiated.' , array ( $ sResponse ) ) ; $ oMsgManager = TCMSMessageManager :: GetInstance ( ) ; $ oMsgManager -> AddMessage ( $ sMessageConsumer , 'ERROR-ORDER-REQUEST-PAYMENT-ERROR' , array ( 'errorMsg' => 'Error Number: ' . $ aResponse [ 'L_ERRORCODE0' ] ) ) ; } return $ sSuccess ; }
return the URL to the IFrame we call in order for paypal to collect the data.

@param string $sMessageConsumer - the name of the message handler that can display messages if an error occurs (assuming you return false)

@return string
return the URL to the IFrame we call in order for paypal to collect the data .