You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PayController.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\controller\api\v1;
  3. use crmeb\services\AliPayService;
  4. use crmeb\services\wechat\Payment;
  5. /**
  6. * 支付相关回调
  7. * Class PayController
  8. * @package app\api\controller\v1
  9. */
  10. class PayController
  11. {
  12. /**
  13. * 支付回调
  14. * @param string $type
  15. * @return string|\think\Response
  16. * @throws \EasyWeChat\Kernel\Exceptions\Exception
  17. */
  18. public function notify(string $type)
  19. {
  20. switch (urldecode($type)) {
  21. case 'alipay':
  22. return AliPayService::handleNotify();
  23. break;
  24. case 'routine':
  25. return Payment::instance()->setAccessEnd(Payment::MINI)->handleNotify();
  26. break;
  27. case 'wechat':
  28. return Payment::instance()->setAccessEnd(Payment::WEB)->handleNotify();
  29. break;
  30. case 'app':
  31. return Payment::instance()->setAccessEnd(Payment::APP)->handleNotify();
  32. break;
  33. }
  34. }
  35. /**
  36. * 退款回调
  37. * @param string $type
  38. * @return \think\Response
  39. * @throws \EasyWeChat\Kernel\Exceptions\Exception
  40. */
  41. public function refund(string $type)
  42. {
  43. switch (urldecode($type)) {
  44. case 'alipay':
  45. break;
  46. case 'routine':
  47. return Payment::instance()->setAccessEnd(Payment::MINI)->handleRefundedNotify();
  48. break;
  49. case 'wechat':
  50. return Payment::instance()->setAccessEnd(Payment::WEB)->handleRefundedNotify();
  51. break;
  52. case 'app':
  53. return Payment::instance()->setAccessEnd(Payment::APP)->handleRefundedNotify();
  54. break;
  55. }
  56. }
  57. }