Ejemplo n.º 1
0
 function renderHtml()
 {
     $betaling = new VIH_Model_Betaling($this->context->name());
     $onlinebetaling = new VIH_Onlinebetaling('reversal');
     $eval = $onlinebetaling->reverse($betaling->get('transactionnumber'));
     if ($eval) {
         if (!empty($eval['qpstat']) and $eval['qpstat'] === '000') {
             if ($betaling->setStatus('cancelled')) {
                 $historik = new VIH_Model_Historik($betaling->get('belong_to'), $betaling->get('belong_to_id'));
                 $historik->save(array('type' => 'dankort', 'comment' => 'Reversal transaktion #' . $betaling->get('transactionnumber')));
             }
             return new k_SeeOther($this->context->url('../'));
         } else {
             // An error occured with the capture
             // Dumping return data for debugging
             /*
             echo "<pre>";
             var_dump($eval);
             echo "</pre>";
             */
             $historik = new VIH_Model_Historik($betaling->get('belong_to'), $betaling->get('belong_to_id'));
             $historik->save(array('type' => 'dankort', 'comment' => 'Fejl ved reverse af transaktion #' . $betaling->get('transactionnumber')));
             $betaling->setStatus('invalid');
             throw new Exception('Betalingen kunne ikke annulleres, formentlig fordi den er ugyldig');
         }
     } else {
         throw new Exception('Der var en kommunikationsfejl med Onlinebetalingen');
     }
 }
Ejemplo n.º 2
0
 function renderHtml()
 {
     $tilmelding = new VIH_Model_KortKursus_Tilmelding($this->name());
     if (is_numeric($this->query('sletdeltager'))) {
         $deltager = new VIH_Model_KortKursus_Tilmelding_Deltager($tilmelding, $this->query('sletdeltager'));
         $deltager->delete();
     } elseif ($this->query('action') == 'sendemail') {
         if ($tilmelding->sendEmail()) {
             $historik = new VIH_Model_Historik('kortekurser', $tilmelding->get('id'));
             if (!$historik->save(array('type' => 'kode', 'comment' => 'Kode sendt med e-mail'))) {
                 throw new Exception('Historikken kunne ikke gemmes');
             }
         } else {
             throw new Exception('E-mailen kunne ikke sendes');
         }
     }
     if ($this->query('slet_historik_id')) {
         $historik = new VIH_Model_Historik(intval($this->query('slet_historik_id')));
         $historik->delete();
     }
     $deltagere = $tilmelding->getDeltagere();
     $historik_object = new VIH_Model_Historik('kortekurser', $tilmelding->get("id"));
     $betalinger = new VIH_Model_Betaling('kortekurser', $tilmelding->get("id"));
     if ($this->query('registrer_betaling')) {
         if ($betalinger->save(array('type' => 'giro', 'amount' => $this->query('beloeb')))) {
             $betalinger->setStatus('approved');
             return new k_SeeOther($this->url());
         } else {
             throw new Exception("Betalingen kunne ikke gemmes. Det kan skyldes et ugyldigt beløb");
         }
     }
     $tilmelding->loadBetaling();
     $this->document->setTitle('Tilmelding #' . $tilmelding->getId());
     $this->document->addOption('Tilbage til liste', $this->url('../'));
     $this->document->addOption('Ret', $this->url('edit'));
     $this->document->addOption('Slet', $this->url(null, array('delete')));
     if ($tilmelding->get('email')) {
         $this->document->addOption('E-mail', $this->url('email'));
     }
     $this->document->addOption('Kundens side', KORTEKURSER_LOGIN_URI . $tilmelding->get('code'));
     $data = array('deltagere' => $deltagere, 'indkvartering' => !$tilmelding->kursus->isFamilyCourse(), 'type' => $tilmelding->get('keywords'), 'vis_slet' => 'ja');
     $historik = array('historik' => $historik_object->getList(), 'tilmelding' => $tilmelding);
     $historik_tpl = $this->templates->create('tilmelding/historik');
     $betaling_data = array('caption' => 'Afventende betalinger', 'betalinger' => $betalinger->getList('not_approved'), 'msg_ingen', 'Der er ingen afventende betalinger.');
     $prisoversigt_data = array('tilmelding' => $tilmelding);
     $prisoversigt_tpl = $this->templates->create('kortekurser/tilmelding/prisoversigt');
     $deltager_tpl = $this->templates->create('kortekurser/deltagere');
     $betaling_tpl = $this->templates->create('tilmelding/betalinger');
     $tilmelding = array('tilmelding' => $tilmelding, 'historik_object' => $historik_object, 'deltagere' => $deltager_tpl->render($this, $data), 'status' => $tilmelding->get('status'), 'prisoversigt' => $prisoversigt_tpl->render($this, $prisoversigt_data), 'historik' => $historik_tpl->render($this, $historik), 'betalinger' => $betaling_tpl->render($this, $betaling_data));
     $tpl = $this->templates->create('kortekurser/tilmelding');
     return $tpl->render($this, $tilmelding);
 }
