| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- namespace Biz\Pay\Payment;
- /**
- * 汇付天下接口
- */
- class DuoBaoScanPayment extends \Biz\Pay\BasePayment {
- function init() {
- $this->sellerInfo = array(
- 'busKey' => "9e4503ba878d4019b62127fa0b27c65c",
- 'busAccount' => '987858', //360cd.cn
- );
- # code...
- }
- protected $getWay = "https://gw.169.cc/interface/AutoBank/index.aspx";
- protected $paymentName = "DuoBaoScan";
- function toPay() {
- $payType = 0;
- $payment_list = $this->getPaymentType();
- if (isset($payment_list[$this->dataAccess->payType])) {
- $payType = $payment_list[$this->dataAccess->payType];
- } else {
- JsonReturn('', -3, '支付类型不正确');
- }
- $data = array(
- 'parter' => $this->sellerInfo['busAccount'],
- 'type' => $payType,
- 'value' => $this->dataAccess->money,
- 'orderid' => $this->dataAccess->orderSn,
- 'callbackurl' => $this->notifyUrl,
- );
- $sign = $this->md5mcrypt($data, $this->sellerInfo['busKey']);
- $data['onlyqr'] = 'Y';
- $data['attach'] = '';
- $data['sign'] = $sign;
- $data = $this->goPayCurl($this->getWay, 'POST', $data);
- if (empty($data)) {
- if ($this->returnType == 'json') {
- JsonReturn(array(), -1, "支付异常请联系管理员");
- } else {
- exit($data . "支付异常请联系管理员");
- }
- }
- $index = explode('&', $data);
- array_pop($index);
- $uri = implode('&', $index);
- if ($this->returnType == 'json') {
- JsonReturn(array('qrcode' => $uri), 1, 'success');
- }
- $qrcode_url = $uri;
- $orderSn = $this->dataAccess->orderSn;
- include View();
- return;
- }
- function md5mcrypt($data, $key) {
- $str = http_build_query($data) . $key;
- $str = urldecode($str);
- return md5($str);
- }
- public function notify($order) {
- # code...
- $re = $this->check($order);
- return $re;
- }
- public function redirect($order) {
- $re = $this->check($order);
- return $re;
- }
- public function check($order) {
- $data = array();
- $this->dataAccess->orderSn = $data['orderid'] = $_GET['orderid'];
- $data['opstate'] = $_GET['opstate'];
- $this->dataAccess->money = $data['ovalue'] = $_GET['ovalue'];
- $sign = $this->md5mcrypt($data, $this->sellerInfo['busKey']);
- $this->dataAccess->goodsName = '';
- $data['sysorderid'] = $_GET['sysorderid'];
- $data['attach'] = $_GET['attach'];
- $data['msg'] = $_GET['msg'];
- $data['sign'] = $_GET['sign'];
- if ($sign == $data['sign']) {
- if ($data['opstate'] == '0') {
- return 1;
- } else {
- return 0;
- }
- }
- }
- function notifyMsg($key) {
- if ($key > 0) {
- echo 'opstate=0';
- } else {
- echo '';
- }
- }
- public function getPaymentType() {
- # code...
- return array(
- "alipay" => "1006", //"支付宝",
- "weixin" => "1007", //"微信",
- "qqpay" => "993 ", //QQ钱包",
- );
- }
- }
|