Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Express Class Reference
Inheritance diagram for Express:
AbstractMethod AbstractExtensibleModel MethodInterface PaymentMethodInterface AbstractModel CustomAttributesDataInterface DataObject ExtensibleDataInterface Express Bml Bml PayflowExpress

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, ProFactory $proFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Paypal\Model\CartFactory $cartFactory, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Framework\Exception\LocalizedExceptionFactory $exception, \Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository, \Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface $transactionBuilder, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 setStore ($store)
 
 canUseCheckout ()
 
 canUseForCurrency ($currencyCode)
 
 getConfigPaymentAction ()
 
 isAvailable (\Magento\Quote\Api\Data\CartInterface $quote=null)
 
 getConfigData ($field, $storeId=null)
 
 order (\Magento\Payment\Model\InfoInterface $payment, $amount)
 
 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)
 
 getCheckoutRedirectUrl ()
 
 fetchTransactionInfo (\Magento\Payment\Model\InfoInterface $payment, $transactionId)
 
 getApi ()
 
 assignData (\Magento\Framework\DataObject $data)
 
 canVoid ()
 
 canCapture ()
 
 isActive ($storeId=null)
 
- Public Member Functions inherited from AbstractMethod
 __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\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[], DirectoryHelper $directory=null)
 
 setStore ($storeId)
 
 getStore ()
 
 canOrder ()
 
 canAuthorize ()
 
 canCapture ()
 
 canCapturePartial ()
 
 canCaptureOnce ()
 
 canRefund ()
 
 canRefundPartialPerInvoice ()
 
 canVoid ()
 
 canUseInternal ()
 
 canUseCheckout ()
 
 canEdit ()
 
 canFetchTransactionInfo ()
 
 fetchTransactionInfo (InfoInterface $payment, $transactionId)
 
 isGateway ()
 
 isOffline ()
 
 isInitializeNeeded ()
 
 canUseForCountry ($country)
 
 canUseForCurrency ($currencyCode)
 
 getCode ()
 
 getFormBlockType ()
 
 getInfoBlockType ()
 
 getInfoInstance ()
 
 setInfoInstance (InfoInterface $info)
 
 validate ()
 
 order (\Magento\Payment\Model\InfoInterface $payment, $amount)
 
 authorize (\Magento\Payment\Model\InfoInterface $payment, $amount)
 
 capture (\Magento\Payment\Model\InfoInterface $payment, $amount)
 
 refund (\Magento\Payment\Model\InfoInterface $payment, $amount)
 
 cancel (\Magento\Payment\Model\InfoInterface $payment)
 
 void (\Magento\Payment\Model\InfoInterface $payment)
 
 canReviewPayment ()
 
 acceptPayment (InfoInterface $payment)
 
 denyPayment (InfoInterface $payment)
 
 getTitle ()
 
 getConfigData ($field, $storeId=null)
 
 assignData (\Magento\Framework\DataObject $data)
 
 isAvailable (\Magento\Quote\Api\Data\CartInterface $quote=null)
 
 isActive ($storeId=null)
 
 initialize ($paymentAction, $stateObject)
 
 getConfigPaymentAction ()
 
 getDebugFlag ()
 
 debugData ($debugData)
 
 getDebugReplacePrivateDataKeys ()
 
- Public Member Functions inherited from AbstractExtensibleModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 getCustomAttributes ()
 
 getCustomAttribute ($attributeCode)
 
 setCustomAttributes (array $attributes)
 
 setCustomAttribute ($attributeCode, $attributeValue)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 setId ($value)
 
 __sleep ()
 
 __wakeup ()
 
- Public Member Functions inherited from AbstractModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 __sleep ()
 
 __wakeup ()
 
 setIdFieldName ($name)
 
 getIdFieldName ()
 
 getId ()
 
 setId ($value)
 
 isDeleted ($isDeleted=null)
 
 hasDataChanges ()
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 setDataChanges ($value)
 
 getOrigData ($key=null)
 
 setOrigData ($key=null, $data=null)
 
 dataHasChangedFor ($field)
 
 getResourceName ()
 
 getResourceCollection ()
 
 getCollection ()
 
 load ($modelId, $field=null)
 
 beforeLoad ($identifier, $field=null)
 
 afterLoad ()
 
 isSaveAllowed ()
 
 setHasDataChanges ($flag)
 
 save ()
 
 afterCommitCallback ()
 
 isObjectNew ($flag=null)
 
 beforeSave ()
 
 validateBeforeSave ()
 
 getCacheTags ()
 
 cleanModelCache ()
 
 afterSave ()
 
 delete ()
 
 beforeDelete ()
 
 afterDelete ()
 
 afterDeleteCommit ()
 
 getResource ()
 
 getEntityId ()
 
 setEntityId ($entityId)
 
 clearInstance ()
 
 getStoredData ()
 
 getEventPrefix ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 
