Example #1
0
 /**
  * Get payment method
  *
  * @return \XLite\Model\Payment\Method
  */
 public function getPaymentMethod()
 {
     if (!isset($this->paymentMethod)) {
         $this->paymentMethod = Paypal\Main::getPaymentMethod(Paypal\Main::PP_METHOD_PC);
     }
     return $this->paymentMethod && static::MODULE_NAME === $this->paymentMethod->getModuleName() ? $this->paymentMethod : null;
 }
Example #2
0
 /**
  * doExpressCheckoutReturn 
  * 
  * @return void
  */
 protected function doActionExpressCheckoutReturn()
 {
     $request = \XLite\Core\Request::getInstance();
     $cart = $this->getCart();
     \XLite\Module\CDev\Paypal\Main::addLog('doExpressCheckoutReturn()', $request->getData());
     if (isset($request->cancel)) {
         \XLite\Core\Session::getInstance()->ec_token = null;
         \XLite\Core\Session::getInstance()->ec_date = null;
         \XLite\Core\Session::getInstance()->ec_payer_id = null;
         \XLite\Core\Session::getInstance()->ec_type = null;
         $cart->unsetPaymentMethod();
         \XLite\Core\TopMessage::getInstance()->addWarning('Express Checkout process stopped.');
     } elseif (!isset($request->token) || $request->token != \XLite\Core\Session::getInstance()->ec_token) {
         \XLite\Core\TopMessage::getInstance()->addError('Wrong token of Express Checkout.');
     } elseif (!isset($request->PayerID)) {
         \XLite\Core\TopMessage::getInstance()->addError('PayerID value was not returned by PayPal.');
     } else {
         // Express Checkout shortcut flow processing
         \XLite\Core\Session::getInstance()->ec_type = \XLite\Module\CDev\Paypal\Model\Payment\Processor\ExpressCheckout::EC_TYPE_SHORTCUT;
         \XLite\Core\Session::getInstance()->ec_payer_id = $request->PayerID;
         $paymentMethod = $this->getExpressCheckoutPaymentMethod();
         $buyerData = $paymentMethod->getProcessor()->doGetExpressCheckoutDetails($paymentMethod, $request->token);
         if (empty($buyerData)) {
             \XLite\Core\TopMessage::getInstance()->addError('Your address data was not received from PayPal.');
         } else {
             // Fill the cart with data received from Paypal
             $this->requestData = $this->prepareBuyerData($buyerData);
             $this->updateProfile();
             $this->requestData['billingAddress'] = $this->requestData['shippingAddress'];
             $this->requestData['same_address'] = true;
             $this->updateShippingAddress();
             $this->updateBillingAddress();
         }
     }
 }
Example #3
0
 /**
  * Get publisher id
  *
  * @param string $email Email
  *
  * @return string
  */
 public function getPublisherId($email)
 {
     $publisherId = null;
     $sellerName = \XLite\Core\Config::getInstance()->Company->company_name;
     $data = array('sellerName' => $sellerName, 'emailAddress' => $email, 'bnCode' => static::BN_CODE);
     $request = new \XLite\Core\HTTP\Request(static::END_POINT);
     if (function_exists('curl_version')) {
         $request->setAdditionalOption(\CURLOPT_SSLVERSION, 1);
         $curlVersion = curl_version();
         if ($curlVersion && $curlVersion['ssl_version'] && 0 !== strpos($curlVersion['ssl_version'], 'NSS')) {
             $request->setAdditionalOption(\CURLOPT_SSL_CIPHER_LIST, 'TLSv1');
         }
     }
     $request->body = json_encode($data);
     $request->verb = 'POST';
     $timeStamp = LC_START_TIME . '000';
     $authorization = 'FPA ' . static::CLIENT_KEY;
     $authorization .= ':' . sha1(static::SHARED_SECRET . $timeStamp);
     $authorization .= ':' . $timeStamp;
     $request->setHeader('Authorization', $authorization);
     $request->setHeader('Accept', 'application/json');
     $request->setHeader('Content-Type', 'application/json');
     $response = $request->sendRequest();
     \XLite\Module\CDev\Paypal\Main::addLog('getPublisherId', $response->body);
     if (201 == $response->code) {
         $responseData = json_decode($response->body, true);
         if ($responseData && isset($responseData['publisherId'])) {
             $publisherId = $responseData['publisherId'];
         }
     }
     return $publisherId;
 }
