/** * Creates the notification object and checks the received data. * * @param array $aData request data * @return boolean */ public function checkData(array $aData) { $this->_oNotification = new Barzahlen_Notification($this->_sShopId, $this->_sNotificationKey, $aData); try { $this->_oNotification->validate(); } catch (Exception $e) { $this->_logIpnError("Notification failed: " . $e); } return $this->_oNotification->isValid(); }
/** * Checks received data and validates hash. * * @param string $receivedData received data * @return boolean */ function validateParameters() { $notification = new Barzahlen_Notification(MODULE_PAYMENT_BARZAHLEN_SHOPID, MODULE_PAYMENT_BARZAHLEN_NOTIFICATIONKEY, $this->receivedData); try { $notification->validate(); } catch (Exception $e) { $this->bzLog('barzahlen/ipn: ' . $e); return false; } return $notification->isValid(); }
/** * Test function with valid refund notification without custom vars and origin order id. */ public function testValidateWithValidShortRefundNotification() { $params = array('state' => 'refund_completed', 'refund_transaction_id' => '1', 'origin_transaction_id' => '1', 'shop_id' => '10483', 'customer_email' => '*****@*****.**', 'amount' => '24.95', 'currency' => 'EUR', 'hash' => 'da5ec940ce1be06fab76f96aa192953db093e0997f0c5e62a5e47ebde3b1f5791daf29fe5eafeea176f07c07e470bae8d9ced710bfd90f62dd238bf621d20717', 'page' => 'ipn/barzahlen'); $notification = new Barzahlen_Notification(SHOPID, NOTIFICATIONKEY, $params); $notification->validate(); $this->assertTrue($notification->isValid()); }
/** * Notifications are valided and the updates will be performed. * States set in DB in table s_core_states */ public function notifyAction() { $config = Shopware()->Plugins()->Frontend()->ZerintPaymentBarzahlen()->Config(); $shopId = $config->barzahlenShopId; $notificationKey = $config->barzahlenNotificationKey; $notify = new Barzahlen_Notification($shopId, $notificationKey, $this->Request()->getParams()); try { $notify->validate(); } catch (Exception $e) { $this->_logError($e); } if ($notify->isValid()) { $this->_sendHeader(200); $order = Shopware()->Modules()->Order(); $orderId = $this->_getOrderId($this->Request()->transaction_id); $orderNumber = isset($this->Request()->order_id) ? $this->Request()->order_id : $this->_getOrderNumber($orderId); if (!$this->_checkPaymentStatus($orderId)) { $order->setPaymentStatus($orderId, self::PAYMENT_VERIFY); $this->_logError("Payment for order " . $orderNumber . " couldn't be updated by notification. Already processed."); return; } switch ($this->Request()->state) { case 'paid': $order->setPaymentStatus($orderId, self::PAYMENT_PAID); $this->_setClearedDate($this->Request()->transaction_id); break; case 'expired': $order->setPaymentStatus($orderId, self::PAYMENT_EXPIRED); break; default: $order->setPaymentStatus($orderId, self::PAYMENT_VERIFY); break; } } else { $this->_sendHeader(400); } }