AuthcodePay.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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\alipay\event;
  12. use addon\alipay\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 = [25, 26, 27, 28, 29, 30];
  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($site_id);
  35. $result = $pay_model->micropay(array_merge($params, $pay_info));
  36. return $result;
  37. }
  38. }
  39. }
  40. }
  41. }