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

Public Member Functions

 __construct (Context $context, StoreManagerInterface $storeManager, OrderFactory $orderFactory)
 
 getSaveOrderUrlParams ($controller)
 
 getRedirectIframeUrl ($params)
 
 getSuccessOrderUrl ($params)
 
 updateOrderEditIncrements (\Magento\Sales\Model\Order $order)
 
 convertMessagesToMessage ($messages)
 
 getTransactionMessage ( $payment, $requestType, $lastTransactionId, $card, $amount=false, $exception=false, $additionalMessage=false)
 
 getPaymentMethodsHtml (\Magento\Framework\App\ViewInterface $view)
 
 getRelayUrl ($storeId=null)
 
 getAllowedCurrencyCodes ()
 
 getFdsFilterActionLabel ($key)
 
 getTransactionStatusLabel ($key)
 
 wrapGatewayError ($text)
 
- Public Member Functions inherited from AbstractHelper
 __construct (Context $context)
 
 isModuleOutputEnabled ($moduleName=null)
 

Protected Member Functions

 _getUrl ($route, $params=[])
 
 getOperation ($requestType)
 
 formatPrice ($payment, $amount)
 
- Protected Member Functions inherited from AbstractHelper
 _getRequest ()
 
 _getModuleName ()
 
 _getUrl ($route, $params=[])
 

Protected Attributes

 $storeManager
 
 $orderFactory
 
 $allowedCurrencyCodes = ['USD']
 
 $transactionStatuses
 
 $fdsFilterActions
 
- Protected Attributes inherited from AbstractHelper
 $_moduleName
 
 $_request
 
 $_moduleManager
 
 $_logger
 
 $_urlBuilder
 
 $_httpHeader
 
 $_eventManager
 
 $_remoteAddress
 
 $urlEncoder
 
 $urlDecoder
 
 $scopeConfig
 
 $_cacheConfig
 

Detailed Description

Authorize.net Data Helper

@api

Since
100.0.2

Definition at line 21 of file Data.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Context  $context,
StoreManagerInterface  $storeManager,
OrderFactory  $orderFactory 
)
Parameters
\Magento\Framework\App\Helper\Context$context
\Magento\Store\Model\StoreManagerInterface$storeManager
\Magento\Sales\Model\OrderFactory$orderFactory

Definition at line 74 of file Data.php.

78  {
79  $this->storeManager = $storeManager;
80  $this->orderFactory = $orderFactory;
81  parent::__construct($context);
82  }

Member Function Documentation

◆ _getUrl()

_getUrl (   $route,
  $params = [] 
)
protected

Set secure url checkout is secure for current store.

Parameters
string$route
array$params
Returns
string

Definition at line 91 of file Data.php.

92  {
94  if (isset($params['is_secure'])) {
95  $params['_secure'] = (bool)$params['is_secure'];
96  } elseif ($this->storeManager->getStore()->isCurrentlySecure()) {
97  $params['_secure'] = true;
98  }
99  return parent::_getUrl($route, $params);
100  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ convertMessagesToMessage()

convertMessagesToMessage (   $messages)

Converts a lot of messages to message

Parameters
array$messages
Returns
string

Definition at line 183 of file Data.php.

184  {
185  return implode(' | ', $messages);
186  }

◆ formatPrice()

formatPrice (   $payment,
  $amount 
)
protected

Format price with currency sign

Parameters
\Magento\Payment\Model\InfoInterface$payment
float$amount
Returns
string

Definition at line 262 of file Data.php.

263  {
264  return $payment->getOrder()->getBaseCurrency()->formatTxt($amount);
265  }
$amount
Definition: order.php:14
$payment
Definition: order.php:17

◆ getAllowedCurrencyCodes()

getAllowedCurrencyCodes ( )

Get allowed currencies

Returns
array

Definition at line 302 of file Data.php.

303  {
305  }

◆ getFdsFilterActionLabel()

getFdsFilterActionLabel (   $key)

Get translated filter action label

Parameters
string$key
Returns
\Magento\Framework\Phrase|string

Definition at line 313 of file Data.php.

314  {
315  return isset($this->fdsFilterActions[$key]) ? __($this->fdsFilterActions[$key]) : $key;
316  }
__()
Definition: __.php:13

◆ getOperation()

getOperation (   $requestType)
protected

Return operation name for request type

Parameters
string$requestType
Returns
\Magento\Framework\Phrase|bool

Definition at line 238 of file Data.php.

239  {
240  switch ($requestType) {
242  return __('authorize');
244  return __('authorize and capture');
246  return __('capture');
248  return __('refund');
250  return __('void');
251  default:
252  return false;
253  }
254  }
__()
Definition: __.php:13

◆ getPaymentMethodsHtml()

getPaymentMethodsHtml ( \Magento\Framework\App\ViewInterface  $view)

Get payment method step html

Parameters
\Magento\Framework\App\ViewInterface$view
Returns
string

Definition at line 273 of file Data.php.

274  {
275  $layout = $view->getLayout();
276  $update = $layout->getUpdate();
277  $update->load('checkout_onepage_paymentmethod');
278  $layout->generateXml();
279  $layout->generateElements();
280  $output = $layout->getOutput();
281  return $output;
282  }

◆ getRedirectIframeUrl()

getRedirectIframeUrl (   $params)

Retrieve redirect iframe url

Parameters
array$params
Returns
string

Definition at line 138 of file Data.php.

139  {
140  return $this->_getUrl('authorizenet/directpost_payment/redirect', $params);
141  }
_getUrl($route, $params=[])
Definition: Data.php:91
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ getRelayUrl()

getRelayUrl (   $storeId = null)

Get direct post relay url

Parameters
null | int | string$storeId
Returns
string

Definition at line 290 of file Data.php.

291  {
292  $baseUrl = $this->storeManager->getStore($storeId)
293  ->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK);
294  return $baseUrl . 'authorizenet/directpost_payment/response';
295  }

