pay.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. define('IN_MOBILE', true);
  7. require '../../framework/bootstrap.inc.php';
  8. require '../../app/common/bootstrap.app.inc.php';
  9. load()->app('common');
  10. load()->app('template');
  11. load()->model('payment');
  12. $sl = $_GPC['ps'];
  13. $params = @json_decode(base64_decode($sl), true);
  14. if($_GPC['done'] == '1') {
  15. $sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `plid`=:plid';
  16. $pars = array();
  17. $pars[':plid'] = $_GPC['tid'];
  18. $log = pdo_fetch($sql, $pars);
  19. if(!empty($log) && !empty($log['status'])) {
  20. if (!empty($log['tag'])) {
  21. $tag = iunserializer($log['tag']);
  22. $log['uid'] = $tag['uid'];
  23. }
  24. $site = WeUtility::createModuleSite($log['module']);
  25. if(!is_error($site)) {
  26. $method = 'payResult';
  27. if (method_exists($site, $method)) {
  28. $ret = array();
  29. $ret['weid'] = $log['uniacid'];
  30. $ret['uniacid'] = $log['uniacid'];
  31. $ret['result'] = 'success';
  32. $ret['type'] = $log['type'];
  33. $ret['from'] = 'return';
  34. $ret['tid'] = $log['tid'];
  35. $ret['uniontid'] = $log['uniontid'];
  36. $ret['user'] = $log['openid'];
  37. $ret['fee'] = $log['fee'];
  38. $ret['tag'] = $tag;
  39. $ret['is_usecard'] = $log['is_usecard'];
  40. $ret['card_type'] = $log['card_type'];
  41. $ret['card_fee'] = $log['card_fee'];
  42. $ret['card_id'] = $log['card_id'];
  43. exit($site->$method($ret));
  44. }
  45. }
  46. }
  47. }
  48. $setting = uni_setting($_W['uniacid'], array('payment'));
  49. if(!is_array($setting['payment'])) {
  50. exit('没有设定支付参数.');
  51. }
  52. $jueqiymf = $setting['payment']['jueqiymf'];
  53. $sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `plid`=:plid';
  54. $paylog = pdo_fetch($sql, array(':plid' => $params['tid']));
  55. if(!empty($paylog) && $paylog['status'] != '0') {
  56. exit('这个订单已经支付成功, 不需要重复支付.');
  57. }
  58. $auth = sha1($sl . $paylog['uniacid'] . $_W['config']['setting']['authkey']);
  59. if($auth != $_GPC['auth']) {
  60. exit('参数传输错误.');
  61. }
  62. $host = $jueqiymf['url'];
  63. $uid = $paylog['module'];
  64. $selfOrdernum = $params['tid'];
  65. $openId = $_W['fans']['from_user'];
  66. $customerId = $jueqiymf['mchid'];
  67. $money = $params['fee'];
  68. ksort($params, SORT_STRING);
  69. $string1 = '';
  70. foreach ($params as $k => $v) {
  71. $string1 .= "&{$k}={$v}";
  72. }
  73. $notifyUrl =base64_encode(urlencode(($_W['siteroot'] . '/payment/jueqiymf/notify.php?1=1'.$string1)));
  74. $successUrl =base64_encode(urlencode(($_W['siteroot'] . '/payment/jueqiymf/pay.php?i='.$_W['uniacid'].'&done=1'.$string1)));
  75. $goodsName=$params['title'];
  76. $url=$host.'/index.php?s=/Home/linewq/m_pay';
  77. $url=$url.'/selfOrdernum/'.$selfOrdernum.'/openId/'.$openId.'/customerId/'.$customerId.'/money/'.$money.'/notifyUrl/'.$notifyUrl.'/successUrl/'.$successUrl.'/uid/'.$uid.'/goodsName/'.$goodsName.'/remark/'.$remark;
  78. header('location:'.$url);
  79. exit;