AuthcodePay.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. // +---------------------------------------------------------------------+
  3. // | NiuCloud | [ WE CAN DO IT JUST NiuCloud ]  |
  4. // +---------------------------------------------------------------------+
  5. // | Copy right 2019-2029 www.niucloud.com  |
  6. // +---------------------------------------------------------------------+
  7. // | Author | NiuCloud <niucloud@outlook.com>  |
  8. // +---------------------------------------------------------------------+
  9. // | Repository | https://github.com/niucloud/framework.git  |
  10. // +---------------------------------------------------------------------+
  11. namespace addon\wechatpay\event;
  12. use addon\wechatpay\model\Pay as PayModel;
  13. use app\model\system\Pay as PayCommon;
  14. /**
  15. * 支付回调
  16. */
  17. class AuthcodePay
  18. {
  19. /**
  20. * 支付方式及配置
  21. */
  22. public function handle($params)
  23. {
  24. $out_trade_no = $params['out_trade_no'] ?? '';
  25. $auth_code_array = [10, 11, 12, 13, 14, 15];
  26. if(!empty($out_trade_no)){
  27. $auth_code = $params['auth_code'];
  28. $sub_str = substr($auth_code , 0 , 2);
  29. if(in_array($sub_str, $auth_code_array)){
  30. $pay = new PayCommon();
  31. $pay_info = $pay->getPayInfo($out_trade_no)['data'] ?? [];
  32. if(!empty($pay_info)){
  33. $site_id = $pay_info['site_id'] ?? 0;
  34. $pay_model = new PayModel(0, $site_id);
  35. $result = $pay_model->micropay(array_merge($params, $pay_info));
  36. return $result;
  37. }
  38. }
  39. }
  40. }
  41. }