ScanByWechatPay.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace addons\YunfastPay\common\services\pays\cashier;
  3. use addons\YunfastPay\common\services\pays\PayAbstract;
  4. use addons\YunfastPay\common\services\trans\nocash\ScanPayTrans;
  5. use Yii;
  6. use yii\helpers\Json;
  7. /**
  8. * 微信收银台支付
  9. * @package addons\YunfastPay\common\services\pays\cashier
  10. */
  11. class ScanByWechatPay extends PayAbstract
  12. {
  13. /**
  14. * @return ScanPayTrans
  15. */
  16. public function getTrans()
  17. {
  18. $trade = $this->pay->getTrade();
  19. $openid = $this->pay->getOpenid();
  20. $app_id = Yii::$app->services->setting->mall->get($this->pay->mall_id, 'wechat.app_id');
  21. $trans = new ScanPayTrans(
  22. $trade->out_trade_no,
  23. $trade->pay_fee,
  24. $trade->title
  25. );
  26. // 设置环境
  27. $trans->setBrowser('wxpay');
  28. $trans->setAppid($app_id);
  29. $trans->setBuyerCd($openid);
  30. return $trans;
  31. }
  32. public function getPayData(array $result)
  33. {
  34. $result = Json::decode($result['qrData']);
  35. $result['timestamp'] = $result['timeStamp'];
  36. return $result;
  37. }
  38. }