ShengpayController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * AlipayController.php UTF-8
  4. * 支付宝对外处理页面
  5. *
  6. * @date : 2018/2/8 15:42
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace api\sdk\controller;
  13. use api\common\controller\V2ApiBaseController;
  14. use huo\controller\pay\Notify;
  15. use huolib\pay\Pay;
  16. use think\Config;
  17. class ShengpayController extends V2ApiBaseController {
  18. function _initialize() {
  19. parent::_initialize();
  20. \think\Log::write($this->request->getContent(), 'error');
  21. Config::set('default_return_type', 'html');
  22. }
  23. /**
  24. * 盛付通支付回调地址
  25. * shengpay/notify
  26. */
  27. public function notifyUrl() {
  28. $_class = new Notify();
  29. if (!isset($_REQUEST['Ext1'])) {
  30. exit('fail');
  31. }
  32. $_ext1 = $_REQUEST['Ext1'];
  33. $_ext1 = htmlspecialchars_decode($_ext1);
  34. $_ext = json_decode($_ext1, true);
  35. $_product_id = $_ext['product_id'];
  36. $_class->notifyUrl('shengpay', $_product_id);
  37. }
  38. /**
  39. * 盛付通支付成功后通知地址
  40. * shengpay/return
  41. *
  42. * @return mixed
  43. * @throws \think\Exception
  44. */
  45. public function returnUrl() {
  46. $_pay_class = Pay::ins()->get('shengpay');
  47. $_pay_rs = $_pay_class->returnUrl();
  48. $this->assign('info', $_pay_rs);
  49. $_msg = "支付成功!";
  50. $this->assign('return_url', '');
  51. if ("3" == $_pay_rs['status']) {
  52. $_msg = "支付失败!";
  53. $this->assign('msg', $_msg);
  54. return $this->fetch('order/failed');
  55. }
  56. $this->assign('msg', $_msg);
  57. return $this->fetch('order/success');
  58. }
  59. }