You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

98 lines
2.7 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 倪宗锋
  12. * PhpStorm PayService.php
  13. * Create By 2017/3/3 19:53 $
  14. */
  15. namespace addons\nzf;
  16. class PayService
  17. {
  18. /**
  19. * Des:扫码支付
  20. * Name: sao
  21. * @param $params array order_id:订单ID name:订单名称 total_fee:总金额-元
  22. * @param int $type 3、微信4、支付宝
  23. * @return array
  24. * @author 倪宗锋
  25. */
  26. public static function sao($params, $type = 1)
  27. {
  28. if ($type == 3) {
  29. $pay = new WeChatPay();//微信支付类
  30. } else {
  31. $pay = new AliPay();//支付宝支付类
  32. }
  33. $return = $pay->unifiedOrderByOrderIdForSao($params);
  34. return $return;
  35. }
  36. /**
  37. * Des:取消订单
  38. * Name: cancel
  39. * @param $params array order_id:订单ID name:订单名称 total_fee:总金额-元 refund_fee退款金额
  40. * @param int $type 3、微信 4、支付宝
  41. * @return array
  42. * @author 倪宗锋
  43. */
  44. public static function cancel($params, $type)
  45. {
  46. if ($type == 3) {//微信支付
  47. $pay = new WeChatPay();
  48. $return = $pay->cancelOrder($params);
  49. } else {//阿里支付
  50. $pay = new AliPay();
  51. $return = $pay->cancelOrder($params);
  52. }
  53. return $return;
  54. }
  55. /**
  56. * Des: 直接付款
  57. * Name: pay
  58. * @param $params array
  59. * $order_id string 订单表 订单ID
  60. * $name string 产品名称
  61. * $total_fee int 总金额 单位元
  62. * $openid string 用户opendid
  63. * @param $type 1微信 2支付宝
  64. *
  65. * @return array
  66. * @author 倪宗锋
  67. */
  68. public static function pay($params,$type = 1)
  69. {
  70. if($type == 1) {
  71. $pay = new WeChatPay();//微信支付类
  72. }else {
  73. $pay = new AliPay();//支付宝支付类
  74. }
  75. $return = $pay->webPay($params);
  76. return $return['data']['payData'];
  77. }
  78. /**
  79. * Des: 支付 目前只支持微信直接支付
  80. * Name: pay
  81. * @param $orderId string 订单ID
  82. *
  83. * @return array
  84. * @author 倪宗锋
  85. */
  86. public static function checkIsPay($orderId)
  87. {
  88. $pay = new WeChatPay();
  89. $return = $pay->checkIsPay($orderId);
  90. return $return;
  91. }
  92. }