国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
3.6KB

  1. <?php
  2. if (!defined('DEDEMEMBER')) exit("Request Error!");
  3. //财付通 网上支付接口
  4. /*这里替换为您的实际商户号*/
  5. $strSpid = $payment_userid[0];
  6. /*strSpkey是32位商户密钥, 请替换为您的实际密钥*/
  7. $strSpkey = $payment_key[0];
  8. /*银行类型:
  9. 0 财付通
  10. 1001 招商银行
  11. 1002 中国工商银行
  12. 1003 中国建设银行
  13. 1004 上海浦东发展银行
  14. 1005 中国农业银行
  15. 1006 中国民生银行
  16. 1008 深圳发展银行
  17. 1009 兴业银行 */
  18. if(!isset($BankType)) $BankType = 0;
  19. $BankType = preg_replace("#[^0-9]#","",$BankType);
  20. if($BankType < 1) $BankType = 0;
  21. $strBankType= $BankType;
  22. $strCmdNo = "1";
  23. $strBillDate= date('Ymd');
  24. /*商品名称*/
  25. if(!isset($pname)) $pname = '服务购买';
  26. $strDesc = $pname;
  27. /*用户QQ号码, 现在置为空串*/
  28. $strBuyerId = "";
  29. /*商户号*/
  30. $strSaler = $payment_userid[0];
  31. //支付手续费
  32. if($payment_exp[0] < 0) $payment_exp[0] = 0;
  33. $piice_ex = $price*$payment_exp[0];
  34. $price = $price+$piice_ex;
  35. //支付金额
  36. $strTotalFee = $price*100;
  37. if( $strTotalFee < 1){
  38. $dsql->Close();
  39. exit('金额不对');
  40. }
  41. $strSpBillNo = $buyid;;
  42. /*重要: 交易单号
  43. 交易单号(28位): 商户号(10位) + 日期(8位) + 流水号(10位), 必须按此格式生成, 且不能重复
  44. 如果sp_billno超过10位, 则截取其中的流水号部分加到transaction_id后部(不足10位左补0)
  45. 如果sp_billno不足10位, 则左补0, 加到transaction_id后部*/
  46. $strTransactionId = $strSpid . $strBillDate . time();
  47. /*货币类型: 1 – RMB(人民币) 2 - USD(美元) 3 - HKD(港币)*/
  48. $strFeeType = "1";
  49. /*财付通回调页面地址, 推荐使用ip地址的方式(最长255个字符)*/
  50. $strRetUrl = $cfg_basehost."/member/paycenter/tenpay/notify_handler.php";
  51. /*商户私有数据, 请求回调页面时原样返回*/
  52. $strAttach = "my_magic_string";
  53. /*生成MD5签名*/
  54. $strSignText = "cmdno=" . $strCmdNo . "&date=" . $strBillDate . "&bargainor_id=" . $strSaler .
  55. "&transaction_id=" . $strTransactionId . "&sp_billno=" . $strSpBillNo .
  56. "&total_fee=" . $strTotalFee . "&fee_type=" . $strFeeType . "&return_url=" . $strRetUrl .
  57. "&attach=" . $strAttach . "&key=" . $strSpkey;
  58. $strSign = strtoupper(md5($strSignText));
  59. /*请求支付串*/
  60. $strRequest = "cmdno=" . $strCmdNo . "&date=" . $strBillDate . "&bargainor_id=" . $strSaler .
  61. "&transaction_id=" . $strTransactionId . "&sp_billno=" . $strSpBillNo .
  62. "&total_fee=" . $strTotalFee . "&fee_type=" . $strFeeType . "&return_url=" . $strRetUrl .
  63. "&attach=" . $strAttach . "&bank_type=" . $strBankType . "&desc=" . $strDesc .
  64. "&purchaser_id=" . $strBuyerId .
  65. "&sign=" . $strSign ;
  66. $strRequestUrl = "https://www.tenpay.com/cgi-bin/v1.0/pay_gate.cgi?".$strRequest;
  67. if($cfg_soft_lang == 'utf-8')
  68. {
  69. $strRequestUrl = utf82gb($strRequestUrl);
  70. echo '<html>
  71. <head>
  72. <title>转到财付通支付页面</title>
  73. </head>
  74. <body onload="document.tenpay.submit();">
  75. <form name="tenpay" action="paycenter/tenpay/tenpay_gbk_page.php?strReUrl='.urlencode($strRequestUrl).'" method="post">
  76. </form>
  77. </body>
  78. </html>';
  79. }else{
  80. echo '<html>
  81. <head>
  82. <title>转到财付通支付页面</title>
  83. </head>
  84. <body onload="document.tenpay.submit();">
  85. <form name="tenpay" action="'.$strRequestUrl.'" method="post">
  86. </form>
  87. </body>
  88. </html>';
  89. }
  90. exit;