- Public Member Functions inherited from MethodInterface
 order (\Magento\Payment\Model\InfoInterface $payment, $amount)
 
 authorize (\Magento\Payment\Model\InfoInterface $payment, $amount)
 
 capture (\Magento\Payment\Model\InfoInterface $payment, $amount)
 
 refund (\Magento\Payment\Model\InfoInterface $payment, $amount)
 
 cancel (\Magento\Payment\Model\InfoInterface $payment)
 
 void (\Magento\Payment\Model\InfoInterface $payment)
 
 assignData (DataObject $data)
 
 isAvailable (CartInterface $quote=null)
 
- Public Member Functions inherited from PaymentMethodInterface
 getStoreId ()
 
 getIsActive ()
 

Protected Member Functions

 _setApiProcessableErrors ()
 
 _placeOrder (Payment $payment, $amount)
 
 _importToPayment ($api, $payment)
 
 _callDoAuthorize ($amount, $payment, $parentTransactionId)
 
 _isTransactionExpired (Transaction $transaction, $period)
 
 getOrderTransaction ($payment)
 
- Protected Member Functions inherited from AbstractMethod
 initializeData ($data=[])
 
 _debug ($debugData)
 
- Protected Member Functions inherited from AbstractExtensibleModel
 filterCustomAttributes ($data)
 
 initializeCustomAttributes ()
 
 convertCustomAttributeValues (array &$customAttributes)
 
 getCustomAttributesCodes ()
 
 _setExtensionAttributes (\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
 
 _getExtensionAttributes ()
 
- Protected Member Functions inherited from AbstractModel
 _construct ()
 
 _init ($resourceModel)
 
 _setResourceModel ($resourceName, $collectionName=null)
 
 _getResource ()
 
 _getEventData ()
 
 _beforeLoad ($modelId, $field=null)
 
 _afterLoad ()
 
 _hasModelChanged ()
 
 _getValidatorBeforeSave ()
 
 _createValidatorBeforeSave ()
 
 _getValidationRulesBeforeSave ()
 
 _clearReferences ()
 
 _clearData ()
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $_code = \Magento\Paypal\Model\Config::METHOD_WPP_EXPRESS
 
 $_formBlockType = \Magento\Paypal\Block\Express\Form::class
 
 $_infoBlockType = \Magento\Paypal\Block\Payment\Info::class
 
 $_isGateway = false
 
 $_canOrder = true
 
 $_canAuthorize = true
 
 $_canCapture = true
 
 $_canCapturePartial = true
 
 $_canRefund = true
 
 $_canRefundInvoicePartial = true
 
 $_canVoid = true
 
 $_canUseInternal = false
 
 $_canUseCheckout = true
 
 $_canFetchTransactionInfo = true
 
 $_canReviewPayment = true
 
 $_pro
 
 $_isOrderPaymentActionKey = 'is_order_action'
 
 $_authorizationCountKey = 'authorization_count'
 
 $_storeManager
 
 $_urlBuilder
 
 $_cartFactory
 
 $_checkoutSession
 
 $_exception
 
 $transactionRepository
 
 $transactionBuilder
 
- Protected Attributes inherited from AbstractMethod
 $_code
 
 $_formBlockType = \Magento\Payment\Block\Form::class
 
 $_infoBlockType = \Magento\Payment\Block\Info::class
 
 $_isGateway = false
 
 $_isOffline = false
 
 $_canOrder = false
 
 $_canAuthorize = false
 
 $_canCapture = false
 
 $_canCapturePartial = false
 
 $_canCaptureOnce = false
 
 $_canRefund = false
 
 $_canRefundInvoicePartial = false
 
 $_canVoid = false
 
 $_canUseInternal = true
 
 $_canUseCheckout = true
 
 $_isInitializeNeeded = false
 
 $_canFetchTransactionInfo = false
 
 $_canReviewPayment = false
 
 $_canCancelInvoice = false
 
 $_debugReplacePrivateDataKeys = []
 
 $_paymentData
 
 $_scopeConfig
 
 $logger
 
- Protected Attributes inherited from AbstractExtensibleModel
 $extensionAttributesFactory
 
 $extensionAttributes
 
 $customAttributeFactory
 
 $customAttributesCodes = null
 
 $customAttributesChanged = false
 
- Protected Attributes inherited from AbstractModel
 $_eventPrefix = 'core_abstract'
 
 $_eventObject = 'object'
 
 $_idFieldName = 'id'
 
 $_hasDataChanges = false
 
 $_origData
 
 $_isDeleted = false
 
 $_resource
 
 $_resourceCollection
 
 $_resourceName
 
 $_collectionName
 
 $_cacheTag = false
 
 $_dataSaveAllowed = true
 
 $_isObjectNew = null
 
 $_validatorBeforeSave = null
 
 $_eventManager
 
 $_cacheManager
 
 $_registry
 
 $_logger
 
 $_appState
 
 $_actionValidator
 
 $storedData = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Data Fields inherited from AbstractMethod
const STATUS_UNKNOWN = 'UNKNOWN'
 
const STATUS_APPROVED = 'APPROVED'
 
const STATUS_ERROR = 'ERROR'
 
const STATUS_DECLINED = 'DECLINED'
 
const STATUS_VOID = 'VOID'
 
const STATUS_SUCCESS = 'SUCCESS'
 
- Data Fields inherited from CustomAttributesDataInterface
const CUSTOM_ATTRIBUTES = 'custom_attributes'
 
- Data Fields inherited from ExtensibleDataInterface
const EXTENSION_ATTRIBUTES_KEY = 'extension_attributes'
 
- Data Fields inherited from MethodInterface
const ACTION_ORDER = 'order'
 
const ACTION_AUTHORIZE = 'authorize'
 
const ACTION_AUTHORIZE_CAPTURE = 'authorize_capture'
 
const CHECK_USE_FOR_COUNTRY = 'country'
 
const CHECK_USE_FOR_CURRENCY = 'currency'
 
const CHECK_USE_CHECKOUT = 'checkout'
 
const CHECK_USE_INTERNAL = 'internal'
 
const CHECK_ORDER_TOTAL_MIN_MAX = 'total'
 
const CHECK_ZERO_TOTAL = 'zero_total'
 
const GROUP_OFFLINE = 'offline'
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

PayPal Express Module @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes() @SuppressWarnings(PHPMD.TooManyFields) @SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 25 of file Express.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,
ProFactory  $proFactory,
\Magento\Store\Model\StoreManagerInterface  $storeManager,
\Magento\Framework\UrlInterface  $urlBuilder,
\Magento\Paypal\Model\CartFactory  $cartFactory,
\Magento\Checkout\Model\Session  $checkoutSession,
\Magento\Framework\Exception\LocalizedExceptionFactory  $exception,
\Magento\Sales\Api\TransactionRepositoryInterface  $transactionRepository,
\Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface  $transactionBuilder,
\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
ProFactory$proFactory
\Magento\Store\Model\StoreManagerInterface$storeManager
\Magento\Framework\UrlInterface$urlBuilder
CartFactory$cartFactory
\Magento\Checkout\Model\Session$checkoutSession
\Magento\Framework\Exception\LocalizedExceptionFactory$exception
\Magento\Sales\Api\TransactionRepositoryInterface$transactionRepository
Transaction\BuilderInterface$transactionBuilder
\Magento\Framework\Model\ResourceModel\AbstractResource$resource
\Magento\Framework\Data\Collection\AbstractDb$resourceCollection
array$data@SuppressWarnings(PHPMD.ExcessiveParameterList)

Definition at line 203 of file Express.php.

222  {
223  parent::__construct(
224  $context,
225  $registry,
226  $extensionFactory,
228  $paymentData,
229  $scopeConfig,
230  $logger,
231  $resource,
232  $resourceCollection,
233  $data
234  );
235  $this->_storeManager = $storeManager;
236  $this->_urlBuilder = $urlBuilder;
237  $this->_cartFactory = $cartFactory;
238  $this->_checkoutSession = $checkoutSession;
239  $this->_exception = $exception;
240  $this->transactionRepository = $transactionRepository;
241  $this->transactionBuilder = $transactionBuilder;
242 
243  $proInstance = array_shift($data);
244  if ($proInstance && $proInstance instanceof \Magento\Paypal\Model\Pro) {
245  $this->_pro = $proInstance;
246  } else {
247  $this->_pro = $proFactory->create();
248  }
249  $this->_pro->setMethod($this->_code);
250  $this->_setApiProcessableErrors();
251  }
$storeManager
$resource
Definition: bulk.php:12

Member Function Documentation

◆ _callDoAuthorize()

_callDoAuthorize (   $amount,
  $payment,
  $parentTransactionId 
)
protected

Call DoAuthorize

Parameters
int$amount
\Magento\Framework\DataObject$payment
string$parentTransactionId
Returns
\Magento\Paypal\Model\Api\AbstractApi

Definition at line 775 of file Express.php.

776  {
777  $apiData = $this->_pro->getApi()->getData();
778  foreach ($apiData as $k => $v) {
779  if (is_object($v)) {
780  unset($apiData[$k]);
781  }
782  }
783  $this->_checkoutSession->setPaypalTransactionData($apiData);
784  $this->_pro->resetApi();
785  $api = $this->_setApiProcessableErrors()
786  ->setAmount($amount)
787  ->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())
788  ->setTransactionId($parentTransactionId)
789  ->callDoAuthorization();
790 
791  $payment->setAdditionalInformation(
792  $this->_authorizationCountKey,
793  $payment->getAdditionalInformation($this->_authorizationCountKey) + 1
794  );
795 
796  return $api;
797  }
$amount
Definition: order.php:14
$payment
Definition: order.php:17

