示例#1
0
 public function processPdt($get)
 {
     if (isset($get['tx']) && isset($get['st']) && strtolower($get['st']) == 'completed') {
         $db = new DBHandler();
         $db->connect();
         $paypal = new Paypal();
         $data = $paypal->pdt($get['tx']);
         // Datas
         $u = new Utility();
         $params = array();
         $items = array();
         //            if ((isset($data['option_selection20']) && $data['option_selection20'] != '') && (isset($data['option_selection21']) && $data['option_selection21'] != '')) {
         //                $params = $u->processBookingPaypalData($data);
         //                $params['couponCode'] = $db->retrieveLeadLastId() . 'SEDA' . $u->generateBookingCode();
         //                // Items
         //                $items = $u->processBookingPaypalItems($data);
         //            } else {
         $params = $u->processPaypalData($data);
         $params['couponCode'] = $db->retrieveLeadLastId() . $u->generateCode();
         // Items
         $items = $u->processPaypalItems($data);
         //            }
         // End of Datas
         if (DEBUG == true) {
             $datas = implode(",", $params);
             error_log(date('[Y-m-d H:i e] ') . "Save Data Leads in PDT: {$datas}" . PHP_EOL, 3, DATA_LOG);
         }
         $lead = array();
         $check = $db->retrieveLeadByTxnId($get['tx']);
         if (!$check) {
             //                if ((isset($data['option_selection20']) && $data['option_selection20'] != '') && (isset($data['option_selection21']) && $data['option_selection21'] != '')) {
             //                    $db->insertBookLead($params, $items);
             //                    if ($params['singlet'] == 'XS') {
             //                        $db->updateInventory();
             //                    }
             //                } else {
             $db->insertLead($params, $items);
             if ($params['singlet'] == 'XS') {
                 $db->updateInventory();
             }
             //                }
             //
             //                $analytics = new Analytics;
             //                $analytics->ga($params, $items);
             //
             //                $now = new DateTime();
             //                $params['date_added'] = $now->format('Y-m-d G:i:s');
             //
             //                $mail = new MailerHandler();
             //                $mail->sendMail($params);
             //
             //
             //                $sms = new SMS();
             //                $sms->sendSms($params['contact'],$get['tx']);
             //                if ((isset($data['option_selection20']) && $data['option_selection20'] != '') && (isset($data['option_selection21']) && $data['option_selection21'] != '')) {
             //                    $mail->sendMailToSeda($params);
             //                }
             //$bm = new BenchmarkHandler;
             //$bm->addOnlineLeadToBenchmark($params);
             $now = new DateTime();
             $params['date_added'] = $now->format('Y-m-d G:i:s');
             $lead = $params;
         } else {
             //                $book = $db->retrieveBookingByLeadId($check['id']);
             //                if ($book) {
             //                    $check['revenue'] = $book['total_payment'];
             //                    $check['check_in'] = $book['check_in'];
             //                    $check['check_out'] = $book['check_out'];
             //                    $check['booked_room'] = $book['booked_room'];
             //                    $check['max'] = $book['max'];
             //                    $check['hotel'] = $book['hotel'];
             //                    $check['days'] = $book['days'];
             //                }
             //                $lead = $check;
         }
         //            $ss = new SpreadsheetHandler;
         //            $duplicate = $ss->isEntryDuplicate($get['tx']);
         //            if (!$duplicate) {
         //                $ss->addLeadToDocs($params);
         //                if ((isset($data['option_selection20']) && $data['option_selection20'] != '') && (isset($data['option_selection21']) && $data['option_selection21'] != '')) {
         //                    $ss->addHotelBookingToDocs($params);
         //                }
         //            }
         if ($lead) {
             // Go to Thank you page.
             return $lead;
         } else {
             // Go to failed or pending page
             return array();
         }
     } else {
         return false;
     }
 }