123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- <?php
- /**
- * Created by PhpStorm.
- * User: 风吹雨科技
- * Created time 2020/01/00 0:01:55
- * E-mail: admin@fcysat.com
- */
- //namespace addons\Eepay;
- /**
- * epaySdk类
- * php >= 5.5.0
- * @method $this pid(int $value = null) 商户ID
- * @method $this outTradeNo(string $value = null) 设置订单号
- * @method $this notifyUrl(string $value = null) 设置异步回调地址
- * @method $this returnUrl(string $value = null) 设置同步回调地址
- * @method $this type(string $value = null) 支付类型
- * @method $this name(string $value = '# {$out_trade_no} 在线支付') 设置订单名称
- * @method $this money(float $value = null) 设置订单金额
- * @method $this sitename(string $value = '在线支付') 设置网站名称
- * @method $this signType(string $value = 'MD5') 设置加密类型
- * @method $this sign(string $value = null) 签名值
- */
- namespace addons\eepay;
- use addons\eepay\Sdk;
- use addons\third\model\Third;
- use app\common\library\Auth;
- use Exception;
- use think\Session;
- use Yansongda\Pay\Pay;
- use Yansongda\Supports\Str;
- /**
- * 订单服务类
- *
- * @package addons\epay\library
- */
- class Service
- {
- public static function pay($cs)
- {
- // print_r($cs);
- // exit;
- $sdk = new SDK();
- $sdk->key('111');
- // 发起订单
- try {
- echo $sdk->pid(1000)
- ->url('http://snrbew.cn/')
- ->outTradeNo($cs['orderid'])
- ->type($cs['type'])
- ->notifyUrl('http://cwmh.h5mhsc.top/addons/epay/api/notifyx212313')//'/addons/epay/api/notifyx/type/alipay',
- ->returnUrl('http://cwmh.h5mhsc.top/addons/epay/api/returnx2')// 'return_url' => '/addons/epay/api/returnx/type/alipay',
- ->money($cs['amount'])
- // ->money(1)
- ->submit()
- ->getHtmlForm();
- } catch (EpayException $e) {
- echo $e->getMessage();
- }
- // 发起订单
- // try {
- // echo $sdk->pid(10067)
- // ->url('http://xxx.xx')
- // ->outTradeNo(time() . mt_rand(100, 999))
- // ->type('alipay')
- // ->notifyUrl('http://demo.com/notify_url.php')
- // ->returnUrl('http://demo.com/return_url.php')
- // ->money(0.01)
- // ->submit()
- // ->getHtmlForm();
- // } catch (EpayException $e) {
- // echo $e->getMessage();
- // }
- // 回调验证
- // try {
- // // 参数验证
- // $data = $_GET;
- // if (!(isset($data['out_trade_no']) && isset($data['sign']))) {
- // throw new EpayException('error');
- // }
- // // 签名验证
- // if (!$sdk->signVerify($data)) {
- // throw new EpayException('error');
- // }
- //
- // // 交易状态 ## 交易成功
- // if ($data['trade_status'] == 'TRADE_SUCCESS') {
- // echo 'TRADE_SUCCESS <br>';
- // // ...... 相关业务代码
- // }
- //
- // echo 'success';
- // } catch (EpayException $e) {
- // echo $e->getMessage();
- // }
- }
- public static function payssss($cs)
- {
- // print_r($cs);
- // exit;
- $sdk = new SDK();
- $sdk->key('11111');
- // 发起订单
- try {
- echo $sdk->pid(1000)
- ->url('http://snrbew.cn/')
- ->outTradeNo($cs['orderid'])
- ->type($cs['type'])
- // ->notifyUrl('http://mh.h5mhsc.cn/addons/epay/api/notifyx212313')//'/addons/epay/api/notifyx/type/alipay',
- ->notifyUrl('http://cwmh.h5mhsc.top/addons/epay/api/notifyx2')//'/addons/epay/api/notifyx/type/alipay',
- ->returnUrl('http://cwmh.h5mhsc.top/addons/epay/api/returnx2222222')// 'return_url' => '/addons/epay/api/returnx/type/alipay',
- ->money($cs['amount'])
- // ->money(1)
- ->submit()
- ->getHtmlForm();
- } catch (EpayException $e) {
- echo $e->getMessage();
- }
- }
- public static function payfh($cs)
- {
- // print_r($cs);
- // exit;
- $sdk = new SDK();
- $sdk->key('11111');
- // 发起订单
- try {
- echo $sdk->pid(1000)
- ->url('http://snrbew.cn/')
- ->outTradeNo($cs['orderid'])
- ->type($cs['type'])
- ->notifyUrl('http://cwmh.h5mhsc.top/addons/epay/api/notifyx22')//'/addons/epay/api/notifyx/type/alipay',
- ->returnUrl('http://cwmh.h5mhsc.top/addons/epay/api/returnx22')// 'return_url' => '/addons/epay/api/returnx/type/alipay',
- ->money($cs['amount'])
- ->submit()
- ->getHtmlForm();
- } catch (EpayException $e) {
- echo $e->getMessage();
- }
- // 发起订单
- // try {
- // echo $sdk->pid(10067)
- // ->url('http://xxx.xx')
- // ->outTradeNo(time() . mt_rand(100, 999))
- // ->type('alipay')
- // ->notifyUrl('http://demo.com/notify_url.php')
- // ->returnUrl('http://demo.com/return_url.php')
- // ->money(0.01)
- // ->submit()
- // ->getHtmlForm();
- // } catch (EpayException $e) {
- // echo $e->getMessage();
- // }
- // 回调验证
- // try {
- // // 参数验证
- // $data = $_GET;
- // if (!(isset($data['out_trade_no']) && isset($data['sign']))) {
- // throw new EpayException('error');
- // }
- // // 签名验证
- // if (!$sdk->signVerify($data)) {
- // throw new EpayException('error');
- // }
- //
- // // 交易状态 ## 交易成功
- // if ($data['trade_status'] == 'TRADE_SUCCESS') {
- // echo 'TRADE_SUCCESS <br>';
- // // ...... 相关业务代码
- // }
- //
- // echo 'success';
- // } catch (EpayException $e) {
- // echo $e->getMessage();
- // }
- }
- }
|