Controller/ExpressCheckoutDispatcher.php
protected function setDeliverySetListForCallbackResponse($payPalService, $deliverySetList, $user, $basket)
    {
        $maxDeliveryAmount = $this->getPayPalConfig()->getMaxPayPalDeliveryAmount();
        $cur = \OxidEsales\Eshop\Core\Registry::getConfig()->getActShopCurrencyObject();
        $basketPrice = $basket->getPriceForPayment() / $cur->rate;
        $actShipSet = $basket->getShippingId();
        $hasActShipSet = false;
        $cnt = 0;

        // VAT for delivery will be calculated always
        $delVATPercent = $basket->getAdditionalServicesVatPercent();

        foreach ($deliverySetList as $delSetId => $delSetName) {
            // checking if PayPal is valid payment for selected delivery set
            if (!$this->isPayPalInDeliverySet($delSetId, $basketPrice, $user)) {
                continue;
            }

            $deliveryListProvider = oxNew(\OxidEsales\Eshop\Application\Model\DeliveryList::class);
            $deliveryList = array();

            // list of active delivery costs
            if ($deliveryListProvider->hasDeliveries($basket, $user, $this->getUserShippingCountryId($user), $delSetId)) {
                $deliveryList = $deliveryListProvider->getDeliveryList($basket, $user, $this->getUserShippingCountryId($user), $delSetId);
            }

            if (count($deliveryList) > 0) {
                $price = 0;

                if (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('bl_perfLoadDelivery')) {
                    foreach ($deliveryList as $delivery) {
                        $price += $delivery->getDeliveryPrice($delVATPercent)->getBruttoPrice();
                    }
                }

                if ($price <= $maxDeliveryAmount) {
                    $payPalService->setParameter("L_SHIPPINGOPTIONNAME{$cnt}", \OxidEsales\Eshop\Core\Str::getStr()->html_entity_decode($delSetName));
                    $payPalService->setParameter("L_SHIPPINGOPTIONLABEL{$cnt}", \OxidEsales\Eshop\Core\Registry::getLang()->translateString("OEPAYPAL_PRICE"));
                    $payPalService->setParameter("L_SHIPPINGOPTIONAMOUNT{$cnt}", $this->formatFloat($price));

                    //setting active delivery set
                    if ($delSetId == $actShipSet) {
                        $hasActShipSet = true;
                        $payPalService->setParameter("L_SHIPPINGOPTIONISDEFAULT{$cnt}", "true");
                    } else {
                        $payPalService->setParameter("L_SHIPPINGOPTIONISDEFAULT{$cnt}", "false");
                    }

                    if ($basket->isCalculationModeNetto()) {
                        $payPalService->setParameter("L_TAXAMT{$cnt}", $this->formatFloat($basket->getPayPalBasketVatValue()));
                    } else {
                        $payPalService->setParameter("L_TAXAMT{$cnt}", $this->formatFloat(0));
                    }
                }

                $cnt++;
            }
        }

        //checking if active delivery set was set - if not, setting first in the list
        if ($cnt > 0 && !$hasActShipSet) {
            $payPalService->setParameter("L_SHIPPINGOPTIONISDEFAULT0", "true");
        }

        return $cnt;
    }
protected function setDeliverySetListForCallbackResponse($payPalService, $deliverySetList, $user, $basket)
    {
        $maxDeliveryAmount = $this->getPayPalConfig()->getMaxPayPalDeliveryAmount();
        $cur = \OxidEsales\Eshop\Core\Registry::getConfig()->getActShopCurrencyObject();
        $basketPrice = $basket->getPriceForPayment() / $cur->rate;
        $actShipSet = $basket->getShippingId();
        $hasActShipSet = false;
        $cnt = 0;

        // VAT for delivery will be calculated always
        $delVATPercent = $basket->getAdditionalServicesVatPercent();

        foreach ($deliverySetList as $delSetId => $delSetName) {
            // checking if PayPal is valid payment for selected delivery set
            if (!$this->isPayPalInDeliverySet($delSetId, $basketPrice, $user)) {
                continue;
            }

            $deliveryListProvider = oxNew(\OxidEsales\Eshop\Application\Model\DeliveryList::class);
            $deliveryList = array();

            // list of active delivery costs
            if ($deliveryListProvider->hasDeliveries($basket, $user, $this->getUserShippingCountryId($user), $delSetId)) {
                $deliveryList = $deliveryListProvider->getDeliveryList($basket, $user, $this->getUserShippingCountryId($user), $delSetId);
            }

            if (count($deliveryList) > 0) {
                $price = 0;

                if (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('bl_perfLoadDelivery')) {
                    foreach ($deliveryList as $delivery) {
                        $price += $delivery->getDeliveryPrice($delVATPercent)->getBruttoPrice();
                    }
                }

                if ($price <= $maxDeliveryAmount) {
                    $payPalService->setParameter("L_SHIPPINGOPTIONNAME{$cnt}", \OxidEsales\Eshop\Core\Str::getStr()->html_entity_decode($delSetName));
                    $payPalService->setParameter("L_SHIPPINGOPTIONLABEL{$cnt}", \OxidEsales\Eshop\Core\Registry::getLang()->translateString("OEPAYPAL_PRICE"));
                    $payPalService->setParameter("L_SHIPPINGOPTIONAMOUNT{$cnt}", $this->formatFloat($price));

                    //setting active delivery set
                    if ($delSetId == $actShipSet) {
                        $hasActShipSet = true;
                        $payPalService->setParameter("L_SHIPPINGOPTIONISDEFAULT{$cnt}", "true");
                    } else {
                        $payPalService->setParameter("L_SHIPPINGOPTIONISDEFAULT{$cnt}", "false");
                    }

                    if ($basket->isCalculationModeNetto()) {
                        $payPalService->setParameter("L_TAXAMT{$cnt}", $this->formatFloat($basket->getPayPalBasketVatValue()));
                    } else {
                        $payPalService->setParameter("L_TAXAMT{$cnt}", $this->formatFloat(0));
                    }
                }

                $cnt++;
            }
        }

        //checking if active delivery set was set - if not, setting first in the list
        if ($cnt > 0 && !$hasActShipSet) {
            $payPalService->setParameter("L_SHIPPINGOPTIONISDEFAULT0", "true");
        }

        return $cnt;
    }
