DuoBaoPayment.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace Biz\Pay\Payment;
  3. /**
  4. * 汇付天下接口
  5. */
  6. class DuoBaoPayment 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/CashierDesk.aspx";
  15. protected $paymentName = "DuoBao";
  16. function toPay() {
  17. $data = array(
  18. 'parter' => $this->sellerInfo['busAccount'],
  19. 'type' => 0,
  20. 'value' => $this->dataAccess->money,
  21. 'orderid' => $this->dataAccess->orderSn,
  22. 'callbackurl' => $this->notifyUrl,
  23. );
  24. $sign = $this->md5mcrypt($data, $this->sellerInfo['busKey']);
  25. $data['onlyqr'] = '';
  26. $data['attach'] = '';
  27. $data['hrefbackurl'] = $this->redirectUrl;
  28. $data['sign'] = $sign;
  29. $data = $this->goPay($data);
  30. }
  31. function md5mcrypt($data, $key) {
  32. $str = http_build_query($data) . $key;
  33. $str = urldecode($str);
  34. return md5($str);
  35. }
  36. public function notify($order) {
  37. # code...
  38. $re = $this->check($order);
  39. return $re;
  40. }
  41. public function redirect($order) {
  42. $re = $this->check($order);
  43. return $re;
  44. }
  45. public function check($order) {
  46. $data = array();
  47. $this->dataAccess->orderSn = $data['orderid'] = $_GET['orderid'];
  48. $data['opstate'] = $_GET['opstate'];
  49. $this->dataAccess->money = $data['ovalue'] = $_GET['ovalue'];
  50. $sign = $this->md5mcrypt($data, $this->sellerInfo['busKey']);
  51. $this->dataAccess->goodsName = '';
  52. $data['sysorderid'] = $_GET['sysorderid'];
  53. $data['attach'] = $_GET['attach'];
  54. $data['msg'] = $_GET['msg'];
  55. $data['sign'] = $_GET['sign'];
  56. if ($sign == $data['sign']) {
  57. if ($data['opstate'] == '0') {
  58. return 1;
  59. } else {
  60. return 0;
  61. }
  62. }
  63. }
  64. function notifyMsg($key) {
  65. if ($key > 0) {
  66. echo 'opstate=0';
  67. } else {
  68. echo '';
  69. }
  70. }
  71. public function getPaymentType() {
  72. # code...
  73. return array(
  74. "alipay" => "1006", //"支付宝",
  75. "weixin" => "1007", //"微信",
  76. "qqpay" => "993 ", //QQ钱包",
  77. );
  78. }
  79. }