public function getPaymentByControl($control, $method_id, PAP_Model_Payment $payment) { $adapter = Zend_Db_Table::getDefaultAdapter(); $statement = "SELECT p.* FROM payment p WHERE p.control = '" . $control . "' AND p.method_id = '" . $method_id . "';"; $result = $adapter->fetchAll($statement); if (isset($result)) { $payment->setId($result->payment_id)->setChargeId($result->charge_id)->setAmount($result->amount)->setStatus($result->status)->setControlId($result->control_id)->setPaymentType($result->payment_type)->setInfo($result->info)->setCreated($result->created); } else { return false; } return true; }
public function sendpaymentAction() { $this->_helper->layout->setLayout('json'); $callback = $this->getRequest()->getParam('jsoncallback'); if ($callback != "") { // strip all non alphanumeric elements from callback $callback = preg_replace('/[^a-zA-Z0-9_]/', '', $callback); } $this->view->callback = $callback; $data = $this->_getParam("data"); $payment_json = $data['data'][0]; $charges = $payment_json['charges_ids']; $charges = explode(',', $charges); try { foreach ($charges as $charge_id) { $charge = new PAP_Model_Charge(); $charge->loadById($charge_id); $payment = new PAP_Model_Payment(); $payment->setAmount($charge->getAmount())->setChargeId($charge->getId())->setControl($payment_json['nro_tx'])->setMethodId($payment_json['operacion'])->setPaymentDate($payment_json['fecha']); if ($payment_json['operacion'] == "T") { $payment->setEntity($payment_json['banco_origen']); } else { $payment->setEntity($payment_json['banco_destino']); } $payment->save(); $charge->setStatus('S'); $charge->save(); } $data = array(); $data['result_code'] = '0'; $data['result_message'] = 'Información del pago informada guardada con éxito.'; $response = $this->getFrontController()->getResponse(); $response->appendBody($callback . '(' . json_encode($data) . ')'); $this->getFrontController()->setResponse($response); } catch (Exception $ex) { $data = array(); $data['result_code'] = $ex->getCode(); $data['result_message'] = 'Hubo un error guardando la información del pago. Por favor envíe un email a soporte@promosalpaso.com con dicha información.'; $response = $this->getFrontController()->getResponse(); $response->appendBody($callback . '(' . json_encode($data) . ')'); $this->getFrontController()->setResponse($response); } }
private function getPendingPayments(PAP_Model_User $user = null) { $payments = array(); $unpaidCharges = PAP_Model_Charge::getUnpaidCharges($user); $periods = array(); foreach ($unpaidCharges as $charge) { $period = new PAP_Model_Period(); $period->loadByCode($charge->getPeriod()); $periods[$charge->getId()] = $period; } if (!isset($user)) { $payments = PAP_Model_Payment::getAllPayments($periods); } else { $payments = PAP_Model_Payment::getPayments($user, $periods); } return $payments; }
public static function getPendigPaymentsMP($user_id = 0) { $result = array(); $mapper = new PAP_Model_PaymentMapper(); $payments = $mapper->getPendingPayments('MP', $user_id); foreach ($payments as $payment_record) { $payment = new PAP_Model_Payment(); $payment->setAmount($payment_record['amount'])->setChargeId($payment_record['charge_id'])->setControl($payment_record['control'])->setCreated($payment_record['created'])->setEntity($payment_record['entity'])->setId($payment_record['payment_id'])->setMethodId($payment_record['method_id'])->setPaymentDate($payment_record['payment_date'])->setStatus($payment_record['status']); $result[] = $payment; } return $result; }
public function getTotalPromoCost() { return PAP_Model_Payment::getGrandTotal($this); }