H5PayTrans.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace addons\YunfastPay\common\services\trans\nocash;
  3. use addons\YunfastPay\common\services\trans\TransAbstract;
  4. /**
  5. * h5支付
  6. * H5PayTrans class
  7. * @package addons\YunfastPay\common\services\trans\nocash
  8. * @see https://yunfastpay.com/#/interface/tyxd
  9. */
  10. class H5PayTrans extends TransAbstract
  11. {
  12. /**
  13. * @var string
  14. */
  15. protected $appid;
  16. /**
  17. * 实例化
  18. *
  19. * @param string $outOrderId
  20. * @param float $transAmt
  21. * @param string $appid
  22. * @param string $outOrderTitle
  23. * @param string $outOrderDesc
  24. */
  25. public function __construct(
  26. string $outOrderId,
  27. float $transAmt,
  28. string $appid,
  29. string $outOrderTitle,
  30. string $outOrderDesc = ''
  31. )
  32. {
  33. parent::__construct($outOrderId, $transAmt, $outOrderTitle, $outOrderDesc);
  34. $this->appid = $appid;
  35. }
  36. /**
  37. * 交易码
  38. *
  39. * @return string
  40. */
  41. public function getTrscode() :string
  42. {
  43. return 'TRANS1119';
  44. }
  45. /**
  46. * 聚合:tran
  47. *
  48. * @return string
  49. */
  50. public function getProCd() :string
  51. {
  52. return 'tran';
  53. }
  54. /**
  55. * 费率通道
  56. *
  57. * @return integer
  58. */
  59. public function getChanelType() :int
  60. {
  61. return 2;
  62. }
  63. public function getTransData(string $mchtCd) :array
  64. {
  65. $reqData['orgCd'] = $this->config['org_cd'];
  66. $reqData['trscode'] = $this->getTrscode();
  67. $reqData['mchtCd'] = $mchtCd;
  68. $reqData['outOrderId'] = $this->outOrderId;
  69. $reqData['transAmt'] = $this->transAmt;
  70. $reqData['appid'] = $this->appid;
  71. $reqData['proCd'] = $this->getProCd();
  72. $reqData['chanelType'] = $this->getChanelType();
  73. $reqData['outOrderTitle'] = $this->outOrderTitle;
  74. $reqData['outOrderDesc'] = $this->outOrderDesc;
  75. $reqData['browser'] = $this->getBrowser();
  76. $reqData['expireTime'] = $this->getExpireTime();
  77. $reqData['isSplitBill'] = $this->getIsSplitBill();
  78. // 分账信息
  79. $itemsList = $this->getSplitBill();
  80. $itemsList && $reqData['itemsList'] = $itemsList;
  81. return $reqData;
  82. }
  83. }