|
歐富寶 大大你好
我看了建立訂單頁面
https://developers.opay.tw/AioCreditCard/CreateOrder
我抓了網頁上的step2代碼
- HashKey=5294y06JbISpM5x9&ChoosePayment=Credit&ClientBackURL=https://developers.opay.tw/AioMock/MerchantClientBackUrl&CreditInstallment=&EncryptType=1&InstallmentAmount=&ItemName=MacBook 30元X2#iPhone6s 40元X1&MerchantID=2000132&MerchantTradeDate=2019/10/24 16:57:03&MerchantTradeNo=DX20191024165703ba1c&PaymentType=aio&Redeem=&ReturnURL=https://developers.opay.tw/AioMock/MerchantReturnUrl&StoreID=&TotalAmount=5&TradeDesc=建立信用卡測試訂單&HashIV=v77hoKGq4kWxNNIS
複製代碼 step4 頁面上的 urlencode 代碼
- hashkey%3d5294y06jbispm5x9%26choosepayment%3dcredit%26clientbackurl%3dhttps%3a%2f%2fdevelopers.opay.tw%2faiomock%2fmerchantclientbackurl%26creditinstallment%3d%26encrypttype%3d1%26installmentamount%3d%26itemname%3dmacbook+30%e5%85%83x2%23iphone6s+40%e5%85%83x1%26merchantid%3d2000132%26merchanttradedate%3d2019%2f10%2f24+16%3a57%3a03%26merchanttradeno%3ddx20191024165703ba1c%26paymenttype%3daio%26redeem%3d%26returnurl%3dhttps%3a%2f%2fdevelopers.opay.tw%2faiomock%2fmerchantreturnurl%26storeid%3d%26totalamount%3d5%26tradedesc%3d%e5%bb%ba%e7%ab%8b%e4%bf%a1%e7%94%a8%e5%8d%a1%e6%b8%ac%e8%a9%a6%e8%a8%82%e5%96%ae%26hashiv%3dv77hokgq4kwxnnis
複製代碼 我的
step4 頁面上的 urlencode 代碼
- hashkey%3d5294y06jbispm5x9%26choosepayment%3dcredit%26clientbackurl%3dhttps%3a%2f%2fdevelopers.opay.tw%2faiomock%2fmerchantclientbackurl%26creditinstallment%3d%26encrypttype%3d1%26installmentamount%3d%26itemname%3dmacbook+30%e5%85%83x2%23iphone6s+40%e5%85%83x1%26merchantid%3d2000132%26merchanttradedate%3d2019%2f10%2f24+15%3a59%3a23%26merchanttradeno%3ddx201910241559239cca%26paymenttype%3daio%26redeem%3d%26returnurl%3dhttps%3a%2f%2fdevelopers.opay.tw%2faiomock%2fmerchantreturnurl%26storeid%3d%26totalamount%3d5%26tradedesc%3d%e5%bb%ba%e7%ab%8b%e4%bf%a1%e7%94%a8%e5%8d%a1%e6%b8%ac%e8%a9%a6%e8%a8%82%e5%96%ae%26hashiv%3dv77hokgq4kwxnnis
複製代碼
我發現不一樣的地方是在merchanttradedate merchanttradeno部分
請問一下我該如何處理
我的程式代碼如下
- <form id="formCreditCard" method="post" accept-charset="UTF-8"
- action="https://payment-stage.opay.tw/Cashier/AioCheckOut/V5">
- <?php
- date_default_timezone_set("Asia/Taipei");
- $HashKey="5294y06JbISpM5x9";
- $HashIV="v77hoKGq4kWxNNIS";
- $opystr ="HashKey=5294y06JbISpM5x9&ChoosePayment=Credit&ClientBackURL=https://developers.opay.tw/AioMock/MerchantClientBackUrl&CreditInstallment=&EncryptType=1&InstallmentAmount=&ItemName=MacBook 30元X2#iPhone6s 40元X1&MerchantID=2000132&MerchantTradeDate=2019/10/24 15:59:23&MerchantTradeNo=DX201910241559239Cca&PaymentType=aio&Redeem=&ReturnURL=https://developers.opay.tw/AioMock/MerchantReturnUrl&StoreID=&TotalAmount=5&TradeDesc=建立信用卡測試訂單&HashIV=v77hoKGq4kWxNNIS";
- $opyUrlEncode = $opay->generate($opystr);
- //echo $opyUrlEncode ;
- ?>
- <form id="formCreditCard" method="post" accept-charset="UTF-8"
- action="https://payment-stage.opay.tw/Cashier/AioCheckOut/V5">
- MerchantID 商店代號:
- <input type="text" name="MerchantID" value="2000132" /><br />
- MerchantTradeNo 商店交易編號:
- <input type="text" name="MerchantTradeNo" value="<?php echo "DX".date("YmdHis")."f963" ?>" /><br />
- MerchantTradeDate 商店交易時間:
- <input type="text" name="MerchantTradeDate" value="<?php echo date("Y/m/d H:i:s")?>" /><br />
- PaymentType 交易類型:
- <input type="text" name="PaymentType" value="aio" /><br />
- TotalAmount 交易金額:
- <input type="text" name="TotalAmount" value="5" /><br />
- TradeDesc 交易描述:
- <input type="text" name="TradeDesc" value="建立信用卡測試訂單" /><br />
- ItemName 商品名稱:
- <input type="text" name="ItemName" value="MacBook 30元X2#iPhone6s 40元X1" /><br />
- ReturnURL 付款完成通知回傳網址:
- <input type="text" name="ReturnURL" value="https://developers.opay.tw/AioMock/MerchantReturnUrl" /><br />
- ChoosePayment 預設付款方式:
- <input type="text" name="ChoosePayment" value="Credit" /><br />
- 會員商店代碼:
- <input type="text" name="StoreID" value="" /><br />
- ClientBackURL Client端返回廠商網址:
- <input type="text" name="ClientBackURL" value="https://developers.opay.tw/AioMock/MerchantClientBackUrl" /><br />
- CreditInstallment 刷卡分期期數:
- <input type="text" name="CreditInstallment" value="" /><br />
- InstallmentAmount 使用刷卡分期的付款金額:
- <input type="text" name="InstallmentAmount" value="" /><br />
- Redeem 信用卡是否使用紅利折抵:
- <input type="text" name="Redeem" value="" /><br />
- CheckMacValue 簽章類型:
- <input type="text" name="EncryptType" value="1" /><br />
- CheckMacValue 檢查碼:
- <input type="text" name="CheckMacValue" value="<?php echo $opyUrlEncode;?>" /><br />
- <input type="submit" value="送出訂單" />
- </form>
-
- <?php
- class OpayCheckMacValue1
- {
- public function generate($arParameters ){
- //echo $arParameters."<br>";
- $sMacValue = '' ;
- if(isset($arParameters))
- {
-
- $sMacValue = urlencode($arParameters);
- // 轉成小寫
-
- $sMacValue = strtolower($sMacValue);
- // 取代為與 dotNet 相符的字元
-
- $sMacValue = str_replace('%2d', '-', $sMacValue);
- $sMacValue = str_replace('%5f', '_', $sMacValue);
- $sMacValue = str_replace('%2e', '.', $sMacValue);
- $sMacValue = str_replace('%21', '!', $sMacValue);
- $sMacValue = str_replace('%2a', '*', $sMacValue);
- $sMacValue = str_replace('%28', '(', $sMacValue);
- $sMacValue = str_replace('%29', ')', $sMacValue);
- // 編碼
- echo $sMacValue;
-
- $sMacValue = hash('sha256', $sMacValue);
-
-
- $sMacValue = strtoupper($sMacValue);
-
- }
-
- return $sMacValue ;
- }
- /**
- * 自訂排序使用
- */
- private static function merchantSort($a,$b)
- {
- return strcasecmp($a, $b);
- }
- }
- ?>
複製代碼
我的平台是 CentOs 7.7
PHP 5.5.38
|
|