Payment.php 2.5 KB

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