金流出現錯誤問題(以解決) - 金流服務 - 歐付寶討論版

歐付寶討論版

查詢
查看: 2790|回覆: 0
打印 上一主題 下一主題

金流出現錯誤問題(以解決)

[複製連結]
1066077
發表於 2019-11-1 22:07:46 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
歐富寶大大你好

我COPY了下面網址的原始代碼
https://developers.opay.tw/AioCreditCard/CreateOrder

並改了一些變數帶入

請問為什麼一直錯誤




原始碼如下
請問大大我哪裡弄錯了
麻煩大大了

原來是字串末端HashIV打成HashKey

  1. <?php
  2. include('Opay.Payment.Integration.php');
  3. $opay = new OpayCheckMacValue1;
  4. date_default_timezone_set("Asia/Taipei");
  5. $HashKey="5294y06JbISpM5x9";
  6. $HashIV="v77hoKGq4kWxNNIS";
  7. $items = "MacBook 30元X2#iPhone6s 40元X1";
  8. $TD = "建立信用卡測試訂單";
  9. $dateMTN = "A".date("YmdHis");
  10. $dateMTD = date("Y/m/d H:i:s");
  11. $returnurl = "https://developers.opay.tw/AioMock/MerchantReturnUrl";
  12. $clientbackURL = "https://developers.opay.tw/AioMock/MerchantClientBackUrl";

  13. echo $opystr = "HashKey=".$HashKey."&ChoosePayment=Credit&ClientBackURL=".$clientbackURL."&CreditInstallment=&EncryptType=1&InstallmentAmount=&ItemName=".$items."&MerchantID=2000132&MerchantTradeDate=".$dateMTD."&MerchantTradeNo=".$dateMTN."&PaymentType=aio&Redeem=&ReturnURL=".$returnurl."&StoreID=&TotalAmount=5&TradeDesc=".$TD."&HashKey=".$HashKey;
  14. $opyUrlEncode = $opay->generate($opystr);
  15. //echo $opyUrlEncode ;
  16. ?>

  17. <form id="formCreditCard" method="post" accept-charset="UTF-8" action="https://payment-stage.opay.tw/Cashier/AioCheckOut/V5">
  18. MerchantID 商店代號:
  19. <input type="text" name="MerchantID" value="2000132" /><br />
  20. MerchantTradeNo 商店交易編號:
  21. <input type="text" name="MerchantTradeNo" value="<?php echo $dateMTN; ?>" /><br />
  22. MerchantTradeDate 商店交易時間:
  23. <input type="text" name="MerchantTradeDate" value="<?php echo $dateMTD; ?>" /><br />
  24. PaymentType 交易類型:
  25. <input type="text" name="PaymentType" value="aio" /><br />
  26. TotalAmount 交易金額:
  27. <input type="text" name="TotalAmount" value="5" /><br />
  28. TradeDesc 交易描述:
  29. <input type="text" name="TradeDesc" value="<?php echo $TD ?>" /><br />
  30. ItemName 商品名稱:
  31. <input type="text" name="ItemName" value="<?php echo $items ?>" /><br />
  32. ReturnURL 付款完成通知回傳網址:
  33. <input type="text" name="ReturnURL" value="<?php echo $returnurl ?>" /><br />
  34. ChoosePayment 預設付款方式:
  35. <input type="text" name="ChoosePayment" value="Credit" /><br />
  36. 會員商店代碼:
  37. <input type="text" name="StoreID" value="" /><br />
  38. ClientBackURL Client端返回廠商網址:
  39. <input type="text" name="ClientBackURL" value="<?php echo $clientbackURL?>" /><br />
  40. CreditInstallment 刷卡分期期數:
  41. <input type="text" name="CreditInstallment" value="" /><br />
  42. InstallmentAmount 使用刷卡分期的付款金額:
  43. <input type="text" name="InstallmentAmount" value="" /><br />
  44. Redeem 信用卡是否使用紅利折抵:
  45. <input type="text" name="Redeem" value="" /><br />
  46. CheckMacValue 簽章類型:
  47. <input type="text" name="EncryptType" value="1" /><br />
  48. CheckMacValue 檢查碼:
  49. <input type="text" name="CheckMacValue" value="<?php echo $opyUrlEncode;?>" /><br />
  50. <input type="submit" value="送出訂單" />
  51. </form>
  52.                                                                      
  53. <?php
  54. class OpayCheckMacValue1
  55. {
  56.     public function generate($arParameters ){
  57.                 //echo $arParameters."<br>";
  58.         $sMacValue = '' ;
  59.         if(isset($arParameters))
  60.         {
  61.             $sMacValue = urlencode($arParameters);
  62.             // 轉成小寫
  63.             $sMacValue = strtolower($sMacValue);
  64.             // 取代為與 dotNet 相符的字元
  65.             $sMacValue = str_replace('%2d', '-', $sMacValue);
  66.             $sMacValue = str_replace('%5f', '_', $sMacValue);
  67.             $sMacValue = str_replace('%2e', '.', $sMacValue);
  68.             $sMacValue = str_replace('%21', '!', $sMacValue);
  69.             $sMacValue = str_replace('%2a', '*', $sMacValue);
  70.             $sMacValue = str_replace('%28', '(', $sMacValue);
  71.             $sMacValue = str_replace('%29', ')', $sMacValue);
  72.             // 編碼
  73.                         //echo "result:".$sMacValue;
  74.             $sMacValue = hash('sha256', $sMacValue);
  75.             $sMacValue = strtoupper($sMacValue);               
  76.         }
  77.         return $sMacValue ;
  78.     }
  79.     /**
  80.     * 自訂排序使用
  81.     */
  82.     private static function merchantSort($a,$b)
  83.     {
  84.         return strcasecmp($a, $b);
  85.     }
  86. }
  87. ?>
複製代碼



GMT+8, 2024-4-20 04:32 , Processed in 0.161437 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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