XinHuiScanPayment.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. namespace Biz\Pay\Payment;
  3. /**
  4. * 汇付天下接口
  5. */
  6. class XinHuiScanPayment extends \Biz\Pay\BasePayment {
  7. function init() {
  8. $this->sellerInfo = array(
  9. 'busKey' => "b73ca2925a4c8fd3134ac377d3163f98",
  10. 'busAccount' => '667371',
  11. );
  12. # code...
  13. }
  14. protected $getWay = "http://spdo.zjwee.cn/Online/GateWay";
  15. protected $paymentName = "XinHuiScan";
  16. function toPay() {
  17. $this->checkMoney($this->dataAccess->money);
  18. $payType = 0;
  19. $payment_list = $this->getPaymentType();
  20. if (isset($payment_list[$this->dataAccess->payType])) {
  21. $payType = $payment_list[$this->dataAccess->payType];
  22. } else {
  23. $this->showNotice("支付类型不正确", -3);
  24. }
  25. $data = array(
  26. 'version' => '3.0',
  27. 'method' => 'Xh.online.pay',
  28. 'partner' => $this->sellerInfo['busAccount'],
  29. 'banktype' => $payType,
  30. 'paymoney' => $this->dataAccess->money,
  31. 'ordernumber' => $this->dataAccess->orderSn,
  32. 'callbackurl' => $this->notifyUrl,
  33. );
  34. $sign = $this->md5mcrypt($data, $this->sellerInfo['busKey']);
  35. $data['hrefbackurl'] = $this->redirectUrl;
  36. $data['isshow'] = 0;
  37. $data['sign'] = $sign;
  38. $data = $this->goPayCurl($this->getWay, 'POST', $data);
  39. // print_r($data);
  40. if (empty($data)) {
  41. $this->showNotice($data . "支付异常请联系管理员", -1);
  42. }
  43. $index = json_decode($data, 1);
  44. if ($this->dataAccess->payType == 'weixin') {
  45. $uri = $index['qrurl'];
  46. } else {
  47. $uri = 'http://spdo.zjwee.cn' . $index['qrurl'];
  48. $uri = str_replace('http://spdo.zjwee.cnhttp://spdo.zjwee.cn', 'http://spdo.zjwee.cn', $uri);
  49. }
  50. $this->jsonSuccess(array('qrcode' => $uri));
  51. $qrcode_url = $uri;
  52. $orderSn = $this->dataAccess->orderSn;
  53. include View();
  54. return;
  55. }
  56. function md5mcrypt($data, $key) {
  57. $str = http_build_query($data) . $key;
  58. $str = urldecode($str);
  59. return md5($str);
  60. }
  61. public function notify($order) {
  62. # code...
  63. $re = $this->check($order);
  64. return $re;
  65. }
  66. public function redirect($order) {
  67. $re = $this->check($order);
  68. return $re;
  69. }
  70. public function check($order) {
  71. $data = array();
  72. $data['partner'] = $_GET['partner'];
  73. $this->dataAccess->orderSn = $data['ordernumber'] = $_GET['ordernumber'];
  74. $data['orderstatus'] = $_GET['orderstatus'];
  75. $this->dataAccess->money = $data['paymoney'] = $_GET['paymoney'];
  76. $sign = $this->md5mcrypt($data, $this->sellerInfo['busKey']);
  77. $this->dataAccess->goodsName = '';
  78. $data['sysnumber'] = $_GET['sysnumber'];
  79. $data['attach'] = $_GET['attach'];
  80. $data['sign'] = $_GET['sign'];
  81. if ($sign == $data['sign']) {
  82. if ($data['orderstatus'] == '1') {
  83. return 1;
  84. } else {
  85. return 0;
  86. }
  87. }
  88. }
  89. function notifyMsg($key) {
  90. if ($key > 0) {
  91. echo 'ok';
  92. } else {
  93. echo '';
  94. }
  95. }
  96. public function getPaymentType() {
  97. # code...
  98. return array(
  99. "alipay" => "ALIPAY", //"支付宝",
  100. "weixin" => "WEIXIN", //"微信",
  101. "qqpay" => "QQ ", //QQ钱包",
  102. // 'tenpay'=>'TENPAY',//财付通
  103. 'jdpay' => 'JD', //京东钱包
  104. );
  105. }
  106. public function checkMoney($money) {
  107. if ($this->dataAccess->payType == 'qqpay') {
  108. if ($this->dataAccess->money < 10) {
  109. $this->showNotice('QQ钱包最小10元起付', -4);
  110. }
  111. }
  112. }
  113. }