public function executeCheck(sfWebRequest $request) { $eventReservation = $this->getUser()->getAttribute('eventReservation'); $event = EventPeer::retrieveByPK($eventReservation['event_id']); $card_number = $eventReservation['credit_card_no']; $security_code = $eventReservation['security_code']; //transection check $month = $eventReservation['expiration_month']; $year = $eventReservation['expiration_year']; $cardnumber = str_replace('-', '', $card_number); $ccardcode = $security_code; //find out total amount $adult_per_cost = $event->getAdultCost(); $child_per_cost = $event->getChildCost(); $adult_guests = $eventReservation['adult_guests']; $child_guests = $eventReservation['child_guests']; $total_adult_cost = $adult_per_cost * $adult_guests; $total_child_cost = $child_per_cost * $child_guests; $total = $adult_per_cost + $total_adult_cost + $total_child_cost; //end total $payment = new afids_paymentGateway(); $payment->gateway_name = "novapointe"; $payment->transaction_type = "sale"; $item_data = "&total=" . $total; $item_data .= "&tax=" . 0; $item_data .= "&bill_first_name=" . $eventReservation['first_name']; $item_data .= "&bill_last_name=" . $eventReservation['last_name']; $item_data .= "&bill_address1=" . $eventReservation['address']; $item_data .= "&bill_city=" . $eventReservation['city']; $item_data .= "&bill_state=" . $eventReservation['state']; $item_data .= "&bill_zip=" . $eventReservation['zipcode']; $item_data .= "&bill_country=" . $eventReservation['country']; $item_data .= "&bill_phone=" . $eventReservation['phone']; $item_data .= "&ccard=" . $cardnumber; $item_data .= "&expmonth=" . $month; $item_data .= "&expyear=" . $year; $item_data .= "&cvv2=" . $ccardcode; $payment->item_data = $item_data; $payment->shipping_code = "USPS"; $data = json_decode($payment->submitPayment()); if ($data->http_result == 'success' && $data->transaction_result == 'success') { # send email $this->getComponent('mail', 'EventReservationSuccessMail', array('first_name' => $eventReservation['first_name'], 'email' => $eventReservation['email'], 'event_name' => $event->getEventName(), 'date' => $event->getEventDate(), 'time' => $event->getEventTime(), 'location' => $event->getLocation(), 'Adult_guest' => $eventReservation['adult_guests'], 'child_guest' => $eventReservation['child_guests'], 'total_amount' => $total)); //saving date to event_reservation table $date = date(); //find out member $query = "select member.id from member,person where member.person_id=person.id and person.first_name ='" . trim($eventReservation['first_name']) . "' and person.last_name='" . trim($eventReservation['last_name']) . "' and person.city='" . trim($eventReservation['city']) . "' and person.state='" . trim($eventReservation['state']) . "' and person.zipcode='" . trim($eventReservation['zipcode']) . "' and person.email='" . trim($eventReservation['email']) . "' limit 1"; $conn = Propel::getConnection(); $statement = $conn->prepare($query); $statement->execute(); $row = $statement->fetch(PDO::FETCH_ASSOC); if (!empty($row)) { $member_id = $row['id']; } else { $member_id = NULL; } //end find member $event_reservaton = new EventReservation(); $event_reservaton->setEventId($eventReservation['event_id']); $event_reservaton->setMemberId($member_id); $event_reservaton->setReservationDate($date); $event_reservaton->setFirstName($eventReservation['first_name']); $event_reservaton->setLastName($eventReservation['last_name']); $event_reservaton->setAddress($eventReservation['address']); $event_reservaton->setCity($eventReservation['city']); $event_reservaton->setState($eventReservation['state']); $event_reservaton->setZipcode($eventReservation['zipcode']); $event_reservaton->setPhone($eventReservation['phone']); $event_reservaton->setEmail($eventReservation['email']); $event_reservaton->setAdultGuests($eventReservation['adult_guests']); $event_reservaton->setChildGuests($eventReservation['child_guests']); $event_reservaton->setGuestNames($eventReservation['guest_names']); $event_reservaton->setAmtPaid($total); $event_reservaton->setPaymentDate($date); $event_reservaton->setAuthNumber($data->ccard_approval_number); $event_reservaton->setStatus('success'); $event_reservaton->setNovapointeTransId($data->transaction_id); $event_reservaton->save(); //decrement max person $remaning_people = $event->getMaxPersons(); $remaning_people = $remaning_people - 1; $event->setMaxPersons($remaning_people); $event->save(); //end //end of event event_reservation entry $this->redirect('eventReservation/thankyou'); } else { $this->getUser()->setFlash('warning', 'Event reservation Transaction failed. Please check your credit card information.'); $this->redirect('eventReservation/step3'); } //transection check end }