/** * EC PE won't be available if the EC is available * * @param \Magento\Sales\Model\Quote|null $quote * @return bool */ public function isAvailable($quote = null) { if (!parent::isAvailable($quote)) { return false; } if (!$this->_ecInstance) { $this->_ecInstance = $this->_paymentData->getMethodInstance(Config::METHOD_WPP_EXPRESS); } if ($quote && $this->_ecInstance) { $this->_ecInstance->setStore($quote->getStoreId()); } return $this->_ecInstance ? !$this->_ecInstance->isAvailable() : false; }
public function testOrder() { $this->_nvp->expects($this->any())->method('setProcessableErrors')->will($this->returnSelf()); $this->_nvp->expects($this->any())->method('setAmount')->will($this->returnSelf()); $this->_nvp->expects($this->any())->method('setCurrencyCode')->will($this->returnSelf()); $this->_nvp->expects($this->any())->method('setTransactionId')->will($this->returnSelf()); $this->_nvp->expects($this->any())->method('callDoAuthorization')->will($this->returnSelf()); $this->_pro->expects($this->any())->method('getApi')->will($this->returnValue($this->_nvp)); $this->_checkoutSession->expects($this->once())->method('getPaypalTransactionData')->will($this->returnValue([])); $this->_checkoutSession->expects($this->once())->method('setPaypalTransactionData')->with([]); $currency = $this->getMock('Magento\\Directory\\Model\\Currency', ['__wakeup', 'formatTxt'], [], '', false); $paymentModel = $this->getMock('Magento\\Sales\\Model\\Order\\Payment', ['__wakeup', 'getBaseCurrency', 'getOrder', 'getIsTransactionPending', 'addStatusHistoryComment'], [], '', false); $paymentModel->expects($this->any())->method('getOrder')->will($this->returnSelf()); $paymentModel->expects($this->any())->method('getBaseCurrency')->will($this->returnValue($currency)); $paymentModel->expects($this->any())->method('getIsTransactionPending')->will($this->returnSelf()); $this->_model = $this->_helper->getObject('Magento\\Paypal\\Model\\Express', ['proFactory' => $this->_pro, 'checkoutSession' => $this->_checkoutSession]); $this->_model->order($paymentModel, 12.3); $this->assertEquals('payment_review', $paymentModel->getState()); }
public function testAssignData() { $transportValue = 'something'; $data = new DataObject([PaymentInterface::KEY_ADDITIONAL_DATA => [Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => $transportValue]]); $this->_model = $this->_helper->getObject('Magento\\Paypal\\Model\\Express', ['data' => [$this->_pro], 'checkoutSession' => $this->_checkoutSession, 'transactionBuilder' => $this->transactionBuilder, 'eventDispatcher' => $this->eventManagerMock]); $paymentInfo = $this->getMock(InfoInterface::class); $this->_model->setInfoInstance($paymentInfo); $paymentInfo->expects(static::once())->method('setAdditionalInformation')->with(Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT, $transportValue); $this->_model->assignData($data); }
/** * EC PE won't be available if the EC is available * * @param \Magento\Quote\Api\Data\CartInterface|\Magento\Quote\Model\Quote|null $quote * @return bool */ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { if (!parent::isAvailable($quote)) { return false; } if (!$this->_ecInstance) { $this->_ecInstance = $this->_paymentData->getMethodInstance(Config::METHOD_WPP_EXPRESS); } if ($quote) { $this->_ecInstance->setStore($quote->getStoreId()); } return !$this->_ecInstance->isAvailable(); }
/** * Manage status * * @param RecurringPayment $payment * @return void */ public function updateStatus(RecurringPayment $payment) { $api = $this->_paymentMethod->getApi(); $action = null; switch ($payment->getNewState()) { case States::CANCELED: $action = 'cancel'; break; case States::SUSPENDED: $action = 'suspend'; break; case States::ACTIVE: $action = 'activate'; break; } $state = $payment->getState(); $api->setRecurringPaymentId($payment->getReferenceId())->setIsAlreadyCanceled($state == States::CANCELED)->setIsAlreadySuspended($state == States::SUSPENDED)->setIsAlreadyActive($state == States::ACTIVE)->setAction($action)->callManageRecurringPaymentStatus(); }
/** * @param DataObject $data */ private function parentAssignDataExpectation(DataObject $data) { $eventData = [AbstractDataAssignObserver::METHOD_CODE => $this, AbstractDataAssignObserver::MODEL_CODE => $this->_model->getInfoInstance(), AbstractDataAssignObserver::DATA_CODE => $data]; $this->eventManagerMock->expects(static::exactly(2))->method('dispatch')->willReturnMap([['payment_method_assign_data_' . $this->_model->getCode(), $eventData], ['payment_method_assign_data', $eventData]]); }