◆ _importToPayment()

_importToPayment (   $api,
  $payment 
)
protected

Import payment info to payment

Parameters
Nvp$api
Payment$payment
Returns
void

Definition at line 695 of file Express.php.

696  {
697  $payment->setTransactionId(
698  $api->getTransactionId()
699  )->setIsTransactionClosed(
700  0
701  )->setAdditionalInformation(
702  ExpressCheckout::PAYMENT_INFO_TRANSPORT_REDIRECT,
703  $api->getRedirectRequired()
704  );
705 
706  if ($api->getBillingAgreementId()) {
707  $payment->setBillingAgreementData(
708  [
709  'billing_agreement_id' => $api->getBillingAgreementId(),
711  ]
712  );
713  }
714 
715  $this->_pro->importPaymentInfo($api, $payment);
716  }
$payment
Definition: order.php:17

◆ _isTransactionExpired()

_isTransactionExpired ( Transaction  $transaction,
  $period 
)
protected

Check transaction for expiration in PST

Parameters
Transaction$transaction
int$period
Returns
bool

11:49:00 PayPal transactions closing time

Definition at line 806 of file Express.php.

807  {
808  $period = intval($period);
809  if (0 == $period) {
810  return true;
811  }
812 
813  $transactionClosingDate = new \DateTime($transaction->getCreatedAt(), new \DateTimeZone('GMT'));
814  $transactionClosingDate->setTimezone(new \DateTimeZone('US/Pacific'));
818  $transactionClosingDate->setTime(11, 49, 00);
819  $transactionClosingDate->modify('+' . $period . ' days');
820 
821  $currentTime = new \DateTime(null, new \DateTimeZone('US/Pacific'));
822 
823  if ($currentTime > $transactionClosingDate) {
824  return true;
825  }
826 
827  return false;
828  }
$transaction

