function doCheckBuyAndDownload($config) { $objFormParam = new SC_FormParam(); $this->lfInitParam($objFormParam); $objFormParam->setParam($_REQUEST); $objCustomer = new SC_Customer_Ex(); $objQuery = SC_Query::getSingletonInstance(); $detect = new Mobile_Detect(); $version = $detect->version("iOS", Mobile_Detect::VERSION_TYPE_FLOAT); $contentid = $this->arrProduct["product_code_min"]; $curl = $this->curl_init(KISEKAE_TOUCH_IPHONE_API01); $post = $this->getPost($config, array("contentid" => $contentid, "device" => $objFormParam->getValue("device_name", "iPhone6"), "version" => floor($version), "apiversion" => null, "operator" => "au", "lang" => "ja")); $this->getDs($post, $config); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post)); GC_Utils_Ex::gfPrintLog(print_r($post, TRUE), DEBUG_LOG_REALFILE); $result = curl_exec($curl); $status = SC_XML::xpath($result, "//status/@value"); $vid = SC_XML::xpath($result, "//validation/@id"); switch ($status) { default: SC_Utils_Ex::sfDispSiteError(PAGE_ERROR); case "000": GC_Utils_Ex::gfDebugLog($result); $_COOKIE["product_ktc_vid"] = $vid; break; } // API2 $openid = $objCustomer->getValue("au_open_id"); $curl = $this->curl_init(KISEKAE_TOUCH_IPHONE_API02); $post = $this->getPost($config, array("contentid" => $contentid, "userid" => $openid, "vid" => $vid)); $this->getDs($post, $config); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post)); GC_Utils_Ex::gfPrintLog(print_r($post, TRUE), DEBUG_LOG_REALFILE); $result = curl_exec($curl); $status = SC_XML::xpath($result, "//status/@value"); switch ($status) { default: SC_Utils_Ex::sfDispSiteError(PAGE_ERROR); break; case "000": case "010": // TEST // /ios/products/detail.php?mode=check_buy_and_download&product_id=13&classcategory_id1=0&classcategory_id2=0&quantity=1&admin=&favorite_product_id=&product_class_id=&device_name=iPhone6Plus&device_height=736&device_width=414&device_rate=3&device_lang=ja&ignore_redownload=1 if ($_GET["ignore_redownload"] == "1") { $status = "000"; } break; } if ($status == "000") { // FIXME 課金処理 // API03 $curl = $this->curl_init(KISEKAE_TOUCH_IPHONE_API03); if ($objCustomer->getValue("buy_to_nopoint") == "1") { $price = $this->arrProduct["price02_min"]; $settlementtype = "998"; $redownloaddate = date("Ymd"); } else { $price = $this->arrProduct["price02_min"]; $settlementtype = "001"; $redownloaddate = date("Ymd", strtotime($this->downloadable_days2)); } $post = $this->getPost($config, array("contentid" => $contentid, "price" => $price, "redownloaddate" => $redownloaddate, "userid" => $openid, "vid" => $vid, "settlementtype" => $settlementtype)); $this->getDs($post, $config); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post)); GC_Utils_Ex::gfPrintLog(print_r($post, TRUE), DEBUG_LOG_REALFILE); $result = curl_exec($curl); $authentication_id = SC_XML::xpath($result, "//authentication/@id"); $objFormParam = new SC_FormParam(); $this->setOrderParam($objFormParam, $vid, $authentication_id); $objFormParam->convParam(); $message = ''; $arrValBef = array(); $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->saveShippingTemp(array()); $order_id = $this->doRegister("", $objPurchase, $objFormParam, $message, $arrValBef); $customer_id = $objCustomer->getValue("customer_id"); $this->addPointHistory($order_id, $customer_id, $objFormParam, $objQuery); } else { $authentication_id = SC_XML::xpath($result, "//authentication/@id"); } $netUrl = new Net_URL(KISEKAE_TOUCH_IPHONE_CST02); $netUrl->addQueryString("aid", $authentication_id); $netUrl->addQueryString("cpid", $config["cpid"]); $netUrl->addQueryString("siteid", $config["siteid"]); $netUrl->addQueryString("contentid", $contentid); $netUrl->addQueryString("ts", date("YmdHis")); $post2 = $netUrl->querystring; $this->getDs($post2, $config); $netUrl->addRawQueryString(http_build_query($post2)); GC_Utils_Ex::gfPrintLog(print_r($post2, TRUE), DEBUG_LOG_REALFILE); header("Location: " . $netUrl->getURL()); }
function doCheckBuyAndDownloadOk($config, $re_download = false) { $objCustomer = new SC_Customer_Ex(); $objQuery = SC_Query_Ex::getSingletonInstance(); if (empty($_REQUEST["product_ktc_vid"])) { SC_Utils_Ex::sfDispSiteError(PAGE_ERROR); } $vid = $_REQUEST["product_ktc_vid"]; $curl = $this->curl_init(KISEKAE_TOUCH_API02); $post = $this->getPost($config, array("contentid" => $this->arrProduct["product_code_min"], "vid" => $vid)); $this->getDs($post, $config); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post)); GC_Utils_Ex::gfPrintLog(print_r($post, TRUE), DEBUG_LOG_REALFILE); $result = curl_exec($curl); $status = SC_XML::xpath($result, "//status/@value"); switch ($status) { default: SC_Utils_Ex::sfDispSiteError(PAGE_ERROR); break; case "000": case "010": break; } if ($status == "000") { // FIXME 課金処理 // API03 $curl = $this->curl_init(KISEKAE_TOUCH_API03); if ($objCustomer->getValue("buy_to_nopoint") == "1") { $price = $this->arrProduct["price02_min"]; $settlementtype = "998"; $redownloaddate = date("Ymd"); } elseif ($re_download) { $price = 0; $settlementtype = "900"; $redownloaddate = date("Ymd"); } else { $price = $this->arrProduct["price02_min"]; $settlementtype = "001"; $redownloaddate = date("Ymd", strtotime($this->downloadable_days2)); } $contentid = $this->arrProduct["product_code_min"]; $post = compact("contentid", "price", "redownloaddate", "vid", "settlementtype"); $post = $this->getPost($config, $post); $this->getDs($post, $config); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post)); GC_Utils_Ex::gfPrintLog(print_r($post, TRUE), DEBUG_LOG_REALFILE); $result = curl_exec($curl); $authentication_id = SC_XML::xpath($result, "//authentication/@id"); $objFormParam = new SC_FormParam(); $this->setOrderParam($objFormParam, $vid, $authentication_id); $objFormParam->convParam(); $message = ''; $arrValBef = array(); $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->saveShippingTemp(array()); $order_id = $this->doRegister("", $objPurchase, $objFormParam, $message, $arrValBef); $customer_id = $objCustomer->getValue("customer_id"); $this->addPointHistory($order_id, $customer_id, $objFormParam, $objQuery); } else { $authentication_id = SC_XML::xpath($result, "//authentication/@id"); } $netUrl = new Net_URL(KISEKAE_TOUCH_CST02); $netUrl->addQueryString("aid", $authentication_id); $netUrl->addQueryString("cpid", $post["cpid"]); $netUrl->addQueryString("siteid", $post["siteid"]); $netUrl->addQueryString("contentid", $post["contentid"]); $netUrl->addQueryString("ts", $post["ts"]); $post2 = $netUrl->querystring; $this->getDs($post2, $config); $netUrl->addRawQueryString(http_build_query($post2)); header("Location: " . $netUrl->getURL()); }