<?php
/**
 * @copyright ONE/DEPO Project
 * @license   PHP License 3.01 <http://www.php.net/license/3_01.txt>
 */


//JSONを扱うためのパーサ
//require_once(WEBAPP_DIR."/JSON.php");

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
require_once 'Net/UserAgent/Mobile.php';

/**
 * [[機能説明]]
 *
 * @package     [[package名]]
 * @author      Your Name <mail@example.com>
 * @access      public
 */
class Customer_Itembuy_Cashier_Cvsresult
{
    var $title;
    var $pagename;

    var $actionChain;
    var $session;
    var $c_member;
    var $member_data;
    var $membercd;
    var $auth;
    var $c_preorder;
    var $c_cart;
    var $c_pref;
    var $c_consumer;
    var $deposit;

    var $payment;

    var $errer_return;

    var $cardmessage;
    var $cvsmessage;

    /**
     * [[機能説明]]
     *
     * @access  public
     */
    function execute()
    {
        $this->session->removeParameter("payment");
        $this->session->removeParameter("destination");
        $this->session->removeParameter("cart_items");
        $this->session->removeParameter("takkyubin");

        $mobile = &Net_UserAgent_Mobile::isMobile();
        $re_str = ($mobile) ? "mobile_" : "";

        $errorList =& $this->actionChain->getCurErrorList();
        $log =& LogFactory::getLog();

        $this->membercd = $this->auth->getAuthData("membercd");


        if (empty($_POST['X-S_TORIHIKI_NO'])) {
            trigger_error("remise cvs error", E_USER_ERROR);
            exit;
        }

        if ($_POST['X-R_CODE']!='0:0000') {
            trigger_error("remise cvs error", E_USER_ERROR);
            exit;
        }

        $log->debug(print_r($_POST, true), "remise cvs");

        $orderno = $_POST["X-S_TORIHIKI_NO"];
        $data = array("pay_cvs" => $_POST["X-PAY_CSV"],
                      "no1" => $_POST["X-PAY_NO1"],
                      "no2" => $_POST["X-PAY_NO2"]
                     );

        $r = $this->payment->updateRemiseCvs($orderno, $data, $this->cvsmessage);

        if (!$r) {
            // 商品情報が不正
            $errorList -> add(1, 
                              mb_convert_encoding($ret["MErrMsg"], 
                              "UTF-8", "UTF-8,EUC-JP")
                              );
            $this->errer_return = "customer_itembuy_cart";
            return $re_str ."input";
        }

        return $re_str .'success';
    }

    function getCardmessage() {
        return $this->cardmessage;
    }
    function getCVSmessage() {
        return $this->cvsmessage;
    }
    function getDaibikimessage() {
        return "";
    }
    function getBankmessage() {
        return "";
    }
    function getYuubinmessage() {
        return;
    }
    function getDl() { 
        return $this->payment->getDl();
    }
    function getTrackerdata() { 
        return $this->payment->getTrackerdata(); 
    } 
}
?>
