public function testFindCaptureLitleTxnToRefundForPayment()
 {
     $capture = new Varien_Object();
     $capture->setTxnId(2);
     $payment = $this->getMock('Mage_Sales_Model_Order_Payment');
     $payment->expects($this->any())->method('lookupTransaction')->with($this->equalTo(false), $this->equalTo(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE))->will($this->returnValue($capture));
     $litle = new Litle_CreditCard_Model_PaymentLogic();
     $litleTxnId = $litle->findCaptureLitleTxnToRefundForPayment($payment);
     $this->assertEquals(2, $litleTxnId);
 }
Example #2
0
 public function testPerformRequestWithPayIdAndPayIdSubForRefund()
 {
     $order = Mage::getModel('sales/order');
     $payment = Mage::getModel('sales/order_payment');
     $payment->setMethod('ops_directDebit');
     $payment->setAdditionalInformation('paymentId', 4711);
     $payment->setAdditionalInformation('status', 81);
     $order->setPayment($payment);
     $fakeTransaction = new Varien_Object();
     $fakeTransaction->setTxnId(1);
     $directLinkHelperMock = $this->getHelperMock('ops/directlink', array('getPaymentTransaction'));
     $directLinkHelperMock->expects($this->once())->method('getPaymentTransaction')->will($this->returnValue($fakeTransaction));
     $statusUpdateApiMock = $this->getModelMock('ops/status_update', array('updatePaymentStatus'));
     $directLinkApiMock = $this->getModelMock('ops/api_directlink', array('performRequest'));
     $directLinkApiMock->expects($this->once())->method('performRequest')->with(array('PAYID' => 4711, 'PAYIDSUB' => 1), Mage::getModel('ops/config')->getDirectLinkMaintenanceApiPath($order->getStoreId()), $order->getStoreId())->will($this->returnValue(array('STATUS' => 8, 'AMOUNT' => 1)));
     $statusUpdateApiMock->setDirectLinkHelper($directLinkHelperMock);
     $statusUpdateApiMock->setDirectLinkApi($directLinkApiMock);
     $statusUpdateApiMock->updateStatusFor($order);
     $opsResponse = $statusUpdateApiMock->getOpsResponse();
     $this->assertArrayHasKey('STATUS', $opsResponse);
     $this->assertEquals(8, $opsResponse['STATUS']);
     $this->assertArrayHasKey('AMOUNT', $opsResponse);
     $this->assertArrayHasKey('amount', $opsResponse);
     $this->assertEquals(1, $opsResponse['AMOUNT']);
     $this->assertEquals($opsResponse['amount'], $opsResponse['AMOUNT']);
 }