RenXinScanPayment.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. namespace Biz\Pay\Payment;
  3. /**
  4. * 汇付天下接口
  5. */
  6. class RenXinScanPayment extends \Biz\Pay\BasePayment {
  7. function init() {
  8. $this->sellerInfo = array(
  9. 'busKey' => "fbce600379c88a223c70d6a566d834bf",
  10. 'busAccount' => '20424',
  11. );
  12. # code...
  13. }
  14. protected $getWay = "http://dpos.qqjun.cn/Online/GateWay";
  15. protected $paymentName = "RenXinScan";
  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' => 'Rx.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. if (empty($data)) {
  40. $this->showNotice($data . "支付异常请联系管理员", -1);
  41. }
  42. $index = json_decode($data, 1);
  43. $uri = 'http://dpos.qqjun.cn' . $index['qrurl'];
  44. $uri = str_replace('http://dpos.qqjun.cnhttp://dpos.qqjun.cn', 'http://dpos.qqjun.cn', $uri);
  45. $this->jsonSuccess(array('qrcode' => $uri));
  46. $qrcode_url = $uri;
  47. $orderSn = $this->dataAccess->orderSn;
  48. include View();
  49. return;
  50. }
  51. function md5mcrypt($data, $key) {
  52. $str = http_build_query($data) . $key;
  53. $str = urldecode($str);
  54. return md5($str);
  55. }
  56. public function notify($order) {
  57. # code...
  58. $re = $this->check($order);
  59. return $re;
  60. }
  61. public function redirect($order) {
  62. $re = $this->check($order);
  63. return $re;
  64. }
  65. public function check($order) {
  66. $data = array();
  67. $data['partner'] = $_GET['partner'];
  68. $this->dataAccess->orderSn = $data['ordernumber'] = $_GET['ordernumber'];
  69. $data['orderstatus'] = $_GET['orderstatus'];
  70. $this->dataAccess->money = $data['paymoney'] = $_GET['paymoney'];
  71. $sign = $this->md5mcrypt($data, $this->sellerInfo['busKey']);
  72. $this->dataAccess->goodsName = '';
  73. $data['sysnumber'] = $_GET['sysnumber'];
  74. $data['attach'] = $_GET['attach'];
  75. $data['sign'] = $_GET['sign'];
  76. if ($sign == $data['sign']) {
  77. if ($data['orderstatus'] == '1') {
  78. return 1;
  79. } else {
  80. return 0;
  81. }
  82. }
  83. }
  84. function notifyMsg($key) {
  85. if ($key > 0) {
  86. echo 'ok';
  87. } else {
  88. echo '';
  89. }
  90. }
  91. public function getPaymentType() {
  92. # code...
  93. return array(
  94. "alipay" => "ALIPAY", //"支付宝",
  95. "weixin" => "WEIXIN", //"微信",
  96. "qqpay" => "QQ ", //QQ钱包",
  97. // 'tenpay'=>'TENPAY',//财付通
  98. 'jdpay' => 'JD', //京东钱包
  99. );
  100. }
  101. public function checkMoney($money) {
  102. if ($this->dataAccess->payType == 'qqpay') {
  103. if ($this->dataAccess->money < 10) {
  104. $this->showNotice('QQ钱包最小10元起付', -4);
  105. }
  106. }
  107. }
  108. }