Example #4
0
 /**
  * Set return URL
  *
  * @param string $url URL to set
  *
  * @return void
  */
 public function setReturnURL($url)
 {
     if (\XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled() && \XLite\Module\CDev\Paypal\Main::isInContextCheckoutAvailable() && \XLite\Core\Request::getInstance()->cancelUrl) {
         $url = $this->getShopURL(\XLite\Core\Request::getInstance()->cancelUrl, \XLite\Core\Config::getInstance()->Security->customer_security);
     }
     parent::setReturnURL($url);
 }
Example #5
0
 /**
  * Return form attributes
  *
  * @return array
  */
 protected function getFormAttributes()
 {
     $list = parent::getFormAttributes();
     if (\XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled() && \XLite\Module\CDev\Paypal\Main::isInContextCheckoutAvailable()) {
         $list['data-paypal-id'] = \XLite\Module\CDev\Paypal\Main::getMerchantId();
     }
     return $list;
 }
Example #6
0
 /**
  * Get JS files
  *
  * @return array
  */
 public function getJSFiles()
 {
     $list = parent::getJSFiles();
     if ((!$this->isTokenValid() || \XLite\Module\CDev\Paypal\Model\Payment\Processor\ExpressCheckout::EC_TYPE_SHORTCUT !== \XLite\Core\Session::getInstance()->ec_type) && \XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled() && \XLite\Module\CDev\Paypal\Main::isInContextCheckoutAvailable()) {
         $list[] = 'modules/CDev/Paypal/checkout/payment.js';
     }
     return $list;
 }
Example #7
0
 /**
  * Add CSS files
  *
  * @return array
  */
 public function getCSSFiles()
 {
     $list = parent::getCSSFiles();
     $cart = $this->getCart();
     if (\XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled($cart)) {
         $list[] = 'modules/CDev/Paypal/button/add2cart_popup/style.css';
     }
     return $list;
 }
Example #8
0
 /**
  * Get JS files
  *
  * @return array
  */
 public function getJSFiles()
 {
     $list = parent::getJSFiles();
     $api = \XLite\Module\CDev\Paypal\Main::getRESTAPIInstance();
     if ($api->isInContextSignUpAvailable()) {
         $list[] = 'modules/CDev/Paypal/settings/signup.js';
     }
     return $list;
 }
Example #9
0
 /**
  * getJSFiles
  *
  * @return array
  */
 public function getJSFiles()
 {
     $list = parent::getJSFiles();
     if (!\XLite::isAdminZone() && \XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled() && \XLite\Module\CDev\Paypal\Main::isInContextCheckoutAvailable()) {
         $list[] = 'modules/CDev/Paypal/button/in_context.js';
     } else {
         $list[] = 'modules/CDev/Paypal/button/default.js';
     }
     return $list;
 }
Example #10
0
 /**
  * getFormDefaultParams
  *
  * @return array
  */
 protected function getFormDefaultParams()
 {
     $list = parent::getFormDefaultParams();
     if (\XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled()) {
         $list['expressCheckout'] = false;
         if (\XLite\Module\CDev\Paypal\Main::isInContextCheckoutAvailable()) {
             $list['inContext'] = true;
             $list['cancelUrl'] = $this->isAjax() ? $this->getReferrerURL() : \XLite\Core\URLManager::getSelfURI();
         }
     }
     return $list;
 }
Example #11
0
 /**
  * Process 'Add item' success
  *
  * @return void
  */
 protected function processAddItemSuccess()
 {
     // todo: rewrite add2cartPopup top message block
     // parent::processAddItemSuccess();
     if (\XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled()) {
         if (!\XLite\Core\Request::getInstance()->expressCheckout) {
             \XLite\Core\TopMessage::addInfo(new \XLite\Module\CDev\Paypal\View\Button\TopMessage\ExpressCheckout());
         }
     } else {
         parent::processAddItemSuccess();
     }
 }
