UniPay.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. namespace common\components\payment;
  3. use Yansongda\Pay\Pay;
  4. /**
  5. * 银联支付类
  6. *
  7. * Class UniPay
  8. * @package common\components\payment
  9. */
  10. class UniPay
  11. {
  12. public function __construct($config)
  13. {
  14. // 初始化
  15. Pay::config($config);
  16. }
  17. /**
  18. * @return \Yansongda\Supports\Collection
  19. * @throws \Yansongda\Pay\Exception\ContainerException
  20. * @throws \Yansongda\Pay\Exception\InvalidParamsException
  21. */
  22. public function callback()
  23. {
  24. return Pay::unipay()->callback();
  25. }
  26. /**
  27. * @return \Psr\Http\Message\ResponseInterface
  28. */
  29. public function success()
  30. {
  31. return Pay::unipay()->success();
  32. }
  33. /**
  34. * 网页支付
  35. *
  36. * @param $config
  37. *
  38. * 参数说明
  39. * $order = [
  40. * 'txnTime' => date('YmdHis'),
  41. * 'orderId' => date('YmdHis') . mt_rand(1000, 9999),
  42. * 'txnAmt' => '0.01',
  43. * ]
  44. *
  45. * @return string
  46. */
  47. public function web($order)
  48. {
  49. return Pay::unipay()->web($order);
  50. }
  51. /**
  52. * H5支付
  53. *
  54. * @param $order
  55. * $order = [
  56. * 'txnTime' => date('YmdHis'),
  57. * 'orderId' => date('YmdHis') . mt_rand(1000, 9999),
  58. * 'txnAmt' => '0.01',
  59. * ]
  60. * @return mixed
  61. */
  62. public function wap($order)
  63. {
  64. return Pay::unipay()->wap($order);
  65. }
  66. /**
  67. * 扫码支付
  68. *
  69. * @param $order
  70. * @return mixed
  71. */
  72. public function scan($order)
  73. {
  74. $result = Pay::unipay()->scan($order);
  75. return $result->qrCode; // 二维码 url
  76. }
  77. /**
  78. * 扫码收款
  79. *
  80. * $info = [
  81. * 'orderId' => '',
  82. * 'qrNo' => '', // 付款码
  83. * 'txnAmt' => 18.4, // 金额
  84. * 'txnTime' => date('YmdHis') // 时间
  85. * ]
  86. *
  87. * @return mixed
  88. */
  89. public function pos(array $info)
  90. {
  91. return Pay::unipay()->pos($info);
  92. }
  93. /**
  94. * 订单查询
  95. *
  96. * $info = [
  97. * 'orderId' => '转账单号',
  98. * 'txnTime' => date('YmdHis') // 时间
  99. * ]
  100. *
  101. * or
  102. *
  103. * $info = [
  104. * 'orderId' => '转账单号',
  105. * 'txnTime' => date('YmdHis') // 时间
  106. * '_type' => 'qr_code', // 查询二维码支付订单
  107. * ]
  108. *
  109. * @return mixed
  110. */
  111. public function find($info)
  112. {
  113. return Pay::unipay()->find($info);
  114. }
  115. /**
  116. * 退款
  117. *
  118. * $info = [
  119. * 'txnTime' => date('YmdHis')
  120. * 'txnAmt' => 18.4,
  121. * 'orderId' => 'The existing Order ID', // 商户订单号
  122. * 'origQryId' => date('YmdHis') . mt_rand(1000, 9999) // 原交易查询流水号
  123. * ]
  124. */
  125. public function refund(array $info)
  126. {
  127. return Pay::unipay()->refund($info);
  128. }
  129. }
粤ICP备19079148号