/** * Additional check for PPS * * @return boolean */ public function isEnabled() { $result = parent::isEnabled(); if ($result && \XLite\Module\CDev\Paypal\Main::PP_METHOD_PPS == $this->getServiceName()) { $result = !$this->getProcessor()->isExpressCheckoutEnabled(); } return $result; }
/** * Get payment method admin zone icon URL * * @param \XLite\Model\Payment\Method $method Payment method * * @return string | boolean */ public function getAdminIconURL(\XLite\Model\Payment\Method $method) { if (false !== strpos($method->getServiceName(), 'XPayments.Allowed')) { $name = $method->getServiceName(); } else { $name = str_replace('XPayments', 'XPayments.Allowed', $method->getServiceName()); } $file = 'modules/CDev/XPaymentsConnector/icons/' . $name . '.png'; $filePath = LC_DIR_SKINS . 'admin' . LC_DS . 'en' . LC_DS . str_replace('/', LC_DS, $file); return \Includes\Utils\FileManager::isExists($filePath) ? \XLite\Core\Layout::getInstance()->getResourceWebPath($file) : true; }
/** * Get payemnt method icon path * * @param \XLite\Model\Order $order Order * @param \XLite\Model\Payment\Method $method Payment method * * @return string */ public function getIconPath(\XLite\Model\Order $order, \XLite\Model\Payment\Method $method) { $type = $this->convertServiceNameToType($method->getServiceName()); $icon = isset($this->paymentTypeIcons[$type]) ? $this->paymentTypeIcons[$type] : null; if (is_array($icon)) { $code3 = $order->getProfile() && $order->getProfile()->getBillingAddress() ? $order->getProfile()->getBillingAddress()->getCountry()->getCode3() : null; $icon = $code3 && isset($icon[$code3]) ? $icon[$code3] : null; } return $icon ? 'modules/CDev/Moneybookers/icons/' . $icon : parent::getIconPath($order, $method); }
/** * Return TRUE if the test mode is ON * * @param \XLite\Model\Payment\Method $method Payment method object * * @return boolean */ public function isTestMode(\XLite\Model\Payment\Method $method) { return \XLite\View\FormField\Select\TestLiveMode::TEST === $method->getSetting('mode'); }
/** * Return true if current payment method is PayPal * * @param \XLite\Model\Payment\Method $method Payment method object * * @return boolean */ protected function isPaypalMethod($method) { return isset($method) && in_array($method->getServiceName(), array(\XLite\Module\CDev\Paypal\Main::PP_METHOD_PPA, \XLite\Module\CDev\Paypal\Main::PP_METHOD_PFL, \XLite\Module\CDev\Paypal\Main::PP_METHOD_EC, \XLite\Module\CDev\Paypal\Main::PP_METHOD_PPS)); }
public function isTestMode(\XLite\Model\Payment\Method $method) { return $method->getSetting('test') != 'false'; }
/** * Currency adjusted to payment method (or to all methods in old versions) * * @param \XLite\Model\Payment\Method $paymentMethod Payment method * * @return \XLite\Model\Currency */ public function getCurrencyForPaymentMethod(\XLite\Model\Payment\Method $paymentMethod) { $currencyId = version_compare(\XLite\Core\Config::getInstance()->CDev->XPaymentsConnector->xpc_api_version, '1.3') >= 0 ? $paymentMethod->getSetting('currency') : \XLite\Core\Config::getInstance()->CDev->XPaymentsConnector->xpc_currency; $currency = \XLite\Core\Database::getRepo('XLite\\Model\\Currency')->find($currencyId); return $currency; }
/** * Get payment method configuration page URL * * @param \XLite\Model\Payment\Method $method Payment method * @param boolean $justAdded Flag if the method is just added via administration panel. * Additional init configuration can be provided OPTIONAL * * @return string */ public function getConfigurationURL(\XLite\Model\Payment\Method $method, $justAdded = false) { return \XLite\Core\Converter::buildURL('paypal_settings', '', array('method_id' => $method->getMethodId())); }
/** * Get module name * * @param \XLite\Model\Payment\Method $method Method * * @return string */ protected function getModuleName(\XLite\Model\Payment\Method $method) { return $method->getProcessor()->getModule() ? $method->getProcessor()->getModule()->getModuleName() : null; }
/** * Check - transaction's method and specified method is equal or not * * @param \XLite\Model\Payment\Method $method Anothermethod * * @return boolean */ public function isSameMethod(\XLite\Model\Payment\Method $method) { return $this->getPaymentMethod() && $this->getPaymentMethod()->getMethodId() == $method->getMethodId(); }
/** * {@inheritDoc} */ public function prepareEntityBeforeCommit($type) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'prepareEntityBeforeCommit', array($type)); return parent::prepareEntityBeforeCommit($type); }
/** * Return payment method processor * * @return \XLite\Model\Payment\Base\Processor */ protected function getProcessor() { return $this->method ? $this->method->getProcessor() : null; }
/** * Is forced Merchant API for Paypal Express * https://developer.paypal.com/docs/classic/api/#merchant * * @param \XLite\Model\Payment\Base\Processor $processor Payment processor * * @return boolean */ protected function isForceMerchantAPI($processor) { $parentMethod = $processor->getParentMethod(); return !$processor->isForcedEnabled($this) && ('email' == parent::getSetting('api_type') || 'paypal' == parent::getSetting('api_solution') || $parentMethod && !$processor->isConfigured($parentMethod)); }
/** * Check - payment method is configured or not * * @param \XLite\Model\Payment\Method $method Payment method * * @return boolean */ public function isAllSettingsProvided(\XLite\Model\Payment\Method $method) { return $method->getSetting('merchant_id') && $method->getSetting('pub_cert') && $method->getSetting('pub_key') && $method->getSetting('private_key') && $method->getSetting('private_key_pass') && $method->getSetting('currency'); }
/** * Check - display separate Configure button or not * * @param \XLite\Model\Payment\Method $method Payment method * * @return boolean */ protected function isSeparateConfigureButtonVisible(\XLite\Model\Payment\Method $method) { return ($method->getWarningNote() || $method->isTestMode()) && $method->isConfigurable() && !$method->isForcedEnabled(); }
/** * Check - payment method is configured or not * * @param \XLite\Model\Payment\Method $method Payment method * * @return boolean */ public function isConfigured(\XLite\Model\Payment\Method $method) { return 'live' == $method->getSetting('mode') && $method->getSetting('identitytoken') && $method->getSetting('workflowid') && $method->getSetting('applicationprofileid') && $method->getSetting('merchantprofileid') || 'test' == $method->getSetting('mode') && $method->getSetting('identitytoken') && $method->getSetting('workflowid') && $method->getSetting('applicationprofileid') && $method->getSetting('merchantprofileid'); }
public function isConfigured(\XLite\Model\Payment\Method $method) { return $method->getSetting('secretKey') && $method->getSetting('publicKey'); }
/** * Check last payment method * * @param \XLite\Model\Payment\Method $pmethod Payment method * @param integer $lastPaymentId Last selected payment method id * * @return boolean */ public function checkLastPaymentMethod(\XLite\Model\Payment\Method $pmethod, $lastPaymentId) { $result = $pmethod->getMethodId() == $lastPaymentId; if ($result) { $this->setPaymentMethod($pmethod); } return $result; }
/** * Returns URL to payment module * * @param \XLite\Model\Payment\Method $method Payment method * * @return string */ public function getPaymentModuleURL(\XLite\Model\Payment\Method $method) { $result = ''; list($moduleAuthor, $moduleName) = explode('_', $method->getModuleName()); if ($method->isModuleInstalled()) { // Payment module is installed $pageId = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->getInstalledPageId($moduleAuthor, $moduleName, \XLite\View\Pager\Admin\Module\Manage::getInstance()->getItemsPerPage()); $params = array('clearCnd' => 1, \XLite\View\Pager\APager::PARAM_PAGE_ID => $pageId); $result = \XLite\Core\Converter::buildURL('addons_list_installed', '', $params) . '#' . $moduleName; } else { // Payment module is not installed $widget = new \XLite\View\Pager\Admin\Module\Install(); list(, $limit) = $widget->getLimitCondition()->limit; $pageId = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->getMarketplacePageId($moduleAuthor, $moduleName, $limit); $params = array('clearCnd' => 1, 'clearSearch' => 1, \XLite\View\Pager\APager::PARAM_PAGE_ID => $pageId, \XLite\View\ItemsList\AItemsList::PARAM_SORT_BY => \XLite\View\ItemsList\Module\AModule::SORT_OPT_ALPHA); $result = $this->buildURL('addons_list_marketplace', '', $params) . '#' . $moduleName; } return $result; }
/** * Get initial transaction type (used when customer places order) * * @param \XLite\Model\Payment\Method $method Payment method object OPTIONAL * * @return string */ public function getInitialTransactionType($method = null) { return 'A' == ($method ? $method->getSetting('transaction_type') : $this->getSetting('transaction_type')) ? \XLite\Model\Payment\BackendTransaction::TRAN_TYPE_AUTH : \XLite\Model\Payment\BackendTransaction::TRAN_TYPE_SALE; }
/** * Check - payment method has enabled test mode or not * * @param \XLite\Model\Payment\Method $method Payment method * * @return boolean */ public function isTestMode(\XLite\Model\Payment\Method $method) { return (bool) $method->getSetting('test'); }
/** * Check that existing payment method is in the list of the imported methods. Mark that in the list * * @param \XLite\Model\Payment\Method $paymentMethod Payment method * @param array $list List of the imported payment methods * * @return void */ protected function checkMethodInImportedList(\XLite\Model\Payment\Method $paymentMethod, &$list) { $result = false; foreach ($list as $key => $data) { if ($paymentMethod->getName() == $data['moduleName'] && $paymentMethod->getSetting('id') == $data['id']) { $result = true; $list[$key]['paymentMethodId'] = $paymentMethod->getMethodId(); break; } } return $result; }
/** * Returns 'after' list name (with payment method service name) * * @param \XLite\Model\Payment\Method $method Payment method * * @return string */ protected function getAfterListName(\XLite\Model\Payment\Method $method) { $serviceName = $method->getServiceName(); return 'after.' . preg_replace('/[^\\w]/', '_', $serviceName); }
/** * Check - payment method has enabled test mode or not * * @param \XLite\Model\Payment\Method $method Payment method * * @return boolean */ public function isTestMode(\XLite\Model\Payment\Method $method) { return 'Y' == $method->getSetting('isTestMode'); }
/** * Get initial transaction type (used when customer places order) * * @param \XLite\Model\Payment\Method $method Payment method object OPTIONAL * * @return string */ public function getInitialTransactionType($method = null) { $type = $method ? $method->getSetting('type') : $this->getSetting('type'); return 'sale' == $type ? \XLite\Model\Payment\BackendTransaction::TRAN_TYPE_AUTH : \XLite\Model\Payment\BackendTransaction::TRAN_TYPE_SALE; }