Example #12
0
 /**
  * Perform login action
  *
  * @return void
  */
 protected function doActionLogin()
 {
     $loginApi = new \XLite\Module\CDev\Paypal\Core\Login();
     $requestProcessed = false;
     $returnURL = '';
     \XLite\Module\CDev\Paypal\Main::addLog('Login return', \XLite\Core\Request::getInstance()->getData());
     if ($loginApi->checkRequest()) {
         $accessToken = $loginApi->createFromAuthorisationCode(\XLite\Core\Request::getInstance()->code);
         $profileInfo = isset($accessToken['access_token']) ? $loginApi->getUserinfo($accessToken['access_token']) : null;
         if ($profileInfo && !empty($profileInfo['user_id']) && !empty($profileInfo['email'])) {
             $profile = $this->getSocialLoginProfile($profileInfo['email'], 'PayPal', $profileInfo['user_id'], $profileInfo);
             if ($profile) {
                 if ($profile->isEnabled()) {
                     \XLite\Core\Auth::getInstance()->loginProfile($profile);
                     $accessToken['expirationTime'] = LC_START_TIME + $accessToken['expires_in'];
                     \XLite\Core\Session::getInstance()->paypalAccessToken = $accessToken;
                     // We merge the logged in cart into the session cart
                     $profileCart = $this->getCart();
                     $profileCart->login($profile);
                     \XLite\Core\Database::getEM()->flush();
                     if ($profileCart->isPersistent()) {
                         $this->updateCart();
                     }
                     $returnURL = $this->getAuthReturnURL();
                 } else {
                     \XLite\Core\TopMessage::addError('Profile is disabled');
                     $returnURL = $this->getAuthReturnURL(true);
                 }
             } else {
                 $provider = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->findOneBy(array('login' => $profileInfo['email'], 'order' => null))->getSocialLoginProvider();
                 if ($provider) {
                     $signInVia = 'Please sign in with ' . $provider . '.';
                 } else {
                     $signInVia = 'Profile with the same e-mail address already registered. ' . 'Please sign in the classic way.';
                 }
                 \XLite\Core\TopMessage::addError($signInVia);
                 $returnURL = $this->getAuthReturnURL(true);
             }
             $requestProcessed = true;
         }
     }
     if (!$requestProcessed) {
         \XLite\Core\TopMessage::addError('We were unable to process this request');
         $returnURL = '';
     }
     $this->closePopup($returnURL);
 }
Example #13
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->api = new Paypal\Core\PaypalAdaptiveAPI();
     $method = Paypal\Main::getPaymentMethod(Paypal\Main::PP_METHOD_PAD);
     $this->api->setMethod($method);
     $this->api->setPartnerCode(static::$partnerCode);
 }
Example #14
0
 /**
  * Check if widget is visible
  *
  * @return boolean
  */
 protected function isVisible()
 {
     return parent::isVisible() && (!$this->isTokenValid() || \XLite\Module\CDev\Paypal\Model\Payment\Processor\ExpressCheckout::EC_TYPE_SHORTCUT !== \XLite\Core\Session::getInstance()->ec_type) && \XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled() && \XLite\Module\CDev\Paypal\Main::isInContextCheckoutAvailable();
 }
Example #15
0
 /**
  * Get Express Checkout payment method
  *
  * @return \XLite\Model\Payment\Method
  */
 protected function getExpressCheckoutPaymentMethod()
 {
     $serviceName = \XLite\Core\Request::getInstance()->paypalCredit ? Paypal\Main::PP_METHOD_PC : Paypal\Main::PP_METHOD_EC;
     return Paypal\Main::getPaymentMethod($serviceName);
 }
Example #16
0
 /**
  * Returns true if widget is visible
  *
  * @return boolean
  */
 protected function isVisible()
 {
     /** @var \XLite\Model\Cart $cart */
     $cart = $this->getCart();
     return parent::isVisible() && $cart && 0 < $cart->getTotal() && \XLite\Module\CDev\Paypal\Main::isPaypalCreditEnabled($cart) && $cart->checkCart();
 }
Example #17
0
 /**
  * Returns common request params required for all requests
  *
  * @return array
  */
 protected function getCommonParams()
 {
     $result = array('VENDOR' => $this->getSetting('vendor'), 'USER' => $this->getSetting('user') ?: $this->getSetting('vendor'), 'PWD' => $this->getSetting('pwd'), 'PARTNER' => $this->getSetting('partner') ?: 'Paypal', 'BUTTONSOURCE' => $this->partnerCode, 'VERBOSITY' => 'HIGH');
     // todo: remove?!
     if (\XLite\Core\Config::getInstance()->Security->customer_security) {
         $result['HDRIMG'] = \XLite\Module\CDev\Paypal\Main::getLogo();
     }
     return $result;
 }
 /**
  * Get express checkout method
  *
  * @return \XLite\Model\Payment\Method
  */
 protected function getExpressCheckoutMethod()
 {
     return Paypal\Main::getPaymentMethod(Paypal\Main::PP_METHOD_EC);
 }
