/**
  * 登録・決済を実行する
  *
  * @param EntryExecTranInput $input    入力パラメータ
  * @return  EntryExecTranOutput 登録・決済出力パラメータ
  * @exception GPayException
  */
 function exec(&$input)
 {
     // 取引登録入力パラメータを取得
     $entryTranInput =& $input->getEntryTranInput();
     // 決済実行入力パラメータを取得
     $execTranInput =& $input->getExecTranInput();
     // 登録・決済出力パラメータを生成
     $output = new EntryExecTranOutput();
     // 取引ID、取引パスワードを取得
     $accessId = $execTranInput->getAccessId();
     $accessPass = $execTranInput->getAccessPass();
     // 取引ID、取引パスワードが設定されていないとき
     if (is_null($accessId) || 0 == strlen($accessId) || is_null($accessPass)) {
         // 取引登録を実行
         $this->log->debug("取引登録実行");
         $entryTran = new EntryTran();
         $entryTranOutput = $entryTran->exec($entryTranInput);
         if ($this->errorTrap($entryTran)) {
             return $output;
         }
         // 取引ID、取引パスワードを決済実行用のパラメータに設定
         $accessId = $entryTranOutput->getAccessId();
         $accessPass = $entryTranOutput->getAccessPass();
         $execTranInput->setAccessId($accessId);
         $execTranInput->setAccessPass($accessPass);
         $output->setEntryTranOutput($entryTranOutput);
     }
     $this->log->debug("取引ID : [{$accessId}]  取引パスワード : [{$accessPass}]");
     // 取引登録でエラーが起きたとき決済を実行せずに戻る
     if ($output->isEntryErrorOccurred()) {
         $this->log->debug("<<<取引登録失敗>>>");
         return $output;
     }
     // 決済実行
     $this->log->debug("決済実行");
     $execTran = new ExecTran();
     $execTranOutput = $execTran->exec($execTranInput);
     $output->setExecTranOutput($execTranOutput);
     $this->errorTrap($execTran);
     return $output;
 }
function execTran($member_id, $order_id, $amount)
{
    global $log;
    $entryInput = new EntryTranInput();
    $entryInput->setShopId(PGCARD_SHOP_ID);
    $entryInput->setShopPass(PGCARD_SHOP_PASS);
    $entryInput->setJobCd(JOB_CODE_CAPTURE);
    $entryInput->setOrderId($order_id);
    $entryInput->setAmount($amount);
    $execInput = new ExecTranInput();
    $execInput->setOrderId($order_id);
    $execInput->setMethod(1);
    $execInput->setSiteId(PGCARD_SITE_ID);
    $execInput->setSitePass(PGCARD_SITE_PASS);
    $execInput->setMemberId($member_id);
    $execInput->setCardSeq(CARD_SEQ_DEFAULT);
    $input = new EntryExecTranInput();
    /* @var $input EntryExecTranInput */
    $input->setEntryTranInput($entryInput);
    $input->setExecTranInput($execInput);
    $exe = new EntryExecTran();
    /* @var $exec EntryExecTran */
    $output = $exe->exec($input);
    /* @var $output EntryExecTranOutput */
    $log->info(serialize($input));
    $log->info(serialize($output));
    foreach ($output->getEntryErrList() as $err) {
        $log->error(serialize($input));
        $log->error(serialize($output));
        $errInfo = $err->getErrInfo();
        throw new Exception($errInfo);
    }
    foreach ($output->getExecErrList() as $err) {
        $log->error(serialize($input));
        $log->error(serialize($output));
        $errInfo = $err->getErrInfo();
        throw new Exception($errInfo);
    }
    return $output;
}