Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/magento/module-paypal/CustomerData/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-paypal/CustomerData/BillingAgreement.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Paypal\CustomerData;

use Magento\Customer\CustomerData\SectionSourceInterface;
use Magento\Customer\Helper\Session\CurrentCustomer;
use Magento\Framework\Escaper;
use Magento\Framework\UrlInterface;
use Magento\Paypal\Helper\Data;
use Magento\Paypal\Model\Config;
use Magento\Paypal\Model\ConfigFactory;

/**
 * BillingAgreement section
 */
class BillingAgreement implements SectionSourceInterface
{
    /**
     * @var CurrentCustomer
     */
    private $currentCustomer;

    /**
     * Paypal data
     *
     * @var Data
     */
    private $paypalData;

    /**
     * @var Config
     */
    private $config;

    /**
     * Url Builder
     *
     * @var UrlInterface
     */
    private $urlBuilder;

    /**
     * Escaper
     *
     * @var Escaper
     */
    private $escaper;

    /**
     * Start express action
     *
     * @var string
     */
    private $startAction = 'paypal/express/start/button/1';

    /**
     * @param CurrentCustomer $currentCustomer
     * @param Data $paypalData
     * @param ConfigFactory $paypalConfigFactory
     * @param UrlInterface $urlBuilder
     * @param Escaper $escaper
     */
    public function __construct(
        CurrentCustomer $currentCustomer,
        Data $paypalData,
        ConfigFactory $paypalConfigFactory,
        UrlInterface $urlBuilder,
        Escaper $escaper
    ) {
        $this->currentCustomer = $currentCustomer;
        $this->paypalData = $paypalData;
        $this->urlBuilder = $urlBuilder;
        $this->escaper = $escaper;
        $this->config = $paypalConfigFactory->create();
        $this->config->setMethod(Config::METHOD_EXPRESS);
    }

    /**
     * @inheritdoc
     */
    public function getSectionData()
    {
        $customerId = $this->currentCustomer->getCustomerId();
        if ($this->paypalData->shouldAskToCreateBillingAgreement($this->config, $customerId)) {
            return [
                'askToCreate' => true,
                'confirmUrl' => $this->escaper->escapeUrl(
                    $this->urlBuilder->getUrl(
                        $this->startAction,
                        [\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1]
                    )
                ),
                'confirmMessage' => $this->escaper->escapeHtml(
                    __('Would you like to sign a billing agreement to streamline further purchases with PayPal?')
                )
            ];
        }

        return [];
    }
}

Spamworldpro Mini