更新已解決
將後端
$obj->Send['ClientRedirectURL']
修改成
$obj->SendExtend['ClientRedirectURL']
POST成功囉!
如標題,已有設定PaymentInfoURL及ClientRedirectURL參數,但是資料post出去後都是直接停在綠界的取號畫面後不動了。故意把兩個參數設定一樣依然沒有改變。以下是我的code
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"/>
</head>
<body>
<form id="idFormAioCheckOut" method="post" action="<?=base_url('index.php/manager/ecatmposttest')?>">
<input type="text" name="ServiceURL" value="https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5" class="form-control"/>
<input type="text" name="MerchantTradeNo" value="fmtest20181002001" class="form-control"/>
<input type="text" name="MerchantTradeDate" value="<?=date('Y-m-d H:i:s')?>" class="form-control"/>
<input type="text" name="PaymentType" value="aio" class="form-control"/>
<input type="text" name="TotalAmount" value="9487" class="form-control"/>
<input type="text" name="TradeDesc" value="Desc" class="form-control"/>
<input type="text" name="ItemName" value="A#B" class="form-control"/>
<input type="text" name="ReturnURL" value="<?=base_url('index.php/manager/ecatmposttest2')?>" class="form-control"/>
<input type="text" name="ChoosePayment" value="ATM"/>
<input type="hidden" name="MerchantID" value="2000132" />
<input type="hidden" name="HashKey" value="5294y06JbISpM5x9" />
<input type="hidden" name="HashIV" value="v77hoKGq4kWxNNIS" />
<input type="hidden" name="ChooseSubPayment" value="ESUN" />
<input type="hidden" name="ClientRedirectURL" value="<?=base_url('index.php/manager/ecatmposttest3')?>" />
<input type="hidden" name="PaymentInfoURL" value="<?=base_url('index.php/manager/ecatmposttest3')?>" />
<button type="submit" class="btn btn-default">綠界線上支付</button>
</form>
</body>
</html>
後端
require_once 'ECPay.Payment.Integration.php';
$obj = new \ECPay_AllInOne();
//服務參數
$obj->ServiceURL = $_POST['ServiceURL'];
$obj->HashKey = $_POST['HashKey'];
$obj->HashIV = $_POST['HashIV'];
$obj->MerchantID = $_POST['MerchantID'];
//
$obj->Send['MerchantTradeNo'] = $_POST['MerchantTradeNo'];
$obj->Send['MerchantTradeDate'] = $_POST['MerchantTradeDate'];
$obj->Send['PaymentType'] = $_POST['PaymentType'];
$obj->Send['TotalAmount'] = (int)$_POST['TotalAmount'];
$obj->Send['TradeDesc'] = $_POST['TradeDesc'];
$obj->Send['ReturnURL'] = $_POST['ReturnURL'];
$obj->Send['ChoosePayment'] = $_POST['ChoosePayment'];
$obj->Send['CreditInstallment'] = $_POST['CreditInstallment'];
$obj->Send['ChooseSubPayment'] = $_POST['ChooseSubPayment'];
$obj->Send['ClientRedirectURL'] = $_POST['ClientRedirectURL'];
$obj->Send['PaymentInfoURL'] = $_POST['PaymentInfoURL'];
//訂單的商品資料
array_push($obj->Send['Items'], array(
'Name' => 'aaa',
'Price' => 9487,
'Currency' => "元",
'Quantity' => (int)"1"
)
);
//產生訂單(auto submit至ECPay)
//$obj->CheckOut();
$Response = (string)$obj->CheckOutString();
echo $Response;
// 自動將表單送出
echo '<script>document.getElementById("__ecpayForm").submit();</script>';
最後畫面