52 protected $_apiType = \Magento\Paypal\Model\Api\Nvp::class;
90 \
Magento\Paypal\Model\InfoFactory $infoFactory,
94 $this->_apiFactory = $apiFactory;
95 $this->_infoFactory = $infoFactory;
108 if (
null === $this->_config) {
113 $this->_config = $this->_configFactory->create($this->_configType, [
'params' =>
$params]);
115 $this->_config->setMethod(
$code);
117 $this->_config->setStoreId(
$storeId);
132 $this->_config = $instance;
134 $this->_config->setStoreId(
$storeId);
157 if (
null === $this->_api) {
158 $this->_api = $this->_apiFactory->create($this->_apiType);
160 $this->_api->setConfigObject($this->_config);
183 if (
null === $this->_infoInstance) {
184 $this->_infoInstance = $this->_infoFactory->create();
199 $this->
getInfo()->importToPayment($from, $to);
206 $to->setIsTransactionPending(
true);
207 $to->setIsFraudDetected(
true);
209 $to->setIsTransactionPending(
true);
214 $to->setIsTransactionApproved(
true);
216 $to->setIsTransactionDenied(
true);
232 if ($authTransactionId) {
234 $api->setPayment(
$payment)->setAuthorizationId($authTransactionId)->callDoVoid();
237 throw new \Magento\Framework\Exception\LocalizedException(
238 __(
'You need an authorization transaction to void.')
254 if (!$authTransactionId) {
258 ->setAuthorizationId($authTransactionId)
263 $orderIncrementId =
$order->getIncrementId();
264 $api->setCurrencyCode(
$order->getBaseCurrencyCode())
265 ->setInvNum($orderIncrementId)
266 ->setCustref($orderIncrementId)
267 ->setPonum(
$order->getId());
270 $api->callDoCapture();
287 $order = $payment->getOrder();
295 $order->getBaseCurrencyCode()
297 $canRefundMore =
$payment->getCreditmemo()->getInvoice()->canRefund();
298 $isFullRefund = !$canRefundMore &&
299 0 == (double)
$order->getBaseTotalOnlineRefunded() + (double)
$order->getBaseTotalOfflineRefunded();
305 $api->callRefundTransaction();
308 throw new \Magento\Framework\Exception\LocalizedException(
309 __(
'We can\'t issue a refund transaction because there is no capture transaction.')
322 if (!
$payment->getOrder()->getInvoiceCollection()->count()) {
323 $this->
void($payment);
361 $api = $this->
getApi()->setTransactionId($payment->getLastTransId());
364 $api->callGetTransactionDetails();
371 $api->setAction($action)->callManagePendingTransactionStatus();
372 $api->callGetTransactionDetails();
386 $api = $this->
getApi()->setTransactionId($transactionId)->setRawResponseNeeded(
true);
387 $api->callGetTransactionDetails();
389 $data = $api->getRawSuccessResponseData();
402 $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(
false);
417 $api->getRefundTransactionId()
418 )->setIsTransactionClosed(
420 )->setShouldCloseParentTransaction(
434 return $payment->getParentTransactionId();
static isPaymentReviewRequired(\Magento\Payment\Model\InfoInterface $payment)
cancel(\Magento\Framework\DataObject $payment)
void(\Magento\Framework\DataObject $payment)
elseif(isset( $params[ 'redirect_parent']))
const PAYMENT_REVIEW_DENY
reviewPayment(\Magento\Payment\Model\InfoInterface $payment, $action)
__construct(\Magento\Paypal\Model\Config\Factory $configFactory, \Magento\Paypal\Model\Api\Type\Factory $apiFactory, \Magento\Paypal\Model\InfoFactory $infoFactory, TransactionRepositoryInterface $transactionRepository)
const PAYMENTSTATUS_REVIEW
capture(\Magento\Framework\DataObject $payment, $amount)
static isPaymentFailed(\Magento\Payment\Model\InfoInterface $payment)
const PAYMENT_REVIEW_ACCEPT
canReviewPayment(\Magento\Payment\Model\InfoInterface $payment)
static isPaymentSuccessful(\Magento\Payment\Model\InfoInterface $payment)
_importRefundResultToPayment($api, $payment, $canRefundMore)
_getParentTransactionId(\Magento\Framework\DataObject $payment)
setConfig(\Magento\Paypal\Model\Config $instance, $storeId=null)
refund(\Magento\Framework\DataObject $payment, $amount)
setMethod($code, $storeId=null)
const PENDING_REASON_GLOBAL
_isPaymentReviewRequired(\Magento\Payment\Model\InfoInterface $payment)
const REFUND_TYPE_PARTIAL
_importCaptureResultToPayment($api, $payment)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
importPaymentInfo(\Magento\Framework\DataObject $from, \Magento\Payment\Model\InfoInterface $to)
fetchTransactionInfo(\Magento\Payment\Model\InfoInterface $payment, $transactionId)