/**
  * @covers oePayPalOrderRefundAction::process
  * @covers oePayPalOrderRefundActionHandler::getPayPalResponse
  * @covers oePayPalOrderRefundActionHandler::getPayPalRequest
  * @covers oePayPalOrderRefundActionData::getAmount
  * @covers oePayPalOrderRefundActionData::getType
  */
 public function testActionRefund()
 {
     $aRequestParams = array('refund_amount' => '10', 'refund_type' => 'Complete', 'transaction_id' => 'capturedTransaction');
     $aResponseParams = array('REFUNDTRANSACTIONID' => 'TransactionId', 'REFUNDSTATUS' => 'Pending', 'GROSSREFUNDAMT' => '9.01', 'CURRENCYCODE' => 'EUR');
     $oCapturedPayment = new oePayPalOrderPayment();
     $oCapturedPayment->setOrderId('testOrderId');
     $oCapturedPayment->setTransactionId('capturedTransaction');
     $oCapturedPayment->save();
     $oAction = $this->_createAction('refund', 'testOrderId', $aRequestParams, $aResponseParams);
     $oAction->process();
     $oOrder = $this->_getOrder('testOrderId');
     $this->assertEquals('9.01', $oOrder->getRefundedAmount());
     $aPaymentList = $oOrder->getPaymentList()->getArray();
     $this->assertEquals(2, count($aPaymentList));
     $oPayment = array_shift($aPaymentList);
     $this->assertEquals('refund', $oPayment->getAction());
     $this->assertEquals('testOrderId', $oPayment->getOrderId());
     $this->assertEquals('9.01', $oPayment->getAmount());
     $this->assertEquals('Pending', $oPayment->getStatus());
     $this->assertEquals('EUR', $oPayment->getCurrency());
     $oCapturedPayment = array_shift($aPaymentList);
     $this->assertEquals('9.01', $oCapturedPayment->getRefundedAmount());
     $oPayment->delete();
     $oCapturedPayment->delete();
     $oOrder->delete();
 }
 /**
  * Test loading of payment by transaction id
  */
 public function testGetPaymentBeingRefunded_LoadedByTransactionId_TransactionIdSet()
 {
     $sTransactionId = 'test_transId';
     $oPayment = new oePayPalOrderPayment();
     $oPayment->setTransactionId($sTransactionId);
     $oPayment->setOrderId('_testOrderId');
     $oPayment->save();
     $aParams = array('transaction_id' => $sTransactionId);
     $oRequest = $this->_createStub('oePayPalRequest', array('getPost' => $aParams));
     $oOrder = $this->_getOrder();
     $oActionData = new oePayPalOrderRefundActionData($oRequest, $oOrder);
     $oPayment = $oActionData->getPaymentBeingRefunded();
     $this->assertEquals($sTransactionId, $oPayment->getTransactionId());
 }
 /**
  * Test case add comment to payment
  */
 public function testAddComment_NoDateGiven()
 {
     $oOrderPayment = new oePayPalOrderPayment();
     $oOrderPayment->setOrderId('123');
     $oOrderPayment->save();
     $this->assertEquals(0, count($oOrderPayment->getCommentList()), 'No comments - default value empty array.');
     $oComment = new oePayPalOrderPaymentComment();
     $oComment->setComment('comment');
     $oOrderPayment->addComment($oComment);
     $this->assertEquals(1, count($oOrderPayment->getCommentList()));
 }
Ejemplo n.º 4
0
 /**
  * Returns not yet captured (remaining) order sum.
  *
  * @param oePayPalOrderPayment $oPayment order payment
  *
  * @return oePayPalOrderPayment
  */
 public function addPayment(oePayPalOrderPayment $oPayment)
 {
     //order payment info
     if ($this->getOrderId()) {
         $oPayment->setOrderId($this->getOrderId());
         $oPayment->save();
     }
     $this->load($this->getOrderId());
     return $oPayment;
 }
 /**
  * Testing status IPN and order creation - status completed
  *
  * @dataProvider providerPayment_paymentCompleted
  */
 public function testGetStatus_paymentCompleted($oOrderPaymentVirtual, $sOrderStatus)
 {
     $oOrderPayment = new oePayPalOrderPayment();
     $oOrderPayment->setOrderId('order');
     $oOrderPayment->setStatus('Completed');
     $oOrderPayment->save();
     $oOrderPayment = new oePayPalOrderPayment();
     $oOrderPayment->setOrderId('order');
     $oOrderPayment->setStatus('Refunded');
     $oOrderPayment->save();
     $oOrderPayment = new oePayPalOrderPayment();
     $oOrderPayment->setOrderId('order');
     $oOrderPayment->setStatus('Voided');
     $oOrderPayment->save();
     $oOrder = new oePayPalPayPalOrder();
     $oOrder->setOrderId('order');
     $oManager = new oePayPalOrderPaymentStatusCalculator();
     $oManager->setOrder($oOrder);
     $oManager->setOrderPayment($oOrderPaymentVirtual);
     $this->assertEquals($sOrderStatus, $oManager->getStatus());
 }
 /**
  * Add comment for request payment if comment exists.
  * Function must only be called when the payment object this
  * comment is related to is already stored in the database and has an oxid.
  * Comment will be immediately saved to database.
  *
  * @param  oePayPalOrderPayment $paypalOrderPayment
  *
  * @return oePayPalOrderPayment
  */
 private function addRequestPaymentComment($paypalOrderPayment)
 {
     $request = $this->getRequest();
     $memo = $request->getRequestParameter(self::PAYPAL_IPN_MEMO);
     if ($memo) {
         $comment = oxNew('oePayPalOrderPaymentComment');
         $comment->setComment($memo);
         $paypalOrderPayment->addComment($comment);
         if (0 < $paypalOrderPayment->getId()) {
             $paypalOrderPayment->save();
         }
     }
     return $paypalOrderPayment;
 }
 /**
  * Test case for oePayPalOrderPayment::hasPendingPayment()
  * Checks if list has pending payments
  *
  * @return null
  */
 public function testAddPayment()
 {
     $oOrderPaymentList = new oePayPalOrderPaymentList();
     $oOrderPaymentList->load("order");
     $this->assertEquals(0, count($oOrderPaymentList));
     $oOrderPayment = new oePayPalOrderPayment();
     $oOrderPayment->setOrderId("order");
     $oOrderPayment->save();
     $oOrderPaymentList = new oePayPalOrderPaymentList();
     $oOrderPaymentList->load("order");
     $this->assertEquals(1, count($oOrderPaymentList));
     $oOrderPayment = new oePayPalOrderPayment();
     $oOrderPayment->setDate('2013-01-12');
     $oOrderPayment->setAction('Pending');
     $oOrderPaymentList->addPayment($oOrderPayment);
     $oOrderPaymentList = new oePayPalOrderPaymentList();
     $oOrderPaymentList->load("order");
     $this->assertEquals(2, count($oOrderPaymentList));
 }
Ejemplo n.º 8
0
 /**
  * Update the parent transaction in case of refund.
  *
  * @param oePayPalOrderPayment $orderPaymentParent
  * @param oePayPalOrderPayment $requestOrderPayment
  *
  * @return null
  */
 protected function updateParentTransaction($orderPaymentParent, $requestOrderPayment)
 {
     if (oePayPalIPNRequestPaymentSetter::REFUND_ACTION == $requestOrderPayment->getAction()) {
         $orderPaymentParent->addRefundedAmount($requestOrderPayment->getAmount());
         $orderPaymentParent->save();
     }
 }