예제 #1
0
/**
 * Description of linkGreenWorld
 *
 * @author 李泓承
 */

include_once(dirname(__FILE__).'/../../config/config.inc.php');
include_once(dirname(__FILE__).'/../../header.php');
include_once(dirname(__FILE__).'/../../init.php');
include_once(dirname(__FILE__).'/greenworld_cvs.php');
include_once(dirname(__FILE__).'/../../classes/OrderHistory.php');

session_start();

global $cookie;
$CheckPay=new greenworld_cvs();
$authorized = false;
foreach (Module::getPaymentModules() as $module)
    if ($module['name'] == $CheckPay->name){
            $authorized = true;
            break;
    }
if (!$authorized)
    die(Tools::displayError('This payment method is not available.'));


$customer = new Customer((int)$cart->id_customer);
$total = $cart->getOrderTotal(true, Cart::BOTH);
$inttotal=round($total);
$HomePage=Tools::getShopDomain(true, true).__PS_BASE_URI__;
$order = new Order((int)$CheckPay->currentOrder);
예제 #2
0
<?php

include_once dirname(__FILE__) . '/../../config/config.inc.php';
include_once dirname(__FILE__) . '/../../init.php';
include_once dirname(__FILE__) . '/greenworld_cvs.php';
include_once dirname(__FILE__) . '/../../classes/OrderHistory.php';
$checkTemp = new greenworld_cvs();
// 商店設定在ECBank管理後台的交易加密私鑰
$key = $checkTemp->getEncryptionCode();
$amount = $checkTemp->getAmount(Tools::getValue("od_sob"));
$serial = trim($_REQUEST['proc_date'] . $_REQUEST['proc_time'] . $_REQUEST['tsr']);
// 回傳的交易驗證壓碼
$tac = trim($_REQUEST['tac']);
// ECBank 驗證Web Service網址
$ws_url = 'https://ecbank.com.tw/web_service/get_outmac_valid.php?key=' . $key . '&serial=' . $serial . '&tac=' . $tac;
// 取得驗證結果 (也可以使用curl)
$tac_valid = file_get_contents($ws_url);
if ($tac_valid == 'valid=1') {
    if ($amount == $_REQUEST['amt'] && $_REQUEST['succ'] == '1') {
        $id_order = $_REQUEST['od_sob'];
        $newOrderStatusId = 2;
        $history = new OrderHistory();
        $history->id_order = (int) $id_order;
        $history->changeIdOrderState($newOrderStatusId, $id_order);
        $history->addWithemail();
        echo 'OK';
    } else {
        echo '付款失敗';
    }
} else {
    echo '交易失敗';