Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Hostedpro Class Reference
Inheritance diagram for Hostedpro:
Direct

Public Member Functions

 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Payment\Model\Method\Logger $logger, \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Paypal\Model\ProFactory $proFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\App\RequestInterface $requestHttp, \Magento\Paypal\Model\CartFactory $cartFactory, \Magento\Paypal\Model\Hostedpro\RequestFactory $hostedproRequestFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 getAllowedCcTypes ()
 
 getMerchantCountry ()
 
 validate ()
 
 getReturnUrl ($storeId=null)
 
 getNotifyUrl ($storeId=null)
 
 getCancelUrl ($storeId=null)
 
- Public Member Functions inherited from Direct
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Payment\Model\Method\Logger $logger, \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Paypal\Model\ProFactory $proFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\App\RequestInterface $requestHttp, \Magento\Paypal\Model\CartFactory $cartFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 setStore ($store)
 
 canUseForCurrency ($currencyCode)
 
 getConfigPaymentAction ()
 
 getAllowedCcTypes ()
 
 isAvailable (\Magento\Quote\Api\Data\CartInterface $quote=null)
 
 getConfigData ($field, $storeId=null)
 
 authorize (\Magento\Payment\Model\InfoInterface $payment, $amount)
 
 void (\Magento\Payment\Model\InfoInterface $payment)
 
 capture (\Magento\Payment\Model\InfoInterface $payment, $amount)
 
 refund (\Magento\Payment\Model\InfoInterface $payment, $amount)
 
 cancel (\Magento\Payment\Model\InfoInterface $payment)
 
 canReviewPayment ()
 
 acceptPayment (\Magento\Payment\Model\InfoInterface $payment)
 
 denyPayment (\Magento\Payment\Model\InfoInterface $payment)
 
 fetchTransactionInfo (\Magento\Payment\Model\InfoInterface $payment, $transactionId)
 
 canVoid ()
 

Data Fields

const BM_BUTTON_CODE = 'TOKEN'
 
const BM_BUTTON_TYPE = 'PAYMENT'
 
const BM_BUTTON_METHOD = 'BMCreateButton'
 

Protected Member Functions

 setPaymentFormUrl (InfoInterface $payment)
 
 buildFormUrlRequest (InfoInterface $payment)
 
 sendFormUrlRequest (Request $request)
 
 buildBasicRequest ()
 
 getUrl ($path, $storeId, $secure=null)
 
- Protected Member Functions inherited from Direct
 _placeOrder (Payment $payment, $amount)
 
 _getFormattedCcExpirationDate ($month, $year)
 
 _importResultToPayment ($api, $payment)
 

Protected Attributes

 $_code = Config::METHOD_HOSTEDPRO
 
 $_formBlockType = \Magento\Paypal\Block\Hosted\Pro\Form::class
 
 $_infoBlockType = \Magento\Paypal\Block\Hosted\Pro\Info::class
 
 $_canUseInternal = false
 
 $_canSaveCc = false
 
 $_isInitializeNeeded = true
 
 $hostedproRequestFactory
 
- Protected Attributes inherited from Direct
 $_code = \Magento\Paypal\Model\Config::METHOD_WPP_DIRECT
 
 $_infoBlockType = \Magento\Paypal\Block\Payment\Info::class
 
 $_isGateway = true
 
 $_canAuthorize = true
 
 $_canCapture = true
 
 $_canCapturePartial = true
 
 $_canRefund = true
 
 $_canRefundInvoicePartial = true
 
 $_canVoid = true
 
 $_canUseInternal = true
 
 $_canUseCheckout = true
 
 $_canSaveCc = false
 
 $_canFetchTransactionInfo = true
 
 $_canReviewPayment = true
 
 $_pro
 
 $_storeManager
 
 $_urlBuilder
 
 $_requestHttp
 
 $_cartFactory
 

Detailed Description

