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
 /**
  * Return true if "serviceName" method is enabled
  *
  * @param string $serviceName Service name
  *
  * @return boolean
  */
 protected function isPaypalMethodEnabled($serviceName)
 {
     $method = Paypal\Main::getPaymentMethod($serviceName);
     return $method && $method->isEnabled();
 }
Example #3
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 #4
0
 /**
  * Get payment method which forced enabling of Express Checkout
  *
  * @return \XLite\Model\Payment\Method
  */
 public function getParentMethod()
 {
     $result = null;
     $relatedMethods = array(Paypal\Main::PP_METHOD_PPA, Paypal\Main::PP_METHOD_PFL);
     foreach ($relatedMethods as $rm) {
         $m = Paypal\Main::getPaymentMethod($rm);
         if ($m && $m->isEnabled()) {
             $result = $m;
             break;
         }
     }
     return $result;
 }
 /**
  * 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 #6
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 #7
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);
 }
 /**
  * Get express checkout method
  *
  * @return \XLite\Model\Payment\Method
  */
 protected function getExpressCheckoutMethod()
 {
     return Paypal\Main::getPaymentMethod(Paypal\Main::PP_METHOD_EC);
 }
Example #9
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 #10
0
 /**
  * Get payment method
  *
  * @return \XLite\Model\Payment\Method
  */
 protected function getMethod()
 {
     if (is_null($this->method)) {
         $this->method = Paypal\Main::getPaymentMethod(Paypal\Main::PP_METHOD_PC);
     }
     return $this->method;
 }
Example #11
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->method = \XLite\Module\CDev\Paypal\Main::getPaymentMethod(\XLite\Module\CDev\Paypal\Main::PP_METHOD_EC);
 }
Example #12
0
 /**
  * Get express checkout email
  *
  * @return string
  */
 protected function getExpressCheckoutEmail()
 {
     $expressCheckout = Paypal\Main::getPaymentMethod(Paypal\Main::PP_METHOD_EC);
     return $expressCheckout->getSetting('email');
 }
Example #13
0
 /**
  * doActionUpdateCredentials
  *
  * @return void
  */
 protected function doActionUpdateCredentials()
 {
     $request = \XLite\Core\Request::getInstance();
     $data = array();
     if ($request->merchantIdInPayPal) {
         $apiClient = new Paypal\Core\RESTAPI();
         $data = $apiClient->getMerchantCredentials(Paypal\Core\RESTAPI::PARTNER_ID, $request->merchantIdInPayPal);
     }
     $method = Paypal\Main::getPaymentMethod(Paypal\Main::PP_METHOD_EC);
     if ($data && isset($data['api_credentials']) && isset($data['api_credentials']['signature'])) {
         $credentials = $data['api_credentials']['signature'];
         $method->setSetting('api_type', 'api');
         $method->setSetting('api_solution', 'paypal');
         $method->setSetting('api_username', $credentials['api_user_name']);
         $method->setSetting('api_password', $credentials['api_password']);
         $method->setSetting('auth_method', 'signature');
         $method->setSetting('signature', $credentials['signature']);
         $method->setSetting('mode', 'live');
         $method->setSetting('merchantId', $data['merchant_id']);
         $method->update();
         \XLite\Core\Database::getRepo('XLite\\Model\\Config')->createOption(array('category' => 'CDev\\Paypal', 'name' => 'show_admin_welcome', 'value' => 'N'));
         \XLite\Core\TopMessage::getInstance()->addInfo('Your API credentials have been successfully obtained from your PayPal account' . ' and saved for use by your X-Cart store.');
     } else {
         \XLite\Core\TopMessage::getInstance()->addError('Unfortunately, your API credentials could not be obtained from your PayPal account automatically.');
     }
     $this->setReturnURL($this->buildURL('paypal_settings', '', array('method_id' => $method->getMethodId())));
 }
Example #14
0
 /**
  * Returns paupal email
  *
  * @return string
  */
 protected function getPaypalEmail()
 {
     $method = \XLite\Module\CDev\Paypal\Main::getPaymentMethod(\XLite\Module\CDev\Paypal\Main::PP_METHOD_EC);
     return $method->getSetting('email');
 }
Example #15
0
 /**
  * Defines the default location path
  *
  * @return string
  */
 protected function getDefaultLocation()
 {
     $api = \XLite\Module\CDev\Paypal\Main::getRESTAPIInstance();
     $method = \XLite\Module\CDev\Paypal\Main::getPaymentMethod(\XLite\Module\CDev\Paypal\Main::PP_METHOD_EC);
     return $api->isInContextSignUpAvailable() ? $method->getReferralPageURL($method) : $this->buildURL('paypal_settings', '', array('method_id' => $method->getMethodId()));
 }