protected function _toHtml() { $aplazameJsUri = getenv('APLAZAME_JS_URI') ? getenv('APLAZAME_JS_URI') : 'https://aplazame.com/static/aplazame.js'; /** @var Aplazame_Aplazame_Model_Api_Client $client */ $client = Mage::getModel('aplazame/api_client'); /** @var Aplazame_Aplazame_Model_Payment $payment */ $payment = Mage::getModel('aplazame/payment'); $html = ' <html> <body style="margin: 0;"> <script type="text/javascript" src="' . $aplazameJsUri . '" data-api-host="' . $client->apiBaseUri . '" data-aplazame="' . Mage::getStoreConfig('payment/aplazame/public_api_key') . '" data-sandbox="' . (Mage::getStoreConfig('payment/aplazame/sandbox') ? 'true' : 'false') . '"> </script> <script> aplazame.checkout(' . json_encode(Aplazame_Sdk_Serializer_JsonSerializer::serializeValue($payment->getCheckoutSerializer())) . '); </script> <iframe src="' . Mage::getUrl('', array('_secure' => true)) . '" style="position:fixed; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden;"> Your browser does not support IFrames </iframe> </body> </html>'; return $html; }
public function indexAction() { $request = $this->getRequest(); $path = $request->getParam('path', ''); $pathArguments = json_decode($request->getParam('path_arguments', '[]'), true); $queryArguments = json_decode($request->getParam('query_arguments', '[]'), true); $result = $this->route($path, $pathArguments, $queryArguments); $response = $this->getResponse(); $response->setHttpResponseCode($result['status_code']); $response->setHeader('Content-type', 'application/json'); $response->setBody(json_encode(Aplazame_Sdk_Serializer_JsonSerializer::serializeValue($result['payload']))); }
public function historyAction() { $checkout_token = $this->getRequest()->getParam("checkout_token"); if (!$checkout_token) { Mage::throwException($this->__('History has no checkout token.')); } /** @var Mage_Sales_Model_Order $order */ $order = Mage::getModel('sales/order')->loadByIncrementId($checkout_token); $payment = $order->getPayment()->getMethodInstance(); if (!$payment instanceof Aplazame_Aplazame_Model_Payment) { Mage::throwException($this->__('Unexpected payment method.')); } $code = Aplazame_Aplazame_Model_Payment::METHOD_CODE; if (!$payment or $code !== $payment->getCode()) { Mage::throwException($this->__('Order not found.')); } if ($this->_getAccessToken() !== $payment->getConfigData('secret_api_key')) { Mage::throwException($this->__('You don\'t have permissions.')); } /** @var Mage_Sales_Model_Order[] $history_collection */ $history_collection = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', array('like' => $order->getCustomerId())); $historyOrders = array_map(array('Aplazame_Aplazame_Api_BusinessModel_HistoricalOrder', 'createFromOrder'), $history_collection); $this->getResponse()->setHeader('Content-type', 'application/json'); $this->getResponse()->setBody(json_encode(Aplazame_Sdk_Serializer_JsonSerializer::serializeValue($historyOrders))); }