AliPay.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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\storage;
  12. use Alipay\EasySDK\Payment\Common\Models\AlipayTradeFastpayRefundQueryResponse;
  13. use Alipay\EasySDK\Payment\Common\Models\AlipayTradeRefundResponse;
  14. use Alipay\EasySDK\Payment\Wap\Models\AlipayTradeWapPayResponse;
  15. use crmeb\services\pay\BasePay;
  16. use crmeb\services\pay\PayInterface;
  17. use crmeb\services\AliPayService;
  18. /**
  19. * 支付宝支付
  20. * Class AliPay
  21. * @package crmeb\services\pay\storage
  22. */
  23. class AliPay extends BasePay implements PayInterface
  24. {
  25. protected function initialize(array $config)
  26. {
  27. // TODO: Implement initialize() method.
  28. }
  29. /**
  30. * 创建订单发起支付
  31. * @param string $orderId
  32. * @param string $totalFee
  33. * @param string $attach
  34. * @param string $body
  35. * @param string $detail
  36. * @param string|null $tradeType
  37. * @param array $options
  38. * @return AlipayTradeWapPayResponse|mixed
  39. */
  40. public function create(string $orderId, string $totalFee, string $attach, string $body, string $detail, array $options = [])
  41. {
  42. $code = false;
  43. if (request()->isPC() || request()->isRoutine()) {
  44. $code = true;
  45. }
  46. return AliPayService::instance()->create($body, $orderId, $totalFee, $attach, $options['quitUrl'] ?? '', $options['returnUrl'] ?? '', $code);
  47. }
  48. /**
  49. * 企业支付到零钱
  50. * @param string $openid
  51. * @param string $orderId
  52. * @param string $amount
  53. * @param array $options
  54. * @return bool|mixed
  55. */
  56. public function merchantPay(string $openid, string $orderId, string $amount, array $options = [])
  57. {
  58. return false;
  59. }
  60. /**
  61. * 退款
  62. * @param string $outTradeNo
  63. * @param string $totalAmount
  64. * @param string $refund_id
  65. * @param array $options
  66. * @return AlipayTradeRefundResponse|mixed
  67. */
  68. public function refund(string $outTradeNo, array $options = [])
  69. {
  70. return AliPayService::instance()->refund($outTradeNo, $options['totalAmount'], $options['refund_id']);
  71. }
  72. /**
  73. * 查询退款
  74. * @param string $outTradeNo
  75. * @param string $outRequestNo
  76. * @param array $other
  77. * @return AlipayTradeFastpayRefundQueryResponse|mixed
  78. */
  79. public function queryRefund(string $outTradeNo, string $outRequestNo, array $other = [])
  80. {
  81. return AliPayService::instance()->queryRefund($outTradeNo, $outRequestNo);
  82. }
  83. /**
  84. * 支付异步回调
  85. * @return mixed|string
  86. */
  87. public function handleNotify()
  88. {
  89. return AliPayService::handleNotify();
  90. }
  91. }