DuoBaoScanPayment.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace Biz\Pay\Payment;
  3. /**
  4. * 汇付天下接口
  5. */
  6. class DuoBaoScanPayment extends \Biz\Pay\BasePayment {
  7. function init() {
  8. $this->sellerInfo = array(
  9. 'busKey' => "9e4503ba878d4019b62127fa0b27c65c",
  10. 'busAccount' => '987858', //360cd.cn
  11. );
  12. # code...
  13. }
  14. protected $getWay = "https://gw.169.cc/interface/AutoBank/index.aspx";
  15. protected $paymentName = "DuoBaoScan";
  16. function toPay() {
  17. $payType = 0;
  18. $payment_list = $this->getPaymentType();
  19. if (isset($payment_list[$this->dataAccess->payType])) {
  20. $payType = $payment_list[$this->dataAccess->payType];
  21. } else {
  22. JsonReturn('', -3, '支付类型不正确');
  23. }
  24. $data = array(
  25. 'parter' => $this->sellerInfo['busAccount'],
  26. 'type' => $payType,
  27. 'value' => $this->dataAccess->money,
  28. 'orderid' => $this->dataAccess->orderSn,
  29. 'callbackurl' => $this->notifyUrl,
  30. );
  31. $sign = $this->md5mcrypt($data, $this->sellerInfo['busKey']);
  32. $data['onlyqr'] = 'Y';
  33. $data['attach'] = '';
  34. $data['sign'] = $sign;
  35. $data = $this->goPayCurl($this->getWay, 'POST', $data);
  36. if (empty($data)) {
  37. if ($this->returnType == 'json') {
  38. JsonReturn(array(), -1, "支付异常请联系管理员");
  39. } else {
  40. exit($data . "支付异常请联系管理员");
  41. }
  42. }
  43. $index = explode('&', $data);
  44. array_pop($index);
  45. $uri = implode('&', $index);
  46. if ($this->returnType == 'json') {
  47. JsonReturn(array('qrcode' => $uri), 1, 'success');
  48. }
  49. $qrcode_url = $uri;
  50. $orderSn = $this->dataAccess->orderSn;
  51. include View();
  52. return;
  53. }
  54. function md5mcrypt($data, $key) {
  55. $str = http_build_query($data) . $key;
  56. $str = urldecode($str);
  57. return md5($str);
  58. }
  59. public function notify($order) {
  60. # code...
  61. $re = $this->check($order);
  62. return $re;
  63. }
  64. public function redirect($order) {
  65. $re = $this->check($order);
  66. return $re;
  67. }
  68. public function check($order) {
  69. $data = array();
  70. $this->dataAccess->orderSn = $data['orderid'] = $_GET['orderid'];
  71. $data['opstate'] = $_GET['opstate'];
  72. $this->dataAccess->money = $data['ovalue'] = $_GET['ovalue'];
  73. $sign = $this->md5mcrypt($data, $this->sellerInfo['busKey']);
  74. $this->dataAccess->goodsName = '';
  75. $data['sysorderid'] = $_GET['sysorderid'];
  76. $data['attach'] = $_GET['attach'];
  77. $data['msg'] = $_GET['msg'];
  78. $data['sign'] = $_GET['sign'];
  79. if ($sign == $data['sign']) {
  80. if ($data['opstate'] == '0') {
  81. return 1;
  82. } else {
  83. return 0;
  84. }
  85. }
  86. }
  87. function notifyMsg($key) {
  88. if ($key > 0) {
  89. echo 'opstate=0';
  90. } else {
  91. echo '';
  92. }
  93. }
  94. public function getPaymentType() {
  95. # code...
  96. return array(
  97. "alipay" => "1006", //"支付宝",
  98. "weixin" => "1007", //"微信",
  99. "qqpay" => "993 ", //QQ钱包",
  100. );
  101. }
  102. }