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