◆ getSaveOrderUrlParams()

getSaveOrderUrlParams (   $controller)

Retrieve save order url params

Parameters
string$controller
Returns
array

Definition at line 108 of file Data.php.

109  {
110  $route = [];
111  switch ($controller) {
112  case 'onepage':
113  $route['action'] = 'saveOrder';
114  $route['controller'] = 'onepage';
115  $route['module'] = 'checkout';
116  break;
117 
118  case 'sales_order_create':
119  case 'sales_order_edit':
120  $route['action'] = 'save';
121  $route['controller'] = 'sales_order_create';
122  $route['module'] = 'admin';
123  break;
124 
125  default:
126  break;
127  }
128 
129  return $route;
130  }
$controller
Definition: info.phtml:14

◆ getSuccessOrderUrl()

getSuccessOrderUrl (   $params)

Retrieve place order url

Parameters
array$params
Returns
string

Definition at line 149 of file Data.php.

150  {
151  return $this->_getUrl('checkout/onepage/success', $params);
152  }
_getUrl($route, $params=[])
Definition: Data.php:91
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ getTransactionMessage()

getTransactionMessage (   $payment,
  $requestType,
  $lastTransactionId,
  $card,
  $amount = false,
  $exception = false,
  $additionalMessage = false 
)

Return message for gateway transaction request

Parameters
\Magento\Payment\Model\InfoInterface$payment
string$requestType
string$lastTransactionId
\Magento\Framework\DataObject$card
bool | float$amount
bool | string$exception
bool | string$additionalMessage
Returns
bool|string

Definition at line 200 of file Data.php.

208  {
209  $message[] = __('Credit Card: xxxx-%1', $card->getCcLast4());
210  if ($amount) {
211  $message[] = __('amount %1', $this->formatPrice($payment, $amount));
212  }
213  $operation = $this->getOperation($requestType);
214  if (!$operation) {
215  return false;
216  } else {
217  $message[] = $operation;
218  }
219  $message[] = ($exception) ? '- ' . __('failed.') : '- ' . __('successful.');
220  if ($lastTransactionId !== null) {
221  $message[] = __('Authorize.Net Transaction ID %1.', $lastTransactionId);
222  }
223  if ($additionalMessage) {
224  $message[] = $additionalMessage;
225  }
226  if ($exception) {
227  $message[] = $exception;
228  }
229  return implode(' ', $message);
230  }
getOperation($requestType)
Definition: Data.php:238
__()
Definition: __.php:13
$message
$amount
Definition: order.php:14
$payment
Definition: order.php:17
formatPrice($payment, $amount)
Definition: Data.php:262

◆ getTransactionStatusLabel()

getTransactionStatusLabel (   $key)

Get translated transaction status label

Parameters
string$key
Returns
\Magento\Framework\Phrase|string

Definition at line 324 of file Data.php.

325  {
326  return isset($this->transactionStatuses[$key]) ? __($this->transactionStatuses[$key]) : $key;
327  }
__()
Definition: __.php:13

◆ updateOrderEditIncrements()

updateOrderEditIncrements ( \Magento\Sales\Model\Order  $order)

Update all child and parent order's edit increment numbers. Needed for Admin area.

Parameters
\Magento\Sales\Model\Order$order
Returns
void

Definition at line 161 of file Data.php.

162  {
163  if ($order->getId() && $order->getOriginalIncrementId()) {
164  $collection = $order->getCollection();
165  $quotedIncrId = $collection->getConnection()->quote($order->getOriginalIncrementId());
166  $collection->getSelect()->where(
167  "original_increment_id = {$quotedIncrId} OR increment_id = {$quotedIncrId}"
168  );
169 
170  foreach ($collection as $orderToUpdate) {
171  $orderToUpdate->setEditIncrement($order->getEditIncrement());
172  $orderToUpdate->save();
173  }
174  }
175  }
$order
Definition: order.php:55

◆ wrapGatewayError()

wrapGatewayError (   $text)

Gateway error response wrapper

Parameters
string$text
Returns
\Magento\Framework\Phrase

Definition at line 335 of file Data.php.

336  {
337  return __('Gateway error: %1', $text);
338  }
__()
Definition: __.php:13
endifif( $block->getLastPageNum()>1)( 'Page') ?></strong >< ul class $text
Definition: pager.phtml:43

Field Documentation

◆ $allowedCurrencyCodes

$allowedCurrencyCodes = ['USD']
protected

Definition at line 38 of file Data.php.

◆ $fdsFilterActions

$fdsFilterActions
protected
Initial value:
= [
'decline ' => 'Decline',
'hold' => 'Hold',
'authAndHold' => 'Authorize and Hold',
'report' => 'Report Only'
]

Definition at line 62 of file Data.php.

◆ $orderFactory

$orderFactory
protected

Definition at line 31 of file Data.php.

◆ $storeManager

$storeManager
protected

Definition at line 26 of file Data.php.

◆ $transactionStatuses

$transactionStatuses
protected
Initial value:
= [
'authorizedPendingCapture' => 'Authorized/Pending Capture',
'capturedPendingSettlement' => 'Captured/Pending Settlement',
'refundSettledSuccessfully' => 'Refund/Settled Successfully',
'refundPendingSettlement' => 'Refund/Pending Settlement',
'declined' => 'Declined',
'expired' => 'Expired',
'voided' => 'Voided',
'FDSPendingReview' => 'FDS - Pending Review',
'FDSAuthorizedPendingReview' => 'FDS - Authorized/Pending Review'
]

Definition at line 45 of file Data.php.


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