◆ _placeOrder()

_placeOrder ( Payment  $payment,
  $amount 
)
protected

Place an order with authorization or capture action

Parameters
Payment$payment
float$amount
Returns
$this

Definition at line 646 of file Express.php.

647  {
648  $order = $payment->getOrder();
649 
650  // prepare api call
651  $token = $payment->getAdditionalInformation(ExpressCheckout::PAYMENT_INFO_TRANSPORT_TOKEN);
652 
653  $cart = $this->_cartFactory->create(['salesModel' => $order]);
654 
655  $api = $this->getApi()->setToken(
656  $token
657  )->setPayerId(
658  $payment->getAdditionalInformation(ExpressCheckout::PAYMENT_INFO_TRANSPORT_PAYER_ID)
659  )->setAmount(
660  $amount
661  )->setPaymentAction(
662  $this->_pro->getConfig()->getValue('paymentAction')
663  )->setNotifyUrl(
664  $this->_urlBuilder->getUrl('paypal/ipn/')
665  )->setInvNum(
666  $order->getIncrementId()
667  )->setCurrencyCode(
668  $order->getBaseCurrencyCode()
669  )->setPaypalCart(
670  $cart
671  )->setIsLineItemsEnabled(
672  $this->_pro->getConfig()->getValue('lineItemsEnabled')
673  );
674  if ($order->getIsVirtual()) {
675  $api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
676  } else {
677  $api->setAddress($order->getShippingAddress());
678  $api->setBillingAddress($order->getBillingAddress());
679  }
680 
681  // call api and get details from it
682  $api->callDoExpressCheckoutPayment();
683 
684  $this->_importToPayment($api, $payment);
685  return $this;
686  }
$order
Definition: order.php:55
$amount
Definition: order.php:14
$payment
Definition: order.php:17
_importToPayment($api, $payment)
Definition: Express.php:695

◆ _setApiProcessableErrors()

_setApiProcessableErrors ( )
protected

Set processable error codes to API model

Returns
\Magento\Paypal\Model\Api\Nvp

Definition at line 258 of file Express.php.

259  {
260  return $this->_pro->getApi()->setProcessableErrors(
261  [
262  ApiProcessableException::API_INTERNAL_ERROR,
263  ApiProcessableException::API_UNABLE_PROCESS_PAYMENT_ERROR_CODE,
264  ApiProcessableException::API_DO_EXPRESS_CHECKOUT_FAIL,
265  ApiProcessableException::API_UNABLE_TRANSACTION_COMPLETE,
266  ApiProcessableException::API_TRANSACTION_EXPIRED,
267  ApiProcessableException::API_MAX_PAYMENT_ATTEMPTS_EXCEEDED,
268  ApiProcessableException::API_COUNTRY_FILTER_DECLINE,
269  ApiProcessableException::API_MAXIMUM_AMOUNT_FILTER_DECLINE,
270  ApiProcessableException::API_OTHER_FILTER_DECLINE,
271  ApiProcessableException::API_ADDRESS_MATCH_FAIL,
272  ]
273  );
274  }

