Пример #1
0
 public static function buyTicket($date, $time, $visa)
 {
     // call payment service
     // confirm ticket availability and call make payment
     if (TicketService::checkAvailability($date, $time) && PaymentService::makePayment($visa)) {
         return true;
     } else {
         return false;
     }
 }
 public function setUp()
 {
     parent::setUp();
     Payment::config()->allowed_gateways = array('PayPal_Express', 'PaymentExpress_PxPay', 'Manual', 'Dummy');
     Payment::config()->parameters = array('PaymentExpress_PxPay' => array('username' => 'EXAMPLEUSER', 'password' => '235llgwxle4tol23l'));
     //set up a payment here to make tests shorter
     $this->payment = Payment::create()->setGateway("Dummy")->setAmount(1222)->setCurrency("GBP");
     PaymentService::set_http_client($this->getHttpClient());
     PaymentService::set_http_request($this->getHttpRequest());
 }
Пример #3
0
 function filterPayment($paymentMethods)
 {
     if (isCorporateUser()) {
         $paymentMethods = PaymentService::getPaymentProcessors(false);
         foreach ($paymentMethods as $i => $paymentMethod) {
             if (!($paymentMethod->type == "cash")) {
                 unset($paymentMethods[$i]);
             }
         }
     }
     return $paymentMethods;
 }
 public function setUp()
 {
     parent::setUp();
     ShopTest::setConfiguration();
     //set supported gateways
     Payment::config()->allowed_gateways = array('Dummy', 'Manual', 'PaymentExpress_PxPay', 'PaymentExpress_PxPost');
     PaymentService::set_http_client($this->getHttpClient());
     PaymentService::set_http_request($this->getHttpRequest());
     //publish products
     $this->objFromFixture("Product", "socks")->publish('Stage', 'Live');
     $this->objFromFixture("CheckoutPage", "checkout")->publish('Stage', 'Live');
     $this->objFromFixture("CartPage", "cart")->publish('Stage', 'Live');
 }
Пример #5
0
 /**
  * Get payment methods
  * @return multitype:unknown
  */
 function getPaymentMethods()
 {
     $paymentMethods = PaymentService::getPaymentProcessors();
     return $paymentMethods;
 }
Пример #6
0
 /**
  * Method to save the form data.
  *
  * @param   array  The form data.
  * @return  boolean  True on success.
  */
 public function save($data)
 {
     $id = !empty($data['reservationId']) ? $data['reservationId'] : (int) $this->getState('reservation.id');
     $isNew = empty($id);
     $reservationDetails = $this->getReservationDetails($data);
     //dmp($reservationDetails);
     //exit;
     require_once JPATH_COMPONENT_SITE . '/models/confirmation.php';
     $confirmationModel = new JHotelReservationModelConfirmation();
     $reservaitonId = $confirmationModel->saveConfirmation($reservationDetails);
     if ($isNew && $reservaitonId != -1) {
         $reservationDetails->confirmation_id = $reservaitonId;
         $processor = PaymentService::createPaymentProcessor(PROCESSOR_CASH);
         $paymentDetails = $processor->processTransaction($reservationDetails);
         PaymentService::addPayment($paymentDetails);
     }
     if ($reservaitonId != -1) {
         $this->setState('reservation.id', $reservaitonId);
     } else {
         $this->setState('reservation.id', $id);
         $this->setError($confirmationModel->getError());
         return false;
     }
     // Clean the cache
     $this->cleanCache();
     return true;
 }