Ejemplo n.º 3
0
 /**
  * NOTICE: First we need to make a local payment, so we have a
  * local id to use for capture at quickpay.
  * When the payment has been captured we set status = 000
  */
 function postForm()
 {
     $tilmelding = VIH_Model_KortKursus_Tilmelding::factory($this->context->name());
     if ($this->getForm()->validate()) {
         $eval = false;
         $betaling = new VIH_Model_Betaling("kortekurser", $tilmelding->get("id"));
         $betaling_amount = $this->body('amount') / 100;
         $betaling_id = $betaling->save(array('type' => 'quickpay', 'amount' => $betaling_amount));
         if ($betaling_id == 0) {
             throw new Exception("Kunne ikke oprette betaling");
         }
         $onlinebetaling = new VIH_Onlinebetaling('authorize');
         $onlinebetaling->addCustomVar("Kursusnavn", "Kortkursus: " . $tilmelding->kursus->getKursusNavn());
         $onlinebetaling->addCustomVar("Kontaktnavn", $tilmelding->get("navn"));
         $onlinebetaling->addCustomVar("Tilmelding_ID", $tilmelding->get("id"));
         $eval = $onlinebetaling->authorize($this->body('cardnumber'), $this->body('yy') . $this->body('mm'), $this->body('cvd'), $betaling_id, $this->body('amount'));
         if ($eval) {
             if ($eval['qpstat'] === '000') {
                 // The authorization was completed
                 $betaling->setTransactionnumber($eval['transaction']);
                 $betaling->setStatus('completed');
                 $historik = new VIH_Model_Historik($betaling->get('belong_to'), $betaling->get('belong_to_id'));
                 if (!$historik->save(array('betaling_id' => $betaling->get('id'), 'type' => 'dankort', 'comment' => 'Onlinebetaling # ' . $betaling->get('transactionnumber')))) {
                     throw new Exception('Der var en fejl med at gemme historikken.');
                 }
                 return new k_SeeOther($this->context->url());
             } else {
                 // An error occured with the authorize
                 $this->extra_text = '<p class="warning">Der opstod en fejl under transaktionen. ' . $onlinebetaling->statuskoder[$eval['qpstat']] . '. Du kan prøve igen.</p>';
             }
         } else {
             $this->extra_text = 'Kommunikationsfejl med PBS eller QuickPay';
         }
     }
     return $this->render();
 }
 }
 $onlinebetaling = new VIH_Onlinebetaling('authorize');
 $onlinebetaling->addCustomVar('Elevforeningsmedlem', $contact['number']);
 $onlinebetaling->addCustomVar('Kontaktid', $contact['id']);
 $eval = $onlinebetaling->authorize($form->exportValue('cardnumber'), $form->exportValue('yy') . $form->exportValue('mm'), $form->exportValue('cvd'), $betaling_id, $betaling_amount_quickpay);
 if ($eval) {
     if ($eval['qpstat'] === '000') {
         // The authorization was completed
         /*
         echo 'Authorization: ' . $qpstatText["" . $eval['qpstat'] . ""] . '<br />';
         echo "<pre>";
         var_dump($eval);
         echo "</pre>";
         */
         $betaling->setTransactionnumber($eval['transaction']);
         $betaling->setStatus('completed');
         $historik = new VIH_Model_Historik($betaling->get('belong_to'), $betaling->get('belong_to_id'));
         if (!$historik->save(array('type' => 'dankort', 'comment' => 'Onlinebetaling # ' . $betaling->get('transactionnumber')))) {
             trigger_error('Der var en fejl med at gemme historikken.', E_USER_ERROR);
         }
         $data = array('belong_to' => 'order', 'belong_to_id' => $order_id, 'transaction_number' => $eval['transaction'], 'transaction_status' => $eval['qpstat'], 'pbs_status' => $eval['pbsstat'], 'amount' => $betaling_amount);
         $client->saveOnlinePayment($data);
         //$client->addOnlinePayment($order_id, $eval['transaction'], $eval['qpstat'], $betaling_amount);
         header("Location: index.php");
         exit;
     } else {
         // An error occured with the authorize
         $error = '<p class="warning">Der opstod en fejl under transaktionen. ' . $onlinebetaling->statuskoder[$eval['qpstat']] . '. Du kan prøve igen.</p>';
         /*
         echo 'Authorization: ' . $qpstatText["" . $eval['qpstat'] . ""] . '<br />';
         echo "<pre>";
Ejemplo n.º 5
0
 function renderHtml()
 {
     $tilmelding = $this->getTilmelding();
     if ($this->query('get_prices')) {
         if (!$tilmelding->getPriserFromKursus()) {
             throw new Exception('Priser kunne ikke hentes');
         } else {
             return new k_SeeOther($this->url());
         }
     }
     $historik = new VIH_Model_Historik('langekurser', $tilmelding->get("id"));
     $betalinger = new VIH_Model_Betaling('langekurser', $tilmelding->get("id"));
     $rater = $tilmelding->getRater();
     if ($this->query('action') == 'sendemail') {
         if ($tilmelding->sendEmail()) {
             if (!$historik->save(array('type' => 'kode', 'comment' => 'Kode sendt med e-mail'))) {
                 throw new Exception('Historikken kunne ikke gemmes');
             }
         } else {
             throw new Exception('E-mailen kunne ikke sendes');
         }
     } elseif ($this->query('action') == 'opretrater') {
         if (!$tilmelding->opretRater()) {
             throw new Exception('Raterne kunne ikke oprettes');
         } else {
             return new k_SeeOther($this->url());
         }
     } elseif ($this->query('registrer_betaling')) {
         if ($betalinger->save(array('type' => 'giro', 'amount' => $this->query('beloeb')))) {
             $betalinger->setStatus('approved');
         } else {
             throw new Exception("Betalingen kunne ikke gemmes. Det kan skyldes et ugyldigt beløb");
         }
     } elseif ($this->query('slet_historik_id')) {
         $historik = new VIH_Model_Historik(intval($this->query('slet_historik_id')));
         $historik->delete();
     }
     $tilmelding->loadBetaling();
     $this->document->setTitle('Tilmelding #' . $tilmelding->get('id'));
     $this->document->addOption('Til kursus', $this->url('../../' . $tilmelding->kursus->get('id')));
     $this->document->addOption('Tilmeldinger', $this->url('../../' . $tilmelding->kursus->get('id') . '/tilmeldinger'));
     $this->document->addOption('Ret', $this->url(null, array('edit')));
     $this->document->addOption('Delete', $this->url(null, array('delete')));
     $this->document->addOption('Protokol', $this->url('../../../protokol/holdliste/' . $tilmelding->get('id')));
     $this->document->addOption('Brev', $this->url('brev'));
     $this->document->addOption('F*g', $this->url('f*g'));
     $this->document->addOption('Diplom', $this->url('diplom'));
     $this->document->addOption('Kundens side', LANGEKURSER_LOGIN_URI . $tilmelding->get('code'));
     $opl_data = array('tilmelding' => $tilmelding);
     $pris_data = array('tilmelding' => $tilmelding);
     $betal_data = array('betalinger' => $betalinger->getList('not_approved'), 'caption' => 'Betalinger');
     $hist_data = array('tilmelding' => $tilmelding, 'historik' => $historik->getList());
     $opl_tpl = $this->templates->create('langekurser/tilmelding/oplysninger');
     $pris_tpl = $this->templates->create('langekurser/tilmelding/prisoversigt');
     $betal_tpl = $this->templates->create('tilmelding/betalinger');
     $his_tpl = $this->templates->create('tilmelding/historik');
     $data = array('tilmelding' => $tilmelding, 'oplysninger' => $opl_tpl->render($this, $opl_data), 'prisoversigt' => $pris_tpl->render($this, $pris_data), 'betalinger' => $betal_tpl->render($this, $betal_data), 'historik' => $his_tpl->render($this, $hist_data));
     // rater
     if (count($rater) > 0) {
         $rater_tpl = $this->templates->create('langekurser/tilmelding/rater');
         $rater_data = array('tilmelding' => $tilmelding);
         $data['rater'] = $rater_tpl->render($this, $rater_data);
     } else {
         if ($tilmelding->kursus->antalRater() > 0) {
             $data['rater'] = '<p><a href="' . $this->url(null, array('get_prices' => $tilmelding->get('id'))) . '">Hent priserne fra kurset</a>. Der er endnu ikke oprettet nogen rater <a href="' . $this->url(null, array('action' => 'opretrater')) . '">Opret &rarr;</a></p>';
         } else {
             $data['rater'] = '<p>Der er endnu ikke oprettet rater på selve kurset. Dem skal du lige oprette først <a href="' . $this->url('../../' . $tilmelding->getKursus()->get('id') . '/rater') . '">Opret &rarr;</a></p>';
         }
     }
     $data['message'] = '';
     $tpl = $this->templates->create('langekurser/tilmelding');
     return $tpl->render($this, $data);
 }