public function pendingAction() { $paidCharges = $_GET['external_reference']; $status = $_GET['collection_status']; $status = $this->getStatusChar($status); $collection_id = $_GET['collection_id']; $entity = $_GET['payment_type']; $paidCharges = explode(',', $paidCharges); foreach ($paidCharges as $charge_id) { $charge = new PAP_Model_Charge(); $charge->loadById($charge_id); $charge->setStatus($status); $charge->save(); $payment = new PAP_Model_Payment(); $payment->setAmount($charge->getAmount())->setControl($collection_id)->setChargeId($charge->getId())->setMethodId('MP')->setPaymentDate(date('Y-m-d H:i:s'))->setEntity($entity); $payment->save(); } }
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); } }
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; }