人人商城

refund.ctrl.php 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. defined('IN_IA') or exit('Access Denied');
  7. load()->model('payment');
  8. load()->model('account');
  9. $dos = array('save_setting', 'display');
  10. $do = in_array($do, $dos) ? $do : 'display';
  11. permission_check_account_user('profile_payment_refund');
  12. $_W['page']['title'] = '退款参数 - 公众号选项';
  13. if ($do == 'display') {
  14. $setting = uni_setting_load('payment', $_W['uniacid']);
  15. $setting = (array)$setting['payment'];
  16. if (empty($setting['wechat_refund'])) {
  17. $setting['wechat_refund'] = array('switch' => 0, 'key' => '', 'cert' => '');
  18. }
  19. if (empty($setting['ali_refund'])) {
  20. $setting['ali_refund'] = array('switch' => 0, 'private_key' => '');
  21. }
  22. }
  23. if ($do == 'save_setting') {
  24. $type = $_GPC['type'];
  25. $param = $_GPC['param'];
  26. $setting = uni_setting_load('payment', $_W['uniacid']);
  27. $pay_setting = (array)$setting['payment'];
  28. if ($type == 'wechat_refund') {
  29. if (empty($_FILES['cert']['tmp_name'])) {
  30. if (empty($setting['payment']['wechat_refund']['cert']) && $param['switch'] == 1) {
  31. itoast('请上传apiclient_cert.pem证书', '', 'info');
  32. }
  33. $param['cert'] = $setting['payment']['wechat_refund']['cert'];
  34. } else {
  35. $param['cert'] = file_get_contents($_FILES['cert']['tmp_name']);
  36. if (strexists($param['cert'], '<?php') || substr($param['cert'], 0, 27) != '-----BEGIN CERTIFICATE-----' || substr($param['cert'], -24, 23) != '---END CERTIFICATE-----') {
  37. itoast('apiclient_cert.pem证书内容不合法,请重新上传');
  38. }
  39. $param['cert'] = authcode($param['cert'], 'ENCODE');
  40. }
  41. if (empty($_FILES['key']['tmp_name'])) {
  42. if (empty($setting['payment']['wechat_refund']['key']) && $param['switch'] == 1) {
  43. itoast ('请上传apiclient_key.pem证书', '', 'info');
  44. }
  45. $param['key'] = $setting['payment']['wechat_refund']['key'];
  46. } else {
  47. $param['key'] = file_get_contents($_FILES['key']['tmp_name']);
  48. if (strexists($param['key'], '<?php') || substr($param['key'], 0, 27) != '-----BEGIN PRIVATE KEY-----' || substr($param['key'], -24, 23) != '---END PRIVATE KEY-----') {
  49. itoast('apiclient_key.pem证书内容不合法,请重新上传');
  50. }
  51. $param['key'] = authcode($param['key'], 'ENCODE');
  52. }
  53. } elseif ($type == 'ali_refund') {
  54. if (empty($_FILES['private_key']['tmp_name'])) {
  55. if (empty($setting['payment']['ali_refund']['private_key']) && $param['switch'] == 1) {
  56. itoast('请上传rsa_private_key.pem证书', '', 'info');
  57. }
  58. $param['private_key'] = $setting['payment']['ali_refund']['private_key'];
  59. } else {
  60. $param['private_key'] = file_get_contents($_FILES['private_key']['tmp_name']);
  61. if (strexists($param['private_key'], '<?php') || substr($param['private_key'], 0, 27) != '-----BEGIN RSA PRIVATE KEY-' || substr($param['private_key'], -24, 23) != 'ND RSA PRIVATE KEY-----') {
  62. itoast('rsa_private_key.pem证书内容不合法,请重新上传');
  63. }
  64. $param['private_key'] = authcode($param['private_key'], 'ENCODE');
  65. }
  66. }
  67. $pay_setting[$type] = $param;
  68. uni_setting_save('payment', $pay_setting);
  69. itoast('设置成功', '', 'success');
  70. }
  71. template('profile/refund');