◆ acceptPayment()

acceptPayment ( \Magento\Payment\Model\InfoInterface  $payment)

Attempt to accept a pending payment

Parameters
\Magento\Payment\Model\Info | Payment$payment
Returns
bool

Definition at line 561 of file Express.php.

562  {
563  parent::acceptPayment($payment);
564  return $this->_pro->reviewPayment($payment, \Magento\Paypal\Model\Pro::PAYMENT_REVIEW_ACCEPT);
565  }
const PAYMENT_REVIEW_ACCEPT
Definition: Pro.php:22
$payment
Definition: order.php:17

◆ assignData()

assignData ( \Magento\Framework\DataObject  $data)

Assign data to info model instance

Parameters
array | \Magento\Framework\DataObject$data
Returns
\Magento\Payment\Model\Info
Exceptions

Definition at line 618 of file Express.php.

619  {
620  parent::assignData($data);
621 
622  $additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA);
623 
624  if (!is_array($additionalData)) {
625  return $this;
626  }
627 
628  foreach ($additionalData as $key => $value) {
629  // Skip extension attributes
630  if ($key === \Magento\Framework\Api\ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY) {
631  continue;
632  }
633 
634  $this->getInfoInstance()->setAdditionalInformation($key, $value);
635  }
636  return $this;
637  }
$value
Definition: gender.phtml:16

◆ authorize()

authorize ( \Magento\Payment\Model\InfoInterface  $payment,
  $amount 
)

Authorize payment

Parameters
\Magento\Framework\DataObject | \Magento\Payment\Model\InfoInterface | Payment$payment
float$amount
Returns
$this

Definition at line 394 of file Express.php.

395  {
396  return $this->_placeOrder($payment, $amount);
397  }
$amount
Definition: order.php:14
$payment
Definition: order.php:17
_placeOrder(Payment $payment, $amount)
Definition: Express.php:646

◆ canCapture()

canCapture ( )

Check capture availability

Returns
bool

Implements MethodInterface.

Definition at line 742 of file Express.php.

743  {
744  $payment = $this->getInfoInstance();
745  $this->_pro->getConfig()->setStoreId($payment->getOrder()->getStore()->getId());
746 
747  if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
748  $orderTransaction = $this->getOrderTransaction($payment);
749  if ($orderTransaction->getIsClosed()) {
750  return false;
751  }
752 
753  $orderValidPeriod = abs(intval($this->getConfigData('order_valid_period')));
754 
755  $dateCompass = new \DateTime($orderTransaction->getCreatedAt());
756  $dateCompass->modify('+' . $orderValidPeriod . ' days');
757  $currentDate = new \DateTime();
758 
759  if ($currentDate > $dateCompass || $orderValidPeriod == 0) {
760  return false;
761  }
762  }
763 
764  return $this->_canCapture;
765  }
$payment
Definition: order.php:17
getConfigData($field, $storeId=null)
Definition: Express.php:353

◆ cancel()

cancel ( \Magento\Payment\Model\InfoInterface  $payment)

Cancel payment

Parameters
\Magento\Framework\DataObject | \Magento\Payment\Model\InfoInterface | Payment$payment
Returns
$this

Definition at line 539 of file Express.php.

540  {
541  $this->void($payment);
542 
543  return $this;
544  }
$payment
Definition: order.php:17
void(\Magento\Payment\Model\InfoInterface $payment)
Definition: Express.php:406

◆ canReviewPayment()

canReviewPayment ( )

Whether payment can be reviewed

Returns
bool

Implements MethodInterface.

Definition at line 550 of file Express.php.

551  {
552  return parent::canReviewPayment() && $this->_pro->canReviewPayment($this->getInfoInstance());
553  }

◆ canUseCheckout()

canUseCheckout ( )

Can be used in regular checkout

Returns
bool

Implements MethodInterface.

Definition at line 298 of file Express.php.

299  {
300  if ($this->_scopeConfig->isSetFlag(
301  'payment/hosted_pro/active',
303  ) && !$this->_scopeConfig->isSetFlag(
304  'payment/hosted_pro/display_ec',
306  )
307  ) {
308  return false;
309  }
310  return parent::canUseCheckout();
311  }

◆ canUseForCurrency()

canUseForCurrency (   $currencyCode)

Whether method is available for specified currency

Parameters
string$currencyCode
Returns
bool

Implements MethodInterface.

Definition at line 319 of file Express.php.

320  {
321  return $this->_pro->getConfig()->isCurrencyCodeSupported($currencyCode);
322  }