Example #19
0
 /**
  * Check if widget is visible
  *
  * @return boolean
  */
 protected function isVisible()
 {
     $result = parent::isVisible() && (Paypal\Main::isPaypalCreditEnabled() || Paypal\Main::isPaypalWPSEnabled()) && $this->isValidTarget() && $this->getPublisherId() && $this->getSetting('agreement');
     if ($result) {
         $settingName = 'bannerOn' . ucfirst($this->getParam(static::PARAM_PAGE));
         $result = $this->getParam(static::PARAM_POSITION) == $this->getSetting($settingName);
     }
     return $result;
 }
Example #20
0
    /**
     * Redirect customer to Paypal server for authorization and address selection
     *
     * @param string $token Express Checkout token
     *
     * @return void
     */
    public function redirectToPaypal($token)
    {
        $url = $this->getRedirectURL($this->getPostParams($token));
        \XLite\Module\CDev\Paypal\Main::addLog('redirectToPaypal()', $url);
        $page = <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body onload="self.location = '{$url}';">
</body>
</html>
HTML;
        print $page;
    }
Example #21
0
 /**
  * Returns true if widget is visible
  *
  * @return boolean
  */
 protected function isVisible()
 {
     return parent::isVisible() && \XLite\Module\CDev\Paypal\Main::isBuyNowEnabled();
 }
Example #22
0
 /**
  * Define inContext widget param
  *
  * @return boolean
  */
 protected function defineInContext()
 {
     return \XLite\Module\CDev\Paypal\Main::isInContextCheckoutAvailable();
 }
Example #23
0
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $method = \XLite\Module\CDev\Paypal\Main::getPaymentMethod(\XLite\Module\CDev\Paypal\Main::PP_METHOD_PFL);
     $this->api->setMethod($method);
 }
Example #24
0
 /**
  * isExpressCheckoutEnabled 
  * 
  * @return boolean
  */
 protected function isVisible()
 {
     $cart = $this->getCart();
     return parent::isVisible() && $cart && 0 < $cart->getTotal() && $cart->checkCart() && \XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled($cart);
 }
 /**
  * Get allowed backend transactions
  *
  * @return string Status code
  */
 public function getAllowedTransactions()
 {
     $method = \XLite\Module\CDev\Paypal\Main::getPaymentMethod(\XLite\Module\CDev\Paypal\Main::PP_METHOD_EC);
     return $method && $this->api->isConfiguredApiSolution() ? parent::getAllowedTransactions() : array();
 }
