urlencode 編碼問題 -信用卡-建立訂單 - 金流服務 - 歐付寶討論版
請選擇 進入手機版 | 繼續訪問電腦版

歐付寶討論版

查詢
查看: 3151|回覆: 2

urlencode 編碼問題 -信用卡-建立訂單

[複製連結]
2232236
發表於 2019-10-24 18:19:23 | 顯示全部樓層 |閱讀模式
歐富寶 大大你好
我看了建立訂單頁面
https://developers.opay.tw/AioCreditCard/CreateOrder

我抓了網頁上的step2代碼
  1. 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 代碼
  1. 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 代碼
  1. 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部分


請問一下我該如何處理
我的程式代碼如下
  1. <form id="formCreditCard" method="post" accept-charset="UTF-8"
  2. action="https://payment-stage.opay.tw/Cashier/AioCheckOut/V5">
  3. <?php
  4. date_default_timezone_set("Asia/Taipei");
  5. $HashKey="5294y06JbISpM5x9";
  6. $HashIV="v77hoKGq4kWxNNIS";
  7. $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";

  8. $opyUrlEncode = $opay->generate($opystr);
  9. //echo $opyUrlEncode ;
  10. ?>

  11. <form id="formCreditCard" method="post" accept-charset="UTF-8"
  12. action="https://payment-stage.opay.tw/Cashier/AioCheckOut/V5">

  13. MerchantID 商店代號:
  14. <input type="text" name="MerchantID" value="2000132" /><br />
  15. MerchantTradeNo 商店交易編號:
  16. <input type="text" name="MerchantTradeNo" value="<?php echo "DX".date("YmdHis")."f963" ?>" /><br />
  17. MerchantTradeDate 商店交易時間:
  18. <input type="text" name="MerchantTradeDate" value="<?php echo date("Y/m/d H:i:s")?>" /><br />
  19. PaymentType 交易類型:
  20. <input type="text" name="PaymentType" value="aio" /><br />
  21. TotalAmount 交易金額:
  22. <input type="text" name="TotalAmount" value="5" /><br />
  23. TradeDesc 交易描述:
  24. <input type="text" name="TradeDesc" value="建立信用卡測試訂單" /><br />
  25. ItemName 商品名稱:
  26. <input type="text" name="ItemName" value="MacBook 30元X2#iPhone6s 40元X1" /><br />
  27. ReturnURL 付款完成通知回傳網址:
  28. <input type="text" name="ReturnURL" value="https://developers.opay.tw/AioMock/MerchantReturnUrl" /><br />
  29. ChoosePayment 預設付款方式:
  30. <input type="text" name="ChoosePayment" value="Credit" /><br />
  31. 會員商店代碼:
  32. <input type="text" name="StoreID" value="" /><br />
  33. ClientBackURL Client端返回廠商網址:
  34. <input type="text" name="ClientBackURL" value="https://developers.opay.tw/AioMock/MerchantClientBackUrl" /><br />
  35. CreditInstallment 刷卡分期期數:
  36. <input type="text" name="CreditInstallment" value="" /><br />
  37. InstallmentAmount 使用刷卡分期的付款金額:
  38. <input type="text" name="InstallmentAmount" value="" /><br />
  39. Redeem 信用卡是否使用紅利折抵:
  40. <input type="text" name="Redeem" value="" /><br />
  41. CheckMacValue 簽章類型:
  42. <input type="text" name="EncryptType" value="1" /><br />
  43. CheckMacValue 檢查碼:
  44. <input type="text" name="CheckMacValue" value="<?php echo $opyUrlEncode;?>" /><br />
  45. <input type="submit" value="送出訂單" />

  46. </form>
  47.                                                                      
  48. <?php
  49. class OpayCheckMacValue1
  50. {
  51.     public function generate($arParameters ){
  52.                 //echo $arParameters."<br>";
  53.         $sMacValue = '' ;
  54.         if(isset($arParameters))
  55.         {
  56.                         
  57.             $sMacValue = urlencode($arParameters);
  58.             // 轉成小寫
  59.                         
  60.             $sMacValue = strtolower($sMacValue);
  61.             // 取代為與 dotNet 相符的字元
  62.                         
  63.             $sMacValue = str_replace('%2d', '-', $sMacValue);
  64.             $sMacValue = str_replace('%5f', '_', $sMacValue);
  65.             $sMacValue = str_replace('%2e', '.', $sMacValue);
  66.             $sMacValue = str_replace('%21', '!', $sMacValue);
  67.             $sMacValue = str_replace('%2a', '*', $sMacValue);
  68.             $sMacValue = str_replace('%28', '(', $sMacValue);
  69.             $sMacValue = str_replace('%29', ')', $sMacValue);
  70.             // 編碼
  71.                         echo $sMacValue;
  72.             
  73.             $sMacValue = hash('sha256', $sMacValue);
  74.    
  75.                

  76.             $sMacValue = strtoupper($sMacValue);
  77.                                 
  78.         }
  79.                
  80.         return $sMacValue ;
  81.     }
  82.     /**
  83.     * 自訂排序使用
  84.     */
  85.     private static function merchantSort($a,$b)
  86.     {
  87.         return strcasecmp($a, $b);
  88.     }
  89. }
  90. ?>
複製代碼


我的平台是 CentOs 7.7
PHP 5.5.38
1099236
發表於 2019-10-28 09:14:58 | 顯示全部樓層
MerchantTradeDate  不一樣呢~ 這樣會檢查碼錯誤唷~

1066077
發表於 2019-11-1 21:21:47 | 顯示全部樓層
1099236 發表於 2019-10-28 09:14
MerchantTradeDate  不一樣呢~ 這樣會檢查碼錯誤唷~



請問我該怎麼改?

麻煩大大指導一下

GMT+8, 2024-4-19 09:04 , Processed in 0.064303 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回覆 返回頂部 返回列表