Pay.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // +---------------------------------------------------------------------+
  3. // | NiuCloud | [ WE CAN DO IT JUST NiuCloud ]  |
  4. // +---------------------------------------------------------------------+
  5. // | Copy right 2019-2029 www.niucloud.com  |
  6. // +---------------------------------------------------------------------+
  7. // | Author | NiuCloud <niucloud@outlook.com>  |
  8. // +---------------------------------------------------------------------+
  9. // | Repository | https://github.com/niucloud/framework.git  |
  10. // +---------------------------------------------------------------------+
  11. declare (strict_types = 1);
  12. namespace addon\wechatpay\event;
  13. use addon\wechatpay\model\Pay as PayModel;
  14. /**
  15. * 生成支付
  16. */
  17. class Pay
  18. {
  19. /**
  20. * 支付
  21. */
  22. public function handle($params)
  23. {
  24. // print_r($params);die;
  25. if($params["pay_type"] == "wechatpay"){
  26. $app_type = $params['app_type'];
  27. $is_weapp = 0;
  28. switch ($app_type){
  29. case 'h5' :
  30. $trade_type = "MWEB";
  31. break;
  32. case 'wechat' :
  33. $trade_type = "JSAPI";
  34. break;
  35. case 'weapp' :
  36. $is_weapp = 1;
  37. $trade_type = "JSAPI";
  38. break;
  39. case 'app' :
  40. $trade_type = "APP";
  41. break;
  42. case 'pc' :
  43. $trade_type = "NATIVE";
  44. break;
  45. }
  46. $params["trade_type"] = $trade_type;
  47. $pay_model = new PayModel($is_weapp);
  48. print_r($params);die;
  49. $result = $pay_model->pay($params);
  50. return $result;
  51. }
  52. }
  53. }