/**
  * Looks up and updates orders for payment notifications.
  *
  * @return boolean
  */
 public function updatePayment()
 {
     $oOrder = $this->_getOrder();
     if ($this->_oNotification->getOrderId() != null && $oOrder->oxorder__oxordernr->value != $this->_oNotification->getOrderId()) {
         $this->_logIpnError("Order ID not valid for " . $this->_oNotification->getTransactionId());
         return false;
     }
     if ($oOrder->oxorder__bzstate->value != self::STATE_PENDING) {
         $this->_logIpnError("Unable to change state of transaction " . $this->_oNotification->getTransactionId());
         return false;
     }
     if ($this->_oNotification->getState() == self::STATE_PAID) {
         $oOrder->oxorder__oxpaid->setValue(date("Y-m-d H:i:s", time()));
     } elseif ($this->_oNotification->getState() == self::STATE_EXPIRED) {
         $oOrder->cancelOrder();
     }
     $oOrder->oxorder__bzstate = new oxField($this->_oNotification->getState());
     $oOrder->save();
     return true;
 }
 /**
  * Test function with valid refund notification.
  */
 public function testValidateWithValidRefundNotification()
 {
     $params = array('state' => 'refund_completed', 'refund_transaction_id' => '1', 'origin_transaction_id' => '1', 'shop_id' => '10483', 'customer_email' => '*****@*****.**', 'amount' => '24.95', 'currency' => 'EUR', 'origin_order_id' => '1', 'custom_var_0' => 'PHP SDK', 'custom_var_1' => 'Euro 2012', 'custom_var_2' => 'Barzahlen v.1.3.3.7', 'hash' => '55b3b182caf79881f5ac9a4fd7ac4f84824267fc8ac8a18dcfd25535b48a646eb28a0acf864faaff006365fd5f0480c09341930bf15dbcbe3ad27e4fa0d5c9f5', 'page' => 'ipn/barzahlen');
     $notification = new Barzahlen_Notification(SHOPID, NOTIFICATIONKEY, $params);
     $this->assertEquals(null, $notification->getState());
     $this->assertEquals(null, $notification->getOriginTransactionId());
     $this->assertEquals(null, $notification->getShopId());
     $notification->validate();
     $this->assertTrue($notification->isValid());
     $this->assertEquals('refund', $notification->getNotificationType());
     $this->assertEquals('refund_completed', $notification->getState());
     $this->assertEquals('1', $notification->getRefundTransactionId());
     $this->assertEquals(null, $notification->getTransactionId());
     $this->assertEquals('1', $notification->getOriginTransactionId());
     $this->assertEquals('10483', $notification->getShopId());
     $this->assertEquals('*****@*****.**', $notification->getCustomerEmail());
     $this->assertEquals('24.95', $notification->getAmount());
     $this->assertEquals('EUR', $notification->getCurrency());
     $this->assertEquals(null, $notification->getOrderId());
     $this->assertEquals('1', $notification->getOriginOrderId());
     $this->assertEquals('PHP SDK', $notification->getCustomVar0());
     $this->assertEquals('Euro 2012', $notification->getCustomVar1());
     $this->assertEquals('Barzahlen v.1.3.3.7', $notification->getCustomVar2());
     $this->assertEquals(array('PHP SDK', 'Euro 2012', 'Barzahlen v.1.3.3.7'), $notification->getCustomVar());
     $this->assertEquals($params, $notification->getNotificationArray());
 }