protected function setupAuthorizeRequest(array $configData, $vault, $registry, $existingCustomer, array $paymentInfo, array $expectedRequestAttributes, $paymentObject, $storeId, $amount) { //setup general payment and order information $transactionRequest = $this->setupPaymentObject($paymentObject, $storeId); //setup config options foreach ($configData as $methodName => $value) { $this->configMock->expects($this->any())->method($methodName)->willReturn($value); } //setup payment info instance $this->infoInstanceMock->expects($this->any())->method('getAdditionalInformation')->willReturnMap($paymentInfo); $this->model->setInfoInstance($this->infoInstanceMock); $expectedRequestAttribs = array_merge($transactionRequest, $expectedRequestAttributes); $expectedRequestAttribs['amount'] = $amount; if ($existingCustomer !== null) { $this->vaultMock->expects($this->once())->method('exists')->with(self::CUSTOMER_ID)->willReturn($existingCustomer); if ($existingCustomer) { unset($expectedRequestAttribs['customer']); } } if (!empty($vault['canSaveCard'])) { $this->vaultMock->expects($this->once())->method('canSaveCard')->with(self::AUTH_CC_LAST_4)->willReturn($vault['canSaveCard']); } if (array_key_exists('registry', $registry)) { $this->registryMock->expects($this->once())->method('registry')->with(PaymentMethod::REGISTER_NAME)->willReturn($registry['registry']); } if (array_key_exists('register', $registry)) { $this->registryMock->expects($this->once())->method('register')->with(PaymentMethod::REGISTER_NAME, true); } return $expectedRequestAttribs; }
protected function setupAuthorizeRequest(array $configData, array $paymentInfo, array $expectedRequestAttributes, $paymentObject, $storeId, $amount) { //setup general payment and order information $transactionRequest = $this->setupPaymentObject($paymentObject, $storeId); //setup config options foreach ($configData as $methodName => $value) { $this->configMock->expects($this->any())->method($methodName)->willReturn($value); } //setup payment info instance $this->infoInstanceMock->expects($this->any())->method('getAdditionalInformation')->willReturnMap($paymentInfo); $this->model->setInfoInstance($this->infoInstanceMock); $expectedRequestAttribs = array_merge($transactionRequest, $expectedRequestAttributes); $expectedRequestAttribs['amount'] = $amount; return $expectedRequestAttribs; }
/** * @covers \PayStand\PayStandMagento\Model\Directpost::fetchTransactionInfo * * @param $transactionId * @param $resultStatus * @param $responseStatus * @param $responseCode * @return void * * @dataProvider dataProviderTransaction */ public function testFetchVoidedTransactionInfo($transactionId, $resultStatus, $responseStatus, $responseCode) { $paymentId = 36; $orderId = 36; $this->paymentMock->expects(static::once())->method('getId')->willReturn($paymentId); $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['getId', '__wakeup'])->getMock(); $orderMock->expects(static::once())->method('getId')->willReturn($orderId); $this->paymentMock->expects(static::once())->method('getOrder')->willReturn($orderMock); $transactionMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment\\Transaction')->disableOriginalConstructor()->getMock(); $this->transactionRepositoryMock->expects(static::once())->method('getByTransactionId')->with($transactionId, $paymentId, $orderId)->willReturn($transactionMock); $document = $this->getTransactionXmlDocument($transactionId, TransactionService::PAYMENT_UPDATE_STATUS_CODE_SUCCESS, $resultStatus, $responseStatus, $responseCode); $this->transactionServiceMock->expects(static::once())->method('getTransactionDetails')->with($this->directpost, $transactionId)->willReturn($document); // transaction should be closed $this->paymentMock->expects(static::once())->method('setIsTransactionDenied')->with(true); $this->paymentMock->expects(static::once())->method('setIsTransactionClosed')->with(true); $transactionMock->expects(static::once())->method('close'); $this->directpost->fetchTransactionInfo($this->paymentMock, $transactionId); }
/** * @covers \Magento\Authorizenet\Model\Directpost::refund() * @return void */ public function testSuccessRefund() { $card = 1111; $this->paymentMock->expects(static::exactly(2))->method('getCcLast4')->willReturn($card); $this->paymentMock->expects(static::once())->method('decrypt')->willReturn($card); $this->paymentMock->expects(static::exactly(3))->method('getParentTransactionId')->willReturn(self::TRANSACTION_ID . '-capture'); $this->paymentMock->expects(static::once())->method('getPoNumber')->willReturn(self::INVOICE_NUM); $this->paymentMock->expects(static::once())->method('setIsTransactionClosed')->with(true)->willReturnSelf(); $orderMock = $this->getOrderMock(); $this->paymentMock->expects(static::exactly(2))->method('getOrder')->willReturn($orderMock); $transactionMock = $this->getMockBuilder(Order\Payment\Transaction::class)->disableOriginalConstructor()->setMethods(['getAdditionalInformation'])->getMock(); $transactionMock->expects(static::once())->method('getAdditionalInformation')->with(Directpost::REAL_TRANSACTION_ID_KEY)->willReturn(self::TRANSACTION_ID); $this->transactionRepositoryMock->expects(static::once())->method('getByTransactionId')->willReturn($transactionMock); $response = $this->getRefundResponseBody(Directpost::RESPONSE_CODE_APPROVED, Directpost::RESPONSE_REASON_CODE_APPROVED, 'Successful'); $this->httpClientMock->expects(static::once())->method('getBody')->willReturn($response); $this->responseMock->expects(static::once())->method('getXResponseCode')->willReturn(Directpost::RESPONSE_CODE_APPROVED); $this->responseMock->expects(static::once())->method('getXResponseReasonCode')->willReturn(Directpost::RESPONSE_REASON_CODE_APPROVED); $this->dataHelperMock->expects(static::never())->method('wrapGatewayError'); $this->directpost->refund($this->paymentMock, self::TOTAL_AMOUNT); }
/** * @param bool $isGatewayActionsLocked * @param bool $canCapture * * @dataProvider canCaptureDataProvider */ public function testCanCapture($isGatewayActionsLocked, $canCapture) { $this->directpost->setData('info_instance', $this->paymentMock); $this->paymentMock->expects($this->any())->method('getAdditionalInformation')->with(Directpost::GATEWAY_ACTIONS_LOCKED_STATE_KEY)->willReturn($isGatewayActionsLocked); $this->assertEquals($canCapture, $this->directpost->canCapture()); }