/** * @depends testSerializationDeserialization * @param WebhookEvent $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getCreateTime(), "TestSample"); $this->assertEquals($obj->getResourceType(), "TestSample"); $this->assertEquals($obj->getEventType(), "TestSample"); $this->assertEquals($obj->getSummary(), "TestSample"); $this->assertEquals($obj->getResource(), "TestSampleObject"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); }
/** * Load and validate order, instantiate proper configuration * * @return Mage_Sales_Model_Order * @throws Exception */ protected function getOrder(\PayPal\Api\WebhookEvent $webhookEvent) { if (empty($this->_order)) { // get proper order $resource = $webhookEvent->getResource(); if (!$resource) { throw new Exception('Event resource not found.'); } if (isset($resource->parent_payment)) { $transactionId = $resource->parent_payment; } else { $transactionId = $resource->id; } $transaction = Mage::getModel('sales/order_payment_transaction')->load($transactionId, 'txn_id'); $this->_order = Mage::getModel('sales/order')->load($transaction->getOrderId()); if (!$this->_order->getId()) { $this->_debugData['exception'] = sprintf('Wrong order ID: "%s".', $id); Mage::app()->getResponse()->setHeader('HTTP/1.1', '503 Service Unavailable')->sendResponse(); exit; } } return $this->_order; }
/** * Load and validate order, instantiate proper configuration * * @return Mage_Sales_Model_Order * @throws Exception */ protected function getOrder(\PayPal\Api\WebhookEvent $webhookEvent) { if (empty($this->_order)) { // get proper order $resource = $webhookEvent->getResource(); if (!$resource) { throw new Exception('Event resource not found.'); } $transactionId = $resource->id; $transaction = Mage::getModel('sales/order_payment_transaction')->load($transactionId, 'txn_id'); $this->_order = Mage::getModel('sales/order')->load($transaction->getOrderId()); if (!$this->_order->getId()) { Mage::throwException('Order not found.'); } } return $this->_order; }