Ejemplo n.º 1
0
 /**
  * Test method
  * with resultCode = RESPONSE_CODE_APPROVED and Origresult != RESPONSE_CODE_FRAUDSERVICE_FILTER
  */
 public function testAuthorize()
 {
     $this->initializationAuthorizeMock();
     $this->buildRequestData();
     $paymentTokenMock = $this->getMock(PaymentTokenInterface::class);
     $extensionAttributes = $this->getMockBuilder('Magento\\Sales\\Api\\Data\\OrderPaymentExtensionInterface')->disableOriginalConstructor()->setMethods(['setVaultPaymentToken'])->getMock();
     $ccDetails = ['cc_type' => 'VI', 'cc_number' => '1111'];
     $this->responseMock->setData('result_code', Payflowpro::RESPONSE_CODE_APPROVED);
     $this->responseMock->setData('origresult', 0);
     $this->responseMock->setData('pnref', 'test-pnref');
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($this->responseMock);
     $this->responseValidator->expects($this->once())->method('validate')->with($this->responseMock);
     $this->paymentMock->expects($this->once())->method('setTransactionId')->with('test-pnref')->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('setIsTransactionClosed')->with(0);
     $this->paymentMock->expects($this->once())->method('getCcExpYear')->willReturn('2017');
     $this->paymentMock->expects($this->once())->method('getCcExpMonth')->willReturn('12');
     $this->paymentMock->expects(static::any())->method('getAdditionalInformation')->willReturnMap([[Transparent::CC_DETAILS, $ccDetails], [Transparent::PNREF, 'test-pnref']]);
     $this->paymentTokenFactory->expects(static::once())->method('create')->willReturn($paymentTokenMock);
     $paymentTokenMock->expects(static::once())->method('setGatewayToken')->with('test-pnref');
     $paymentTokenMock->expects(static::once())->method('setTokenDetails')->with(json_encode($ccDetails));
     $paymentTokenMock->expects(static::once())->method('setExpiresAt')->with('2018-01-01 00:00:00');
     $this->paymentMock->expects(static::once())->method('getExtensionAttributes')->willReturn($extensionAttributes);
     $extensionAttributes->expects(static::once())->method('setVaultPaymentToken')->with($paymentTokenMock);
     $this->assertSame($this->object, $this->object->authorize($this->paymentMock, 33));
 }
Ejemplo n.º 2
0
 /**
  * Test method
  * with resultCode = RESPONSE_CODE_APPROVED and Origresult != RESPONSE_CODE_FRAUDSERVICE_FILTER
  */
 public function testAuthorize()
 {
     $this->initializationAuthorizeMock();
     $this->buildRequestData();
     $this->responseMock->expects($this->any())->method('getResultCode')->willReturn(Payflowpro::RESPONSE_CODE_APPROVED);
     $this->responseMock->expects($this->any())->method('getOrigresult')->willReturn(0);
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($this->responseMock);
     $this->responseValidator->expects($this->once())->method('validate')->with($this->responseMock);
     $this->responseMock->expects($this->once())->method('getPnref')->willReturn('test-pnref');
     $this->paymentMock->expects($this->once())->method('setTransactionId')->with('test-pnref')->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('setIsTransactionClosed')->with(0);
     $this->assertSame($this->object, $this->object->authorize($this->paymentMock, 33));
 }