ScanPayTrans.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. namespace addons\YunfastPay\common\services\trans\nocash;
  3. use addons\YunfastPay\common\services\trans\TransAbstract;
  4. /**
  5. * 扫码支付
  6. * ScanPayTrans class
  7. * @package addons\YunfastPay\common\services\trans\nocash
  8. * @see https://yunfastpay.com/#/interface/sm
  9. */
  10. class ScanPayTrans extends TransAbstract
  11. {
  12. /**
  13. * 微信openid
  14. *
  15. * @var string
  16. */
  17. protected $buyerCd;
  18. /**
  19. * 公众号appid
  20. *
  21. * @var string
  22. */
  23. protected $appid;
  24. /**
  25. * 实例化
  26. *
  27. * @param string $outOrderId
  28. * @param float $transAmt
  29. * @param string $outOrderTitle
  30. * @param string $outOrderDesc
  31. */
  32. public function __construct(
  33. string $outOrderId,
  34. float $transAmt,
  35. string $outOrderTitle,
  36. string $outOrderDesc = ''
  37. )
  38. {
  39. parent::__construct($outOrderId, $transAmt, $outOrderTitle, $outOrderDesc);
  40. }
  41. /**
  42. * @param string $appid
  43. * @return void
  44. */
  45. public function setAppid(string $appid)
  46. {
  47. $this->appid = $appid;
  48. }
  49. /**
  50. * @param string $buyerCd
  51. * @return void
  52. */
  53. public function setBuyerCd(string $buyerCd)
  54. {
  55. $this->buyerCd = $buyerCd;
  56. }
  57. /**
  58. * 交易码,扫码支付固定:TRANS0105
  59. *
  60. * @return string
  61. */
  62. public function getTrscode() :string
  63. {
  64. return 'TRANS0105';
  65. }
  66. /**
  67. * 聚合:tran
  68. *
  69. * @return string
  70. */
  71. public function getProCd() :string
  72. {
  73. return 'tran';
  74. }
  75. /**
  76. * 费率通道
  77. *
  78. * @return integer
  79. */
  80. public function getChanelType() :int
  81. {
  82. return 1;
  83. }
  84. public function getTransData(string $mchtCd) :array
  85. {
  86. $reqData['trscode'] = $this->getTrscode();
  87. $reqData['mchtCd'] = $mchtCd;
  88. $reqData['outOrderId'] = $this->outOrderId;
  89. $reqData['transAmt'] = $this->transAmt;
  90. $reqData['proCd'] = $this->getProCd();
  91. $reqData['chanelType'] = $this->getChanelType();
  92. $reqData['outOrderTitle'] = $this->outOrderTitle;
  93. $reqData['outOrderDesc'] = $this->outOrderDesc;
  94. $reqData['browser'] = $this->getBrowser();
  95. $reqData['expireTime'] = $this->getExpireTime();
  96. $reqData['isSplitBill'] = 1; // $this->getIsSplitBill();
  97. // 微信环境下使用数据
  98. $this->appid && $reqData['appid'] = $this->appid;
  99. $this->buyerCd && $reqData['buyerCd'] = $this->buyerCd;
  100. // 分账信息
  101. // $itemsList = $this->getSplitBill();
  102. // $itemsList && $reqData['itemsList'] = $itemsList;
  103. return $reqData;
  104. }
  105. }