Website Payments Pro Hosted Solution payment gateway model @SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 18 of file Hostedpro.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Model\Context  $context,
\Magento\Framework\Registry  $registry,
\Magento\Framework\Api\ExtensionAttributesFactory  $extensionFactory,
\Magento\Framework\Api\AttributeValueFactory  $customAttributeFactory,
\Magento\Payment\Helper\Data  $paymentData,
\Magento\Framework\App\Config\ScopeConfigInterface  $scopeConfig,
\Magento\Payment\Model\Method\Logger  $logger,
\Magento\Framework\Module\ModuleListInterface  $moduleList,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface  $localeDate,
\Magento\Paypal\Model\ProFactory  $proFactory,
\Magento\Store\Model\StoreManagerInterface  $storeManager,
\Magento\Framework\UrlInterface  $urlBuilder,
\Magento\Framework\App\RequestInterface  $requestHttp,
\Magento\Paypal\Model\CartFactory  $cartFactory,
\Magento\Paypal\Model\Hostedpro\RequestFactory  $hostedproRequestFactory,
\Magento\Framework\Model\ResourceModel\AbstractResource  $resource = null,
\Magento\Framework\Data\Collection\AbstractDb  $resourceCollection = null,
array  $data = [] 
)
Parameters
\Magento\Framework\Model\Context$context
\Magento\Framework\Registry$registry
\Magento\Framework\Api\ExtensionAttributesFactory$extensionFactory
\Magento\Framework\Api\AttributeValueFactory$customAttributeFactory
\Magento\Payment\Helper\Data$paymentData
\Magento\Framework\App\Config\ScopeConfigInterface$scopeConfig
\Magento\Payment\Model\Method\Logger$logger
\Magento\Framework\Module\ModuleListInterface$moduleList
\Magento\Framework\Stdlib\DateTime\TimezoneInterface$localeDate
ProFactory$proFactory
\Magento\Store\Model\StoreManagerInterface$storeManager
\Magento\Framework\UrlInterface$urlBuilder
\Magento\Framework\App\RequestInterface$requestHttp
CartFactory$cartFactory
Hostedpro\RequestFactory$hostedproRequestFactory
\Magento\Framework\Model\ResourceModel\AbstractResource$resource
\Magento\Framework\Data\Collection\AbstractDb$resourceCollection
array$data@SuppressWarnings(PHPMD.ExcessiveParameterList)

Definition at line 99 of file Hostedpro.php.

118  {
119  $this->hostedproRequestFactory = $hostedproRequestFactory;
120  parent::__construct(
121  $context,
122  $registry,
123  $extensionFactory,
124  $customAttributeFactory,
125  $paymentData,
126  $scopeConfig,
127  $logger,
128  $moduleList,
129  $localeDate,
130  $proFactory,
132  $urlBuilder,
133  $requestHttp,
134  $cartFactory,
135  $resource,
136  $resourceCollection,
137  $data
138  );
139  }
$storeManager
$resource
Definition: bulk.php:12
$logger

Member Function Documentation

◆ buildBasicRequest()

buildBasicRequest ( )
protected

Return request object with basic information

Returns
\Magento\Paypal\Model\Hostedpro\Request

Definition at line 257 of file Hostedpro.php.

258  {
259  $request = $this->hostedproRequestFactory->create()->setData(
260  [
261  'METHOD' => self::BM_BUTTON_METHOD,
262  'BUTTONCODE' => self::BM_BUTTON_CODE,
263  'BUTTONTYPE' => self::BM_BUTTON_TYPE,
264  ]
265  );
266  return $request;
267  }

◆ buildFormUrlRequest()

buildFormUrlRequest ( InfoInterface  $payment)
protected

Returns request object with needed data for API request to PayPal to get form URL.

Parameters
\Magento\Payment\Model\InfoInterface$payment
Returns
\Magento\Paypal\Model\Hostedpro\Request

Definition at line 227 of file Hostedpro.php.

228  {
229  $order = $payment->getOrder();
230  $request = $this->buildBasicRequest()->setOrder($order)->setPaymentMethod($this)->setAmount($order);
231 
232  return $request;
233  }
$order
Definition: order.php:55
$payment
Definition: order.php:17

◆ getAllowedCcTypes()

getAllowedCcTypes ( )

Return available CC types for gateway based on merchant country. We do not have to check the availability of card types.

Returns
true

Definition at line 147 of file Hostedpro.php.

148  {
149  return true;
150  }

◆ getCancelUrl()

getCancelUrl (   $storeId = null)

Get cancel URL

Parameters
int | null$storeId
Returns
string

Definition at line 297 of file Hostedpro.php.

298  {
299  return $this->getUrl('paypal/hostedpro/cancel', $storeId);
300  }
getUrl($path, $storeId, $secure=null)
Definition: Hostedpro.php:310

◆ getMerchantCountry()

getMerchantCountry ( )

Return merchant country code from config, use default country if it not specified in General settings

Returns
string

Definition at line 158 of file Hostedpro.php.

