Order.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\framework\EasyWechat\Payment;
  3. use EasyWeChat\Payment\Order\Client as BaseClient;
  4. use EasyWeChat\Kernel\Support;
  5. class Order extends BaseClient
  6. {
  7. public function microPay(array $params, $isContract = false)
  8. {
  9. $params['spbill_create_ip'] = Support\get_server_ip();
  10. $params['appid'] = $this->app['config']->app_id;
  11. $columns = ['appid', 'mch_id', 'device_info', 'nonce_str', 'sign', 'sign_type', 'body',
  12. 'detail', 'attach', 'out_trade_no', 'total_fee', 'fee_type', 'spbill_create_ip',
  13. 'goods_tag', 'limit_pay', 'time_start', 'time_expire', 'receipt', 'auth_code',
  14. 'profit_sharing', 'scene_info'
  15. ];
  16. foreach ($params as $k => $v) {
  17. if (!in_array($k, $columns)) {
  18. unset($params[$k]);
  19. }
  20. }
  21. // $params['notify_url'] = $params['notify_url'] ?? $this->app['config']['notify_url'];
  22. // if (empty($params['spbill_create_ip'])) {
  23. // $params['spbill_create_ip'] = ('NATIVE' === $params['trade_type']) ? Support\get_server_ip() : Support\get_client_ip();
  24. // }
  25. //
  26. // $params['appid'] = $this->app['config']->app_id;
  27. // $params['notify_url'] = $params['notify_url'] ?? $this->app['config']['notify_url'];
  28. //
  29. // if ($isContract) {
  30. // $params['contract_appid'] = $this->app['config']['app_id'];
  31. // $params['contract_mchid'] = $this->app['config']['mch_id'];
  32. // $params['request_serial'] = $params['request_serial'] ?? time();
  33. // $params['contract_notify_url'] = $params['contract_notify_url'] ?? $this->app['config']['contract_notify_url'];
  34. //
  35. // return $this->request($this->wrap('pay/contractorder'), $params);
  36. // }
  37. //
  38. // return $this->request('https://api.mch.weixin.qq.com/pay/micropay',$params);
  39. return $this->request($this->wrap('pay/micropay'), $params);
  40. }
  41. }