00001 <?php
00002
00016
00017
00018 import('payment.ocs.OCSQueuedPayment');
00019 import('payment.PaymentManager');
00020
00021 define('QUEUED_PAYMENT_TYPE_REGISTRATION', 0x000000001);
00022
00023 class OCSPaymentManager extends PaymentManager {
00024 function &getManager() {
00025 static $manager;
00026 if (!isset($manager)) {
00027 $manager = new OCSPaymentManager();
00028 }
00029 return $manager;
00030 }
00031
00032 function &createQueuedPayment($conferenceId, $schedConfId, $type, $userId, $assocId, $amount, $currencyCode) {
00033 $payment = new OCSQueuedPayment($amount, $currencyCode, $userId, $assocId);
00034 $payment->setConferenceId($conferenceId);
00035 $payment->setSchedConfId($schedConfId);
00036 $payment->setType($type);
00037 $payment->setRequestUrl(Request::url(null, null, 'payment', 'landing'));
00038 return $payment;
00039 }
00040
00041 function &getPaymentPlugin() {
00042 $schedConf =& Request::getSchedConf();
00043 $paymentMethodPluginName = $schedConf->getSetting('paymentMethodPluginName');
00044 $paymentMethodPlugin = null;
00045 if (!empty($paymentMethodPluginName)) {
00046 $plugins =& PluginRegistry::loadCategory('paymethod');
00047 if (isset($plugins[$paymentMethodPluginName])) $paymentMethodPlugin =& $plugins[$paymentMethodPluginName];
00048 }
00049 return $paymentMethodPlugin;
00050 }
00051
00057 function fulfillQueuedPayment($queuedPaymentId, &$queuedPayment) {
00058 if ($queuedPayment) switch ($queuedPayment->getType()) {
00059 case QUEUED_PAYMENT_TYPE_REGISTRATION:
00060 $registrationId = $queuedPayment->getAssocId();
00061 $registrationDao =& DAORegistry::getDAO('RegistrationDAO');
00062 $registration =& $registrationDao->getRegistration($registrationId);
00063 if (!$registration || $registration->getUserId() != $queuedPayment->getUserId() || $registration->getSchedConfId() != $queuedPayment->getSchedConfId()) {error_log(print_r($registration, true)); return false;}
00064
00065 $registration->setDatePaid(Core::getCurrentDate());
00066 $registrationDao->updateRegistration($registration);
00067
00068 $queuedPaymentDao =& DAORegistry::getDAO('QueuedPaymentDAO');
00069 $queuedPaymentDao->deleteQueuedPayment($queuedPaymentId);
00070 return true;
00071 }
00072 return false;
00073 }
00074 }
00075
00076 ?>