9 use Magento\Payment\Helper\Formatter;
182 'paypal_express' =>
'EC',
183 'paypal_direct' =>
'DP',
184 'payflow_express' =>
'EC',
193 'page_style' =>
'page_style',
194 'paypal_hdrimg' =>
'hdrimg',
195 'paypal_hdrbordercolor' =>
'hdrbordercolor',
196 'paypal_hdrbackcolor' =>
'hdrbackcolor',
197 'paypal_payflowcolor' =>
'payflowcolor',
615 \
Magento\Paypal\Model\CertFactory $certFactory,
618 parent::__construct($scopeConfig);
621 $this->_cctypeFactory = $cctypeFactory;
622 $this->_certFactory = $certFactory;
713 $countryCode = $this->_scopeConfig->getValue(
719 $countryCode = $this->directoryHelper->getDefaultCountry($this->_storeId);
737 if ($countryCode ===
null) {
820 if ($countryCode ===
null) {
821 return $countryMethods;
823 return isset($countryMethods[$countryCode]) ? $countryMethods[$countryCode] : $countryMethods[
'other'];
835 'cmd' =>
'_express-checkout',
840 $params[
'useraction'] =
'commit';
853 return $this->_scopeConfig->getValue(
854 self::XML_PATH_PAYPAL_EXPRESS_SKIP_ORDER_REVIEW_STEP_FLAG,
869 'https://www.%spaypal.com/checkoutnow%s',
870 $this->
getValue(
'sandboxFlag') ?
'sandbox.' :
'',
871 '?token=' . urlencode(
$token)
883 return $this->
getPaypalUrl([
'cmd' =>
'_express-checkout',
'order_id' => $orderId]);
894 return $this->
getPaypalUrl([
'cmd' =>
'_express-checkout',
'useraction' =>
'continue',
'token' =>
$token]);
906 return $this->
getPaypalUrl([
'cmd' =>
'_complete-express-checkout',
'token' =>
$token]);
917 return $this->
getPaypalUrl([
'cmd' =>
'_customer-billing-agreement',
'token' =>
$token]);
929 'https://www.%spaypal.com/cgi-bin/webscr%s',
930 $this->
getValue(
'sandboxFlag') ?
'sandbox.' :
'',
943 'https://ipnpb.%spaypal.com/cgi-bin/webscr',
944 $this->
getValue(
'sandboxFlag') ?
'sandbox.' :
'' 971 return $this->
_getDynamicImageUrl(self::EC_BUTTON_TYPE_SHORTCUT, $localeCode, $orderTotal, $pal);
973 if ($this->
getValue(
'buttonType') === self::EC_BUTTON_TYPE_MARK) {
990 if ($localeCode ===
'en_US') {
991 return 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-medium.png';
994 return sprintf(
'https://www.paypal.com/%s/i/btn/btn_xpressCheckout.gif', $localeCode);
1011 return $this->
_getDynamicImageUrl(self::EC_BUTTON_TYPE_MARK, $localeCode, $orderTotal, $pal);
1014 if (
null === $staticSize) {
1015 $staticSize = $this->
getValue(
'paymentMarkSize');
1018 switch ($staticSize) {
1028 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/pp-acceptance-%s.png',
1042 $countryCode =
'US';
1043 if (
null !== $localeResolver) {
1044 $shouldEmulate =
null !== $this->_storeId && $this->_storeManager->getStore()->getId() !=
$this->_storeId;
1045 if ($shouldEmulate) {
1046 $localeResolver->emulate($this->_storeId);
1048 $countryCode = \Locale::getRegion($localeResolver->getLocale());
1049 if ($shouldEmulate) {
1050 $localeResolver->revert();
1054 'https://www.paypal.com/%s/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside',
1055 strtolower($countryCode)
1070 'https://www.paypal.com/%s/i/bnr/%s_solution_PP%s.gif',
1072 $isVertical ?
'vertical' :
'horizontal',
1073 $isEcheck ?
'eCheck' :
'' 1087 $imageType =
'logo';
1088 $domain =
'paypal.com';
1089 list(, $country) = explode(
'_', $locale);
1090 $countryPrefix = $country .
'/';
1094 $imageName =
'horizontal_solution_PP';
1096 $countryPrefix =
'';
1099 $imageName =
'lockbox_150x47';
1102 $imageName =
'bnr_horizontal_solution_PP_327wx80h';
1105 $domain =
'paypalobjects.com';
1108 $imageName =
'bnr_horizontal_solution_PP_178wx80h';
1110 $domain =
'paypalobjects.com';
1113 $imageName =
'PayPal_mark_60x38';
1114 $countryPrefix =
'';
1117 return sprintf(
'https://www.%s/%s/%si/%s/%s.gif', $domain, $locale, $countryPrefix, $imageType, $imageName);
1128 'wePrefer_150x60' =>
__(
'We prefer PayPal (150 X 60)'),
1129 'wePrefer_150x40' =>
__(
'We prefer PayPal (150 X 40)'),
1130 'nowAccepting_150x60' =>
__(
'Now accepting PayPal (150 X 60)'),
1131 'nowAccepting_150x40' =>
__(
'Now accepting PayPal (150 X 40)'),
1132 'paymentsBy_150x60' =>
__(
'Payments by PayPal (150 X 60)'),
1133 'paymentsBy_150x40' =>
__(
'Payments by PayPal (150 X 40)'),
1134 'shopNowUsing_150x60' =>
__(
'Shop now using (150 X 60)'),
1135 'shopNowUsing_150x40' =>
__(
'Shop now using (150 X 40)')
1148 $configType = $this->_scopeConfig->getValue(
1159 if (!in_array(
$type, $supportedTypes)) {
1162 return sprintf(
'https://www.paypalobjects.com/%s/i/bnr/bnr_%s.gif', $locale,
$type);
1172 return [self::EC_FLAVOR_DYNAMIC =>
__(
'Dynamic'), self::EC_FLAVOR_STATIC =>
__(
'Static')];
1183 self::EC_BUTTON_TYPE_SHORTCUT =>
__(
'Shortcut'),
1184 self::EC_BUTTON_TYPE_MARK =>
__(
'Acceptance Mark Image')
1196 self::PAYMENT_ACTION_AUTH =>
__(
'Authorization'),
1197 self::PAYMENT_ACTION_SALE =>
__(
'Sale'),
1199 if ($this->_methodCode !==
null && $this->_methodCode == self::METHOD_WPP_EXPRESS) {
1202 return $paymentActions;
1213 self::REQUIRE_BILLING_ADDRESS_ALL =>
__(
'Yes'),
1214 self::REQUIRE_BILLING_ADDRESS_NO =>
__(
'No'),
1215 self::REQUIRE_BILLING_ADDRESS_VIRTUAL =>
__(
'For Virtual Quotes Only')
1226 switch ($this->
getValue(
'paymentAction')) {
1228 return \Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE;
1230 return \Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE_CAPTURE;
1232 return \Magento\Payment\Model\Method\AbstractMethod::ACTION_ORDER;
1246 return [self::EC_SOLUTION_TYPE_SOLE =>
__(
'Yes'), self::EC_SOLUTION_TYPE_MARK =>
__(
'No')];
1257 self::EC_BA_SIGNUP_AUTO =>
__(
'Auto'),
1258 self::EC_BA_SIGNUP_ASK =>
__(
'Ask Customer'),
1259 self::EC_BA_SIGNUP_NEVER =>
__(
'Never')
1271 return $this->
getValue(
'allow_ba_signup') === self::EC_BA_SIGNUP_ASK
1282 return [self::WPS_TRANSPORT_IPN =>
__(
'IPN (Instant Payment Notification) Only')];
1292 return $this->_cctypeFactory->create()->setAllowedTypes(
1293 [
'AE',
'VI',
'MC',
'SM',
'SO',
'DI']
1304 return $this->_cctypeFactory->create()->setAllowedTypes(
1305 [
'VI',
'MC',
'SM',
'SO',
'AE']
1316 return $this->_cctypeFactory->create()->setAllowedTypes([
'AE',
'VI',
'MC',
'JCB',
'DI',
'DN'])->toOptionArray();
1346 if (in_array(
$code, $this->_supportedCurrencyCodes)) {
1369 foreach ($this->_ecStyleConfigMap as $key => $exportKey) {
1370 $configValue = $this->
getValue($key);
1372 $to->setData($exportKey, $configValue);
1390 'cmd' =>
'_dynamic-image',
1391 'buttontype' =>
$type,
1395 $params[
'ordertotal'] = $this->formatPrice($orderTotal);
1400 if (
$params[
'locale'] ==
'en_US') {
1403 return 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/ppcredit-logo-medium.png';
1406 return 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-medium.png';
1410 'https://fpdbs%s.paypal.com/dynamicimageweb?%s',
1411 $this->
getValue(
'sandboxFlag') ?
'.sandbox' :
'',
1424 if (!$localeCode || !in_array($localeCode, $this->_supportedImageLocales)) {
1441 switch ($this->_methodCode) {
1459 if (
$path ===
null) {
1460 switch ($this->_methodCode) {
1475 if (
$path ===
null) {
1478 if (
$path ===
null) {
1493 switch ($fieldName) {
1494 case 'transfer_shipping_options':
1495 case 'solution_type':
1496 case 'visible_on_cart':
1497 case 'visible_on_product':
1498 case 'require_billing_address':
1499 case 'authorization_honor_period':
1500 case 'order_valid_period':
1501 case 'child_authorization_number':
1502 case 'allow_ba_signup':
1505 return "payment/{$this->_methodCode}/{$fieldName}";
1519 switch ($fieldName) {
1520 case 'allow_ba_signup':
1521 return "payment/" . self::METHOD_WPP_EXPRESS .
"/{$fieldName}";
1535 switch ($fieldName) {
1536 case 'allow_ba_signup':
1537 return "payment/" . self::METHOD_WPP_PE_EXPRESS .
"/{$fieldName}";
1551 switch ($fieldName) {
1553 return "payment/{$this->_methodCode}/{$fieldName}";
1568 switch ($fieldName) {
1569 case 'api_authentication':
1570 case 'api_username':
1571 case 'api_password':
1572 case 'api_signature':
1574 case 'sandbox_flag':
1578 case 'button_flavor':
1580 return "paypal/wpp/{$fieldName}";
1595 $pathPrefix =
'paypal/wpuk';
1596 if ($this->_methodCode == self::METHOD_WPP_PE_EXPRESS && $this->
isMethodAvailable(self::METHOD_PAYFLOWLINK)) {
1597 $pathPrefix =
'payment/payflow_link';
1599 self::METHOD_PAYFLOWADVANCED
1602 $pathPrefix =
'payment/payflow_advanced';
1603 }
elseif ($this->_methodCode == self::METHOD_WPP_PE_EXPRESS) {
1604 $pathPrefix =
'payment/payflowpro';
1605 }
elseif ($this->_methodCode == self::METHOD_PAYFLOWADVANCED || $this->_methodCode == self::METHOD_PAYFLOWLINK
1607 return 'payment/' . $this->_methodCode .
'/' . $fieldName;
1609 switch ($fieldName) {
1614 case 'sandbox_flag':
1618 return $pathPrefix .
'/' . $fieldName;
1632 switch ($fieldName) {
1635 case 'paypal_hdrimg':
1636 case 'paypal_hdrbackcolor':
1637 case 'paypal_hdrbordercolor':
1638 case 'paypal_payflowcolor':
1639 return "paypal/style/{$fieldName}";
1653 switch ($fieldName) {
1654 case 'business_account':
1655 case 'merchant_country':
1656 return "paypal/general/{$fieldName}";
1671 if (!$this->_methodCode) {
1674 switch ($fieldName) {
1677 case 'payment_action':
1678 case 'allowspecific':
1679 case 'specificcountry':
1680 case 'line_items_enabled':
1685 return "payment/{$this->_methodCode}/{$fieldName}";
1698 return [
'0' =>
__(
'API Signature'),
'1' =>
__(
'API Certificate')];
1708 $websiteId = $this->_storeManager->getStore($this->_storeId)->getWebsiteId();
1709 return $this->_certFactory->create()->loadByWebsite(
$websiteId,
false)->getCertPath();
1719 return $this->_scopeConfig->getValue(
1720 'payment/' . self::METHOD_WPP_BML .
'/publisher_id',
1734 $display = $this->_scopeConfig->getValue(
1735 'payment/' . self::METHOD_WPP_BML .
'/' . $section .
'_display',
1739 $bmlActive = $this->_scopeConfig->getValue(
1740 'payment/' . self::METHOD_WPP_BML .
'/active',
1744 $bmlUkActive = $this->_scopeConfig->getValue(
1745 'payment/' . self::METHOD_WPP_PE_BML .
'/active',
1749 return (($bmlActive && $this->
isMethodActive(self::METHOD_WPP_EXPRESS))
1750 || ($bmlUkActive && $this->
isMethodActive(self::METHOD_WPP_PE_EXPRESS))) ? $display : 0;
1761 return $this->_scopeConfig->getValue(
1762 'payment/' . self::METHOD_WPP_BML .
'/' . $section .
'_position',
1776 return $this->_scopeConfig->getValue(
1777 'payment/' . self::METHOD_WPP_BML .
'/' . $section .
'_size',
const FRAUD_ACTION_ACCEPT
_mapGenericStyleFieldset($fieldName)
_mapWppFieldset($fieldName)
getPayPalBasicStartUrl($token)
isOrderReviewStepDisabled()
const METHOD_PAYFLOWADVANCED
_mapExpressFieldset($fieldName)
shouldAskToCreateBillingAgreement()
shouldUseUnilateralPayments()
const AUTHORIZATION_AMOUNT_ONE
getExpressCheckoutEditUrl($token)
elseif(isset( $params[ 'redirect_parent']))
$_supportedBuyerCountryCodes
const EC_BUTTON_TYPE_SHORTCUT
getApiAuthenticationMethods()
getExpressCheckoutBASignupOptions()
const EC_SOLUTION_TYPE_SOLE
getWpsPaymentDeliveryMethods()
const TRANSFER_SHIPPING_OPTIONS
getCountryMethods($countryCode=null)
const PAYMENT_MARK_MEDIUM
_mapWpukFieldset($fieldName)
_getSupportedLocaleCode($localeCode=null)
getPaypalUrl(array $params=[])
isCurrencyCodeSupported($code)
getWppCcTypesAsOptionArray()
getExpressCheckoutStartUrl($token)
getAdditionalOptionsLogoUrl($localeCode, $type=false)
_mapDirectFieldset($fieldName)
getPayflowproCcTypesAsOptionArray()
getExpressCheckoutButtonFlavors()
getPaymentMarkImageUrl($localeCode, $orderTotal=null, $pal=null, $staticSize=null)
getValue($key, $storeId=null)
_mapBmlPayflowFieldset($fieldName)
const XML_PATH_PAYPAL_EXPRESS_SKIP_ORDER_REVIEW_STEP_FLAG
const REQUIRE_BILLING_ADDRESS_VIRTUAL
exportExpressCheckoutStyleSettings(\Magento\Framework\DataObject $to)
getExpressCheckoutOrderUrl($orderId)
_getSpecificConfigPath($fieldName)
_mapBmlFieldset($fieldName)
getExpressCheckoutShortcutImageUrl($localeCode, $orderTotal=null, $pal=null)
getPaymentFormLogoUrl($localeCode)
const AUTHORIZATION_AMOUNT_FULL
const PAYMENT_ACTION_AUTH
getExpressCheckoutButtonTypes()
const EC_BUTTON_TYPE_MARK
_mapMethodFieldset($fieldName)
_getDynamicImageUrl($type, $localeCode, $orderTotal, $pal)
getSupportedBuyerCountryCodes()
const REQUIRE_BILLING_ADDRESS_ALL
static getIsCreditCardMethod($code)
getRequireBillingAddressOptions()
const METHOD_WPP_PE_EXPRESS
const PAYMENT_ACTION_SALE
getPaymentMarkWhatIsPaypalUrl(\Magento\Framework\Locale\ResolverInterface $localeResolver=null)
isMethodSupportedForCountry($method=null, $countryCode=null)
getAdditionalOptionsLogoTypes()
getExpressCheckoutCompleteUrl($token)
__construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Directory\Helper\Data $directoryHelper, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Payment\Model\Source\CctypeFactory $cctypeFactory, \Magento\Paypal\Model\CertFactory $certFactory, $params=[])
isMethodAvailable($methodCode=null)
const WPS_TRANSPORT_IPN_PDT
const REFUND_TYPE_PARTIAL
getSupportedMerchantCountryCodes()
getStartBillingAgreementUrl($token)
const PAYMENT_ACTION_ORDER
getSolutionImageUrl($localeCode, $isVertical=false, $isEcheck=false)
getExpressCheckoutSolutionTypes()
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
const EC_SOLUTION_TYPE_MARK
const METHOD_BILLING_AGREEMENT
_mapGeneralFieldset($fieldName)
const TRANSFER_CART_LINE_ITEMS
getWppPeCcTypesAsOptionArray()
getExpressCheckoutInContextImageUrl($localeCode)
const REQUIRE_BILLING_ADDRESS_NO