public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs) { //if ($request->getActionName() == 'cron') return $this->onHourly(); if ($request->getActionName() == 'thanks') { return $this->thanksAction($request, $response, $invokeArgs); } $invoice = $this->getDi()->invoiceTable->findBySecureId($request->getFiltered('id'), $this->getId()); if (!$invoice) { throw new Am_Exception_InputError(___("Sorry, seems you have used wrong link")); } $u = $invoice->getUser(); $xml = new DOMDocument('1.0', 'utf-8'); $e = new DOMElement('PesapalDirectOrderInfo'); $el = $xml->appendChild($e); $el->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchemainstance'); $el->setAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); $el->setAttribute('Amount', number_format($invoice->first_total, 2)); $el->setAttribute('Description', $invoice->getLineDescription()); $el->setAttribute('Code', ''); $el->setAttribute('Type', 'MERCHANT'); $el->setAttribute('PaymentMethod', ''); $el->setAttribute('Reference', $invoice->public_id); $el->setAttribute('FirstName', $u->name_f); $el->setAttribute('LastName', $u->name_l); $el->setAttribute('Email', $u->email); $el->setAttribute('PhoneNumber', $u->phone); $el->setAttribute('UserName', $u->email); $el->setAttribute('Currency', $invoice->currency); $el->setAttribute('xmlns', 'http://www.pesapal.com'); //post transaction to pesapal $consumer = $this->getConsumer(); $token = $params = NULL; $method = $this->getMethod(); $iframe_src = OAuthRequest::from_consumer_and_token($consumer, $token, "GET", self::URL, $params); $iframe_src->set_parameter("oauth_callback", $this->getPluginUrl('thanks')); $iframe_src->set_parameter("pesapal_request_data", $s = htmlentities($xml->saveXML())); $iframe_src->sign_request($method, $consumer, $token); $view = new Am_View(); $view->addScriptPath(dirname(__FILE__)); $view->invoice = $invoice; $view->iframe_src = $iframe_src; $response->setBody($view->render("payment-pesapal-confirm.phtml")); }