159  {
160  return $this->_pro->getConfig()->getMerchantCountry();
161  }

◆ getNotifyUrl()

getNotifyUrl (   $storeId = null)

Get notify (IPN) URL

Parameters
int | null$storeId
Returns
string

Definition at line 286 of file Hostedpro.php.

287  {
288  return $this->getUrl('paypal/ipn', $storeId, false);
289  }
getUrl($path, $storeId, $secure=null)
Definition: Hostedpro.php:310

◆ getReturnUrl()

getReturnUrl (   $storeId = null)

Get return URL

Parameters
int | null$storeId
Returns
string

Definition at line 275 of file Hostedpro.php.

276  {
277  return $this->getUrl('paypal/hostedpro/return', $storeId);
278  }
getUrl($path, $storeId, $secure=null)
Definition: Hostedpro.php:310

◆ getUrl()

getUrl (   $path,
  $storeId,
  $secure = null 
)
protected

Build URL for store

Parameters
string$path
int$storeId
bool | null$secure
Returns
string

Definition at line 310 of file Hostedpro.php.

311  {
312  $store = $this->_storeManager->getStore($storeId);
313  return $this->_urlBuilder->getUrl(
314  $path,
315  ["_secure" => $secure === null ? $store->isCurrentlySecure() : $secure]
316  );
317  }

◆ sendFormUrlRequest()

sendFormUrlRequest ( Request  $request)
protected

Returns form URL from request to PayPal.

Parameters
\Magento\Paypal\Model\Hostedpro\Request$request
Returns
string|false

Definition at line 241 of file Hostedpro.php.

242  {
243  $api = $this->_pro->getApi();
244  $response = $api->call(self::BM_BUTTON_METHOD, $request->getRequestData());
245 
246  if (!isset($response['EMAILLINK'])) {
247  return false;
248  }
249  return $response['EMAILLINK'];
250  }
$response
Definition: 404.php:11

◆ setPaymentFormUrl()

setPaymentFormUrl ( InfoInterface  $payment)
protected

Sends API request to PayPal to get form URL, then sets this URL to $payment object.

Parameters
\Magento\Payment\Model\InfoInterface$payment
Returns
void
Exceptions

Definition at line 210 of file Hostedpro.php.

211  {
214  if ($response) {
215  $payment->setAdditionalInformation('secure_form_url', $response);
216  } else {
217  throw new LocalizedException(__('Cannot get secure form URL from PayPal'));
218  }
219  }
$response
Definition: 404.php:11
buildFormUrlRequest(InfoInterface $payment)
Definition: Hostedpro.php:227
__()
Definition: __.php:13
$payment
Definition: order.php:17
sendFormUrlRequest(Request $request)
Definition: Hostedpro.php:241

◆ validate()

validate ( )

Do not validate payment form using server methods

Returns
true

Definition at line 168 of file Hostedpro.php.

169  {
170  return true;
171  }

Field Documentation

◆ $_canSaveCc

$_canSaveCc = false
protected

Definition at line 64 of file Hostedpro.php.

◆ $_canUseInternal

$_canUseInternal = false
protected

Definition at line 57 of file Hostedpro.php.

◆ $_code

$_code = Config::METHOD_HOSTEDPRO
protected

Definition at line 40 of file Hostedpro.php.

◆ $_formBlockType

$_formBlockType = \Magento\Paypal\Block\Hosted\Pro\Form::class
protected

Definition at line 45 of file Hostedpro.php.

◆ $_infoBlockType

$_infoBlockType = \Magento\Paypal\Block\Hosted\Pro\Info::class
protected

Definition at line 50 of file Hostedpro.php.

◆ $_isInitializeNeeded

$_isInitializeNeeded = true
protected

Definition at line 71 of file Hostedpro.php.

◆ $hostedproRequestFactory

$hostedproRequestFactory
protected

Definition at line 76 of file Hostedpro.php.

◆ BM_BUTTON_CODE

const BM_BUTTON_CODE = 'TOKEN'

Button code

Definition at line 23 of file Hostedpro.php.

◆ BM_BUTTON_METHOD

const BM_BUTTON_METHOD = 'BMCreateButton'

Paypal API method name for button creation

Definition at line 33 of file Hostedpro.php.

◆ BM_BUTTON_TYPE

const BM_BUTTON_TYPE = 'PAYMENT'

Button type

Definition at line 28 of file Hostedpro.php.


The documentation for this class was generated from the following file: