示例#1
0
 /**
  * @dataProvider canVoidDataProvider
  * @param bool $canVoid
  */
 public function testCanVoid($canVoid)
 {
     $this->_orderMock->expects($this->once())->method('getPayment')->will($this->returnValue($this->_paymentMock));
     $this->_paymentMock->expects($this->once())->method('canVoid', '__wakeup')->with($this->equalTo($this->_model))->will($this->returnValue($canVoid));
     $this->_model->setState(\Magento\Sales\Model\Order\Invoice::STATE_PAID);
     $this->assertEquals($canVoid, $this->_model->canVoid());
 }
示例#2
0
 /**
  * @expectedException \Magento\Framework\Model\Exception
  */
 public function testInitialize()
 {
     $order = $this->getMock('Magento\\Sales\\Model\\Order', [], [], '', false);
     $this->infoInstance->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $this->paypalConfig->expects($this->once())->method('getBuildNotationCode')->will($this->returnValue('build notation code'));
     $this->payflowRequest->expects($this->once())->method('setData')->with('BNCODE', 'build notation code')->will($this->returnSelf());
     $this->model->initialize(\Magento\Paypal\Model\Config::PAYMENT_ACTION_AUTH, new \Magento\Framework\Object());
 }
示例#3
0
 /**
  * @dataProvider canVoidDataProvider
  * @param bool $canVoid
  */
 public function testCanVoid($canVoid)
 {
     $entityName = 'invoice';
     $this->orderMock->expects($this->once())->method('getPayment')->will($this->returnValue($this->_paymentMock));
     $this->orderMock->expects($this->once())->method('setHistoryEntityName')->with($entityName)->will($this->returnSelf());
     $this->_paymentMock->expects($this->once())->method('canVoid', '__wakeup')->will($this->returnValue($canVoid));
     $this->model->setState(\Magento\Sales\Model\Order\Invoice::STATE_PAID);
     $this->assertEquals($canVoid, $this->model->canVoid());
 }
 /**
  * @covers \Magento\BraintreeTwo\Gateway\Response\CaptureDetailsHandler::handle
  */
 public function testHandle()
 {
     $paymentData = $this->getPaymentDataObjectMock();
     $subject['payment'] = $paymentData;
     $this->payment->expects(static::once())->method('setIsTransactionClosed')->with(false);
     $response = ['object' => ['success' => true]];
     $this->subjectReader->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->captureHandler->handle($subject, $response);
 }
 protected function setUp()
 {
     $this->payment = $this->getMockBuilder(Payment::class)->disableOriginalConstructor()->setMethods(['setCcTransId', 'setLastTransId', 'setAdditionalInformation'])->getMock();
     $this->subjectReader = $this->getMockBuilder(SubjectReader::class)->disableOriginalConstructor()->getMock();
     $this->payment->expects(static::once())->method('setCcTransId');
     $this->payment->expects(static::once())->method('setLastTransId');
     $this->payment->expects(static::any())->method('setAdditionalInformation');
     $this->paymentHandler = new PaymentDetailsHandler($this->subjectReader);
 }
 public function testBuild()
 {
     $additionalData = [DataAssignObserver::DEVICE_DATA => self::DEVICE_DATA];
     $expectedResult = [KountPaymentDataBuilder::DEVICE_DATA => self::DEVICE_DATA];
     $buildSubject = ['payment' => $this->paymentDO];
     $this->paymentMock->expects(static::exactly(count($additionalData)))->method('getAdditionalInformation')->willReturn($additionalData);
     $this->configMock->expects(static::once())->method('hasFraudProtection')->willReturn(true);
     $this->paymentDO->expects(static::once())->method('getPayment')->willReturn($this->paymentMock);
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($buildSubject)->willReturn($this->paymentDO);
     static::assertEquals($expectedResult, $this->builder->build($buildSubject));
 }
 /**
  * @covers \Magento\BraintreeTwo\Gateway\Response\CloneDetailsHandler::handle
  */
 public function testHandle()
 {
     $paymentData = $this->getPaymentDataObjectMock();
     $transaction = $this->getBraintreeTransaction();
     $subject['payment'] = $paymentData;
     $this->payment->expects(static::once())->method('setTransactionId')->with(self::TRANSACTION_ID);
     $response = ['object' => $transaction];
     $this->subjectReader->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->subjectReader->expects(self::once())->method('readTransaction')->with($response)->willReturn($transaction);
     $this->cloneHandler->handle($subject, $response);
 }
 public function testBuild()
 {
     $additionalData = [[DataAssignObserver::PAYMENT_METHOD_NONCE, self::PAYMENT_METHOD_NONCE]];
     $expectedResult = [PaymentDataBuilder::AMOUNT => 10.0, PaymentDataBuilder::PAYMENT_METHOD_NONCE => self::PAYMENT_METHOD_NONCE, PaymentDataBuilder::MERCHANT_ACCOUNT_ID => self::MERCHANT_ACCOUNT_ID];
     $buildSubject = ['payment' => $this->paymentDO, 'amount' => 10.0];
     $this->paymentMock->expects(static::exactly(count($additionalData)))->method('getAdditionalInformation')->willReturnMap($additionalData);
     $this->configMock->expects(static::once())->method('getValue')->with(Config::KEY_MERCHANT_ACCOUNT_ID)->willReturn(self::MERCHANT_ACCOUNT_ID);
     $this->paymentDO->expects(static::once())->method('getPayment')->willReturn($this->paymentMock);
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($buildSubject)->willReturn($this->paymentDO);
     $this->subjectReaderMock->expects(self::once())->method('readAmount')->with($buildSubject)->willReturn(10.0);
     static::assertEquals($expectedResult, $this->builder->build($buildSubject));
 }
 /**
  * @covers \Magento\BraintreeTwo\Gateway\Response\ThreeDSecureDetailsHandler::handle
  */
 public function testHandle()
 {
     $paymentData = $this->getPaymentDataObjectMock();
     $transaction = $this->getBraintreeTransaction();
     $subject = ['payment' => $paymentData];
     $response = ['object' => $transaction];
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->subjectReaderMock->expects(self::once())->method('readTransaction')->with($response)->willReturn($transaction);
     $this->payment->expects(static::at(1))->method('setAdditionalInformation')->with('liabilityShifted', 'Yes');
     $this->payment->expects(static::at(2))->method('setAdditionalInformation')->with('liabilityShiftPossible', 'Yes');
     $this->handler->handle($subject, $response);
 }
 /**
  * @covers \Magento\BraintreeTwo\Gateway\Response\PayPalDetailsHandler::handle
  */
 public function testHandle()
 {
     $paymentData = $this->getPaymentDataObjectMock();
     $transaction = $this->getBraintreeTransaction();
     $subject = ['payment' => $paymentData];
     $response = ['object' => $transaction];
     $this->subjectReader->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->subjectReader->expects(self::once())->method('readTransaction')->with($response)->willReturn($transaction);
     $this->subjectReader->expects(static::once())->method('readPayPal')->with($transaction)->willReturn($transaction->paypal);
     $this->payment->expects(static::exactly(2))->method('setAdditionalInformation');
     $this->payPalHandler->handle($subject, $response);
 }
 public function testInitialize()
 {
     $order = $this->getMock('Magento\\Sales\\Model\\Order', [], [], '', false);
     $this->infoInstance->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $this->infoInstance->expects($this->any())->method('setAdditionalInformation')->will($this->returnSelf());
     $this->paypalConfig->expects($this->once())->method('getBuildNotationCode')->will($this->returnValue('build notation code'));
     $response = new \Magento\Framework\DataObject(['result' => '0', 'pnref' => 'V19A3D27B61E', 'respmsg' => 'Approved', 'authcode' => '510PNI', 'hostcode' => 'A', 'request_id' => 'f930d3dc6824c1f7230c5529dc37ae5e', 'result_code' => '0']);
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($response);
     $this->payflowRequest->expects($this->exactly(3))->method('setData')->willReturnMap([['user' => null, 'vendor' => null, 'partner' => null, 'pwd' => null, 'verbosity' => null, 'BNCODE' => 'build notation code', 'tender' => 'C'], $this->returnSelf()], ['USER1', 1, $this->returnSelf()], ['USER2', 'a20d3dc6824c1f7780c5529dc37ae5e', $this->returnSelf()]);
     $stateObject = new \Magento\Framework\DataObject();
     $this->model->initialize(\Magento\Paypal\Model\Config::PAYMENT_ACTION_AUTH, $stateObject);
 }
 /**
  * @covers \Magento\Braintree\Gateway\Request\CaptureDataBuilder::build
  */
 public function testBuild()
 {
     $transactionId = 'b3b99d';
     $amount = 10.0;
     $expected = ['transaction_id' => $transactionId, 'amount' => $amount];
     $buildSubject = ['payment' => $this->paymentDO, 'amount' => $amount];
     $this->payment->expects(static::once())->method('getCcTransId')->willReturn($transactionId);
     $this->paymentDO->expects(static::once())->method('getPayment')->willReturn($this->payment);
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($buildSubject)->willReturn($this->paymentDO);
     $this->subjectReaderMock->expects(self::once())->method('readAmount')->with($buildSubject)->willReturn($amount);
     static::assertEquals($expected, $this->builder->build($buildSubject));
 }
 public function aroundIsCaptureFinal(\Magento\Sales\Model\Order\Payment $subject, \Closure $proceed, $amountToCapture)
 {
     $result = $proceed($amountToCapture);
     if (!$result) {
         $order = $subject->getOrder();
         $invoices = $order->getInvoiceCollection();
         $invoice = $invoices->getFirstItem();
         $grandTotalBase = $invoice->getBaseGrandTotal();
         /* validate with partial amount if exists */
         $result = $grandTotalBase == $amountToCapture;
     }
     return $result;
 }
 /**
  * \Magento\BraintreeTwo\Gateway\Request\VaultCaptureDataBuilder::build
  */
 public function testBuild()
 {
     $amount = 30.0;
     $token = '5tfm4c';
     $buildSubject = ['payment' => $this->paymentDO, 'amount' => $amount];
     $expected = ['amount' => $amount, 'paymentMethodToken' => $token];
     $this->subjectReader->expects(self::once())->method('readPayment')->with($buildSubject)->willReturn($this->paymentDO);
     $this->subjectReader->expects(self::once())->method('readAmount')->with($buildSubject)->willReturn($amount);
     $paymentExtension = $this->getMockBuilder(OrderPaymentExtension::class)->setMethods(['getVaultPaymentToken'])->disableOriginalConstructor()->getMock();
     $paymentToken = $this->getMockBuilder(PaymentToken::class)->disableOriginalConstructor()->getMock();
     $paymentExtension->expects(static::once())->method('getVaultPaymentToken')->willReturn($paymentToken);
     $this->payment->expects(static::once())->method('getExtensionAttributes')->willReturn($paymentExtension);
     $paymentToken->expects(static::once())->method('getGatewayToken')->willReturn($token);
     $result = $this->builder->build($buildSubject);
     static::assertEquals($expected, $result);
 }
示例#15
0
 /**
  * @param $context
  */
 protected function initPayment($context)
 {
     $this->payment = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\Sales\\Model\\Order\\Payment', ['context' => $context, 'serviceOrderFactory' => $this->serviceOrderFactory, 'paymentData' => $this->helperMock, 'priceCurrency' => $this->priceCurrencyMock, 'transactionFactory' => $this->transactionFactory, 'transactionCollectionFactory' => $this->transactionCollectionFactory]);
     $this->payment->setMethod('any');
     $this->payment->setOrder($this->orderMock);
     $this->transactionId = 100;
 }
示例#16
0
 /**
  * @covers \Magento\Sales\Model\Order\Payment::getShouldCloseParentTransaction()
  * @return void
  */
 public function testGetShouldCloseParentTransaction()
 {
     $this->payment->setShouldCloseParentTransaction(1);
     static::assertTrue($this->payment->getShouldCloseParentTransaction());
     $this->payment->setShouldCloseParentTransaction(0);
     static::assertFalse($this->payment->getShouldCloseParentTransaction());
 }
示例#17
0
 /**
  * Magento will consider a transaction for voiding only if it is an authorization
  * Braintree allows voiding captures too
  *
  * Lookup an authorization transaction using parent transaction id, if set
  *
  * @param Payment $subject
  * @param callable $proceed
  *
  * @return \Magento\Sales\Model\Order\Payment\Transaction|false
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function aroundGetAuthorizationTransaction(Payment $subject, \Closure $proceed)
 {
     if ($subject->getMethodInstance()->getCode() != PaymentMethod::METHOD_CODE) {
         return $proceed();
     }
     $invoice = $this->registry->registry('current_invoice');
     if ($invoice && $invoice->getId()) {
         $transactionId = $this->paymentHelper->clearTransactionId($invoice->getTransactionId());
         $collection = $this->salesTransactionCollectionFactory->create()->addFieldToFilter('txn_id', ['eq' => $transactionId]);
         if ($collection->getSize() < 1) {
             return $proceed();
         } else {
             return $collection->getFirstItem();
         }
     }
     return $proceed();
 }
 public function testExecuteUpdateAction()
 {
     $orderId = 30;
     $action = 'update';
     $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->willReturn($orderId);
     $this->requestMock->expects($this->at(1))->method('getParam')->with('action')->willReturn($action);
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRedirectMock);
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Sales\\Model\\Order')->willReturn($this->orderMock);
     $this->orderMock->expects($this->once())->method('load')->with($orderId)->willReturn($this->orderMock);
     $this->orderMock->expects($this->any())->method('getId')->willReturn($orderId);
     $this->orderMock->expects($this->once())->method('getPayment')->willReturn($this->paymentMock);
     $this->orderMock->expects($this->once())->method('save')->willReturnSelf();
     $this->messageManagerMock->expects($this->once())->method('addSuccess')->with('The payment update has been made.');
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/*/')->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('update');
     $result = $this->reviewPayment->execute();
     $this->assertEquals($this->resultRedirectMock, $result);
 }
示例#19
0
 /**
  * {@inheritdoc}
  */
 public function getAuthorizationTransaction()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getAuthorizationTransaction');
     if (!$pluginInfo) {
         return parent::getAuthorizationTransaction();
     } else {
         return $this->___callPlugins('getAuthorizationTransaction', func_get_args(), $pluginInfo);
     }
 }
 public function testExecuteUpdateAction()
 {
     $orderId = 30;
     $action = 'update';
     $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->willReturn($orderId);
     $this->requestMock->expects($this->at(1))->method('getParam')->with('action')->willReturn($action);
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRedirectMock);
     $this->orderRepositoryMock->expects($this->once())->method('get')->with($orderId)->willReturn($this->orderMock);
     $this->orderMock->expects($this->any())->method('getEntityId')->willReturn($orderId);
     $this->orderMock->expects($this->any())->method('getPayment')->willReturn($this->paymentMock);
     $this->orderRepositoryMock->expects($this->once())->method('save')->with($this->orderMock)->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('update');
     $this->paymentMock->expects($this->any())->method('getIsTransactionApproved')->willReturn(true);
     $this->messageManagerMock->expects($this->once())->method('addSuccess');
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/order/view')->willReturnSelf();
     $result = $this->reviewPayment->execute();
     $this->assertEquals($this->resultRedirectMock, $result);
 }
示例#21
0
 public function mockPay($hasForcedState, $forcedState)
 {
     $this->orderMock->expects($this->any())->method('getPayment')->willReturn($this->paymentMock);
     $this->paymentMock->expects($this->once())->method('hasForcedState')->willReturn($hasForcedState);
     if ($hasForcedState) {
         $this->paymentMock->expects($this->once())->method('getForcedState')->willReturn($forcedState);
     } else {
         $this->paymentMock->expects($this->never())->method('getForcedState');
     }
     $this->paymentMock->expects($this->once())->method('pay')->with($this->model)->willReturnSelf();
     $this->eventManagerMock->expects($this->once())->method('dispatch')->with('sales_order_invoice_pay');
 }
 /**
  * @covers \Magento\Braintree\Gateway\Command\CaptureStrategyCommand::execute
  */
 public function testVaultCaptureExecute()
 {
     $paymentData = $this->getPaymentDataObjectMock();
     $subject['payment'] = $paymentData;
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->payment->expects(static::once())->method('getAuthorizationTransaction')->willReturn(true);
     $this->payment->expects(static::once())->method('getId')->willReturn(1);
     $this->buildSearchCriteria();
     $this->transactionRepository->expects(static::once())->method('getTotalCount')->willReturn(1);
     $this->commandPool->expects(static::once())->method('get')->with(CaptureStrategyCommand::VAULT_CAPTURE)->willReturn($this->command);
     $this->strategyCommand->execute($subject);
 }
示例#23
0
 public function testCheckAdvancedAcceptingByPaymentMethod()
 {
     $this->initLayoutMock();
     $this->initOrderMock(self::LAST_REAL_ORDER_ID, Order::STATE_NEW);
     $this->initCheckoutSessionMock(self::LAST_REAL_ORDER_ID, true);
     $this->requestMock->expects($this->once())->method('getParam')->with('RESPMSG')->will($this->returnValue('message'));
     $this->blockMock->expects($this->at(0))->method('setData')->with('goto_section', 'paymentMethod')->will($this->returnSelf());
     $this->blockMock->expects($this->at(1))->method('setData')->with('error_msg', __('Your payment has been declined. Please try again.'))->will($this->returnSelf());
     $this->paymentMock->expects($this->once())->method('getMethod')->will($this->returnValue(Config::METHOD_PAYFLOWADVANCED));
     $payflowadvancedReturnUrl = new PayflowadvancedReturnUrl($this->contextMock, $this->checkoutSessionMock, $this->orderFactoryMock, $this->payflowlinkFactoryMock, $this->helperCheckoutMock, $this->loggerMock);
     $payflowadvancedReturnUrl->execute();
 }