protected function setDeliverySetListForCallbackResponse ( $ payPalService , $ deliverySetList , $ user , $ basket ) { $ maxDeliveryAmount = $ this -> getPayPalConfig ( ) -> getMaxPayPalDeliveryAmount ( ) ; $ cur = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getActShopCurrencyObject ( ) ; $ basketPrice = $ basket -> getPriceForPayment ( ) / $ cur -> rate ; $ actShipSet = $ basket -> getShippingId ( ) ; $ hasActShipSet = false ; $ cnt = 0 ; // VAT for delivery will be calculated always $ delVATPercent = $ basket -> getAdditionalServicesVatPercent ( ) ; foreach ( $ deliverySetList as $ delSetId => $ delSetName ) { // checking if PayPal is valid payment for selected delivery set if ( ! $ this -> isPayPalInDeliverySet ( $ delSetId , $ basketPrice , $ user ) ) { continue ; } $ deliveryListProvider = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ DeliveryList :: class ) ; $ deliveryList = array ( ) ; // list of active delivery costs if ( $ deliveryListProvider -> hasDeliveries ( $ basket , $ user , $ this -> getUserShippingCountryId ( $ user ) , $ delSetId ) ) { $ deliveryList = $ deliveryListProvider -> getDeliveryList ( $ basket , $ user , $ this -> getUserShippingCountryId ( $ user ) , $ delSetId ) ; } if ( count ( $ deliveryList ) > 0 ) { $ price = 0 ; if ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'bl_perfLoadDelivery' ) ) { foreach ( $ deliveryList as $ delivery ) { $ price += $ delivery -> getDeliveryPrice ( $ delVATPercent ) -> getBruttoPrice ( ) ; } } if ( $ price <= $ maxDeliveryAmount ) { $ payPalService -> setParameter ( "L_SHIPPINGOPTIONNAME{$cnt}" , \ OxidEsales \ Eshop \ Core \ Str :: getStr ( ) -> html_entity_decode ( $ delSetName ) ) ; $ payPalService -> setParameter ( "L_SHIPPINGOPTIONLABEL{$cnt}" , \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> translateString ( "OEPAYPAL_PRICE" ) ) ; $ payPalService -> setParameter ( "L_SHIPPINGOPTIONAMOUNT{$cnt}" , $ this -> formatFloat ( $ price ) ) ; //setting active delivery set if ( $ delSetId == $ actShipSet ) { $ hasActShipSet = true ; $ payPalService -> setParameter ( "L_SHIPPINGOPTIONISDEFAULT{$cnt}" , "true" ) ; } else { $ payPalService -> setParameter ( "L_SHIPPINGOPTIONISDEFAULT{$cnt}" , "false" ) ; } if ( $ basket -> isCalculationModeNetto ( ) ) { $ payPalService -> setParameter ( "L_TAXAMT{$cnt}" , $ this -> formatFloat ( $ basket -> getPayPalBasketVatValue ( ) ) ) ; } else { $ payPalService -> setParameter ( "L_TAXAMT{$cnt}" , $ this -> formatFloat ( 0 ) ) ; } } $ cnt ++ ; } } //checking if active delivery set was set - if not, setting first in the list if ( $ cnt > 0 && ! $ hasActShipSet ) { $ payPalService -> setParameter ( "L_SHIPPINGOPTIONISDEFAULT0" , "true" ) ; } return $ cnt ; }
Sets delivery sets parameters to PayPal callback

@param \OxidEsales\PayPalModule\Core\PayPalService $payPalService   PayPal service.
@param array                                       $deliverySetList Delivery list.
@param \OxidEsales\Eshop\Application\Model\User    $user            User object.
@param \OxidEsales\Eshop\Application\Model\Basket  $basket          Basket object.

@return int Total amount of deliveries
Sets delivery sets parameters to PayPal callback