Notify.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\data\controller\api;
  3. use app\data\service\payment\AlipayPaymentService;
  4. use app\data\service\payment\JoinpayPaymentService;
  5. use app\data\service\payment\WechatPaymentService;
  6. use think\admin\Controller;
  7. /**
  8. * 异步通知处理
  9. * Class Notify
  10. * @package app\data\controller\api
  11. */
  12. class Notify extends Controller
  13. {
  14. /**
  15. * 微信支付通知
  16. * @param string $scene 支付场景
  17. * @param string $param 支付参数
  18. * @return string
  19. * @throws \think\admin\Exception
  20. */
  21. public function wxpay(string $scene = 'order', string $param = ''): string
  22. {
  23. if (strtolower($scene) === 'order') {
  24. return WechatPaymentService::instance($param)->notify();
  25. } else {
  26. return 'success';
  27. }
  28. }
  29. /**
  30. * 支付宝支付通知
  31. * @param string $scene 支付场景
  32. * @param string $param 支付参数
  33. * @return string
  34. * @throws \think\admin\Exception
  35. */
  36. public function alipay(string $scene = 'order', string $param = ''): string
  37. {
  38. if (strtolower($scene) === 'order') {
  39. return AlipayPaymentService::instance($param)->notify();
  40. } else {
  41. return 'success';
  42. }
  43. }
  44. /**
  45. * 汇聚支付通知
  46. * @param string $scene 支付场景
  47. * @param string $param 支付参数
  48. * @return string
  49. * @throws \think\admin\Exception
  50. */
  51. public function joinpay(string $scene = 'order', string $param = ''): string
  52. {
  53. if (strtolower($scene) === 'order') {
  54. return JoinpayPaymentService::instance($param)->notify();
  55. } else {
  56. return 'success';
  57. }
  58. }
  59. }