Example #1
0
 /**
  * @param bool $pendingReason
  * @param bool $isReviewRequired
  * @param bool $expected
  * @dataProvider canReviewPaymentDataProvider
  */
 public function testCanReviewPayment($pendingReason, $isReviewRequired, $expected)
 {
     $this->_pro->expects($this->any())->method('_isPaymentReviewRequired')->will($this->returnValue($isReviewRequired));
     $payment = $this->getMockBuilder('Magento\\Payment\\Model\\Info')->disableOriginalConstructor()->setMethods(['getAdditionalInformation', '__wakeup'])->getMock();
     $payment->expects($this->once())->method('getAdditionalInformation')->with($this->equalTo(\Magento\Paypal\Model\Info::PENDING_REASON_GLOBAL))->will($this->returnValue($pendingReason));
     $this->assertEquals($expected, $this->_pro->canReviewPayment($payment));
 }
Example #2
0
 /**
  * @covers \Magento\Paypal\Model\Pro::capture
  */
 public function testCapture()
 {
     $paymentMock = $this->getPaymentMock();
     $orderMock = $this->getOrderMock();
     $this->apiMock->expects(static::any())->method('setAuthorizationId')->willReturnSelf();
     $this->apiMock->expects(static::any())->method('setIsCaptureComplete')->willReturnSelf();
     $this->apiMock->expects(static::any())->method('setAmount')->willReturnSelf();
     $paymentMock->expects(static::once())->method('getOrder')->willReturn($orderMock);
     $this->apiMock->expects(static::once())->method('getTransactionId')->willReturn(45);
     $this->apiMock->expects(static::any())->method('getDataUsingMethod')->willReturn(false);
     $amount = 43.03;
     $this->pro->capture($paymentMock, $amount);
 }
Example #3
0
 /**
  * Refund a capture transaction
  *
  * @param \Magento\Framework\Object $payment
  * @param float $amount
  * @return void
  */
 public function refund(\Magento\Framework\Object $payment, $amount)
 {
     $captureTxnId = $this->_getParentTransactionId($payment);
     if ($captureTxnId) {
         $api = $this->getApi();
         $api->setAuthorizationId($captureTxnId);
     }
     parent::refund($payment, $amount);
 }
Example #4
0
 /**
  * Payment action getter compatible with payment model
  *
  * @see \Magento\Sales\Model\Payment::place()
  * @return string
  */
 public function getConfigPaymentAction()
 {
     return $this->_pro->getConfig()->getPaymentAction();
 }
Example #5
0
 /**
  * Import direct payment results to payment
  *
  * @param \Magento\Paypal\Model\Api\Nvp $api
  * @param Payment $payment
  * @return void
  */
 protected function _importResultToPayment($api, $payment)
 {
     $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0);
     $this->_pro->importPaymentInfo($api, $payment);
 }
Example #6
0
 /**
  * Call DoAuthorize
  *
  * @param int $amount
  * @param \Magento\Framework\DataObject $payment
  * @param string $parentTransactionId
  * @return \Magento\Paypal\Model\Api\AbstractApi
  */
 protected function _callDoAuthorize($amount, $payment, $parentTransactionId)
 {
     $apiData = $this->_pro->getApi()->getData();
     foreach ($apiData as $k => $v) {
         if (is_object($v)) {
             unset($apiData[$k]);
         }
     }
     $this->_checkoutSession->setPaypalTransactionData($apiData);
     $this->_pro->resetApi();
     $api = $this->_setApiProcessableErrors()->setAmount($amount)->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())->setTransactionId($parentTransactionId)->callDoAuthorization();
     $payment->setAdditionalInformation($this->_authorizationCountKey, $payment->getAdditionalInformation($this->_authorizationCountKey) + 1);
     return $api;
 }