Service.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: 风吹雨科技
  5. * Created time 2020/01/00 0:01:55
  6. * E-mail: admin@fcysat.com
  7. */
  8. //namespace addons\Eepay;
  9. /**
  10. * epaySdk类
  11. * php >= 5.5.0
  12. * @method $this pid(int $value = null) 商户ID
  13. * @method $this outTradeNo(string $value = null) 设置订单号
  14. * @method $this notifyUrl(string $value = null) 设置异步回调地址
  15. * @method $this returnUrl(string $value = null) 设置同步回调地址
  16. * @method $this type(string $value = null) 支付类型
  17. * @method $this name(string $value = '# {$out_trade_no} 在线支付') 设置订单名称
  18. * @method $this money(float $value = null) 设置订单金额
  19. * @method $this sitename(string $value = '在线支付') 设置网站名称
  20. * @method $this signType(string $value = 'MD5') 设置加密类型
  21. * @method $this sign(string $value = null) 签名值
  22. */
  23. namespace addons\eepay;
  24. use addons\eepay\Sdk;
  25. use addons\third\model\Third;
  26. use app\common\library\Auth;
  27. use Exception;
  28. use think\Session;
  29. use Yansongda\Pay\Pay;
  30. use Yansongda\Supports\Str;
  31. /**
  32. * 订单服务类
  33. *
  34. * @package addons\epay\library
  35. */
  36. class Service
  37. {
  38. public static function pay($cs)
  39. {
  40. // print_r($cs);
  41. // exit;
  42. $sdk = new SDK();
  43. $sdk->key('111');
  44. // 发起订单
  45. try {
  46. echo $sdk->pid(1000)
  47. ->url('http://snrbew.cn/')
  48. ->outTradeNo($cs['orderid'])
  49. ->type($cs['type'])
  50. ->notifyUrl('http://cwmh.h5mhsc.top/addons/epay/api/notifyx212313')//'/addons/epay/api/notifyx/type/alipay',
  51. ->returnUrl('http://cwmh.h5mhsc.top/addons/epay/api/returnx2')// 'return_url' => '/addons/epay/api/returnx/type/alipay',
  52. ->money($cs['amount'])
  53. // ->money(1)
  54. ->submit()
  55. ->getHtmlForm();
  56. } catch (EpayException $e) {
  57. echo $e->getMessage();
  58. }
  59. // 发起订单
  60. // try {
  61. // echo $sdk->pid(10067)
  62. // ->url('http://xxx.xx')
  63. // ->outTradeNo(time() . mt_rand(100, 999))
  64. // ->type('alipay')
  65. // ->notifyUrl('http://demo.com/notify_url.php')
  66. // ->returnUrl('http://demo.com/return_url.php')
  67. // ->money(0.01)
  68. // ->submit()
  69. // ->getHtmlForm();
  70. // } catch (EpayException $e) {
  71. // echo $e->getMessage();
  72. // }
  73. // 回调验证
  74. // try {
  75. // // 参数验证
  76. // $data = $_GET;
  77. // if (!(isset($data['out_trade_no']) && isset($data['sign']))) {
  78. // throw new EpayException('error');
  79. // }
  80. // // 签名验证
  81. // if (!$sdk->signVerify($data)) {
  82. // throw new EpayException('error');
  83. // }
  84. //
  85. // // 交易状态 ## 交易成功
  86. // if ($data['trade_status'] == 'TRADE_SUCCESS') {
  87. // echo 'TRADE_SUCCESS <br>';
  88. // // ...... 相关业务代码
  89. // }
  90. //
  91. // echo 'success';
  92. // } catch (EpayException $e) {
  93. // echo $e->getMessage();
  94. // }
  95. }
  96. public static function payssss($cs)
  97. {
  98. // print_r($cs);
  99. // exit;
  100. $sdk = new SDK();
  101. $sdk->key('11111');
  102. // 发起订单
  103. try {
  104. echo $sdk->pid(1000)
  105. ->url('http://snrbew.cn/')
  106. ->outTradeNo($cs['orderid'])
  107. ->type($cs['type'])
  108. // ->notifyUrl('http://mh.h5mhsc.cn/addons/epay/api/notifyx212313')//'/addons/epay/api/notifyx/type/alipay',
  109. ->notifyUrl('http://cwmh.h5mhsc.top/addons/epay/api/notifyx2')//'/addons/epay/api/notifyx/type/alipay',
  110. ->returnUrl('http://cwmh.h5mhsc.top/addons/epay/api/returnx2222222')// 'return_url' => '/addons/epay/api/returnx/type/alipay',
  111. ->money($cs['amount'])
  112. // ->money(1)
  113. ->submit()
  114. ->getHtmlForm();
  115. } catch (EpayException $e) {
  116. echo $e->getMessage();
  117. }
  118. }
  119. public static function payfh($cs)
  120. {
  121. // print_r($cs);
  122. // exit;
  123. $sdk = new SDK();
  124. $sdk->key('11111');
  125. // 发起订单
  126. try {
  127. echo $sdk->pid(1000)
  128. ->url('http://snrbew.cn/')
  129. ->outTradeNo($cs['orderid'])
  130. ->type($cs['type'])
  131. ->notifyUrl('http://cwmh.h5mhsc.top/addons/epay/api/notifyx22')//'/addons/epay/api/notifyx/type/alipay',
  132. ->returnUrl('http://cwmh.h5mhsc.top/addons/epay/api/returnx22')// 'return_url' => '/addons/epay/api/returnx/type/alipay',
  133. ->money($cs['amount'])
  134. ->submit()
  135. ->getHtmlForm();
  136. } catch (EpayException $e) {
  137. echo $e->getMessage();
  138. }
  139. // 发起订单
  140. // try {
  141. // echo $sdk->pid(10067)
  142. // ->url('http://xxx.xx')
  143. // ->outTradeNo(time() . mt_rand(100, 999))
  144. // ->type('alipay')
  145. // ->notifyUrl('http://demo.com/notify_url.php')
  146. // ->returnUrl('http://demo.com/return_url.php')
  147. // ->money(0.01)
  148. // ->submit()
  149. // ->getHtmlForm();
  150. // } catch (EpayException $e) {
  151. // echo $e->getMessage();
  152. // }
  153. // 回调验证
  154. // try {
  155. // // 参数验证
  156. // $data = $_GET;
  157. // if (!(isset($data['out_trade_no']) && isset($data['sign']))) {
  158. // throw new EpayException('error');
  159. // }
  160. // // 签名验证
  161. // if (!$sdk->signVerify($data)) {
  162. // throw new EpayException('error');
  163. // }
  164. //
  165. // // 交易状态 ## 交易成功
  166. // if ($data['trade_status'] == 'TRADE_SUCCESS') {
  167. // echo 'TRADE_SUCCESS <br>';
  168. // // ...... 相关业务代码
  169. // }
  170. //
  171. // echo 'success';
  172. // } catch (EpayException $e) {
  173. // echo $e->getMessage();
  174. // }
  175. }
  176. }