示例#1
0
 public function processPurchase($post, $request, $server, $cookie)
 {
     if (isset($post) && isset($server) && isset($request) && $server['REQUEST_METHOD'] == 'POST') {
         $db = new DBHandler();
         $db->connect();
         $lead = array();
         // Datas
         $u = new Utility();
         $request = array_merge($request, $cookie);
         $coupon = strtoupper($request['coupon_code']);
         $branch = isset($request['tnfbranch']) ? $request['tnfbranch'] : $request['branch'];
         $request['txn_id'] = $u->generateTransactionReceipt($branch, $coupon) . $db->retrieveBuyerLastId();
         $params = $u->processPurchaseData($request);
         $params['couponCode'] = $coupon;
         // Items
         $items = $u->processPurchaseItems($request);
         // End of Datas
         $ss = new SpreadsheetHandler();
         $ss->addPurchaseToDocs($items, $params);
         $db->insertBuyer($coupon, $params, $items);
         $analytics = new Analytics();
         $analytics->ga($params, $items);
         $userfname = isset($request['userfname']) ? $request['userfname'] : "";
         $userlname = isset($request['userlname']) ? $request['userlname'] : "";
         $logparams = array("action" => "Coupon Redemption", "module" => "TNF Microsite " . $branch, "content" => $userfname . " " . $userlname . " from " . $branch . " process a promo coupon redemption with promo code " . $coupon, 'ip' => $server['REMOTE_ADDR']);
         $db->updateLogs(0, $logparams, $userfname, $userlname);
         return $params;
     } else {
         return false;
     }
 }