Example #26
0
 /**
  * Convert order to array for SetExpressCheckout
  *
  * @param \XLite\Model\Order $order Order
  *
  * @return array
  * @see    https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/
  */
 public function convertSetExpressCheckoutParams($order)
 {
     /** @var \XLite\Model\Currency $currency */
     $currency = $order->getCurrency();
     $orderTotal = $currency->roundValue($order->getTotal());
     $shippingCost = $this->getShippingCost($order);
     /** @var \XLite\Module\CDev\Paypal\Model\Payment\Processor\ExpressCheckoutMerchantAPI $processor */
     $processor = $this->getProcessor();
     $params = array('RETURNURL' => $processor->getPaymentReturnUrl(), 'CANCELURL' => $processor->getPaymentCancelUrl(), 'NOSHIPPING' => null === $shippingCost ? '1' : '0', 'ALLOWNOTE' => 1, 'PAYMENTREQUEST_0_AMT' => $orderTotal, 'PAYMENTREQUEST_0_PAYMENTACTION' => $this->getPaymentAction(), 'PAYMENTREQUEST_0_CURRENCYCODE' => $currency->getCode(), 'PAYMENTREQUEST_0_HANDLINGAMT' => 0, 'PAYMENTREQUEST_0_INSURANCEAMT' => 0, 'PAYMENTREQUEST_0_SHIPPINGAMT' => (double) $shippingCost);
     if (\XLite\Core\Config::getInstance()->Security->customer_security) {
         $postData['HDRIMG'] = urlencode(\XLite\Module\CDev\Paypal\Main::getLogo());
     }
     $items = $this->getItems($order);
     // To avoid total mismatch clear tax and shipping cost
     $taxAmt = isset($items['PAYMENTREQUEST_0_TAXAMT']) ? $items['PAYMENTREQUEST_0_TAXAMT'] : 0;
     if (abs($orderTotal - $items['PAYMENTREQUEST_0_ITEMAMT'] - $taxAmt - $shippingCost) <= 1.0E-10) {
         $params += $items;
     } else {
         $itemsAmt = $orderTotal - (double) $shippingCost;
         $params['PAYMENTREQUEST_0_ITEMAMT'] = $itemsAmt;
     }
     $type = \XLite\Core\Session::getInstance()->ec_type;
     /** @var \XLite\Model\Profile $profile */
     $profile = $order->getProfile();
     if (\XLite\Module\CDev\Paypal\Model\Payment\Processor\ExpressCheckout::EC_TYPE_SHORTCUT == $type) {
         $params['REQCONFIRMSHIPPING'] = 0;
     }
     if ($profile && $profile->getLogin()) {
         $params += array('EMAIL' => $profile->getLogin());
     }
     if ($profile && $profile->getBillingAddress()) {
         $params += array('PHONENUM' => $profile->getBillingAddress()->getPhone());
     }
     if (null !== $shippingCost && $profile && $profile->getShippingAddress()) {
         /** @var \XLite\Model\Address $address */
         $address = $profile->getShippingAddress();
         $params += array('ADDROVERRIDE' => 1, 'PAYMENTREQUEST_0_SHIPTONAME' => trim($address->getFirstname() . ' ' . $address->getLastname()), 'PAYMENTREQUEST_0_SHIPTOSTREET' => $address->getStreet(), 'PAYMENTREQUEST_0_SHIPTOSTREET2' => '', 'PAYMENTREQUEST_0_SHIPTOCITY' => $address->getCity(), 'PAYMENTREQUEST_0_SHIPTOSTATE' => $address->getState()->getCode() ?: $address->getState()->getState(), 'PAYMENTREQUEST_0_SHIPTOZIP' => $address->getZipcode(), 'PAYMENTREQUEST_0_SHIPTOCOUNTRY' => $address->getCountry()->getCode());
     }
     if (\XLite\Core\Auth::getInstance()->isLogged()) {
         $profile = \XLite\Core\Auth::getInstance()->getProfile();
         if ($profile->isSocialProfile() && 'PayPal' == $profile->getSocialLoginProvider() && \XLite\Core\Session::getInstance()->paypalAccessToken) {
             $accessToken = \XLite\Core\Session::getInstance()->paypalAccessToken;
             if (LC_START_TIME < $accessToken['expirationTime']) {
                 $params['IDENTITYACCESSTOKEN'] = $accessToken['access_token'];
             }
         }
     }
     return $params;
 }
Example #27
0
 /**
  * Get URL of the page to display within iframe
  *
  * @return string
  */
 protected function getIframeData()
 {
     $token = $this->doCreateSecureToken();
     $result = $token ? $this->getPostURL($this->iframeURL, $this->getIframeParams($token)) : null;
     Paypal\Main::addLog('getIframeData()', $result);
     return $result;
 }
Example #28
0
/**
 * Create an administrator account
 *
 * @param array  $params     Database access data and other parameters
 * @param bool   $silentMode Do not display any output during installing
 *
 * @return bool
 */