示例#24
0
 public function testProcessRelation()
 {
     $this->addressHandlerMock->expects($this->once())->method('removeEmptyAddresses')->with($this->orderMock)->willReturnSelf();
     $this->addressHandlerMock->expects($this->once())->method('process')->with($this->orderMock)->willReturnSelf();
     $this->orderMock->expects($this->exactly(2))->method('getItems')->willReturn([$this->orderItemMock]);
     $this->orderMock->expects($this->exactly(3))->method('getId')->willReturn('order-id-value');
     $this->orderItemMock->expects($this->once())->method('setOrderId')->with('order-id-value')->willReturnSelf();
     $this->orderItemMock->expects($this->once())->method('setOrder')->with($this->orderMock)->willReturnSelf();
     $this->orderItemRepositoryMock->expects($this->once())->method('save')->with($this->orderItemMock)->willReturnSelf();
     $this->orderMock->expects($this->exactly(2))->method('getPayment')->willReturn($this->orderPaymentMock);
     $this->orderPaymentMock->expects($this->once())->method('setParentId')->with('order-id-value')->willReturnSelf();
     $this->orderPaymentMock->expects($this->once())->method('setOrder')->with($this->orderMock)->willReturnSelf();
     $this->orderPaymentResourceMock->expects($this->once())->method('save')->with($this->orderPaymentMock)->willReturnSelf();
     $this->orderMock->expects($this->exactly(2))->method('getStatusHistories')->willReturn([$this->orderStatusHistoryMock]);
     $this->orderStatusHistoryMock->expects($this->once())->method('setParentId')->with('order-id-value')->willReturnSelf();
     $this->orderStatusHistoryMock->expects($this->once())->method('setOrder')->with($this->orderMock)->willReturnSelf();
     $this->statusHistoryResource->expects($this->once())->method('save')->with($this->orderStatusHistoryMock)->willReturnSelf();
     $this->orderMock->expects($this->exactly(2))->method('getRelatedObjects')->willReturn([$this->orderInvoiceMock]);
     $this->orderInvoiceMock->expects($this->once())->method('setOrder')->with($this->orderMock)->willReturnSelf();
     $this->orderInvoiceMock->expects($this->once())->method('save')->willReturnSelf();
     $this->relationProcessor->processRelation($this->orderMock);
 }
示例#25
0
文件: order.php 项目: mage2pro/core
/**
 * 2016-05-07
 * @param OP $payment
 * @return O|DFO
 * @throws LE
 */
function df_order_by_payment(OP $payment)
{
    /** @var O|DFO $result */
    $result = $payment->getOrder();
    /**
     * 2016-05-08
     * Раньше здесь стояла проверка !$result->getId()
     * Это оказалось не совсем правильным, потому что в оплаты размещаемого в данный момент заказа
     * у этого заказа ещё нет идентификатора (потому что он не сохранён),
     * но вот increment_id для него создаётся заранее
     * (в том числе, чтобы другие объекты, да и платёжные модули могли к нему привязываться).
     */
    if (!$result->getIncrementId()) {
        throw new LE(__('The order no longer exists.'));
    }
    /**
     * 2016-03-26
     * Очень важно! Иначе order создаст свой экземпляр payment:
     * @used-by \Magento\Sales\Model\Order::getPayment()
     */
    $result[IO::PAYMENT] = $payment;
    return $result;
}
 /**
  * @covers \Magento\BraintreeTwo\Gateway\Command\CaptureStrategyCommand::execute
  */
 public function testCloneExecute()
 {
     $paymentData = $this->getPaymentDataObjectMock();
     $subject['payment'] = $paymentData;
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->payment->expects(static::once())->method('getAuthorizationTransaction')->willReturn(true);
     $this->payment->expects(static::once())->method('getId')->willReturn(1);
     $this->buildSearchCriteria();
     $this->transactionRepository->expects(static::once())->method('getTotalCount')->willReturn(1);
     $paymentExtension = $this->getMockBuilder(OrderPaymentExtension::class)->setMethods(['getVaultPaymentToken'])->disableOriginalConstructor()->getMock();
     $paymentExtension->expects(static::once())->method('getVaultPaymentToken')->willReturn(null);
     $this->payment->expects(static::once())->method('getExtensionAttributes')->willReturn($paymentExtension);
     $this->commandPool->expects(static::once())->method('get')->with(CaptureStrategyCommand::CLONE_TRANSACTION)->willReturn($this->command);
     $this->strategyCommand->execute($subject);
 }
 /**
  * @covers \Magento\BraintreeTwo\Gateway\Response\VaultDetailsHandler::handle
  */
 public function testHandle()
 {
     $this->paymentExtension->expects(self::once())->method('setVaultPaymentToken')->with($this->paymentToken);
     $this->paymentExtension->expects(self::once())->method('getVaultPaymentToken')->willReturn($this->paymentToken);
     $paymentData = $this->getPaymentDataObjectMock();
     $transaction = $this->getBraintreeTransaction();
     $subject = ['payment' => $paymentData];
     $response = ['object' => $transaction];
     $this->subjectReader->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->subjectReader->expects(self::once())->method('readTransaction')->with($response)->willReturn($transaction);
     $this->paymentToken->expects(static::once())->method('setGatewayToken')->with('rh3gd4');
     $this->paymentToken->expects(static::once())->method('setExpiresAt')->with('2022-01-01 00:00:00');
     $this->paymentHandler->handle($subject, $response);
     $this->assertSame($this->paymentToken, $this->payment->getExtensionAttributes()->getVaultPaymentToken());
 }
