/**
  * Page のアクション.
  *
  * @return void
  */
 public function action()
 {
     $this->selectTemplate();
     $order_id = $this->getOrderId();
     if ($order_id === NULL) {
         SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', true, '注文情報の取得が出来ませんでした。<br />この手続きは無効となりました。');
     }
     $objPurchase = new SC_Helper_Purchase_Ex();
     $objCharge = new SC_Mdl_WebPay_Models_Charge($order_id);
     $this->tpl_title = $objCharge->arrOrder['payment_method'];
     $this->validateOrderConsistency($objCharge->arrOrder);
     $arrModuleSetting = SC_Mdl_WebPay_Models_Module::loadCurrentSetting();
     $objWebPay = new SC_Mdl_WebPay_Wrapper($arrModuleSetting['secret_key']);
     $objCustomer = new SC_Mdl_WebPay_Models_Customer($objWebPay, $objCharge->arrOrder['customer_id']);
     $objFormParam = new SC_FormParam_Ex();
     $this->initFormParam($objFormParam);
     switch ($this->getMode()) {
         case 'delete_card':
             $objCustomer->deleteActiveCard();
             break;
         case 'other_card':
             break;
         case 'pay':
             $objFormParam->setParam($_REQUEST);
             $objFormParam->convParam();
             $this->arrErr = $this->checkFormParamError($objFormParam);
             if (empty($this->arrErr)) {
                 $arrData = $objFormParam->getHashArray();
                 $arrPayer = array();
                 $message = $this->selectPayer($objCustomer, $arrData, $arrPayer);
                 if ($message !== null) {
                     $this->tpl_webpay_charge_error = $message;
                     break;
                 }
                 $authorize = $arrModuleSetting['payment'] == 'authorize';
                 $message = $objCharge->createCharge($objWebPay, $authorize, $arrPayer);
                 if ($message !== null) {
                     $this->tpl_webpay_charge_error = $message;
                     break;
                 }
                 SC_Response_Ex::sendRedirect(SHOPPING_COMPLETE_URLPATH);
                 SC_Response_Ex::actionExit();
                 break;
             }
             break;
         default:
             $this->objSavedCard = $objCustomer->fetchSavedCardForCustomer();
             break;
     }
     $this->tpl_is_registered_customer = $objCustomer->getCustomerId() !== 0;
     $this->tpl_webpay_publishable_key = $arrModuleSetting['publishable_key'];
     $this->tpl_url = $_SERVER['REQUEST_URI'];
 }
Exemplo n.º 2
0
 /**
  * hook function called before LC_Page_Admin_Order_Edit
  * Send requests to WebPay if mode is of plg_webpayext
  */
 public function beforeAdminOrderEdit(LC_Page_Ex $objPage)
 {
     if ($objPage->getMode() === 'plg_webpayext_capture') {
         $_GET['mode'] = 'recalculate';
         $order_id = $_POST['order_id'];
         if (empty($order_id)) {
             return;
         }
         $objCharge = new SC_Mdl_WebPay_Models_Charge($order_id);
         $arrModuleSetting = SC_Mdl_WebPay_Models_Module::loadCurrentSetting();
         $objWebPay = new SC_Mdl_WebPay_Wrapper($arrModuleSetting['secret_key']);
         $message = $objCharge->capture($objWebPay);
         if ($message !== null) {
             $objPage->plg_webpayext_capture_error = $message;
         }
     }
 }