AlipayController.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * AlipayController.php UTF-8
  4. *
  5. *
  6. * @date : 2018/6/6 20:22
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : luowei <lw@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace api\wapapp\controller\v8;
  13. use api\common\controller\V2ApiBaseController;
  14. use huolib\pay\Pay;
  15. use think\Config;
  16. class AlipayController extends V2ApiBaseController {
  17. function _initialize() {
  18. parent::_initialize();
  19. Config::set('default_return_type', 'html');
  20. }
  21. /**
  22. * 支付宝支付通知地址
  23. * alipay/return
  24. *
  25. * @return mixed
  26. * @throws \think\Exception
  27. */
  28. public function returnUrl() {
  29. $_pay_class = Pay::ins()->get('alipay');
  30. $_pay_rs = $_pay_class->returnUrl();
  31. $this->assign('info', $_pay_rs);
  32. $_msg = "支付成功!";
  33. if ("3" == $_pay_rs['status']) {
  34. $_msg = "支付失败!";
  35. $this->assign('msg', $_msg);
  36. return $this->fetch('order/failed');
  37. }
  38. $this->assign('msg', $_msg);
  39. return $this->fetch('order/success');
  40. }
  41. /**
  42. * 支付宝支付显示地址
  43. * alipay/show
  44. *
  45. * @return mixed
  46. */
  47. public function showUrl() {
  48. $_order_id = $this->request->param('order_id');
  49. if (empty($_order_id)) {
  50. $_msg = '未支付';
  51. $this->assign('msg', $_msg);
  52. return $this->fetch('order/failed');
  53. }
  54. $_msg = '玩家取消支付,请重新下单';
  55. $this->assign('msg', $_msg);
  56. return $this->fetch('order/failed');
  57. }
  58. }