Пример #7
0
 function processAutomaticResponse()
 {
     $this->log->LogDebug("process automatic response");
     $data = JRequest::get('post');
     $this->log->LogDebug(serialize($data));
     $processorType = JRequest::getVar("processor");
     $processor = PaymentService::createPaymentProcessor($processorType);
     $paymentDetails = $processor->processResponse($data);
     $this->log->LogDebug("Payment Details: " . serialize($paymentDetails));
     if (empty($paymentDetails->confirmation_id)) {
         return;
     }
     $intialPaymentDetails = PaymentService::getConfirmationPaymentDetails($paymentDetails->confirmation_id);
     $this->log->LogDebug("Initial payment details: " . serialize($intialPaymentDetails));
     if ($intialPaymentDetails->payment_status == PAYMENT_STATUS_PAID) {
         return;
     }
     //prevent e-mails to be send again to hotels and customers
     if ($intialPaymentDetails->payment_status == $paymentDetails->payment_status) {
         header("HTTP/1.1 200 OK");
         return;
     }
     //check if the response is a reponse for a waiting transaction
     $sendMailOnlyToAdmin = $intialPaymentDetails->payment_status == PAYMENT_STATUS_WAITING && $paymentDetails->payment_status == PAYMENT_STATUS_PAID;
     $this->log->LogDebug("Send only to admin " . serialize($sendMailOnlyToAdmin));
     PaymentService::updatePayment($paymentDetails);
     if ($paymentDetails->status == PAYMENT_CANCELED || $paymentDetails->status == PAYMENT_ERROR) {
         BookingService::cancelReservation($paymentDetails->confirmation_id);
     } else {
         $confirmationModel = $this->getModel("Confirmation");
         $reservationDetails = $confirmationModel->getReservation($paymentDetails->confirmation_id);
         EmailService::sendConfirmationEmail($reservationDetails, $sendMailOnlyToAdmin);
         //check if hotels has more rooms available
         $hotelId = $reservationDetails->reservationData->userData->hotelId;
         $startDate = $reservationDetails->reservationData->userData->start_date;
         $endDate = $reservationDetails->reservationData->userData->end_date;
         $isHotelAvailable = HotelService::checkAvailability($hotelId, $startDate, $endDate);
         if (!$isHotelAvailable) {
             EmailService::sendNoAvailabilityEmail($hotelId, $startDate, $endDate);
         }
     }
     //http_response_code(200);
     header("HTTP/1.1 200 OK");
 }
 function getPaymentInformation($paymentDetails, $amount, $cost)
 {
     $processor = PaymentService::createPaymentProcessor($paymentDetails->processor_type);
     ob_start();
     echo "<ul style='margin:0px;padding-left: 0;list-style:none'>";
     echo "<li style='margin-left: 0px'>";
     echo $processor->getPaymentDetails($paymentDetails, $amount, $cost);
     echo "</li>";
     echo "</ul>";
     $buff = ob_get_contents();
     ob_end_clean();
     return $buff;
 }
Пример #9
0
 /**
  * Set the symphony http request (for testing)
  * @param Symfony\Component\HttpFoundation\Request $httpRequest symphony http request for testing
  */
 public static function set_http_request(Symfony\Component\HttpFoundation\Request $httpRequest)
 {
     self::$httprequest = $httpRequest;
 }
Пример #10
0
 function processAutomaticResponse()
 {
     $this->log->LogDebug("process automatic response");
     $data = JRequest::get('post');
     $this->log->LogDebug(serialize($data));
     $processorType = JRequest::getVar("processor");
     $this->log->LogDebug("Processor: " . $processorType);
     $processor = PaymentService::createPaymentProcessor($processorType);
     $paymentDetails = $processor->processResponse($data);
     $this->log->LogDebug("Payment Details: " . serialize($paymentDetails));
     if (empty($paymentDetails->order_id)) {
         $this->log->LogDebug("Empty order Id");
         return;
     }
     $intialPaymentDetails = PaymentService::getPaymentDetails($paymentDetails->order_id);
     $this->log->LogDebug("Initial payment details: " . serialize($intialPaymentDetails));
     if ($intialPaymentDetails->payment_status == PAYMENT_STATUS_PAID) {
         $this->log->LogDebug("order has been already paid");
         //return;
     }
     PaymentService::updatePayment($paymentDetails);
     if ($paymentDetails->status == PAYMENT_CANCELED || $paymentDetails->status == PAYMENT_ERROR) {
     } else {
         $orderModel = $this->getModel("Orders");
         $order = $orderModel->updateOrder($paymentDetails, $processor);
         $paymentModel = $this->getModel("Payment");
         $paymentModel->sendPaymentEmail($paymentDetails);
     }
 }
 /**
  * Calls the PagSeguro web service and register this request for payment
  * 
  * @param Credentials $credentials
  * @return The URL to where the user needs to be redirected to in order to complete the payment process
  */
 public function register(Credentials $credentials)
 {
     return PaymentService::createCheckoutRequest($credentials, $this);
 }