public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs) { if ($request->getActionName() == 'thanks') { return $this->thanksAction($request, $response, $invokeArgs); } parent::directAction($request, $response, $invokeArgs); }
public function getConfig($key = null, $default = null) { if (in_array($key, array('merchant_id', 'public_key', 'private_key', 'client_side_key', 'merchant_account_id'))) { return parent::getConfig(($this->getConfig('sandbox') ? 'test_' : '') . $key, $default); } else { return parent::getConfig($key, $default); } }
public function cancelAction() { $id = $this->_request->getFiltered('id'); $invoice = $this->getDi()->invoiceTable->findBySecureId($id, 'STOP' . $this->plugin->getId()); if (!$invoice) { throw new Am_Exception_InputError("No invoice found [{$invoiceId}]"); } if ($invoice->user_id != $this->getDi()->auth->getUserId()) { throw new Am_Exception_InternalError("User tried to access foreign invoice: [{$id}]"); } $invoice->setCancelled(); $this->_redirect('member/payment-history'); }
public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs) { if ($request->getActionName() == 'ipn') { try { parent::directAction($request, $response, $invokeArgs); } catch (Exception $ex) { $this->getDi()->errorLogTable->logException($ex); } echo '45000'; } else { parent::directAction($request, $response, $invokeArgs); } }
public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs) { if ($request->getActionName() == 'ipn') { $accessCode = $request->getFiltered('AccessCode'); $result = new Am_Paysystem_Result(); $transaction = new Am_Paysystem_Transaction_EwayRapid3($this, $accessCode); $transaction->run($result); if (!($invoice = $transaction->getInvoice())) { throw new Am_Exception_InputError(); } $this->_setInvoice($invoice); if ($result->isSuccess()) { Am_Controller::redirectLocation($this->getReturnUrl($invoice)); } else { Am_Controller::redirectLocation($this->getCancelUrl($invoice)); } } else { parent::directAction($request, $response, $invokeArgs); } }
public function updateAction() { $this->form = $this->createUpdateForm(); if ($this->form->isSubmitted() && $this->form->validate()) { $cc = $this->getDi()->ccRecordRecord; $this->form->toCcRecord($cc); $cc->user_id = $this->getDi()->auth->getUserId(); $result = new Am_Paysystem_Result(); $this->plugin->storeCreditCard($cc, $result); if ($result->isSuccess()) { return $this->redirectLocation(REL_ROOT_URL . '/member'); } else { $this->form->getElementById('cc_number-0')->setError($result->getLastError()); } } $this->view->form = $this->form; $this->view->invoice = null; $this->view->display_receipt = false; $this->view->display('cc/info.phtml'); }
public function __construct(Am_Di $di, array $config) { $this->defaultTitle = ___("CC Demo"); $this->defaultDescription = ___("use 4111-1111-1111-1111 for successful transaction"); parent::__construct($di, $config); }
public function cancelPaymentAction(\Am_Request $request, \Zend_Controller_Response_Http $response, array $invokeArgs) { $ret = parent::cancelPaymentAction($request, $response, $invokeArgs); foreach ($response->getHeaders() as $h) { if ($h['name'] == 'Location') { $redirect = $h['value']; } } if ($response->isRedirect()) { $response->clearAllHeaders()->clearBody(); $url = Am_Controller::escape($redirect); $response->setBody("<html>\n <head>\n <script type='text/javascript'>\n window.top.location.href = '{$url}';\n </script>\n </head>\n </html>\n "); } return $ret; }
public function cancelAction(Invoice $invoice, $actionName, Am_Paysystem_Result $result) { $this->cancelInvoice($invoice); parent::cancelAction($invoice, $actionName, $result); }
public function onSetupForms(Am_Event_SetupForms $event) { parent::onSetupForms($event); $event->getForm('paypal-pro')->removeElementByName('payment.' . $this->getId() . '.reattempt'); }
public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs) { $log = $this->logRequest($request); switch ($request->getActionName()) { case 'ipn': // first and rebill payments or subscription cancelled if ($this->getConfig('debugLog')) { Am_Di::getInstance()->errorLogTable->log('Payforit. Request[ipn]: ' . json_encode($request->getParams())); } if ($request->getInt('stop')) { if (!in_array($request->getClientIp(), Am_Paysystem_Payforit::$serverIPs)) { throw new Am_Exception_Paysystem_TransactionInvalid("Bad server IP [{$request->getClientIp()}]"); } $invoice = Am_Di::getInstance()->invoiceTable->findFirstByPublicId($request->getFiltered('key')); $invoice->setCancelled(true); return; } if ($request->getFiltered('status') == 'EXPIRED') { return header("HTTP/1.0 200 OK"); } $transaction = new Am_Paysystem_Transaction_Payforit($this, $request, $response, $invokeArgs); try { $transaction->process(); } catch (Exception $e) { $this->getDi()->errorLogTable->logException($e); return header("HTTP/1.0 400 Bad request"); } $this->invoice = $transaction->getInvoice(); $log->setInvoice($this->invoice)->update(); $response->setRedirect($this->getReturnUrl()); break; default: if ($this->getConfig('debugLog')) { Am_Di::getInstance()->errorLogTable->log('Payforit. Request[default]: ' . json_encode($request->getParams())); } return parent::directAction($request, $response, $invokeArgs); break; } }
public function __construct(Am_Di $di, array $config) { $this->defaultTitle = ___("Pay with your Credit Card"); $this->defaultDescription = ___("accepts all major credit cards"); parent::__construct($di, $config); }
public function init() { parent::init(); }
public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs) { switch ($request->getActionName()) { case self::RETURN_URL_SUCCESS: case self::RETURN_URL_FAIL: $log = $this->logRequest($request); $transaction = $this->createThanksTransaction($request, $response, $invokeArgs); $transaction->setInvoiceLog($log); try { $transaction->process(); } catch (Am_Exception_Paysystem_TransactionAlreadyHandled $e) { // ignore this error, as it happens in "thanks" transaction // we may have received IPN about the payment earlier } catch (Exception $e) { throw $e; $this->getDi()->errorLogTable->logException($e); throw Am_Exception_InternalError(___("Error happened during transaction handling. Please contact website administrator")); } $log->setInvoice($transaction->getInvoice())->update(); $this->invoice = $transaction->getInvoice(); $this->invoice->data()->set(self::DPS_BILLING_ID, $transaction->getDpsBillingId())->update(); $response->setRedirect($this->getReturnUrl()); break; default: parent::directAction($request, $response, $invokeArgs); } }
public function validate() { return parent::validate() && $this->plugin->onFormValidate($this); }
public function getFormOptions() { $ret = parent::getFormOptions(); $ret[] = self::CC_PHONE; return $ret; }
public function createForm() { $form = $this->plugin->createForm($this->_request->getActionName(), $this->invoice); $form->setDataSources(array($this->_request, new HTML_QuickForm2_DataSource_Array($form->getDefaultValues($this->invoice->getUser())))); return $form; }
public function getFormOptions() { return array_merge(parent::getFormOptions(), array(self::CC_CODE)); }
public function init() { parent::init(); $name = $this->addGroup()->setLabel(___("Cardholder Name\n" . 'cardholder first and last name, exactly as on the card')); $name->addRule('required', ___('Please enter debit card holder name')); $name_f = $name->addText('cc_name_f', array('size' => 15)); $name_f->addRule('required', ___('Please enter debit card holder first name'))->addRule('regex', ___('Please enter debit card holder first name'), '|^[a-zA-Z_\' -]+$|'); $name_l = $name->addText('cc_name_l', array('size' => 15)); $name_l->addRule('required', ___('Please enter debit card holder last name'))->addRule('regex', ___('Please enter debit card holder last name'), '|^[a-zA-Z_\' -]+$|'); $options = $this->plugin->getFormOptions(); $company = $this->addText('cc_company')->setLabel(___('Bank Code')); if ($this->formType == self::ADMIN_UPDATE) { $group = $this->addGroup()->setLabel(___('Debit Card Number'), ___('for example: 1111-2222-3333-4444')); $group->addStatic('cc'); $cc = $group->addText('cc_number', array('autocomplete' => 'off', 'size' => 22, 'maxlength' => 22, 'style' => 'display:none')); $cc->addRule('regex', ___('Invalid Debit Card Number'), '/^[0-9 -]+$/'); $group->addScript("")->setScript(<<<CUT \$(function(){ \$("input#cc_number-0").closest(".element").click(function(){ var input = \$("input#cc_number-0").detach(); \$(this).empty().append(input.show()); }); }); CUT ); } else { $cc = $this->addText('cc_number', array('autocomplete' => 'off', 'size' => 22, 'maxlength' => 22))->setLabel(___('Debit Card Number'), ___('for example: 1111-2222-3333-4444')); $cc->addRule('required', ___('Please enter Debit Card Number'))->addRule('regex', ___('Invalid Debit Card Number'), '/^[0-9 -]+$/'); } $fieldSet = $this->addFieldset(___('Address Info'))->setLabel(___("Address Info\n" . '(must match your debit card statement delivery address)')); $street = $fieldSet->addText('cc_street')->setLabel(___('Street Address'))->addRule('required', ___('Please enter Street Address')); $city = $fieldSet->addText('cc_city')->setLabel(___('City'))->addRule('required', ___('Please enter City')); $zip = $fieldSet->addText('cc_zip')->setLabel(___('ZIP'))->addRule('required', ___('Please enter ZIP code')); $country = $fieldSet->addSelect('cc_country')->setLabel(___('Country'))->setId('f_cc_country')->loadOptions(Am_Di::getInstance()->countryTable->getOptions(true)); $country->addRule('required', ___('Please enter Country')); $group = $fieldSet->addGroup()->setLabel(___('State')); $group->addRule('required', ___('Please enter State')); /** @todo load correct states */ $stateSelect = $group->addSelect('cc_state')->setId('f_cc_state')->loadOptions($stateOptions = Am_Di::getInstance()->stateTable->getOptions(@$_REQUEST['cc_country'], true)); $stateText = $group->addText('cc_state')->setId('t_cc_state'); $disableObj = $stateOptions ? $stateText : $stateSelect; $disableObj->setAttribute('disabled', 'disabled')->setAttribute('style', 'display: none'); // if free trial set _TPL_CC_INFO_SUBMIT_BUT2 $buttons = $this->addGroup(); $buttons->addSubmit('_cc_', array('value' => ' ' . $this->payButtons[$this->formType] . ' ')); if ($this->formType == self::USER_UPDATE) { $buttons->addInputButton('_cc_', array('value' => ' ' . ___("Back") . ' ', 'onclick' => 'goBackToMember()')); $this->addScript("")->setScript("function goBackToMember(){ window.location = window.rootUrl + '/member'; }"); } //$this->plugin->onFormInit($this); }
public function getFormOptions() { $ret = parent::getFormOptions(); $ret = array_diff($ret, array(self::CC_ADDRESS)); return $ret; }
public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs) { if ($request->getActionName() == 'iframe') { $p = $this->createController($request, $response, $invokeArgs); $p->setPlugin($this); $p->run(); return; } parent::directAction($request, $response, $invokeArgs); }