function renderHtml() { $betaling = new VIH_Model_Betaling($this->context->name()); $onlinebetaling = new VIH_Onlinebetaling('capture'); $eval = $onlinebetaling->capture($betaling->get('transactionnumber'), (int) $betaling->get('amount') * 100); if ($eval) { if (!empty($eval['qpstat']) and $eval['qpstat'] === '000') { if ($betaling->setStatus('approved')) { $historik = new VIH_Model_Historik($betaling->get('belong_to'), $betaling->get('belong_to_id')); $historik->save(array('type' => 'dankort', 'comment' => 'Capture 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 capture af transaktion #' . $betaling->get('transactionnumber'))); throw new Exception('Betalingen kunne ikke hæves, formentlig fordi den er ugyldig'); } } else { throw new Exception('Der var en kommunikationsfejl med Onlinebetalingen'); } return 'error'; }
/** * 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>"; var_dump($eval);