H5Pay.php 947 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace addons\YunfastPay\common\services\pays\order;
  3. use addons\YunfastPay\common\services\pays\PayAbstract;
  4. use addons\YunfastPay\common\services\trans\nocash\H5PayTrans;
  5. use Yii;
  6. /**
  7. * h5支付
  8. * @package addons\YunfastPay\common\services\pays\order
  9. */
  10. class H5Pay extends PayAbstract
  11. {
  12. /**
  13. * @return H5PayTrans
  14. */
  15. public function getTrans()
  16. {
  17. $app_id = Yii::$app->services->setting->mall->get($this->pay->mall_id, 'mini_program.app_id');
  18. if (empty($app_id)) {
  19. throw new \Exception('小程序APPID未配置');
  20. }
  21. $trade = $this->pay->getTrade();
  22. $trans = new H5PayTrans(
  23. $trade->out_trade_no,
  24. $trade->pay_fee,
  25. $app_id,
  26. $trade->title
  27. );
  28. return $trans;
  29. }
  30. public function getPayData(array $result)
  31. {
  32. return [
  33. 'url' => $result['qrData'],
  34. ];
  35. }
  36. }