BasePay.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace crmeb\services\pay;
  12. use EasyWeChat\Payment\Order;
  13. use crmeb\basic\BaseStorage;
  14. /**
  15. * Class BasePay
  16. * @package crmeb\services\pay
  17. */
  18. abstract class BasePay extends BaseStorage
  19. {
  20. /**
  21. * @var string
  22. */
  23. protected $payType;
  24. /**
  25. * 设置支付类型
  26. * @param string $type
  27. * @return $this
  28. */
  29. public function setPayType(string $type)
  30. {
  31. $this->payType = $type;
  32. return $this;
  33. }
  34. /**
  35. * 设置支付类型
  36. * @param string $type
  37. * @return $this
  38. */
  39. public function authSetPayType()
  40. {
  41. if (!$this->payType) {
  42. if (request()->isPc()) {
  43. $this->payType = Order::NATIVE;
  44. }
  45. if (request()->isApp()) {
  46. $this->payType = Order::APP;
  47. }
  48. if (request()->isRoutine() || request()->isWechat()) {
  49. $this->payType = Order::JSAPI;
  50. }
  51. if (request()->isH5()) {
  52. $this->payType = 'h5';
  53. }
  54. }
  55. }
  56. }