◆ canVoid()

canVoid ( )

Check void availability

Returns
bool
Exceptions

Implements MethodInterface.

Definition at line 724 of file Express.php.

725  {
726  $info = $this->getInfoInstance();
727  if ($info->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
728  $orderTransaction = $this->getOrderTransaction($info);
729  if ($orderTransaction) {
730  $info->setParentTransactionId($orderTransaction->getTxnId());
731  }
732  }
733 
734  return $this->_canVoid;
735  }
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52

◆ capture()

capture ( \Magento\Payment\Model\InfoInterface  $payment,
  $amount 
)

Capture payment

Parameters
\Magento\Framework\DataObject | \Magento\Payment\Model\InfoInterface | Payment$payment
float$amount
Returns
$this @SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity)

Definition at line 432 of file Express.php.

433  {
434  $authorizationTransaction = $payment->getAuthorizationTransaction();
435  $authorizationPeriod = abs(intval($this->getConfigData('authorization_honor_period')));
436  $maxAuthorizationNumber = abs(intval($this->getConfigData('child_authorization_number')));
437  $order = $payment->getOrder();
438  $isAuthorizationCreated = false;
439 
440  if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
441  $voided = false;
442  if (!$authorizationTransaction->getIsClosed() && $this->_isTransactionExpired(
443  $authorizationTransaction,
444  $authorizationPeriod
445  )
446  ) {
447  //Save payment state and configure payment object for voiding
448  $isCaptureFinal = $payment->getShouldCloseParentTransaction();
449  $payment->setShouldCloseParentTransaction(false);
450  $payment->setParentTransactionId($authorizationTransaction->getTxnId());
451  $payment->unsTransactionId();
452  $payment->setVoidOnlyAuthorization(true);
453  $payment->void(new \Magento\Framework\DataObject());
454 
455  //Revert payment state after voiding
456  $payment->unsAuthorizationTransaction();
457  $payment->unsTransactionId();
458  $payment->setShouldCloseParentTransaction($isCaptureFinal);
459  $voided = true;
460  }
461 
462  if ($authorizationTransaction->getIsClosed() || $voided) {
463  if ($payment->getAdditionalInformation($this->_authorizationCountKey) > $maxAuthorizationNumber - 1) {
464  $this->_exception->create(
465  ['phrase' => __('The maximum number of child authorizations is reached.')]
466  );
467  }
468  $api = $this->_callDoAuthorize($amount, $payment, $authorizationTransaction->getParentTxnId());
469 
470  //Adding authorization transaction
471  $this->_pro->importPaymentInfo($api, $payment);
472  $payment->setTransactionId($api->getTransactionId());
473  $payment->setParentTransactionId($authorizationTransaction->getParentTxnId());
474  $payment->setIsTransactionClosed(false);
475 
476  $formatedPrice = $order->getBaseCurrency()->formatTxt($amount);
477 
478  if ($payment->getIsTransactionPending()) {
479  $message = __(
480  'We\'ll authorize the amount of %1 as soon as the payment gateway approves it.',
481  $formatedPrice
482  );
483  } else {
484  $message = __('The authorized amount is %1.', $formatedPrice);
485  }
486 
487  $transaction = $this->transactionBuilder->setPayment($payment)
488  ->setOrder($order)
489  ->setTransactionId($payment->getTransactionId())
490  ->setFailSafe(true)
491  ->build(Transaction::TYPE_AUTH);
492  $payment->addTransactionCommentsToOrder($transaction, $message);
493 
494  $payment->setParentTransactionId($api->getTransactionId());
495  $isAuthorizationCreated = true;
496  }
497  //close order transaction if needed
498  if ($payment->getShouldCloseParentTransaction()) {
499  $orderTransaction = $this->getOrderTransaction($payment);
500 
501  if ($orderTransaction) {
502  $orderTransaction->setIsClosed(true);
503  $order->addRelatedObject($orderTransaction);
504  }
505  }
506  }
507 
508  if (false === $this->_pro->capture($payment, $amount)) {
509  $this->_placeOrder($payment, $amount);
510  }
511 
512  if ($isAuthorizationCreated && isset($transaction)) {
513  $transaction->setIsClosed(true);
514  }
515 
516  return $this;
517  }
$transaction
$order
Definition: order.php:55
__()
Definition: __.php:13
$message
$amount
Definition: order.php:14
$payment
Definition: order.php:17
_callDoAuthorize($amount, $payment, $parentTransactionId)
Definition: Express.php:775
_placeOrder(Payment $payment, $amount)
Definition: Express.php:646
_isTransactionExpired(Transaction $transaction, $period)
Definition: Express.php:806
getConfigData($field, $storeId=null)
Definition: Express.php:353

◆ denyPayment()

denyPayment ( \Magento\Payment\Model\InfoInterface  $payment)