function doCreateAdminAccount(&$params, $silentMode = false)
{
    global $error;
    $result = true;
    if ($silentMode) {
        ob_start();
    }
    $login = get_magic_quotes_gpc() ? trim(stripslashes($params['login'])) : $params['login'];
    $password = get_magic_quotes_gpc() ? trim(stripslashes($params["password"])) : $params["password"];
    if (empty($login) || empty($password)) {
        $result = false;
        $errorMsg = fatal_error(xtr('Login and password can\'t be empty.'), 'params', 'empty admin login or password');
    } else {
        $password = md5($password);
    }
    $profile = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->findByLogin($login);
    if (is_null($profile)) {
        // Register default admin account
        $profile = new \XLite\Model\Profile();
        $profile->setLogin($login);
        echo xtr('Registering primary administrator profile...');
    } else {
        // Account already exists
        echo xtr('Updating primary administrator profile...');
    }
    // Add banner for Paypal express checkout on the admin dashboard
    if ('ru' !== XLITE_EDITION_LNG && class_exists('\\XLite\\Module\\CDev\\Paypal\\Main')) {
        $expressCheckout = \XLite\Module\CDev\Paypal\Main::getPaymentMethod(\XLite\Module\CDev\Paypal\Main::PP_METHOD_EC);
        $expressCheckout->setSetting('email', $login);
        $expressCheckout->setEnabled(true);
        \XLite\Core\Database::getRepo('XLite\\Model\\Config')->createOption(array('category' => 'CDev\\Paypal', 'name' => 'show_admin_welcome', 'value' => 'Y'));
    }
    $profile->setPassword($password);
    $profile->setAccessLevel(100);
    $profile->enable();
    $role = \XLite\Core\Database::getRepo('XLite\\Model\\Role')->findOneRoot();
    $profile->addRoles($role);
    $profile->create();
    $role->addProfiles($profile);
    \XLite\Core\Database::getEM()->persist($role);
    \XLite\Core\Database::getEM()->flush();
    if ($silentMode) {
        ob_end_clean();
    }
    return $result;
}
Example #29
0
 /**
  * Get redirect form fields list
  *
  * @return array
  * @see    https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables
  */
 protected function getFormFields()
 {
     /** @var \XLite\Model\Order $order */
     $order = $this->getOrder();
     /** @var \XLite\Model\Currency $currency */
     $currency = $order->getCurrency();
     $orderTotal = $currency->roundValue($order->getTotal());
     $orderNumber = $this->getTransactionId($this->getSetting('prefix'));
     $shippingCost = $this->getShippingCost($order);
     $params = array('return' => $this->getReturnURL(null, true), 'cancel_return' => $this->getReturnURL(null, true, true), 'shopping_url' => $this->getReturnURL(null, true, true), 'notify_url' => $this->getCallbackURL(null, true), 'rm' => '2', 'bn' => 'XCART5_Cart', 'upload' => 1, 'charset' => 'UTF-8', 'cmd' => '_cart', 'redirect_cmd' => '_xclick', 'business' => $this->getSetting('account'), 'custom' => $order->getOrderId(), 'invoice' => $orderNumber, 'currency_code' => $currency->getCode(), 'handling' => 0, 'shipping_1' => (double) $shippingCost, 'weight_cart' => 0);
     if (\XLite\Core\Config::getInstance()->Security->customer_security) {
         $fields['cpp_header_image'] = Paypal\Main::getLogo();
     }
     $items = $this->getItems($order);
     // To avoid total mismatch clear tax and shipping cost
     $taxAmt = isset($items['tax_cart']) ? $items['tax_cart'] : 0;
     if (abs($orderTotal - $items['items_amount'] - $taxAmt - $shippingCost) <= 1.0E-10) {
         unset($items['items_amount']);
         $params = array_merge($params, $items);
     } else {
         $params['cmd'] = '_ext-enter';
         $params['amount'] = $orderTotal;
         $params['item_name'] = $this->getItemName();
         unset($params['shipping_1']);
     }
     $profile = $this->getProfile();
     $params = array_merge($params, array('address_override' => 1, 'email' => $profile->getLogin()));
     if (null !== $shippingCost) {
         /** @var \XLite\Model\Address $address */
         $address = $profile->getShippingAddress();
         $params = array_merge($params, array('first_name' => $address->getFirstname(), 'last_name' => $address->getLastname(), 'country' => $this->getCountryFieldValue(), 'state' => $this->getStateFieldValue(), 'address1' => $address->getStreet(), 'address2' => 'n/a', 'city' => $address->getCity(), 'zip' => $address->getZipcode()));
     }
     $params = array_merge($params, $this->getPhone());
     return $params;
 }
Example #30
0
 /**
  * Get express checkout email
  *
  * @return string
  */
 protected function getExpressCheckoutEmail()
 {
     $expressCheckout = Paypal\Main::getPaymentMethod(Paypal\Main::PP_METHOD_EC);
     return $expressCheckout->getSetting('email');
 }