示例#28
0
 /**
  * Verify data required for saving
  *
  * @return $this
  */
 public function beforeSave()
 {
     // set parent id
     $this->_verifyPaymentObject();
     if (!$this->getId()) {
         // We need to set order and payment ids only for new transactions
         if (null !== $this->_paymentObject) {
             $this->setPaymentId($this->_paymentObject->getId());
         }
         if (null !== $this->_order) {
             $this->setOrderId($this->_order->getId());
         }
         $this->setCreatedAt($this->_dateFactory->create()->gmtDate());
     }
     return parent::beforeSave();
 }
 /**
  * @param int $size
  * @param string $command
  * @covers       \Magento\BraintreeTwo\Gateway\Command\CaptureStrategyCommand::execute
  * @dataProvider captureDataProvider
  */
 public function testCaptureExecute($size, $command)
 {
     $paymentData = $this->getPaymentDataObjectMock();
     $subject['payment'] = $paymentData;
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->payment->expects(static::once())->method('getAuthorizationTransaction')->willReturn(true);
     $this->payment->expects(static::once())->method('getId')->willReturn(1);
     $this->filterBuilder->expects(static::exactly(2))->method('setField')->willReturnSelf();
     $this->filterBuilder->expects(static::exactly(2))->method('setValue')->willReturnSelf();
     $searchCriteria = new SearchCriteria();
     $this->searchCriteriaBuilder->expects(static::once())->method('addFilters')->willReturnSelf();
     $this->searchCriteriaBuilder->expects(static::once())->method('create')->willReturn($searchCriteria);
     $this->transactionRepository->expects(static::once())->method('getList')->with($searchCriteria)->willReturnSelf();
     $this->transactionRepository->expects(static::once())->method('getTotalCount')->willReturn($size);
     $this->commandPool->expects(static::once())->method('get')->with($command)->willReturn($this->command);
     $this->strategyCommand->execute($subject);
 }
 /**
  * @covers \Magento\BraintreeTwo\Gateway\Response\VaultDetailsHandler::handle
  */
 public function testHandle()
 {
     $this->vaultPaymentMock->expects(self::once())->method('isActiveForPayment')->willReturn(true);
     $this->paymentExtension->expects(self::once())->method('setVaultPaymentToken')->with($this->paymentTokenMock);
     $this->paymentExtension->expects(self::once())->method('getVaultPaymentToken')->willReturn($this->paymentTokenMock);
     $paymentData = $this->getPaymentDataObjectMock();
     $transaction = $this->getBraintreeTransaction();
     $subject = ['payment' => $paymentData];
     $response = ['object' => $transaction];
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->subjectReaderMock->expects(self::once())->method('readTransaction')->with($response)->willReturn($transaction);
     $this->salesOrderMock->setCustomerId(10);
     $this->paymentHandler->handle($subject, $response);
     $this->assertEquals('rh3gd4', $this->paymentTokenMock->getGatewayToken());
     $this->assertEquals('10', $this->paymentTokenMock->getCustomerId());
     $this->assertSame($this->paymentTokenMock, $this->payment->getExtensionAttributes()->getVaultPaymentToken());
 }