Attempt to deny a pending payment

Parameters
\Magento\Payment\Model\InfoInterface | Payment$payment
Returns
bool

Definition at line 573 of file Express.php.

574  {
575  parent::denyPayment($payment);
576  return $this->_pro->reviewPayment($payment, \Magento\Paypal\Model\Pro::PAYMENT_REVIEW_DENY);
577  }
const PAYMENT_REVIEW_DENY
Definition: Pro.php:24
$payment
Definition: order.php:17

◆ fetchTransactionInfo()

fetchTransactionInfo ( \Magento\Payment\Model\InfoInterface  $payment,
  $transactionId 
)

Fetch transaction details info

Parameters
\Magento\Payment\Model\InfoInterface$payment
string$transactionId
Returns
array

Definition at line 598 of file Express.php.

599  {
600  return $this->_pro->fetchTransactionInfo($payment, $transactionId);
601  }
$payment
Definition: order.php:17

◆ getApi()

getApi ( )
Returns
Api\Nvp

Definition at line 606 of file Express.php.

607  {
608  return $this->_pro->getApi();
609  }

◆ getCheckoutRedirectUrl()

getCheckoutRedirectUrl ( )

Checkout redirect URL getter for onepage checkout (hardcode)

See also
\Magento\Checkout\Controller\Onepage::savePaymentAction()
Quote\Payment::getCheckoutRedirectUrl()
Returns
string

Definition at line 586 of file Express.php.

587  {
588  return $this->_urlBuilder->getUrl('paypal/express/start');
589  }

◆ getConfigData()

getConfigData (   $field,
  $storeId = null 
)

Custom getter for payment configuration

Parameters
string$field
int | null$storeId
Returns
mixed @SuppressWarnings(PHPMD.UnusedFormalParameter)

Implements MethodInterface.

Definition at line 353 of file Express.php.

354  {
355  if ('order_place_redirect_url' === $field) {
356  return $this->getOrderPlaceRedirectUrl();
357  }
358  return $this->_pro->getConfig()->getValue($field);
359  }

◆ getConfigPaymentAction()

getConfigPaymentAction ( )

Payment action getter compatible with payment model

See also
\Magento\Sales\Model\Payment::place()
Returns
string

Implements MethodInterface.

Definition at line 330 of file Express.php.

331  {
332  return $this->_pro->getConfig()->getPaymentAction();
333  }

◆ getOrderTransaction()

getOrderTransaction (   $payment)
protected

Get transaction with type order

Parameters
OrderPaymentInterface$payment
Returns
false|\Magento\Sales\Api\Data\TransactionInterface

Definition at line 852 of file Express.php.

853  {
854  return $this->transactionRepository->getByTransactionType(
856  $payment->getId(),
857  $payment->getOrder()->getId()
858  );
859  }
$payment
Definition: order.php:17

◆ isActive()

isActive (   $storeId = null)

Is active

Parameters
int | null$storeId
Returns
bool

Implements MethodInterface.

Definition at line 836 of file Express.php.

837  {
838  $pathStandardExpress = 'payment/' . Config::METHOD_WPS_EXPRESS . '/active';
839  $pathPaypalExpress = 'payment/' . Config::METHOD_WPP_EXPRESS . '/active';
840 
841  return parent::isActive($storeId)
842  || (bool)(int)$this->_scopeConfig->getValue($pathStandardExpress, ScopeInterface::SCOPE_STORE, $storeId)
843  || (bool)(int)$this->_scopeConfig->getValue($pathPaypalExpress, ScopeInterface::SCOPE_STORE, $storeId);
844  }

◆ isAvailable()

isAvailable ( \Magento\Quote\Api\Data\CartInterface  $quote = null)

Check whether payment method can be used

Parameters
\Magento\Quote\Api\Data\CartInterface | Quote | null$quote
Returns
bool

Definition at line 340 of file Express.php.

341  {
342  return parent::isAvailable($quote) && $this->_pro->getConfig()->isMethodAvailable();
343  }
$quote

◆ order()

order ( \Magento\Payment\Model\InfoInterface  $payment,
  $amount 
)

Order payment

Parameters
\Magento\Framework\DataObject | \Magento\Payment\Model\InfoInterface | Payment$payment
float$amount
Returns
$this

Definition at line 368 of file Express.php.

369  {
370  $paypalTransactionData = $this->_checkoutSession->getPaypalTransactionData();
371  if (!is_array($paypalTransactionData)) {
372  $this->_placeOrder($payment, $amount);
373  } else {
374  $this->_importToPayment($this->_pro->getApi()->setData($paypalTransactionData), $payment);
375  }
376 
377  $payment->setAdditionalInformation($this->_isOrderPaymentActionKey, true);
378  if ($payment->getIsFraudDetected()) {
379  return $this;
380  }
381 
382  $payment->getOrder()->setActionFlag(Order::ACTION_FLAG_INVOICE, false);
383 
384  return $this;
385  }
$amount
Definition: order.php:14
$payment
Definition: order.php:17
_placeOrder(Payment $payment, $amount)
Definition: Express.php:646
_importToPayment($api, $payment)
Definition: Express.php:695

