PayNotify.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\wechatpay\event;
  11. use addon\wechatpay\model\Pay as PayModel;
  12. /**
  13. * 支付回调
  14. */
  15. class PayNotify
  16. {
  17. /**
  18. * 支付方式及配置
  19. */
  20. public function handle($param)
  21. {
  22. try {
  23. $reqData = empty($GLOBALS[ 'HTTP_RAW_POST_DATA' ]) ? file_get_contents('php://input') : $GLOBALS[ 'HTTP_RAW_POST_DATA' ];
  24. if (empty($reqData)) {
  25. return;
  26. }
  27. $xmlstring = simplexml_load_string($reqData, 'SimpleXMLElement', LIBXML_NOCDATA);
  28. if (empty($xmlstring)) {
  29. return;
  30. }
  31. $val = json_decode(json_encode($xmlstring), true);
  32. if (!empty($val[ 'trade_type' ]) && $val[ 'trade_type' ] != 'APP') {
  33. return ( new PayModel() )->payNotify();
  34. }
  35. }catch (\Exception $e){
  36. return ( new PayModel() )->payNotify();
  37. }
  38. }
  39. }