Pay.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com.cn
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace app\pay\controller;
  13. use app\Controller;
  14. use think\facade\Log;
  15. /**
  16. * 支付控制器
  17. */
  18. class Pay extends Controller
  19. {
  20. /**
  21. * 支付异步回调
  22. */
  23. public function VipPayNotify()
  24. {
  25. $data = file_get_contents('php://input');
  26. $is_xml = xml_parser($data);
  27. if($is_xml) {
  28. $jsonXml = json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA));
  29. $data = json_decode($jsonXml, true);
  30. Log::write('pay_notifiy:'.$jsonXml, 'notice');
  31. }
  32. else{
  33. $data = input();
  34. Log::write('pay_notifiy_pay:'.var_export($data,true), 'notice');
  35. }
  36. event('VipPayNotify', $data);
  37. }
  38. public function FranchiseePayNotify()
  39. {
  40. $data = file_get_contents('php://input');
  41. $is_xml = xml_parser($data);
  42. if($is_xml) {
  43. $jsonXml = json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA));
  44. $data = json_decode($jsonXml, true);
  45. Log::write('pay_notifiy:'.$jsonXml, 'notice');
  46. }
  47. else{
  48. $data = input();
  49. Log::write('pay_notifiy_pay:'.var_export($data,true), 'notice');
  50. }
  51. event('FranchiseePayNotify', $data);
  52. }
  53. public function OrderPayNotify()
  54. {
  55. $data = file_get_contents('php://input');
  56. $is_xml = xml_parser($data);
  57. if($is_xml) {
  58. $jsonXml = json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA));
  59. $data = json_decode($jsonXml, true);
  60. $data['pay_type']='wechatpay';
  61. Log::write('pay_notifiy:'.$jsonXml, 'notice');
  62. }
  63. else{
  64. $data = input();
  65. $data['pay_type']='alipay';
  66. Log::write('pay_notifiy_pay:'.var_export($data,true), 'notice');
  67. }
  68. event('OrderPayNotify', $data);
  69. }
  70. public function SupplierPayNotify()
  71. {
  72. $data = file_get_contents('php://input');
  73. $is_xml = xml_parser($data);
  74. if($is_xml) {
  75. $jsonXml = json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA));
  76. $data = json_decode($jsonXml, true);
  77. Log::write('pay_notifiy:'.$jsonXml, 'notice');
  78. }
  79. else{
  80. $data = input();
  81. Log::write('pay_notifiy_pay:'.var_export($data,true), 'notice');
  82. }
  83. event('SupplierPayNotify', $data);
  84. }
  85. public function BalancePayNotify()
  86. {
  87. $data = file_get_contents('php://input');
  88. $is_xml = xml_parser($data);
  89. if($is_xml) {
  90. $jsonXml = json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA));
  91. $data = json_decode($jsonXml, true);
  92. Log::write('pay_notifiy:'.$jsonXml, 'notice');
  93. }
  94. else{
  95. $data = input();
  96. Log::write('pay_notifiy_pay:'.var_export($data,true), 'notice');
  97. }
  98. file_put_contents('pay3_log.log', $data["out_trade_no"]);
  99. event('BalancePayNotify', $data);
  100. }
  101. public function payReturn()
  102. {
  103. }
  104. }