Youyunwx_payment.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. $payment_lang = array(
  3. 'name' => '优云宝微信支付',
  4. 'payId' => '商户号',
  5. //'merchantAppId'=> '商户APPID',
  6. 'payKey'=> '商户密钥',
  7. );
  8. $config = array(
  9. 'payId' => array(
  10. 'INPUT_TYPE' => '0',
  11. ), //商户编号
  12. /*'merchantAppId' => array(
  13. 'INPUT_TYPE' => '0',
  14. ), //商户APPID*/
  15. 'payKey' => array(
  16. 'INPUT_TYPE' => '0',
  17. ), //商户私钥
  18. );
  19. /* 模块的基本信息 */
  20. if (isset($read_modules) && $read_modules == true)
  21. {
  22. $module['class_name'] = 'Youyunwx';
  23. /* 名称 */
  24. $module['name'] = $payment_lang['name'];
  25. /* 支付方式:1:在线支付;0:线下支付 2:仅wap支付 3:仅app支付 4:兼容wap和app*/
  26. $module['online_pay'] = '4';
  27. /* 配送 */
  28. $module['config'] = $config;
  29. $module['lang'] = $payment_lang;
  30. $module['reg_url'] = 'http://www.youyunnet.com/';
  31. return $module;
  32. }
  33. // 支付模型
  34. require_once(APP_ROOT_PATH.'system/libs/payment.php');
  35. class Youyunwx_payment implements payment {
  36. public function get_payment_code($payment_notice_id)
  37. {
  38. $pay = array();
  39. $pay['is_wap'] = 1;//
  40. $pay['class_name'] = "Youyunwx";
  41. $pay['url'] = SITE_DOMAIN . APP_ROOT . '/mapi/index.php?ctl=pay&act=get_display_code&pay_code=Youyunwx&notice_id=' . $payment_notice_id;
  42. $pay['sdk_code'] = array("pay_sdk_type" => "yjwap", "config" =>
  43. array(
  44. "url" => SITE_DOMAIN . APP_ROOT . '/mapi/index.php?ctl=pay&act=get_display_code&pay_code=Youyunwx&notice_id=' . $payment_notice_id,
  45. "is_wap" => 1
  46. )
  47. );
  48. return $pay;
  49. }
  50. public function response($request)
  51. {
  52. }
  53. public function notify($request)
  54. {
  55. $payment = $GLOBALS['db']->getRow("select id,config from " . DB_PREFIX . "payment where class_name='Youyunwx'");
  56. $config = unserialize($payment['config']);
  57. $ddh = $request['ddh']; //支付宝订单号
  58. $key = $request['key']; //KEY验证
  59. $name = $_POST['name']; //备注信息 接收网关data 参数 支付订单号
  60. $lb = $_POST['lb']; //分类 =1 支付宝 =2财付通 =3 微信
  61. $money = $_POST['money'];//金额
  62. $paytime = $_POST['paytime'];//充值时间
  63. $key2 = $config['payKey'];//APPKEY 和云端和软件上面保持一致
  64. //回调签名校验
  65. if($key==$key2){
  66. //<--------------------------商户业务代码写在下方-------------------------->
  67. $payment_notice_sn = $name;
  68. $outer_notice_sn = $ddh;
  69. $payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where notice_sn = '" . $payment_notice_sn . "'");
  70. require_once APP_ROOT_PATH . "system/libs/cart.php";
  71. $rs = payment_paid($payment_notice['notice_sn'],$outer_notice_sn);
  72. if($rs['status']==1){
  73. echo "ok";
  74. } else {
  75. echo 'key error';
  76. }
  77. //<--------------------------商户业务代码写在上方-------------------------->
  78. //下方输出是告知ISPAY服务器业务受理成功,请不要修改下方输出内容,否则会导致重复通知,ISPAY服务器会在24小时内通知8次,输出SUCCESS则不再进行通知
  79. //echo "SUCCESS";
  80. }else{
  81. echo 'key error';
  82. exit;
  83. }
  84. }
  85. function get_display_code(){
  86. }
  87. public function display_code($payment_notice_id)
  88. {
  89. $payment_notice = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."payment_notice where id = ".$payment_notice_id);
  90. $money = round($payment_notice['money'],2);
  91. $payment_info = $GLOBALS['db']->getRow("select id,config,logo from ".DB_PREFIX."payment where id=".intval($payment_notice['payment_id']));
  92. $config = unserialize($payment_info['config']);
  93. $order_sn = $payment_notice['notice_sn'];
  94. //商户编号
  95. $Request['pid'] = $config['payId'];
  96. //支付宝1 微信3 QQ钱包2
  97. $Request['lb'] = 3;
  98. //支付通道
  99. /*if (isset($_GET['payChannel'])) {
  100. $Request['payChannel'] = $_GET['payChannel'];
  101. } else {
  102. $Request['payChannel'] = "alipay";
  103. }
  104. $m_config = load_auto_cache("m_config");
  105. $title_name = $m_config['ticket_name'];
  106. if($title_name=='')
  107. $title_name = '虚拟印币';
  108. if(empty($title_name))
  109. {
  110. $title_name = "充值".round($payment_notice['money'],2)."元";
  111. }*/
  112. $post_url = "http://pay1.youyunnet.com/pay/";
  113. //订单标题
  114. //$Request['Subject'] = $title_name;
  115. //交易金额(单位分)
  116. $Request['money'] = intval($money);
  117. //随机生成订单号
  118. $Request['data'] = $order_sn;
  119. //附加数据(没有可不填)
  120. //$Request['attachData'] = "";
  121. //异步通知地址
  122. $Request['url'] = SITE_DOMAIN . '/callback/payment/youyunwx_notify.php';
  123. //客户端同步跳转通知地址
  124. //$Request['Return_url'] = SITE_DOMAIN .'/callback/payment/ispay_response.php';
  125. //签名(加密算法详见开发文档)
  126. //$Request['Sign'] = $Ispay -> Sign($Request);
  127. $payLinks = '<form id="payForm" name="form2" action="' . $post_url . '" method="post">';
  128. $payLinks .= '<input type="hidden" name="pid" id="pid" value="' . $Request['pid'] . '" />';
  129. $payLinks .= '<input type="hidden" name="lb" id="lb" value="' . $Request['lb'] . '"/>';
  130. //$payLinks .= '<input type="hidden" name="Subject" id="Subject" value="' . $Request['Subject'] . '"/>';
  131. $payLinks .= '<input type="hidden" name="money" id="money" value="' . $Request['money'] . '" />';
  132. $payLinks .= '<input type="hidden" name="data" id="data" value="' . $Request['data'] . '"/>';
  133. //$payLinks .= '<input type="hidden" name="attachData" id="attachData" value="' . $Request['attachData'] . '"/>';
  134. $payLinks .= '<input type="hidden" name="url" id="url" value="' . $Request['url'] . '"/>';
  135. //$payLinks .= '<input type="hidden" name="Return_url" id="Return_url" value="' . $Request['Return_url'] . '"/>';
  136. //$payLinks .= '<input type="hidden" name="Sign" id="Sign" value="' . $Request['Sign'] . '"/>';
  137. $payLinks .= '</form>';
  138. $payLinks .= '<script type="text/javascript">document.getElementById("payForm").submit();</script>';
  139. return $payLinks;
  140. }
  141. }
  142. ?>