◆ refund()

refund ( \Magento\Payment\Model\InfoInterface  $payment,
  $amount 
)

Refund capture

Parameters
\Magento\Framework\DataObject | \Magento\Payment\Model\InfoInterface | Payment$payment
float$amount
Returns
$this
Exceptions

Definition at line 527 of file Express.php.

528  {
529  $this->_pro->refund($payment, $amount);
530  return $this;
531  }
$amount
Definition: order.php:14
$payment
Definition: order.php:17

◆ setStore()

setStore (   $store)

Store setter Also updates store ID in config object

Parameters
\Magento\Store\Model\Store | int$store
Returns
$this

Implements MethodInterface.

Definition at line 283 of file Express.php.

284  {
285  $this->setData('store', $store);
286  if (null === $store) {
287  $store = $this->_storeManager->getStore()->getId();
288  }
289  $this->_pro->getConfig()->setStoreId(is_object($store) ? $store->getId() : $store);
290  return $this;
291  }

◆ void()

Void payment

Parameters
\Magento\Framework\DataObject | \Magento\Payment\Model\InfoInterface | Payment$payment
Returns
$this
Exceptions

Definition at line 406 of file Express.php.

407  {
408  //Switching to order transaction if needed
409  if ($payment->getAdditionalInformation(
410  $this->_isOrderPaymentActionKey
411  ) && !$payment->getVoidOnlyAuthorization()
412  ) {
413  $orderTransaction = $this->getOrderTransaction($payment);
414  if ($orderTransaction) {
415  $payment->setParentTransactionId($orderTransaction->getTxnId());
416  $payment->setTransactionId($orderTransaction->getTxnId() . '-void');
417  }
418  }
419  $this->_pro->void($payment);
420  return $this;
421  }
$payment
Definition: order.php:17

Field Documentation

◆ $_authorizationCountKey

$_authorizationCountKey = 'authorization_count'
protected

Definition at line 145 of file Express.php.

◆ $_canAuthorize

$_canAuthorize = true
protected

Definition at line 61 of file Express.php.

◆ $_canCapture

$_canCapture = true
protected

Definition at line 68 of file Express.php.

◆ $_canCapturePartial

$_canCapturePartial = true
protected

Definition at line 75 of file Express.php.

◆ $_canFetchTransactionInfo

$_canFetchTransactionInfo = true
protected

Definition at line 117 of file Express.php.

◆ $_canOrder

$_canOrder = true
protected

Definition at line 54 of file Express.php.

◆ $_canRefund

$_canRefund = true
protected

Definition at line 82 of file Express.php.

◆ $_canRefundInvoicePartial

$_canRefundInvoicePartial = true
protected

Definition at line 89 of file Express.php.

◆ $_canReviewPayment

$_canReviewPayment = true
protected

Definition at line 124 of file Express.php.

◆ $_canUseCheckout

$_canUseCheckout = true
protected

Definition at line 110 of file Express.php.

◆ $_canUseInternal

$_canUseInternal = false
protected

Definition at line 103 of file Express.php.

◆ $_canVoid

$_canVoid = true
protected

Definition at line 96 of file Express.php.

◆ $_cartFactory

$_cartFactory
protected

Definition at line 160 of file Express.php.

◆ $_checkoutSession

$_checkoutSession
protected

Definition at line 165 of file Express.php.

◆ $_code

Definition at line 30 of file Express.php.

◆ $_exception

$_exception
protected

Definition at line 170 of file Express.php.

◆ $_formBlockType

$_formBlockType = \Magento\Paypal\Block\Express\Form::class
protected

Definition at line 35 of file Express.php.

◆ $_infoBlockType

$_infoBlockType = \Magento\Paypal\Block\Payment\Info::class
protected

Definition at line 40 of file Express.php.

◆ $_isGateway

$_isGateway = false
protected

Definition at line 47 of file Express.php.

◆ $_isOrderPaymentActionKey

$_isOrderPaymentActionKey = 'is_order_action'
protected

Definition at line 138 of file Express.php.

◆ $_pro

$_pro
protected

Definition at line 131 of file Express.php.

◆ $_storeManager

$_storeManager
protected

Definition at line 150 of file Express.php.

◆ $_urlBuilder

$_urlBuilder
protected

Definition at line 155 of file Express.php.

◆ $transactionBuilder

$transactionBuilder
protected

Definition at line 180 of file Express.php.

◆ $transactionRepository

$transactionRepository
protected

Definition at line 175 of file Express.php.


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