@@ -182,21 +182,21 @@ function ($value) {
182
182
183
183
$ this ->transactionFactory = $ this ->getMock (
184
184
'Magento\Sales\Model\Order\Payment\TransactionFactory ' ,
185
- [' create ' ],
185
+ [],
186
186
[],
187
187
'' ,
188
188
false
189
189
);
190
190
$ this ->transactionCollectionFactory = $ this ->getMock (
191
191
'Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory ' ,
192
- [' create ' ],
192
+ [],
193
193
[],
194
194
'' ,
195
195
false
196
196
);
197
197
$ this ->serviceOrderFactory = $ this ->getMock (
198
198
'Magento\Sales\Model\Service\OrderFactory ' ,
199
- [' create ' ],
199
+ [],
200
200
[],
201
201
'' ,
202
202
false
@@ -586,6 +586,26 @@ public function testDenyPaymentFalse()
586
586
$ this ->payment ->deny ();
587
587
}
588
588
589
+ /**
590
+ * Test offline IPN calls
591
+ */
592
+ public function testDenyPaymentIpn ()
593
+ {
594
+ $ isOnline = false ;
595
+ $ message = sprintf ('Denied the payment online Transaction ID: "%s" ' , $ this ->transactionId );
596
+
597
+ $ this ->payment ->setTransactionId ($ this ->transactionId );
598
+ $ this ->payment ->setNotificationResult (true );
599
+
600
+ $ this ->mockInvoice ($ this ->transactionId );
601
+ $ this ->mockResultFalseMethods ($ message );
602
+
603
+ $ this ->helperMock ->expects ($ this ->never ())
604
+ ->method ('getMethodInstance ' );
605
+
606
+ $ this ->payment ->deny ($ isOnline );
607
+ }
608
+
589
609
/**
590
610
* @dataProvider acceptPaymentFalseProvider
591
611
* @param bool $isFraudDetected
@@ -658,6 +678,44 @@ public function testDenyPaymentNegativeStateReview()
658
678
$ this ->payment ->deny ();
659
679
}
660
680
681
+ /**
682
+ * Test offline IPN call, negative
683
+ */
684
+ public function testDenyPaymentIpnNegativeStateReview ()
685
+ {
686
+ $ isOnline = false ;
687
+ $ message = sprintf ('Registered notification about denied payment. Transaction ID: "%s" ' , $ this ->transactionId );
688
+
689
+ $ orderState = Order::STATE_PAYMENT_REVIEW ;
690
+
691
+ $ this ->payment ->setTransactionId ($ this ->transactionId );
692
+ $ this ->payment ->setNotificationResult (false );
693
+
694
+ $ this ->orderMock ->expects ($ this ->once ())
695
+ ->method ('getState ' )
696
+ ->willReturn ($ orderState );
697
+
698
+ $ this ->orderMock ->expects ($ this ->never ())
699
+ ->method ('setState ' );
700
+ $ this ->orderMock ->expects ($ this ->once ())
701
+ ->method ('addStatusHistoryComment ' )
702
+ ->with ($ message );
703
+
704
+ $ this ->helperMock ->expects ($ this ->never ())
705
+ ->method ('getMethodInstance ' )
706
+ ->will ($ this ->returnValue ($ this ->paymentMethodMock ));
707
+
708
+ $ this ->paymentMethodMock ->expects ($ this ->never ())
709
+ ->method ('setStore ' )
710
+ ->will ($ this ->returnSelf ());
711
+
712
+ $ this ->paymentMethodMock ->expects ($ this ->never ())
713
+ ->method ('denyPayment ' )
714
+ ->with ($ this ->payment );
715
+
716
+ $ this ->payment ->deny ($ isOnline );
717
+ }
718
+
661
719
/**
662
720
* @param int $transactionId
663
721
* @param int $countCall
@@ -710,6 +768,41 @@ public function testUpdateOnlineTransactionApproved()
710
768
$ this ->assertEquals ($ baseGrandTotal , $ this ->payment ->getBaseAmountPaidOnline ());
711
769
}
712
770
771
+ /**
772
+ * Test update calls from IPN controller
773
+ */
774
+ public function testUpdateOnlineTransactionApprovedIpn ()
775
+ {
776
+ $ isOnline = false ;
777
+ $ message = sprintf ('Registered update about approved payment. Transaction ID: "%s" ' , $ this ->transactionId );
778
+
779
+ $ storeId = 50 ;
780
+ $ baseGrandTotal = 299.99 ;
781
+
782
+ $ this ->payment ->setTransactionId ($ this ->transactionId );
783
+ $ this ->payment ->setData ('is_transaction_approved ' , true );
784
+
785
+ $ this ->mockInvoice ($ this ->transactionId );
786
+ $ this ->mockResultTrueMethods ($ this ->transactionId , $ baseGrandTotal , $ message );
787
+
788
+ $ this ->orderMock ->expects ($ this ->never ())
789
+ ->method ('getStoreId ' )
790
+ ->willReturn ($ storeId );
791
+ $ this ->helperMock ->expects ($ this ->never ())
792
+ ->method ('getMethodInstance ' )
793
+ ->will ($ this ->returnValue ($ this ->paymentMethodMock ));
794
+ $ this ->paymentMethodMock ->expects ($ this ->never ())
795
+ ->method ('setStore ' )
796
+ ->with ($ storeId )
797
+ ->willReturn ($ this ->paymentMethodMock );
798
+ $ this ->paymentMethodMock ->expects ($ this ->never ())
799
+ ->method ('fetchTransactionInfo ' )
800
+ ->with ($ this ->payment , $ this ->transactionId );
801
+
802
+ $ this ->payment ->update ($ isOnline );
803
+ $ this ->assertEquals ($ baseGrandTotal , $ this ->payment ->getBaseAmountPaidOnline ());
804
+ }
805
+
713
806
public function testUpdateOnlineTransactionDenied ()
714
807
{
715
808
$ message = sprintf ('Registered update about denied payment. Transaction ID: "%s" ' , $ this ->transactionId );
0 commit comments