PayReturnService.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\common\service;
  3. use addons\epay\library\Service;
  4. use app\common\model\Payment;
  5. use com\unionpay\acp\sdk\AcpService;
  6. use com\unionpay\acp\sdk\UnionQuery;
  7. use fast\Arr;
  8. use think\App;
  9. class PayReturnService{
  10. /** @var Payment */
  11. protected $payment;
  12. /**
  13. * @param Payment $payment
  14. */
  15. public function setPayment(Payment $payment): void
  16. {
  17. $this->payment = $payment;
  18. }
  19. public function companyBank(){
  20. }
  21. public function wechat(){
  22. $payed=Service::checkNotify('wechat');
  23. return [
  24. $payed!==false,
  25. 'success'
  26. ];
  27. }
  28. public function returnUrl(){
  29. return request()->root(true);
  30. }
  31. public function alipay(){
  32. $payed=Service::checkNotify('alipay');
  33. return [
  34. $payed!==false,
  35. 'success'
  36. ];
  37. }
  38. public function bankUnion(){
  39. require __DIR__.'/../library/upacp_demo_b2c/sdk/acp_service.php';
  40. $postData=input();
  41. $isPay=AcpService::validate($_POST);
  42. $queryPay=UnionQuery::query($postData['orderId'],$this->payment->create_time);
  43. user_log('PayReturnService.bankUnion',compact('isPay','queryPay'));
  44. return [
  45. $isPay && $queryPay,
  46. 'success'
  47. ];
  48. }
  49. public function otherUser(){}
  50. public function offline(){}
  51. public function process(){
  52. $method=Arr::get(OrderPayService::$methods,$this->payment->pay_type);
  53. return App::invokeMethod([$this,$method]);
  54. }
  55. }