/** * Returns payment to refund. * * @return float */ public function getPaymentBeingRefunded() { if (is_null($this->_oPaymentBeingRefunded)) { $this->_oPaymentBeingRefunded = oxNew("oePayPalOrderPayment"); $this->_oPaymentBeingRefunded->loadByTransactionId($this->getTransactionId()); } return $this->_oPaymentBeingRefunded; }
/** * @dataProvider providerHandleRequest */ public function testHandleRequest($sShopOwnerPayPal, $aResponseFromPayPal, $blRequestHandledExpected, $OrderStatusAfterRequest, $blFailureMessageExist, $sTransactionIdPayPal, $dPaymentAmountPayPal, $sPaymentCurrencyPayPal, $sPaymentStatusPayPal, $sTransactionIdShop, $dPaymentAmountShop, $sPaymentCurrencyShop, $PaymentStatusAfterRequest) { $sOrderId = '__handleRequest_order'; $this->_preparePayPalRequest($sShopOwnerPayPal, $sPaymentStatusPayPal, $sTransactionIdPayPal, $dPaymentAmountPayPal, $sPaymentCurrencyPayPal); $oOrder = $this->_createPayPalOrder($sOrderId); $this->_createOrderPayment($sOrderId, $sTransactionIdShop, $dPaymentAmountShop, $sPaymentCurrencyShop); // Mock curl so we do not call PayPal to check if request originally from PayPal. $oIPNRequestVerifier = $this->_createPayPalResponse($aResponseFromPayPal); $oPayPalIPNHandler = new oePayPalIPNHandler(); $oPayPalIPNHandler->setIPNRequestVerifier($oIPNRequestVerifier); $blRequestHandled = $oPayPalIPNHandler->handleRequest(); $oOrder->load(); $oPayment = new oePayPalOrderPayment(); $oPayment->loadByTransactionId($sTransactionIdShop); $this->assertEquals($blRequestHandledExpected, $blRequestHandled, 'Request is not handled as expected.'); $this->assertEquals($PaymentStatusAfterRequest, $oPayment->getStatus(), 'Status did not change to one returned from PayPal.'); $this->assertEquals($OrderStatusAfterRequest, $oOrder->getPaymentStatus(), 'Status did not change to one returned from PayPal.'); $this->assertEquals($dPaymentAmountShop, $oPayment->getAmount(), 'Payment amount should not change to get from PayPal.'); $this->assertEquals($sPaymentCurrencyShop, $oPayment->getCurrency(), 'Payment currency should not change to get from PayPal.'); if (!$blFailureMessageExist) { $this->assertEquals(0, count($oPayment->getCommentList()), 'There should be no failure comment.'); } else { $aComments = $oPayment->getCommentList(); $aComments = $aComments->getArray(); $sComment = $aComments[0]->getComment(); // Failure comment should have all information about request and original payment. $blCommentHasAllInformation = strpos($sComment, (string) $dPaymentAmountPayPal) !== false && strpos($sComment, (string) $sPaymentCurrencyPayPal) !== false && strpos($sComment, (string) $dPaymentAmountShop) !== false && strpos($sComment, (string) $sPaymentCurrencyShop) !== false; $this->assertEquals(1, count($aComments), 'There should failure comment.'); $this->assertTrue($blCommentHasAllInformation, 'Failure comment should have all information about request and original payment: ' . $sComment); } }
/** * Testing loading payment by transaction id */ public function testLoadByTransactionId() { $oOrderPayment = new oePayPalOrderPayment(); $oOrderPayment->setOrderId('orderId'); $oOrderPayment->setTransactionId('transactionId'); $oOrderPayment->save(); $oOrderPayment = new oePayPalOrderPayment(); $oOrderPayment->loadByTransactionId('transactionId'); $this->assertEquals('orderId', $oOrderPayment->getOrderId()); }