/**
  * Wrapper to create order payment.
  *
  * @param string $sTransactionId     transaction id.
  * @param bool   $blValid            if payment should be marked as not valid.
  * @param string $sValidationMessage validation message
  *
  * @return oePayPalOrderPayment
  */
 protected function _prepareOrderPayment($sTransactionId, $blValid = true, $sValidationMessage = '')
 {
     $oOrderPayment = new oePayPalOrderPayment();
     $oOrderPayment->setPaymentId('__a24das5das45');
     $oOrderPayment->setOrderId('_sOrderId');
     $oOrderPayment->setTransactionId($sTransactionId);
     if (!$blValid) {
         $oOrderPayment->setIsValid(false);
     }
     if ($sValidationMessage) {
         $sDate = date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime());
         $oOrderPayment->addComment($sDate, $sValidationMessage);
     }
     return $oOrderPayment;
 }
 /**
  * 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()));
 }
 /**
  * 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;
 }