Payment.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. *
  7. *
  8. * ----------------------------------------------------------------------------
  9. *
  10. * 支付回调控制器
  11. */
  12. class Payment extends MobileMall
  13. {
  14. public function initialize()
  15. {
  16. parent::initialize(); // TODO: Change the autogenerated stub
  17. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/buy.lang.php');
  18. }
  19. /**
  20. * Alipay支付回调
  21. */
  22. public function alipay_h5_return()
  23. {
  24. $out_trade_no = explode('-', input('param.out_trade_no'));
  25. $order_type = $out_trade_no['0'];
  26. $out_trade_no = $out_trade_no['1'];
  27. $trade_no = input('param.trade_no');
  28. $payment_code = 'alipay_h5';
  29. //创建支付接口对象
  30. $logic_payment = model('payment', 'logic');
  31. $result = $logic_payment->getPaymentInfo($payment_code);
  32. if (!$result['code']) {
  33. $this->error($result['msg'], 'Memberorder/index');
  34. }
  35. $payment_info = $result['data'];
  36. //创建支付接口对象
  37. $payment_api = new $payment_info['payment_code']($payment_info);
  38. //取得支付结果
  39. $callback_info = $payment_api->verify_return();
  40. if (!$callback_info) {
  41. View::assign('result', 'fail');
  42. View::assign('message', lang('order_pay_fail'));
  43. } else {
  44. View::assign('result', 'success');
  45. View::assign('message', lang('order_payment_success'));
  46. }
  47. //支付成功后跳转
  48. if ($order_type == 'real_order') {
  49. $pay_ok_url = config('ds_config.h5_site_url') . '/pages/member/order/OrderList';
  50. } elseif ($order_type == 'vr_order') {
  51. $pay_ok_url = config('ds_config.h5_site_url') . '/pages/member/vrorder/OrderList';
  52. } elseif ($order_type == 'pd_order') {
  53. $pay_ok_url = config('ds_config.h5_site_url') . '/pages/member/recharge/RechargeList';
  54. }
  55. View::assign('pay_ok_url', $pay_ok_url);
  56. return View::fetch('payment_message');
  57. }
  58. }