From 04f6e8ea4f192fc6ce63796caec3a69b49417520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D?= <邮箱> Date: Thu, 3 Aug 2023 11:05:41 +0800 Subject: [PATCH] test --- .../payment/dalianpay/cert/channel_public_key.pem | 9 - .../payment/dalianpay/cert/cus_private_key.pem | 28 --- .../dalianpay/cert/cus_private_key.pem.test | 16 -- mobile/plugins/payment/dalianpay/config/config.php | 49 ----- mobile/plugins/payment/dalianpay/demo/cancel.php | 151 -------------- mobile/plugins/payment/dalianpay/demo/close.php | 99 ---------- .../plugins/payment/dalianpay/demo/dalianpay.php | 178 ----------------- mobile/plugins/payment/dalianpay/demo/pay.php | 162 --------------- mobile/plugins/payment/dalianpay/demo/query.php | 98 --------- mobile/plugins/payment/dalianpay/demo/refund.php | 105 ---------- mobile/plugins/payment/dalianpay/demo/scan.php | 158 --------------- mobile/plugins/payment/dalianpay/library/Base.php | 41 ---- mobile/plugins/payment/dalianpay/library/Crypt.php | 220 --------------------- .../plugins/payment/dalianpay/library/Request.php | 156 --------------- mobile/plugins/payment/wxpay.php | 44 ++++- .../helpers/dalianpay/cert/channel_public_key.pem | 9 + .../helpers/dalianpay/cert/cus_private_key.pem | 28 +++ .../dalianpay/cert/cus_private_key.pem.test | 16 ++ mobile/source/helpers/dalianpay/config/config.php | 49 +++++ mobile/source/helpers/dalianpay/demo/cancel.php | 151 ++++++++++++++ mobile/source/helpers/dalianpay/demo/close.php | 99 ++++++++++ mobile/source/helpers/dalianpay/demo/dalianpay.php | 178 +++++++++++++++++ mobile/source/helpers/dalianpay/demo/pay.php | 162 +++++++++++++++ mobile/source/helpers/dalianpay/demo/query.php | 98 +++++++++ mobile/source/helpers/dalianpay/demo/refund.php | 105 ++++++++++ mobile/source/helpers/dalianpay/demo/scan.php | 158 +++++++++++++++ mobile/source/helpers/dalianpay/library/Base.php | 41 ++++ mobile/source/helpers/dalianpay/library/Crypt.php | 220 +++++++++++++++++++++ .../source/helpers/dalianpay/library/Request.php | 156 +++++++++++++++ 29 files changed, 1504 insertions(+), 1480 deletions(-) delete mode 100644 mobile/plugins/payment/dalianpay/cert/channel_public_key.pem delete mode 100644 mobile/plugins/payment/dalianpay/cert/cus_private_key.pem delete mode 100644 mobile/plugins/payment/dalianpay/cert/cus_private_key.pem.test delete mode 100644 mobile/plugins/payment/dalianpay/config/config.php delete mode 100644 mobile/plugins/payment/dalianpay/demo/cancel.php delete mode 100644 mobile/plugins/payment/dalianpay/demo/close.php delete mode 100644 mobile/plugins/payment/dalianpay/demo/dalianpay.php delete mode 100644 mobile/plugins/payment/dalianpay/demo/pay.php delete mode 100644 mobile/plugins/payment/dalianpay/demo/query.php delete mode 100644 mobile/plugins/payment/dalianpay/demo/refund.php delete mode 100644 mobile/plugins/payment/dalianpay/demo/scan.php delete mode 100644 mobile/plugins/payment/dalianpay/library/Base.php delete mode 100644 mobile/plugins/payment/dalianpay/library/Crypt.php delete mode 100644 mobile/plugins/payment/dalianpay/library/Request.php create mode 100644 mobile/source/helpers/dalianpay/cert/channel_public_key.pem create mode 100644 mobile/source/helpers/dalianpay/cert/cus_private_key.pem create mode 100644 mobile/source/helpers/dalianpay/cert/cus_private_key.pem.test create mode 100644 mobile/source/helpers/dalianpay/config/config.php create mode 100644 mobile/source/helpers/dalianpay/demo/cancel.php create mode 100644 mobile/source/helpers/dalianpay/demo/close.php create mode 100644 mobile/source/helpers/dalianpay/demo/dalianpay.php create mode 100644 mobile/source/helpers/dalianpay/demo/pay.php create mode 100644 mobile/source/helpers/dalianpay/demo/query.php create mode 100644 mobile/source/helpers/dalianpay/demo/refund.php create mode 100644 mobile/source/helpers/dalianpay/demo/scan.php create mode 100644 mobile/source/helpers/dalianpay/library/Base.php create mode 100644 mobile/source/helpers/dalianpay/library/Crypt.php create mode 100644 mobile/source/helpers/dalianpay/library/Request.php diff --git a/mobile/plugins/payment/dalianpay/cert/channel_public_key.pem b/mobile/plugins/payment/dalianpay/cert/channel_public_key.pem deleted file mode 100644 index 350d007..0000000 --- a/mobile/plugins/payment/dalianpay/cert/channel_public_key.pem +++ /dev/null @@ -1,9 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgFoZG+UeND0T/PQK41Dg -5bXgpuHwBdc7sfGRTKlB2PmZ1Q8XE4b8u5SMqk9LC7iUL5wJlItJ9rcdXPgc3SnB -xuq133HRqvsNAxWacYQnarYMko7JKKGENdrcE+MY7ZM6Yo60/6+HVOwphIw8BuZL -NvvCKx7BrI84t93TFndn6WVF16XgOhQkPyUmsj2ekfw9vrQg89ipNcTHmBCtH9/K -KEWRPTUkH9xc+GOZ06v5O3Pmpd+hdXyE/Rjtsa1foR3l1UsWFVODHRkeoHTnBdkR -YiOGXpGthazAcvPAZtTWSKtRirKF87soIill1cmHMCw8d9JoZgq9k0L8n9ZpUCw7 -twIDAQAB ------END PUBLIC KEY----- diff --git a/mobile/plugins/payment/dalianpay/cert/cus_private_key.pem b/mobile/plugins/payment/dalianpay/cert/cus_private_key.pem deleted file mode 100644 index 5ec197a..0000000 --- a/mobile/plugins/payment/dalianpay/cert/cus_private_key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCOt2qd98v3uMVM -XtDlEJBks8spkC+SSdi+/9m+6cVE/eqSqzWMAa2QeoZ7j31ard+FV2ZynITj+Y15 -6iRJ84J20k7VTuUfjLSjJ079DrRweYimf5MW/QCRyz93YMjC4A9aWrbSw06pkiz4 -p3DMkitlp9oDEx13vJld0tLw1BO4fSMmoDLg4ri3zFA/PqPb3OWW0R/yRakOdiPx -kjsOYZ7EOesdc67gdYCiiEy2x38jGMKAJ5jqWmRbnCF+4Ij7QPGXQTG7ba63azNN -S8mBis5WNHA1EPK+KgRDykZHWTzV8Hu/x5NRnBUYpTdSlLM2zP//8dAcUOUejakv -DSWbLPDVAgMBAAECggEAVm5KSYTqqAnkow3BIRjY+cPRREioJsZGV9YG/xIAgHnu -eAjsEvBpNtidXXNXDXXDqrN1ve+Ao7hcr/rXI1owJtnTGGgBZwwF0dFaivM+3+ca -lQsp/4AVujYHJ7sbmrmrUqMhmZ7iott+FNEDBUF4usXeyIHpFLzJfQLS8Tre/pkS -KVcepRBKD7WSwSaqI5Gb9i+HHdqgE1UhY4nqMt1F07szFmPSCsS8L5DVGRTKbOlW -KwwbgyY53aUCb1xVVHXhyxCFTU8a02yBwWDXCeG+Qvnu2qED+wui7yF77299ypPP -oim72rjyxj1736+PSymgPlNuLFPkH/HLac5jxdR7eQKBgQDQq6nORGAJpPmt+BLY -nJtJHCJiU4cf4dJ1O+LnUTvlO1dl68wh/fulOG6xwngTXB9izq9Aj6CEGsW7GCne -3Q1vBELlmDcqp1AiyvpHaymtYWRr6+DdW0DKWTfcqaaF+8GEx6RwXBuwUji7kh5y -wCCP3ZLZG9zx7DTL9F0+2h7TwwKBgQCvFiqtPK72VT9C9+Q+Ct8Bwhzv0WDbTwx6 -Ke5YXWuI8mm07TA/osVav4etLrwlKine6QqZ9+1GnYtB09EKX1nmFBgiOgR52woe -hOhOYTG4bFRfH7caiHcgR3L0nsXCdjlfpxqLiUCvFYzwYsXnIGfQYZvWLELFua5o -dhRyTfxXhwKBgHxEzwJE3ADCW+ML6oVPdnbqp1txLPaCsKgaev2Q9h+E4H6VF2Ni -8xso6Vs5WfMFmLdqKRpErq4dl4XdVQohEN/9ZK2AodHoBCRERxqDKjXT208eETMi -JgqbaVYjPkVqcYvWrQoxAFhYDus9kJ575qhmpw5etozoQ2T26RUGJverAoGANKwy -gpNy/2B9+6Of4ppapKjFE9ClltSdKFNdBPB13WkwK+H/VeWeAcMFCjC5IWUh25G4 -QsG3fDsBHfifNsOgw/rfl8xkdFRVIwFQ8eODlbvhVgywhSbwz6EvEDCDxhDTCde3 -wKq17vZIxDiy2OmC0cnLnA8Mt3c45OxBEnIrrBkCgYBgaR0UQJq/Xfnu+CV8/hV3 -HYpzquWzqWve3DgEGSXA/fAVSm6JhcumndywlBVXXyML+A+U6MVdJfGVbLSHxLQV -1f9nTAwXPbauFLrqpHm0hOvCwfAEkK8HDt2mKOfblbWrLo7gF7wErcSEw7tEqJOg -M2OG+6QXvCsCZUKBf8TnnQ== ------END RSA PRIVATE KEY----- diff --git a/mobile/plugins/payment/dalianpay/cert/cus_private_key.pem.test b/mobile/plugins/payment/dalianpay/cert/cus_private_key.pem.test deleted file mode 100644 index 8a28c0b..0000000 --- a/mobile/plugins/payment/dalianpay/cert/cus_private_key.pem.test +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJgHMGYsspghvP+y -CbjLG43CkZuQ3YJyDcmEKxvmgblITfmiTPx2b9Y2iwDT9gnLGExTDm1BL2A8VzMo -bjaHfiCmTbDctu680MLmpDDkVXmJOqdlXh0tcLjhN4+iDA2KkRqiHxsDpiaKT6MM -BuecXQbJtPlVc1XjVhoUlzUgPCrvAgMBAAECgYAV9saYTGbfsdLOF5kYo0dve1Jx -aO7dFMCcgkV+z2ujKtNmeHtU54DlhZXJiytQY5Dhc10cjb6xfFDrftuFcfKCaLiy -6h5ETR8jyv5He6KH/+X6qkcGTkJBYG1XvyyFO3PxoszQAs0mrLCqq0UItlCDn0G7 -2MR9/NuvdYabGHSzEQJBAMXB1/DUvBTHHH4LiKDiaREruBb3QtP72JQS1ATVXA2v -6xJzGPMWMBGQDvRfPvuCPVmbHENX+lRxMLp39OvIn6kCQQDEzYpPcuHW/7h3TYHY -c+T0O6z1VKQT2Mxv92Lj35g1XqV4Oi9xrTj2DtMeV1lMx6n/3icobkCQtuvTI+Ac -qfTXAkB6bCz9NwUUK8sUsJktV9xJN/JnrTxetOr3h8xfDaJGCuCQdFY+rj6lsLPB -TnFUC+Vk4mQVwJIE0mmjFf22NWW5AkAmsVaRGkAmui41Xoq52MdZ8WWm8lY0BLrl -BJlvveU6EPqtcZskWW9KiU2euIO5IcRdpvrB6zNMgHpLD9GfMRcPAkBUWOV/dH13 -v8V2Y/Fzuag/y5k3/oXi/WQnIxdYbltad2xjmofJ7DbB7MJqiZZD8jlr8PCZPwRN -zc5ntDStc959 ------END PRIVATE KEY----- diff --git a/mobile/plugins/payment/dalianpay/config/config.php b/mobile/plugins/payment/dalianpay/config/config.php deleted file mode 100644 index 2130425..0000000 --- a/mobile/plugins/payment/dalianpay/config/config.php +++ /dev/null @@ -1,49 +0,0 @@ - '5503001', - // 'org_num' => '100018380507D2C', - // 商户号 渠道商户号 - 'cusid' => '10147', - // 'cusid' => '563222080502LGB', - // 产品 - 'producp' => 'JX0002', - // 版本 - 'version' => '11', - // 门店号 - 'branchno' => '44', - // 终端号 - 'termcode' => '000000', - // 加密方式 - 'signtype' => 'RSA', - // 渠道公钥 - 'public_key' => dirname(__FILE__) . '/../cert/channel_public_key.pem', - // 商户私钥 - 'private_key' => dirname(__FILE__) . '/../cert/cus_private_key.pem', - - // 统一支付接口 测试地址 - 'pay_url' => 'https://open.dalianpay.cn/payapi/unitorder/pay', - // 统一支付接口 - // 'pay_url' => 'https://epay.dalianpay.cn/payapi/unitorder/pay', - - // 统一扫码接口 测试地址 - 'scan_url' => 'https://open.dalianpay.cn/payapi/unitorder/scanqrpay', - - // 交易撤销 测试地址 - 'cancel_url' => 'https://open.dalianpay.cn/payapi/tranx/cancel', - - // 交易退款 测试地址 - 'refund_url' => 'https://tpay.01pub.com/payapi/tranx/refund', - - // 统一查询接口 测试地址 - 'query_url' => 'https://open.dalianpay.cn/payapi/tranx/query', - - // 订单关闭接口 测试地址 - 'close_url' => 'https://open.dalianpay.cn/payapi/tranx/close', - - 'openid' => '', - - ); - -?> diff --git a/mobile/plugins/payment/dalianpay/demo/cancel.php b/mobile/plugins/payment/dalianpay/demo/cancel.php deleted file mode 100644 index 315a524..0000000 --- a/mobile/plugins/payment/dalianpay/demo/cancel.php +++ /dev/null @@ -1,151 +0,0 @@ -getConfig(); - // var_dump('
', $config);
-
- // 接口URL(测试)
- $api_url = $config['cancel_url'];
-
-// 加个body字段传中文试试
-
- // 组装交易报文
- $reqsn_prefix = date('Ymd');
- $trade_data = array(
- 'orgid' => $config['org_num'],
- 'cusid' => $config['cusid'],
- 'branchno' => $config['branchno'],
- 'termcode' => $config['termcode'],
- 'version' => $config['version'],
- 'trxamt' => '1',
- 'reqsn' => uniqid($reqsn_prefix),
- 'producp' => 'JX0002',
- 'transtype' => 'JSP511',
- 'randomstr' => md5( uniqid() ),
- // 'oldreqsn' => '2023072464be31055e0e0',
- 'oldtrxid' => '100000018608497',
- );
-
- // $trade_data = array(
- // "cusid" => "10147",
- // "branchno" => "44",
- // "termcode" => "000000",
- // "version" => "11",
- // "trxamt" => "1154634",
- // "reqsn" => "112094120001088317",
- // "producp" => "JX0002",
- // "transtype" => "JSP501",
- // "paytype" => "W01",
- // "randomstr" => md5( uniqid() ),
- // "body" => "",
- // "remark" => "",
- // "validtime" => "",
- // "acct" => "",
- // "notify_url" => "",
- // "limit_pay" => "",
- // "sub_appid" => "",
- // "goods_tag" => "",
- // "benefitdetail" => "",
- // "chnlstoreid" => "",
- // "extendparams" => "",
- // "cusip" => "",
- // "front_url" => "",
- // "subbranch" => "",
- // "idno" => "",
- // "truename" => "",
- // "asinfo" => "",
- // "fqnum" => "",
- // "unpid" => "",
- // "terminfo" => "",
- // // 其他参数...
- // );
-
- // $trade_data = array(
- // "appid"=>"00000051",
- // "cusid"=>"990581007426001",
- // "randomstr"=>"82712208",
- // "signtype"=>"RSA",
- // "trxid"=>"112094120001088317",
- // "version"=>"11",
- // );
-
- // 生成签名
- $sign = $Base->Crypt->makeSign($trade_data);
- if($sign === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[sign]: {$sign}";
- // die();
-
- // 加密交易报文
- $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
- if($crypted_trade_data === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[crypted message]: {$crypted_trade_data}";
- // die();
-
- // 发送报文
- echo "\r\n";
- var_dump($api_url);
- $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
- if($response === false)
- {
- echo $Base->Request->err_msg;
- die();
- }
-
- echo "\r\n";
-
- echo "[response message]: {$response}";
-
- // 解析响应报文
- $response = json_decode($response, true);
- $response_data_crypted = $response['data'];
- $response_sign = $response['sign'];
- echo "\r\n";
- echo "[response sign]: {$response_sign}";
- echo "\r\n";
- echo "[response data (ciphertext)]: {$response_data_crypted}";
-
- // 解密响应密文
- $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
- if($response_data === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- // $response_data = mb_convert_encoding($response_data, 'UTF-8', 'GBK');
- echo "[response data(clear text)]: {$response_data}";
- // die();
-
-?>
-
-
-
-
-
-
-
-
-
- 交易撤销Demo
-
-
-
-
diff --git a/mobile/plugins/payment/dalianpay/demo/close.php b/mobile/plugins/payment/dalianpay/demo/close.php
deleted file mode 100644
index dde0178..0000000
--- a/mobile/plugins/payment/dalianpay/demo/close.php
+++ /dev/null
@@ -1,99 +0,0 @@
-getConfig();
- // var_dump('', $config);
-
- // 接口URL(测试)
- $api_url = $config['close_url'];
-
- // 加个body字段传中文试试
-
- // 组装交易报文
- $reqsn_prefix = date('Ymd');
- $trade_data = array(
- 'orgid' => $config['org_num'],
- 'cusid' => $config['cusid'],
- 'branchno' => $config['branchno'],
- 'termcode' => $config['termcode'],
- 'version' => $config['version'],
- 'randomstr' => md5( uniqid() ),
- 'oldtrxid' => '100000018608526',
- );
-
- // 生成签名
- $sign = $Base->Crypt->makeSign($trade_data);
- if($sign === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[sign]: {$sign}";
- // die();
-
- // 加密交易报文
- $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
- if($crypted_trade_data === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[crypted message]: {$crypted_trade_data}";
- // die();
-
- // 发送报文
- echo "\r\n";
- var_dump($api_url);
- $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
- if($response === false)
- {
- echo $Base->Request->err_msg;
- die();
- }
-
- echo "\r\n";
-
- echo "[response message]: {$response}";
-
- // 解析响应报文
- $response = json_decode($response, true);
- $response_data_crypted = $response['data'];
- $response_sign = $response['sign'];
- echo "\r\n";
- echo "[response sign]: {$response_sign}";
- echo "\r\n";
- echo "[response data (ciphertext)]: {$response_data_crypted}";
-
- // 解密响应密文
- $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
- if($response_data === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[response data(clear text)]: {$response_data}";
- // die();
-
-?>
-
-
-
-
-
-
- 订单关闭Demo
-
-
-
-
diff --git a/mobile/plugins/payment/dalianpay/demo/dalianpay.php b/mobile/plugins/payment/dalianpay/demo/dalianpay.php
deleted file mode 100644
index 3434aff..0000000
--- a/mobile/plugins/payment/dalianpay/demo/dalianpay.php
+++ /dev/null
@@ -1,178 +0,0 @@
-decrypt($_GET['openid']);
- // $reqsn = $_GET['reqsn'];
- // $trxamt = $_GET['trxamt'];
-
- $openid = $this->decrypt($openid_crypt);
- // $openid = $openid_crypt;
- $reqsn = $order_sn;
- $trxamt = $order_amount;
-
- $string = $openid . ' + ' . $reqsn . ' + ' . $trxamt;
- // echo $string;
-
- // var_dump($openid);
- // var_dump($reqsn);
- // var_dump($trxamt);
- $redirect_url = $_SESSION['prev_url'];
- // unset($_SESSION['prev_url']);
- // var_dump($redirect_url);
-
- // 加载基础类
- require_once('../library/Base.php');
- $Base = new Base();
-
- // 获取配置信息
- $config = $Base->getConfig();
- // var_dump('', $config);
-
- // 接口URL(测试)
- $api_url = $config['pay_url'];
- // $api_url = $_POST['url'];
- $message = array(
- "url"=>$api_url,
- );
- // echo json_encode($message,true);
- // 加个body字段传中文试试
-
- // 组装交易报文
- $reqsn_prefix = date('Ymd');
- // var_dump("uniq_id(reqsn)");
- // echo "\r\n";
- // var_dump(uniqid($reqsn_prefix));
- $trade_data = array(
- 'orgid' => $config['org_num'],
- 'cusid' => $config['cusid'],
- 'branchno' => $config['branchno'],
- // 'termcode' => $config['termcode'],
- 'version' => $config['version'],
- 'trxamt' => $trxamt, // total_fee
- 'reqsn' => $reqsn, // 交易订单号
- 'producp' => 'JX0002',
- 'transtype' => 'JSP501', // 微信支付
- 'paytype' => 'W02', // 微信js支付
- 'randomstr' => md5( uniqid() ),
- // 'body' => 'pages',
- 'acct' => $openid,
- // 'notify_url' => '', // 交易结果通知地址
- // 'sub_appid' => 'wx79343915f99167e6',
- // 'front_url' => '', // 支付完成跳转
- );
- // 生成签名
- $sign = $Base->Crypt->makeSign($trade_data);
- if($sign === false)
- {
- // echo $Base->Crypt->err_msg;
- $errorMessage = array(
- "data"=>"makeSign error..."
- );
- return json_encode($errorMessage,true);
- die();
- }
-
- // echo "\r\n";
- // echo "[sign]: {$sign}";
-
- // 加密交易报文
- $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
- if($crypted_trade_data === false)
- {
- // echo $Base->Crypt->err_msg;
- $errorMessage = array(
- "data"=>"encryptTradeData error..."
- );
- return json_encode($errorMessage,true);
- die();
- }
-
- // echo "\r\n";
- // echo "[crypted message]: {$crypted_trade_data}";
-
- // 发送报文
- // echo "\r\n";
- // var_dump($api_url);
- $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
- // echo $response;
- if($response === false)
- {
- // echo $Base->Request->err_msg;
- $errorMessage = array(
- "data"=>"send error..."
- );
- return json_encode($errorMessage,true);
- die();
- }
- // echo "\r\n";
- // echo "[response message]: {$response}";
-
- // 解析响应报文
- $response = json_decode($response, true);
- $response_data_crypted = $response['data'];
- $response_sign = $response['sign'];
- // echo "\r\n";
- // echo "[response sign]: {$response_sign}";
- // echo "\r\n";
- // echo "[response data (ciphertext)]: {$response_data_crypted}";
-
-
- // 解密响应密文
- $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
- if($response_data === false)
- {
- // echo $Base->Crypt->err_msg;
- $errorMessage = array(
- "data"=>"decryptTradeData error..."
- );
- return json_encode($errorMessage,true);
- die();
- }
- // echo "\r\n";
- // echo "[response data(clear text)]: {$response_data}";
- // die();
- // var_dump(json_decode($response_data));
- $_SESSION['response_data_json'] = $response_data;
- return $response_data;
-
- // var_dump($_SESSION['user_id']);
- // 跳回之前的地址
- // header('Location: ' . $redirect_url);
- // exit;
- }
-}
-
-// echo 'hi there.....\n\r';
-// $new_plugin = new dalianpay();
-// $openid_crypt = 'oCTanxBeiVFWIekJT_GiPZM2UiGY';
-// $order_sn = '2023080355429';
-// $order_amount = '600';
-// $response_data = $new_plugin->pay($openid_crypt,$order_sn,$order_amount);
-// echo $response_data;
-
-
-?>
-
diff --git a/mobile/plugins/payment/dalianpay/demo/pay.php b/mobile/plugins/payment/dalianpay/demo/pay.php
deleted file mode 100644
index b97f9f1..0000000
--- a/mobile/plugins/payment/dalianpay/demo/pay.php
+++ /dev/null
@@ -1,162 +0,0 @@
-getConfig();
- // var_dump('', $config);
-
- // 接口URL(测试)
- $api_url = $config['pay_url'];
- // $api_url = $_POST['url'];
- $message = array(
- "url"=>$api_url,
- );
- // echo json_encode($message,true);
- // 加个body字段传中文试试
-
- // 组装交易报文
- $reqsn_prefix = date('Ymd');
- // var_dump("uniq_id(reqsn)");
- // echo "\r\n";
- // var_dump(uniqid($reqsn_prefix));
- $trade_data = array(
- 'orgid' => $config['org_num'],
- 'cusid' => $config['cusid'],
- 'branchno' => $config['branchno'],
- // 'termcode' => $config['termcode'],
- 'version' => $config['version'],
- 'trxamt' => $trxamt, // total_fee
- 'reqsn' => $reqsn, // 交易订单号
- 'producp' => 'JX0002',
- 'transtype' => 'JSP501', // 微信支付
- 'paytype' => 'W02', // 微信js支付
- 'randomstr' => md5( uniqid() ),
- // 'body' => 'pages',
- 'acct' => $openid,
- // 'notify_url' => '', // 交易结果通知地址
- // 'sub_appid' => 'wx79343915f99167e6',
- // 'front_url' => '', // 支付完成跳转
- );
- // 生成签名
- $sign = $Base->Crypt->makeSign($trade_data);
- if($sign === false)
- {
- // echo $Base->Crypt->err_msg;
- $errorMessage = array(
- "data"=>"makeSign error..."
- );
- return json_encode($errorMessage,true);
- die();
- }
-
- // echo "\r\n";
- // echo "[sign]: {$sign}";
-
- // 加密交易报文
- $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
- if($crypted_trade_data === false)
- {
- // echo $Base->Crypt->err_msg;
- $errorMessage = array(
- "data"=>"encryptTradeData error..."
- );
- return json_encode($errorMessage,true);
- die();
- }
-
- // echo "\r\n";
- // echo "[crypted message]: {$crypted_trade_data}";
-
- // 发送报文
- // echo "\r\n";
- // var_dump($api_url);
- $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
- echo $response;
- if($response === false)
- {
- // echo $Base->Request->err_msg;
- $errorMessage = array(
- "data"=>"send error..."
- );
- return json_encode($errorMessage,true);
- die();
- }
- // echo "\r\n";
- // echo "[response message]: {$response}";
-
- // 解析响应报文
- $response = json_decode($response, true);
- $response_data_crypted = $response['data'];
- $response_sign = $response['sign'];
- // echo "\r\n";
- // echo "[response sign]: {$response_sign}";
- // echo "\r\n";
- // echo "[response data (ciphertext)]: {$response_data_crypted}";
-
-
- // 解密响应密文
- $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
- if($response_data === false)
- {
- // echo $Base->Crypt->err_msg;
- $errorMessage = array(
- "data"=>"decryptTradeData error..."
- );
- return json_encode($errorMessage,true);
- die();
- }
- // echo "\r\n";
- // echo "[response data(clear text)]: {$response_data}";
- // die();
- var_dump(json_decode($response_data));
- $_SESSION['response_data_json'] = $response_data;
- return $response_data;
-
- // var_dump($_SESSION['user_id']);
- // 跳回之前的地址
- // header('Location: ' . $redirect_url);
- // exit;
- }
-
- // return pay();
-?>
-
diff --git a/mobile/plugins/payment/dalianpay/demo/query.php b/mobile/plugins/payment/dalianpay/demo/query.php
deleted file mode 100644
index 3611b3f..0000000
--- a/mobile/plugins/payment/dalianpay/demo/query.php
+++ /dev/null
@@ -1,98 +0,0 @@
-getConfig();
- // var_dump('', $config);
-
- // 接口URL(测试)
- $api_url = $config['query_url'];
-
- // 加个body字段传中文试试
-
- // 组装交易报文
- $reqsn_prefix = date('Ymd');
- $trade_data = array(
- 'orgid' => $config['org_num'],
- 'cusid' => $config['cusid'],
- 'version' => $config['version'],
- // 'reqsn' => '2023072464be320f45f2a',
- 'trxid' => '100000018608526', // 渠道交易流水号 如果返回的有 优先使用
- 'randomstr' => md5( uniqid() ),
- );
-
- // 生成签名
- $sign = $Base->Crypt->makeSign($trade_data);
- if($sign === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[sign]: {$sign}";
- // die();
-
- // 加密交易报文
- $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
- if($crypted_trade_data === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[crypted message]: {$crypted_trade_data}";
- // die();
-
- // 发送报文
- echo "\r\n";
- var_dump($api_url);
- $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
- if($response === false)
- {
- echo $Base->Request->err_msg;
- die();
- }
-
- echo "\r\n";
-
- echo "[response message]: {$response}";
-
- // 解析响应报文
- $response = json_decode($response, true);
- $response_data_crypted = $response['data'];
- $response_sign = $response['sign'];
- echo "\r\n";
- echo "[response sign]: {$response_sign}";
- echo "\r\n";
- echo "[response data (ciphertext)]: {$response_data_crypted}";
-
- // 解密响应密文
- $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
- if($response_data === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[response data(clear text)]: {$response_data}";
- // die();
-
-?>
-
-
-
-
-
-
- 统一查询Demo
-
-
-
-
diff --git a/mobile/plugins/payment/dalianpay/demo/refund.php b/mobile/plugins/payment/dalianpay/demo/refund.php
deleted file mode 100644
index a3832bd..0000000
--- a/mobile/plugins/payment/dalianpay/demo/refund.php
+++ /dev/null
@@ -1,105 +0,0 @@
-getConfig();
- // var_dump('', $config);
-
- // 接口URL(测试)
- $api_url = $config['refund_url'];
-
-// 加个body字段传中文试试
-
- // 组装交易报文
- $reqsn_prefix = date('Ymd');
- $trade_data = array(
- // 'orgid' => $config['org_num'],
- 'cusid' => $config['cusid'],
- 'branchno' => $config['branchno'],
- // 'termcode' => $config['termcode'],
- 'version' => $config['version'],
- 'trxamt' => '1',
- 'reqsn' => uniqid($reqsn_prefix),
- 'producp' => 'JX0002',
- 'transtype' => 'JSP511',
- 'randomstr' => md5( uniqid() ),
- // 'oldreqsn' => '100000018608489',
- 'oldtrxid' => '100000018608532',
- );
-
- // 生成签名
- $sign = $Base->Crypt->makeSign($trade_data);
- if($sign === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[sign]: {$sign}";
- // die();
-
- // 加密交易报文
- $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
- if($crypted_trade_data === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[crypted message]: {$crypted_trade_data}";
- // die();
-
- // 发送报文
- echo "\r\n";
- var_dump($api_url);
- $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
- if($response === false)
- {
- echo $Base->Request->err_msg;
- die();
- }
-
- echo "\r\n";
-
- echo "[response message]: {$response}";
-
- // 解析响应报文
- $response = json_decode($response, true);
- $response_data_crypted = $response['data'];
- $response_sign = $response['sign'];
- echo "\r\n";
- echo "[response sign]: {$response_sign}";
- echo "\r\n";
- echo "[response data (ciphertext)]: {$response_data_crypted}";
-
- // 解密响应密文
- $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
- if($response_data === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[response data(clear text)]: {$response_data}";
- // die();
-
-?>
-
-
-
-
-
-
-
- 统一扫码Demo
-
-
-
-
diff --git a/mobile/plugins/payment/dalianpay/demo/scan.php b/mobile/plugins/payment/dalianpay/demo/scan.php
deleted file mode 100644
index ddde468..0000000
--- a/mobile/plugins/payment/dalianpay/demo/scan.php
+++ /dev/null
@@ -1,158 +0,0 @@
-getConfig();
- // var_dump('', $config);
-
- // 接口URL(测试)
- $api_url = $config['scan_url'];
-
-// 加个body字段传中文试试
-
- // 组装交易报文
- $reqsn_prefix = date('Ymd');
- $terminfo = array(
- "termsn"=>"dfjskljioe13238023",
- "longitude"=>"+37.12",
- "latitude"=>"-37.12",
- "termno"=>"00000001",
- "devicetype"=>"04",
- );
- $trade_data = array(
- 'orgid' => $config['org_num'],
- 'cusid' => $config['cusid'],
- 'branchno' => $config['branchno'],
- 'termcode' => $config['termcode'],
- 'version' => $config['version'],
- 'trxamt' => '1',
- 'reqsn' => uniqid($reqsn_prefix),
- 'producp' => 'JX0002',
- 'transtype' => 'JSP511',
- 'paytype' => 'W01',
- 'randomstr' => md5( uniqid() ),
- 'terminfo' => json_encode($terminfo),
- 'authcode' => '',
- );
-
- // $trade_data = array(
- // "cusid" => "10147",
- // "branchno" => "44",
- // "termcode" => "000000",
- // "version" => "11",
- // "trxamt" => "1154634",
- // "reqsn" => "112094120001088317",
- // "producp" => "JX0002",
- // "transtype" => "JSP501",
- // "paytype" => "W01",
- // "randomstr" => md5( uniqid() ),
- // "body" => "",
- // "remark" => "",
- // "validtime" => "",
- // "acct" => "",
- // "notify_url" => "",
- // "limit_pay" => "",
- // "sub_appid" => "",
- // "goods_tag" => "",
- // "benefitdetail" => "",
- // "chnlstoreid" => "",
- // "extendparams" => "",
- // "cusip" => "",
- // "front_url" => "",
- // "subbranch" => "",
- // "idno" => "",
- // "truename" => "",
- // "asinfo" => "",
- // "fqnum" => "",
- // "unpid" => "",
- // "terminfo" => "",
- // // 其他参数...
- // );
-
- // $trade_data = array(
- // "appid"=>"00000051",
- // "cusid"=>"990581007426001",
- // "randomstr"=>"82712208",
- // "signtype"=>"RSA",
- // "trxid"=>"112094120001088317",
- // "version"=>"11",
- // );
-
- // 生成签名
- $sign = $Base->Crypt->makeSign($trade_data);
- if($sign === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[sign]: {$sign}";
- // die();
-
- // 加密交易报文
- $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
- if($crypted_trade_data === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[crypted message]: {$crypted_trade_data}";
- // die();
-
- // 发送报文
- echo "\r\n";
- var_dump($api_url);
- $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
- if($response === false)
- {
- echo $Base->Request->err_msg;
- die();
- }
-
- echo "\r\n";
-
- echo "[response message]: {$response}";
-
- // 解析响应报文
- $response = json_decode($response, true);
- $response_data_crypted = $response['data'];
- $response_sign = $response['sign'];
- echo "\r\n";
- echo "[response sign]: {$response_sign}";
- echo "\r\n";
- echo "[response data (ciphertext)]: {$response_data_crypted}";
-
- // 解密响应密文
- $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
- if($response_data === false)
- {
- echo $Base->Crypt->err_msg;
- die();
- }
- echo "\r\n";
- echo "[response data(clear text)]: {$response_data}";
- // die();
-
-?>
-
-
-
-
-
-
-
-
-
- 统一扫码Demo
-
-
-
-
diff --git a/mobile/plugins/payment/dalianpay/library/Base.php b/mobile/plugins/payment/dalianpay/library/Base.php
deleted file mode 100644
index 6f11ca4..0000000
--- a/mobile/plugins/payment/dalianpay/library/Base.php
+++ /dev/null
@@ -1,41 +0,0 @@
-config = require_once('../config/config.php');
- // 实例化加解密类
- require_once('Crypt.php');
- $this->Crypt = new Crypt($this->config);
- // 实例化请求类
- require_once('Request.php');
- $this->Request = new Request($this->config);
- }
-
-
- /**
- * 获取配置信息
- * @return array
- */
- public function getConfig()
- {
- return $this->config;
- }
-
-
-}
-?>
diff --git a/mobile/plugins/payment/dalianpay/library/Crypt.php b/mobile/plugins/payment/dalianpay/library/Crypt.php
deleted file mode 100644
index 79c9848..0000000
--- a/mobile/plugins/payment/dalianpay/library/Crypt.php
+++ /dev/null
@@ -1,220 +0,0 @@
-config = $config;
- }
-
-
- /**
- * 数据校验
- * @param array $data 待校验数据
- * @return bool
- */
- private function checkData(array $data)
- {
- // 非空校验
- if( count($data) == 0 )
- {
- $this->err_msg = '待签名数据为空';
- return false;
- }
- // 一维数组校验
- if( count($data) != count($data, 1) )
- {
- $this->err_msg = '待签名数据不能是多维数组';
- return false;
- }
-
- return true;
- }
-
-
- /**
- * 生成签名
- * @param array $data 待签名数据
- * @return bool|string
- */
- public function makeSign(array $data)
- {
- // 数据校验
- $check_data = $this->checkData($data);
- if($check_data === false)
- {
- return false;
- }
-
- // 升序排列
- ksort($data);
- // 转字符串
- $pre_sign_str = http_build_query($data);
- // echo "[pre_sign_str(jiao yi message)]: {$pre_sign_str}";
- // die();
-
- // 读取私钥
- $private_key = file_get_contents($this->config['private_key']);
- $private_key = openssl_pkey_get_private($private_key);
-
- // 私钥签名
- $res = openssl_sign($pre_sign_str, $sign, $private_key);
- if($res === false)
- {
- $this->err_msg = openssl_error_string();
- return false;
- }
- // 签名转Base64
- $sign = base64_encode($sign);
-
- return $sign;
- }
-
-
- /**
- * 校验签名
- * @param array $data 待校验数据
- * @param string $sign 签名
- * @return bool
- */
- public function checkSign(array $data, string $sign)
- {
- // 数据校验
- $check_data = $this->checkData($data);
- if($check_data === false)
- {
- return false;
- }
-
- // 签名转二进制
- $sign = base64_decode($sign);
-
- // 升序排列
- ksort($data);
- // 转字符串
- $pre_sign_str = http_build_query($data);
- $pre_sign_str = urldecode($pre_sign_str);
- // echo "[pre sign str]: {$pre_sign_str}";
- // die();
-
- // 读取公钥
- $public_key = file_get_contents($this->config['public_key']);
- $public_key = openssl_pkey_get_public($public_key);
-
- // 公钥验签
- $res = openssl_verify($pre_sign_str, $sign, $public_key);
- if($res === false)
- {
- $this->err_msg = openssl_error_string();
- return false;
- }
-
- return $res;
- }
-
-
- /**
- * 加密交易报文
- * @param array $data 待签名数据
- * @return bool|string
- */
- public function encryptTradeData(array $data)
- {
- // 数据校验
- $check_data = $this->checkData($data);
- if($check_data === false)
- {
- return false;
- }
-
- // 读取公钥
- $public_key = file_get_contents($this->config['public_key']);
- $public_key = openssl_pkey_get_public($public_key);
- // 公钥长度(bit)
- $public_key_info = openssl_pkey_get_details($public_key);
- $public_key_bit = $public_key_info['bits'];
- // 数据长度(数据长度=密钥字节数-11,11为OPENSSL_PKCS1_PADDING的填充长度)
- $data_length = $public_key_bit / 8 - 11;
-
- // 待加密数据转json
- $pre_encrypt_data = json_encode($data, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
- // 按密钥长度拆分数据
- $pre_encrypt_data_arr = str_split($pre_encrypt_data, $data_length);
- // 分段公钥加密
- $crypted_data = '';
- foreach($pre_encrypt_data_arr as $key=>$val)
- {
- $res = openssl_public_encrypt($val, $crypted_data_tmp, $public_key, OPENSSL_PKCS1_PADDING);
- if($res === false)
- {
- $this->err_msg = openssl_error_string();
- return false;
- }
- $crypted_data .= $crypted_data_tmp;
- }
- // 加密结果转Base64
- $crypted_data = base64_encode($crypted_data);
-
- return $crypted_data;
- }
-
-
- /**
- * 解密交易报文
- * @param string $data 加密的交易报文
- * @return bool|array
- */
- public function decryptTradeData($data)
- {
- // 加密数据转二进制
- $pre_decrypt_data = base64_decode($data);
-
- // 读取私钥
- $private_key = file_get_contents($this->config['private_key']);
- $private_key = openssl_pkey_get_private($private_key);
- // 私钥长度(bit)
- $private_key_info = openssl_pkey_get_details($private_key);
- $private_key_bit = $private_key_info['bits'];
- // 数据长度(数据长度=密钥字节数,解密时无需考虑OPENSSL_PKCS1_PADDING的填充占位)
- $data_length = $private_key_bit / 8;
-
- // 按密钥长度拆分数据
- $pre_decrypt_data_arr = str_split($pre_decrypt_data, $data_length);
- // 分段私钥解密
- $decrypted_data = '';
- foreach($pre_decrypt_data_arr as $key=>$val)
- {
- $res = openssl_private_decrypt($val, $decrypted_data_tmp, $private_key, OPENSSL_PKCS1_PADDING);
- if($res === false)
- {
- $this->err_msg = openssl_error_string();
- return false;
- }
- $decrypted_data .= $decrypted_data_tmp;
- }
- // 解密结果编码转换(JAVA处理后的中文一般为GBK编码)
- // echo "\r\n";
- // var_dump($decrypted_data);
- $charset = mb_detect_encoding($decrypted_data); // 这个东西有点问题 解析出来是false 先不用了
- // echo "\r\n";
- // var_dump($charset);
- // echo "\r\n";
-
- $decrypted_data = mb_convert_encoding($decrypted_data, 'UTF-8', 'GBK');
- // echo "\r\n";
- // var_dump($decrypted_data);
- return $decrypted_data;
- }
-
-
-}
-
-?>
diff --git a/mobile/plugins/payment/dalianpay/library/Request.php b/mobile/plugins/payment/dalianpay/library/Request.php
deleted file mode 100644
index 462be96..0000000
--- a/mobile/plugins/payment/dalianpay/library/Request.php
+++ /dev/null
@@ -1,156 +0,0 @@
-config = $config;
- }
-
-
- /**
- * 发送curl请求
- * @param string $url 要请求的URL
- * @param string $method 请求方法[get|post]
- * @param string|array $post_data 请求数据,模拟表单提交时为Array,提交JSON数据时为String
- * @param string $data_type 数据类型[form|file|json|xml]
- */
- private function curlRequest($url, $method, $post_data='', $data_type='form')
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- // 请求端口,SSL为443
- curl_setopt($ch, CURLOPT_PORT, 443);
- // 为项目内调用设置专用的UA
- curl_setopt($ch, CURLOPT_USERAGENT, 'Intract cURL');
- // 设置为不自动输出
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- // 不输出头部
- curl_setopt($ch, CURLOPT_HEADER, false);
- // 跳过证书检查
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
-
- // 不从证书中检查SSL加密算法是否存在
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- // // 设定SSL版本,1-3切换
- // curl_setopt($ch, CURLOPT_SSLVERSION, 1);
-
- // 根据$data_type,选择不同的HTTP Header
- $data_type = strtolower($data_type);
- // echo curl_errno($ch);
- switch($data_type)
- {
- case 'form':
- $header = 'application/x-www-form-urlencoded';
- break;
- case 'file':
- $header = 'multipart/form-data';
- break;
- case 'json':
- $header = 'application/json';
- break;
- case 'xml':
- $header = 'text/xml';
- break;
- default:
- // 默认为form
- $header = 'application/x-www-form-urlencoded';
- }
- $header = array(
- 'Content-type: ' . $header,
- 'Content-length: ' . strlen($post_data)
- );
- // 根据不同的提交方式,设置头部和数据
- $method = strtolower($method);
- switch($method)
- {
- case 'get':
- break;
- case 'post':
- // 设置头部
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- // 设置POST提交
- curl_setopt($ch, CURLOPT_POST, true);
- // 设置POST数据
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
- break;
- default:
- ;
- }
- // 执行请求
- $response = curl_exec($ch);
- // 返回数据
- $res = array(
- 'status' => 0,
- 'err_msg' => '',
- 'http_code' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
- 'data' => null
- );
- if($response === false)
- {
- $res['err_msg'] = curl_error($ch);
- }
- else
- {
- $res['status'] = 1;
- $res['data'] = $response;
- }
- // 关闭连接
- curl_close($ch);
-
- return $res;
- }
-
-
- /**
- * 发送报文
- * @param string $url 接口URL
- * @param string $data 加密后的数据
- * @param string $sign 交易报文签名
- * @return bool|string 成功时返回JSON字符串
- */
- public function send($url, $data, $sign)
- {
- // var_dump(gettype($url));
- // echo "\r\n";
- // if (!($url instanceof string))
- // {
- // var_dump("url is not a string");
- // return false;
- // }
- // 组装通用参数
- $post_data = array(
- 'data' => $data,
- // 'data' => urlencode($data),
- 'orgid' => $this->config['org_num'],
- 'signtype' => $this->config['signtype'],
- 'sign' => $sign,
- // 'sign' => urlencode($sign),
- );
- $post_data = json_encode($post_data);
- // echo "\r\n";
- // echo "[send message]: {$post_data}";
-
- // 发送请求
- $send_res = $this->curlRequest($url, 'post', $post_data, 'json');
- if($send_res['status'] !== 1)
- {
- $this->err_msg = $send_res['err_msg'] . '(HTTP Code: ' . $send_res['http_code'] . ')';
- return false;
- }
-
- return $send_res['data'];
- }
-
-
-}
-
-?>
diff --git a/mobile/plugins/payment/wxpay.php b/mobile/plugins/payment/wxpay.php
index e56685c..5a5b180 100755
--- a/mobile/plugins/payment/wxpay.php
+++ b/mobile/plugins/payment/wxpay.php
@@ -122,6 +122,7 @@ class wxpay
// $_SESSION['openid'] = $openid;
$_SESSION['openid'] = 'oCTanxBeiVFWIekJT_GiPZM2UiGY'; //sc_test l or I
}
+ $_SESSION['openid'] = 'oCTanxBeiVFWIekJT_GiPZM2UiGY';
$order_amount = $order['order_amount'] * 100;
// 访问大连支付接口
@@ -144,18 +145,41 @@ class wxpay
echo $order['order_sn'] . "\n\r";
echo $order_amount . "\n\r";
- $directory = BASE_PATH . '../plugins/payment'; // /data/www/wwwroot/dcs1.3/mobile/source/
- $files = scandir($directory);
-
- // 遍历文件列表并打印文件名
- foreach ($files as $file) {
- // 排除当前目录(.)和上级目录(..)
- if ($file != '.' && $file != '..') {
- echo $file . "
";
+ // $directory = BASE_PATH . '../plugins/payment'; // /data/www/wwwroot/dcs1.3/mobile/source/
+ // $files = scandir($directory);
+
+ // // 遍历文件列表并打印文件名
+ // foreach ($files as $file) {
+ // // 排除当前目录(.)和上级目录(..)
+ // if ($file != '.' && $file != '..') {
+ // echo $file . "
";
+ // }
+ // }
+
+ // 递归include文件
+ function includeDirectory($directory) {
+ if ($handle = opendir($directory)) {
+ while (($file = readdir($handle)) !== false) {
+ if ($file != '.' && $file != '..') {
+ $filePath = $directory . '/' . $file;
+ if (is_dir($filePath)) {
+ includeDirectory($filePath); // 递归调用,处理子目录
+ } elseif (pathinfo($file, PATHINFO_EXTENSION) === 'php') {
+ include_once $filePath;
+ echo $filePath . '\n\r';
+ }
+ }
+ }
+ closedir($handle);
}
}
- require_once(BASE_PATH . '../plugins/payment/dalianpay/demo/dalianpay.php');
- include BASE_PATH . "../plugins/payment/dalianpay/demo/dalianpay.php";
+
+ $directory = 'helpers/dalianpay'; // 替换为您要包含文件的目录路径
+ includeDirectory($directory);
+
+ require_once(BASE_PATH . 'helpers/dalianpay/demo/dalianpay.php');
+ include_once(BASE_PATH . "../plugins/payment/dalianpay/demo/dalianpay.php");
+
$new_plugin = new dalianpay();
$response_data = $new_plugin->pay($this->encrypt($_SESSION['openid']), $order['order_sn'], $order_amount);
diff --git a/mobile/source/helpers/dalianpay/cert/channel_public_key.pem b/mobile/source/helpers/dalianpay/cert/channel_public_key.pem
new file mode 100644
index 0000000..350d007
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/cert/channel_public_key.pem
@@ -0,0 +1,9 @@
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgFoZG+UeND0T/PQK41Dg
+5bXgpuHwBdc7sfGRTKlB2PmZ1Q8XE4b8u5SMqk9LC7iUL5wJlItJ9rcdXPgc3SnB
+xuq133HRqvsNAxWacYQnarYMko7JKKGENdrcE+MY7ZM6Yo60/6+HVOwphIw8BuZL
+NvvCKx7BrI84t93TFndn6WVF16XgOhQkPyUmsj2ekfw9vrQg89ipNcTHmBCtH9/K
+KEWRPTUkH9xc+GOZ06v5O3Pmpd+hdXyE/Rjtsa1foR3l1UsWFVODHRkeoHTnBdkR
+YiOGXpGthazAcvPAZtTWSKtRirKF87soIill1cmHMCw8d9JoZgq9k0L8n9ZpUCw7
+twIDAQAB
+-----END PUBLIC KEY-----
diff --git a/mobile/source/helpers/dalianpay/cert/cus_private_key.pem b/mobile/source/helpers/dalianpay/cert/cus_private_key.pem
new file mode 100644
index 0000000..5ec197a
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/cert/cus_private_key.pem
@@ -0,0 +1,28 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCOt2qd98v3uMVM
+XtDlEJBks8spkC+SSdi+/9m+6cVE/eqSqzWMAa2QeoZ7j31ard+FV2ZynITj+Y15
+6iRJ84J20k7VTuUfjLSjJ079DrRweYimf5MW/QCRyz93YMjC4A9aWrbSw06pkiz4
+p3DMkitlp9oDEx13vJld0tLw1BO4fSMmoDLg4ri3zFA/PqPb3OWW0R/yRakOdiPx
+kjsOYZ7EOesdc67gdYCiiEy2x38jGMKAJ5jqWmRbnCF+4Ij7QPGXQTG7ba63azNN
+S8mBis5WNHA1EPK+KgRDykZHWTzV8Hu/x5NRnBUYpTdSlLM2zP//8dAcUOUejakv
+DSWbLPDVAgMBAAECggEAVm5KSYTqqAnkow3BIRjY+cPRREioJsZGV9YG/xIAgHnu
+eAjsEvBpNtidXXNXDXXDqrN1ve+Ao7hcr/rXI1owJtnTGGgBZwwF0dFaivM+3+ca
+lQsp/4AVujYHJ7sbmrmrUqMhmZ7iott+FNEDBUF4usXeyIHpFLzJfQLS8Tre/pkS
+KVcepRBKD7WSwSaqI5Gb9i+HHdqgE1UhY4nqMt1F07szFmPSCsS8L5DVGRTKbOlW
+KwwbgyY53aUCb1xVVHXhyxCFTU8a02yBwWDXCeG+Qvnu2qED+wui7yF77299ypPP
+oim72rjyxj1736+PSymgPlNuLFPkH/HLac5jxdR7eQKBgQDQq6nORGAJpPmt+BLY
+nJtJHCJiU4cf4dJ1O+LnUTvlO1dl68wh/fulOG6xwngTXB9izq9Aj6CEGsW7GCne
+3Q1vBELlmDcqp1AiyvpHaymtYWRr6+DdW0DKWTfcqaaF+8GEx6RwXBuwUji7kh5y
+wCCP3ZLZG9zx7DTL9F0+2h7TwwKBgQCvFiqtPK72VT9C9+Q+Ct8Bwhzv0WDbTwx6
+Ke5YXWuI8mm07TA/osVav4etLrwlKine6QqZ9+1GnYtB09EKX1nmFBgiOgR52woe
+hOhOYTG4bFRfH7caiHcgR3L0nsXCdjlfpxqLiUCvFYzwYsXnIGfQYZvWLELFua5o
+dhRyTfxXhwKBgHxEzwJE3ADCW+ML6oVPdnbqp1txLPaCsKgaev2Q9h+E4H6VF2Ni
+8xso6Vs5WfMFmLdqKRpErq4dl4XdVQohEN/9ZK2AodHoBCRERxqDKjXT208eETMi
+JgqbaVYjPkVqcYvWrQoxAFhYDus9kJ575qhmpw5etozoQ2T26RUGJverAoGANKwy
+gpNy/2B9+6Of4ppapKjFE9ClltSdKFNdBPB13WkwK+H/VeWeAcMFCjC5IWUh25G4
+QsG3fDsBHfifNsOgw/rfl8xkdFRVIwFQ8eODlbvhVgywhSbwz6EvEDCDxhDTCde3
+wKq17vZIxDiy2OmC0cnLnA8Mt3c45OxBEnIrrBkCgYBgaR0UQJq/Xfnu+CV8/hV3
+HYpzquWzqWve3DgEGSXA/fAVSm6JhcumndywlBVXXyML+A+U6MVdJfGVbLSHxLQV
+1f9nTAwXPbauFLrqpHm0hOvCwfAEkK8HDt2mKOfblbWrLo7gF7wErcSEw7tEqJOg
+M2OG+6QXvCsCZUKBf8TnnQ==
+-----END RSA PRIVATE KEY-----
diff --git a/mobile/source/helpers/dalianpay/cert/cus_private_key.pem.test b/mobile/source/helpers/dalianpay/cert/cus_private_key.pem.test
new file mode 100644
index 0000000..8a28c0b
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/cert/cus_private_key.pem.test
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJgHMGYsspghvP+y
+CbjLG43CkZuQ3YJyDcmEKxvmgblITfmiTPx2b9Y2iwDT9gnLGExTDm1BL2A8VzMo
+bjaHfiCmTbDctu680MLmpDDkVXmJOqdlXh0tcLjhN4+iDA2KkRqiHxsDpiaKT6MM
+BuecXQbJtPlVc1XjVhoUlzUgPCrvAgMBAAECgYAV9saYTGbfsdLOF5kYo0dve1Jx
+aO7dFMCcgkV+z2ujKtNmeHtU54DlhZXJiytQY5Dhc10cjb6xfFDrftuFcfKCaLiy
+6h5ETR8jyv5He6KH/+X6qkcGTkJBYG1XvyyFO3PxoszQAs0mrLCqq0UItlCDn0G7
+2MR9/NuvdYabGHSzEQJBAMXB1/DUvBTHHH4LiKDiaREruBb3QtP72JQS1ATVXA2v
+6xJzGPMWMBGQDvRfPvuCPVmbHENX+lRxMLp39OvIn6kCQQDEzYpPcuHW/7h3TYHY
+c+T0O6z1VKQT2Mxv92Lj35g1XqV4Oi9xrTj2DtMeV1lMx6n/3icobkCQtuvTI+Ac
+qfTXAkB6bCz9NwUUK8sUsJktV9xJN/JnrTxetOr3h8xfDaJGCuCQdFY+rj6lsLPB
+TnFUC+Vk4mQVwJIE0mmjFf22NWW5AkAmsVaRGkAmui41Xoq52MdZ8WWm8lY0BLrl
+BJlvveU6EPqtcZskWW9KiU2euIO5IcRdpvrB6zNMgHpLD9GfMRcPAkBUWOV/dH13
+v8V2Y/Fzuag/y5k3/oXi/WQnIxdYbltad2xjmofJ7DbB7MJqiZZD8jlr8PCZPwRN
+zc5ntDStc959
+-----END PRIVATE KEY-----
diff --git a/mobile/source/helpers/dalianpay/config/config.php b/mobile/source/helpers/dalianpay/config/config.php
new file mode 100644
index 0000000..2130425
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/config/config.php
@@ -0,0 +1,49 @@
+ '5503001',
+ // 'org_num' => '100018380507D2C',
+ // 商户号 渠道商户号
+ 'cusid' => '10147',
+ // 'cusid' => '563222080502LGB',
+ // 产品
+ 'producp' => 'JX0002',
+ // 版本
+ 'version' => '11',
+ // 门店号
+ 'branchno' => '44',
+ // 终端号
+ 'termcode' => '000000',
+ // 加密方式
+ 'signtype' => 'RSA',
+ // 渠道公钥
+ 'public_key' => dirname(__FILE__) . '/../cert/channel_public_key.pem',
+ // 商户私钥
+ 'private_key' => dirname(__FILE__) . '/../cert/cus_private_key.pem',
+
+ // 统一支付接口 测试地址
+ 'pay_url' => 'https://open.dalianpay.cn/payapi/unitorder/pay',
+ // 统一支付接口
+ // 'pay_url' => 'https://epay.dalianpay.cn/payapi/unitorder/pay',
+
+ // 统一扫码接口 测试地址
+ 'scan_url' => 'https://open.dalianpay.cn/payapi/unitorder/scanqrpay',
+
+ // 交易撤销 测试地址
+ 'cancel_url' => 'https://open.dalianpay.cn/payapi/tranx/cancel',
+
+ // 交易退款 测试地址
+ 'refund_url' => 'https://tpay.01pub.com/payapi/tranx/refund',
+
+ // 统一查询接口 测试地址
+ 'query_url' => 'https://open.dalianpay.cn/payapi/tranx/query',
+
+ // 订单关闭接口 测试地址
+ 'close_url' => 'https://open.dalianpay.cn/payapi/tranx/close',
+
+ 'openid' => '',
+
+ );
+
+?>
diff --git a/mobile/source/helpers/dalianpay/demo/cancel.php b/mobile/source/helpers/dalianpay/demo/cancel.php
new file mode 100644
index 0000000..315a524
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/demo/cancel.php
@@ -0,0 +1,151 @@
+getConfig();
+ // var_dump('', $config);
+
+ // 接口URL(测试)
+ $api_url = $config['cancel_url'];
+
+// 加个body字段传中文试试
+
+ // 组装交易报文
+ $reqsn_prefix = date('Ymd');
+ $trade_data = array(
+ 'orgid' => $config['org_num'],
+ 'cusid' => $config['cusid'],
+ 'branchno' => $config['branchno'],
+ 'termcode' => $config['termcode'],
+ 'version' => $config['version'],
+ 'trxamt' => '1',
+ 'reqsn' => uniqid($reqsn_prefix),
+ 'producp' => 'JX0002',
+ 'transtype' => 'JSP511',
+ 'randomstr' => md5( uniqid() ),
+ // 'oldreqsn' => '2023072464be31055e0e0',
+ 'oldtrxid' => '100000018608497',
+ );
+
+ // $trade_data = array(
+ // "cusid" => "10147",
+ // "branchno" => "44",
+ // "termcode" => "000000",
+ // "version" => "11",
+ // "trxamt" => "1154634",
+ // "reqsn" => "112094120001088317",
+ // "producp" => "JX0002",
+ // "transtype" => "JSP501",
+ // "paytype" => "W01",
+ // "randomstr" => md5( uniqid() ),
+ // "body" => "",
+ // "remark" => "",
+ // "validtime" => "",
+ // "acct" => "",
+ // "notify_url" => "",
+ // "limit_pay" => "",
+ // "sub_appid" => "",
+ // "goods_tag" => "",
+ // "benefitdetail" => "",
+ // "chnlstoreid" => "",
+ // "extendparams" => "",
+ // "cusip" => "",
+ // "front_url" => "",
+ // "subbranch" => "",
+ // "idno" => "",
+ // "truename" => "",
+ // "asinfo" => "",
+ // "fqnum" => "",
+ // "unpid" => "",
+ // "terminfo" => "",
+ // // 其他参数...
+ // );
+
+ // $trade_data = array(
+ // "appid"=>"00000051",
+ // "cusid"=>"990581007426001",
+ // "randomstr"=>"82712208",
+ // "signtype"=>"RSA",
+ // "trxid"=>"112094120001088317",
+ // "version"=>"11",
+ // );
+
+ // 生成签名
+ $sign = $Base->Crypt->makeSign($trade_data);
+ if($sign === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[sign]: {$sign}";
+ // die();
+
+ // 加密交易报文
+ $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
+ if($crypted_trade_data === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[crypted message]: {$crypted_trade_data}";
+ // die();
+
+ // 发送报文
+ echo "\r\n";
+ var_dump($api_url);
+ $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
+ if($response === false)
+ {
+ echo $Base->Request->err_msg;
+ die();
+ }
+
+ echo "\r\n";
+
+ echo "[response message]: {$response}";
+
+ // 解析响应报文
+ $response = json_decode($response, true);
+ $response_data_crypted = $response['data'];
+ $response_sign = $response['sign'];
+ echo "\r\n";
+ echo "[response sign]: {$response_sign}";
+ echo "\r\n";
+ echo "[response data (ciphertext)]: {$response_data_crypted}";
+
+ // 解密响应密文
+ $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
+ if($response_data === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ // $response_data = mb_convert_encoding($response_data, 'UTF-8', 'GBK');
+ echo "[response data(clear text)]: {$response_data}";
+ // die();
+
+?>
+
+
+
+
+
+
+
+
+
+ 交易撤销Demo
+
+
+
+
diff --git a/mobile/source/helpers/dalianpay/demo/close.php b/mobile/source/helpers/dalianpay/demo/close.php
new file mode 100644
index 0000000..dde0178
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/demo/close.php
@@ -0,0 +1,99 @@
+getConfig();
+ // var_dump('', $config);
+
+ // 接口URL(测试)
+ $api_url = $config['close_url'];
+
+ // 加个body字段传中文试试
+
+ // 组装交易报文
+ $reqsn_prefix = date('Ymd');
+ $trade_data = array(
+ 'orgid' => $config['org_num'],
+ 'cusid' => $config['cusid'],
+ 'branchno' => $config['branchno'],
+ 'termcode' => $config['termcode'],
+ 'version' => $config['version'],
+ 'randomstr' => md5( uniqid() ),
+ 'oldtrxid' => '100000018608526',
+ );
+
+ // 生成签名
+ $sign = $Base->Crypt->makeSign($trade_data);
+ if($sign === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[sign]: {$sign}";
+ // die();
+
+ // 加密交易报文
+ $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
+ if($crypted_trade_data === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[crypted message]: {$crypted_trade_data}";
+ // die();
+
+ // 发送报文
+ echo "\r\n";
+ var_dump($api_url);
+ $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
+ if($response === false)
+ {
+ echo $Base->Request->err_msg;
+ die();
+ }
+
+ echo "\r\n";
+
+ echo "[response message]: {$response}";
+
+ // 解析响应报文
+ $response = json_decode($response, true);
+ $response_data_crypted = $response['data'];
+ $response_sign = $response['sign'];
+ echo "\r\n";
+ echo "[response sign]: {$response_sign}";
+ echo "\r\n";
+ echo "[response data (ciphertext)]: {$response_data_crypted}";
+
+ // 解密响应密文
+ $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
+ if($response_data === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[response data(clear text)]: {$response_data}";
+ // die();
+
+?>
+
+
+
+
+
+
+ 订单关闭Demo
+
+
+
+
diff --git a/mobile/source/helpers/dalianpay/demo/dalianpay.php b/mobile/source/helpers/dalianpay/demo/dalianpay.php
new file mode 100644
index 0000000..c2ccd8a
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/demo/dalianpay.php
@@ -0,0 +1,178 @@
+decrypt($_GET['openid']);
+ // $reqsn = $_GET['reqsn'];
+ // $trxamt = $_GET['trxamt'];
+
+ $openid = $this->decrypt($openid_crypt);
+ // $openid = $openid_crypt;
+ $reqsn = $order_sn;
+ $trxamt = $order_amount;
+
+ $string = $openid . ' + ' . $reqsn . ' + ' . $trxamt;
+ // echo $string;
+
+ // var_dump($openid);
+ // var_dump($reqsn);
+ // var_dump($trxamt);
+ $redirect_url = $_SESSION['prev_url'];
+ // unset($_SESSION['prev_url']);
+ // var_dump($redirect_url);
+
+ // 加载基础类
+ require_once('../library/Base.php');
+ $Base = new Base();
+
+ // 获取配置信息
+ $config = $Base->getConfig();
+ // var_dump('', $config);
+
+ // 接口URL(测试)
+ $api_url = $config['pay_url'];
+ // $api_url = $_POST['url'];
+ $message = array(
+ "url"=>$api_url,
+ );
+ // echo json_encode($message,true);
+ // 加个body字段传中文试试
+
+ // 组装交易报文
+ $reqsn_prefix = date('Ymd');
+ // var_dump("uniq_id(reqsn)");
+ // echo "\r\n";
+ // var_dump(uniqid($reqsn_prefix));
+ $trade_data = array(
+ 'orgid' => $config['org_num'],
+ 'cusid' => $config['cusid'],
+ 'branchno' => $config['branchno'],
+ // 'termcode' => $config['termcode'],
+ 'version' => $config['version'],
+ 'trxamt' => $trxamt, // total_fee
+ 'reqsn' => $reqsn, // 交易订单号
+ 'producp' => 'JX0002',
+ 'transtype' => 'JSP501', // 微信支付
+ 'paytype' => 'W02', // 微信js支付
+ 'randomstr' => md5( uniqid() ),
+ // 'body' => 'pages',
+ 'acct' => $openid,
+ // 'notify_url' => '', // 交易结果通知地址
+ // 'sub_appid' => 'wx79343915f99167e6',
+ // 'front_url' => '', // 支付完成跳转
+ );
+ // 生成签名
+ $sign = $Base->Crypt->makeSign($trade_data);
+ if($sign === false)
+ {
+ // echo $Base->Crypt->err_msg;
+ $errorMessage = array(
+ "data"=>"makeSign error..."
+ );
+ return json_encode($errorMessage,true);
+ die();
+ }
+
+ // echo "\r\n";
+ // echo "[sign]: {$sign}";
+
+ // 加密交易报文
+ $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
+ if($crypted_trade_data === false)
+ {
+ // echo $Base->Crypt->err_msg;
+ $errorMessage = array(
+ "data"=>"encryptTradeData error..."
+ );
+ return json_encode($errorMessage,true);
+ die();
+ }
+
+ // echo "\r\n";
+ // echo "[crypted message]: {$crypted_trade_data}";
+
+ // 发送报文
+ // echo "\r\n";
+ // var_dump($api_url);
+ $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
+ // echo $response;
+ if($response === false)
+ {
+ // echo $Base->Request->err_msg;
+ $errorMessage = array(
+ "data"=>"send error..."
+ );
+ return json_encode($errorMessage,true);
+ die();
+ }
+ // echo "\r\n";
+ // echo "[response message]: {$response}";
+
+ // 解析响应报文
+ $response = json_decode($response, true);
+ $response_data_crypted = $response['data'];
+ $response_sign = $response['sign'];
+ // echo "\r\n";
+ // echo "[response sign]: {$response_sign}";
+ // echo "\r\n";
+ // echo "[response data (ciphertext)]: {$response_data_crypted}";
+
+
+ // 解密响应密文
+ $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
+ if($response_data === false)
+ {
+ // echo $Base->Crypt->err_msg;
+ $errorMessage = array(
+ "data"=>"decryptTradeData error..."
+ );
+ return json_encode($errorMessage,true);
+ die();
+ }
+ // echo "\r\n";
+ // echo "[response data(clear text)]: {$response_data}";
+ // die();
+ // var_dump(json_decode($response_data));
+ $_SESSION['response_data_json'] = $response_data;
+ return $response_data;
+
+ // var_dump($_SESSION['user_id']);
+ // 跳回之前的地址
+ // header('Location: ' . $redirect_url);
+ // exit;
+ }
+}
+
+echo 'hi there.....\n\r';
+$new_plugin = new dalianpay();
+$openid_crypt = 'oCTanxBeiVFWIekJT_GiPZM2UiGY';
+$order_sn = '2023080355429';
+$order_amount = '600';
+$response_data = $new_plugin->pay($openid_crypt,$order_sn,$order_amount);
+echo $response_data;
+
+
+?>
+
diff --git a/mobile/source/helpers/dalianpay/demo/pay.php b/mobile/source/helpers/dalianpay/demo/pay.php
new file mode 100644
index 0000000..b97f9f1
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/demo/pay.php
@@ -0,0 +1,162 @@
+getConfig();
+ // var_dump('', $config);
+
+ // 接口URL(测试)
+ $api_url = $config['pay_url'];
+ // $api_url = $_POST['url'];
+ $message = array(
+ "url"=>$api_url,
+ );
+ // echo json_encode($message,true);
+ // 加个body字段传中文试试
+
+ // 组装交易报文
+ $reqsn_prefix = date('Ymd');
+ // var_dump("uniq_id(reqsn)");
+ // echo "\r\n";
+ // var_dump(uniqid($reqsn_prefix));
+ $trade_data = array(
+ 'orgid' => $config['org_num'],
+ 'cusid' => $config['cusid'],
+ 'branchno' => $config['branchno'],
+ // 'termcode' => $config['termcode'],
+ 'version' => $config['version'],
+ 'trxamt' => $trxamt, // total_fee
+ 'reqsn' => $reqsn, // 交易订单号
+ 'producp' => 'JX0002',
+ 'transtype' => 'JSP501', // 微信支付
+ 'paytype' => 'W02', // 微信js支付
+ 'randomstr' => md5( uniqid() ),
+ // 'body' => 'pages',
+ 'acct' => $openid,
+ // 'notify_url' => '', // 交易结果通知地址
+ // 'sub_appid' => 'wx79343915f99167e6',
+ // 'front_url' => '', // 支付完成跳转
+ );
+ // 生成签名
+ $sign = $Base->Crypt->makeSign($trade_data);
+ if($sign === false)
+ {
+ // echo $Base->Crypt->err_msg;
+ $errorMessage = array(
+ "data"=>"makeSign error..."
+ );
+ return json_encode($errorMessage,true);
+ die();
+ }
+
+ // echo "\r\n";
+ // echo "[sign]: {$sign}";
+
+ // 加密交易报文
+ $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
+ if($crypted_trade_data === false)
+ {
+ // echo $Base->Crypt->err_msg;
+ $errorMessage = array(
+ "data"=>"encryptTradeData error..."
+ );
+ return json_encode($errorMessage,true);
+ die();
+ }
+
+ // echo "\r\n";
+ // echo "[crypted message]: {$crypted_trade_data}";
+
+ // 发送报文
+ // echo "\r\n";
+ // var_dump($api_url);
+ $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
+ echo $response;
+ if($response === false)
+ {
+ // echo $Base->Request->err_msg;
+ $errorMessage = array(
+ "data"=>"send error..."
+ );
+ return json_encode($errorMessage,true);
+ die();
+ }
+ // echo "\r\n";
+ // echo "[response message]: {$response}";
+
+ // 解析响应报文
+ $response = json_decode($response, true);
+ $response_data_crypted = $response['data'];
+ $response_sign = $response['sign'];
+ // echo "\r\n";
+ // echo "[response sign]: {$response_sign}";
+ // echo "\r\n";
+ // echo "[response data (ciphertext)]: {$response_data_crypted}";
+
+
+ // 解密响应密文
+ $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
+ if($response_data === false)
+ {
+ // echo $Base->Crypt->err_msg;
+ $errorMessage = array(
+ "data"=>"decryptTradeData error..."
+ );
+ return json_encode($errorMessage,true);
+ die();
+ }
+ // echo "\r\n";
+ // echo "[response data(clear text)]: {$response_data}";
+ // die();
+ var_dump(json_decode($response_data));
+ $_SESSION['response_data_json'] = $response_data;
+ return $response_data;
+
+ // var_dump($_SESSION['user_id']);
+ // 跳回之前的地址
+ // header('Location: ' . $redirect_url);
+ // exit;
+ }
+
+ // return pay();
+?>
+
diff --git a/mobile/source/helpers/dalianpay/demo/query.php b/mobile/source/helpers/dalianpay/demo/query.php
new file mode 100644
index 0000000..3611b3f
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/demo/query.php
@@ -0,0 +1,98 @@
+getConfig();
+ // var_dump('', $config);
+
+ // 接口URL(测试)
+ $api_url = $config['query_url'];
+
+ // 加个body字段传中文试试
+
+ // 组装交易报文
+ $reqsn_prefix = date('Ymd');
+ $trade_data = array(
+ 'orgid' => $config['org_num'],
+ 'cusid' => $config['cusid'],
+ 'version' => $config['version'],
+ // 'reqsn' => '2023072464be320f45f2a',
+ 'trxid' => '100000018608526', // 渠道交易流水号 如果返回的有 优先使用
+ 'randomstr' => md5( uniqid() ),
+ );
+
+ // 生成签名
+ $sign = $Base->Crypt->makeSign($trade_data);
+ if($sign === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[sign]: {$sign}";
+ // die();
+
+ // 加密交易报文
+ $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
+ if($crypted_trade_data === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[crypted message]: {$crypted_trade_data}";
+ // die();
+
+ // 发送报文
+ echo "\r\n";
+ var_dump($api_url);
+ $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
+ if($response === false)
+ {
+ echo $Base->Request->err_msg;
+ die();
+ }
+
+ echo "\r\n";
+
+ echo "[response message]: {$response}";
+
+ // 解析响应报文
+ $response = json_decode($response, true);
+ $response_data_crypted = $response['data'];
+ $response_sign = $response['sign'];
+ echo "\r\n";
+ echo "[response sign]: {$response_sign}";
+ echo "\r\n";
+ echo "[response data (ciphertext)]: {$response_data_crypted}";
+
+ // 解密响应密文
+ $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
+ if($response_data === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[response data(clear text)]: {$response_data}";
+ // die();
+
+?>
+
+
+
+
+
+
+ 统一查询Demo
+
+
+
+
diff --git a/mobile/source/helpers/dalianpay/demo/refund.php b/mobile/source/helpers/dalianpay/demo/refund.php
new file mode 100644
index 0000000..a3832bd
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/demo/refund.php
@@ -0,0 +1,105 @@
+getConfig();
+ // var_dump('', $config);
+
+ // 接口URL(测试)
+ $api_url = $config['refund_url'];
+
+// 加个body字段传中文试试
+
+ // 组装交易报文
+ $reqsn_prefix = date('Ymd');
+ $trade_data = array(
+ // 'orgid' => $config['org_num'],
+ 'cusid' => $config['cusid'],
+ 'branchno' => $config['branchno'],
+ // 'termcode' => $config['termcode'],
+ 'version' => $config['version'],
+ 'trxamt' => '1',
+ 'reqsn' => uniqid($reqsn_prefix),
+ 'producp' => 'JX0002',
+ 'transtype' => 'JSP511',
+ 'randomstr' => md5( uniqid() ),
+ // 'oldreqsn' => '100000018608489',
+ 'oldtrxid' => '100000018608532',
+ );
+
+ // 生成签名
+ $sign = $Base->Crypt->makeSign($trade_data);
+ if($sign === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[sign]: {$sign}";
+ // die();
+
+ // 加密交易报文
+ $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
+ if($crypted_trade_data === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[crypted message]: {$crypted_trade_data}";
+ // die();
+
+ // 发送报文
+ echo "\r\n";
+ var_dump($api_url);
+ $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
+ if($response === false)
+ {
+ echo $Base->Request->err_msg;
+ die();
+ }
+
+ echo "\r\n";
+
+ echo "[response message]: {$response}";
+
+ // 解析响应报文
+ $response = json_decode($response, true);
+ $response_data_crypted = $response['data'];
+ $response_sign = $response['sign'];
+ echo "\r\n";
+ echo "[response sign]: {$response_sign}";
+ echo "\r\n";
+ echo "[response data (ciphertext)]: {$response_data_crypted}";
+
+ // 解密响应密文
+ $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
+ if($response_data === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[response data(clear text)]: {$response_data}";
+ // die();
+
+?>
+
+
+
+
+
+
+
+ 统一扫码Demo
+
+
+
+
diff --git a/mobile/source/helpers/dalianpay/demo/scan.php b/mobile/source/helpers/dalianpay/demo/scan.php
new file mode 100644
index 0000000..ddde468
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/demo/scan.php
@@ -0,0 +1,158 @@
+getConfig();
+ // var_dump('', $config);
+
+ // 接口URL(测试)
+ $api_url = $config['scan_url'];
+
+// 加个body字段传中文试试
+
+ // 组装交易报文
+ $reqsn_prefix = date('Ymd');
+ $terminfo = array(
+ "termsn"=>"dfjskljioe13238023",
+ "longitude"=>"+37.12",
+ "latitude"=>"-37.12",
+ "termno"=>"00000001",
+ "devicetype"=>"04",
+ );
+ $trade_data = array(
+ 'orgid' => $config['org_num'],
+ 'cusid' => $config['cusid'],
+ 'branchno' => $config['branchno'],
+ 'termcode' => $config['termcode'],
+ 'version' => $config['version'],
+ 'trxamt' => '1',
+ 'reqsn' => uniqid($reqsn_prefix),
+ 'producp' => 'JX0002',
+ 'transtype' => 'JSP511',
+ 'paytype' => 'W01',
+ 'randomstr' => md5( uniqid() ),
+ 'terminfo' => json_encode($terminfo),
+ 'authcode' => '',
+ );
+
+ // $trade_data = array(
+ // "cusid" => "10147",
+ // "branchno" => "44",
+ // "termcode" => "000000",
+ // "version" => "11",
+ // "trxamt" => "1154634",
+ // "reqsn" => "112094120001088317",
+ // "producp" => "JX0002",
+ // "transtype" => "JSP501",
+ // "paytype" => "W01",
+ // "randomstr" => md5( uniqid() ),
+ // "body" => "",
+ // "remark" => "",
+ // "validtime" => "",
+ // "acct" => "",
+ // "notify_url" => "",
+ // "limit_pay" => "",
+ // "sub_appid" => "",
+ // "goods_tag" => "",
+ // "benefitdetail" => "",
+ // "chnlstoreid" => "",
+ // "extendparams" => "",
+ // "cusip" => "",
+ // "front_url" => "",
+ // "subbranch" => "",
+ // "idno" => "",
+ // "truename" => "",
+ // "asinfo" => "",
+ // "fqnum" => "",
+ // "unpid" => "",
+ // "terminfo" => "",
+ // // 其他参数...
+ // );
+
+ // $trade_data = array(
+ // "appid"=>"00000051",
+ // "cusid"=>"990581007426001",
+ // "randomstr"=>"82712208",
+ // "signtype"=>"RSA",
+ // "trxid"=>"112094120001088317",
+ // "version"=>"11",
+ // );
+
+ // 生成签名
+ $sign = $Base->Crypt->makeSign($trade_data);
+ if($sign === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[sign]: {$sign}";
+ // die();
+
+ // 加密交易报文
+ $crypted_trade_data = $Base->Crypt->encryptTradeData($trade_data);
+ if($crypted_trade_data === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[crypted message]: {$crypted_trade_data}";
+ // die();
+
+ // 发送报文
+ echo "\r\n";
+ var_dump($api_url);
+ $response = $Base->Request->send($api_url, $crypted_trade_data, $sign);
+ if($response === false)
+ {
+ echo $Base->Request->err_msg;
+ die();
+ }
+
+ echo "\r\n";
+
+ echo "[response message]: {$response}";
+
+ // 解析响应报文
+ $response = json_decode($response, true);
+ $response_data_crypted = $response['data'];
+ $response_sign = $response['sign'];
+ echo "\r\n";
+ echo "[response sign]: {$response_sign}";
+ echo "\r\n";
+ echo "[response data (ciphertext)]: {$response_data_crypted}";
+
+ // 解密响应密文
+ $response_data = $Base->Crypt->decryptTradeData($response_data_crypted);
+ if($response_data === false)
+ {
+ echo $Base->Crypt->err_msg;
+ die();
+ }
+ echo "\r\n";
+ echo "[response data(clear text)]: {$response_data}";
+ // die();
+
+?>
+
+
+
+
+
+
+
+
+
+ 统一扫码Demo
+
+
+
+
diff --git a/mobile/source/helpers/dalianpay/library/Base.php b/mobile/source/helpers/dalianpay/library/Base.php
new file mode 100644
index 0000000..6f11ca4
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/library/Base.php
@@ -0,0 +1,41 @@
+config = require_once('../config/config.php');
+ // 实例化加解密类
+ require_once('Crypt.php');
+ $this->Crypt = new Crypt($this->config);
+ // 实例化请求类
+ require_once('Request.php');
+ $this->Request = new Request($this->config);
+ }
+
+
+ /**
+ * 获取配置信息
+ * @return array
+ */
+ public function getConfig()
+ {
+ return $this->config;
+ }
+
+
+}
+?>
diff --git a/mobile/source/helpers/dalianpay/library/Crypt.php b/mobile/source/helpers/dalianpay/library/Crypt.php
new file mode 100644
index 0000000..79c9848
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/library/Crypt.php
@@ -0,0 +1,220 @@
+config = $config;
+ }
+
+
+ /**
+ * 数据校验
+ * @param array $data 待校验数据
+ * @return bool
+ */
+ private function checkData(array $data)
+ {
+ // 非空校验
+ if( count($data) == 0 )
+ {
+ $this->err_msg = '待签名数据为空';
+ return false;
+ }
+ // 一维数组校验
+ if( count($data) != count($data, 1) )
+ {
+ $this->err_msg = '待签名数据不能是多维数组';
+ return false;
+ }
+
+ return true;
+ }
+
+
+ /**
+ * 生成签名
+ * @param array $data 待签名数据
+ * @return bool|string
+ */
+ public function makeSign(array $data)
+ {
+ // 数据校验
+ $check_data = $this->checkData($data);
+ if($check_data === false)
+ {
+ return false;
+ }
+
+ // 升序排列
+ ksort($data);
+ // 转字符串
+ $pre_sign_str = http_build_query($data);
+ // echo "[pre_sign_str(jiao yi message)]: {$pre_sign_str}";
+ // die();
+
+ // 读取私钥
+ $private_key = file_get_contents($this->config['private_key']);
+ $private_key = openssl_pkey_get_private($private_key);
+
+ // 私钥签名
+ $res = openssl_sign($pre_sign_str, $sign, $private_key);
+ if($res === false)
+ {
+ $this->err_msg = openssl_error_string();
+ return false;
+ }
+ // 签名转Base64
+ $sign = base64_encode($sign);
+
+ return $sign;
+ }
+
+
+ /**
+ * 校验签名
+ * @param array $data 待校验数据
+ * @param string $sign 签名
+ * @return bool
+ */
+ public function checkSign(array $data, string $sign)
+ {
+ // 数据校验
+ $check_data = $this->checkData($data);
+ if($check_data === false)
+ {
+ return false;
+ }
+
+ // 签名转二进制
+ $sign = base64_decode($sign);
+
+ // 升序排列
+ ksort($data);
+ // 转字符串
+ $pre_sign_str = http_build_query($data);
+ $pre_sign_str = urldecode($pre_sign_str);
+ // echo "[pre sign str]: {$pre_sign_str}";
+ // die();
+
+ // 读取公钥
+ $public_key = file_get_contents($this->config['public_key']);
+ $public_key = openssl_pkey_get_public($public_key);
+
+ // 公钥验签
+ $res = openssl_verify($pre_sign_str, $sign, $public_key);
+ if($res === false)
+ {
+ $this->err_msg = openssl_error_string();
+ return false;
+ }
+
+ return $res;
+ }
+
+
+ /**
+ * 加密交易报文
+ * @param array $data 待签名数据
+ * @return bool|string
+ */
+ public function encryptTradeData(array $data)
+ {
+ // 数据校验
+ $check_data = $this->checkData($data);
+ if($check_data === false)
+ {
+ return false;
+ }
+
+ // 读取公钥
+ $public_key = file_get_contents($this->config['public_key']);
+ $public_key = openssl_pkey_get_public($public_key);
+ // 公钥长度(bit)
+ $public_key_info = openssl_pkey_get_details($public_key);
+ $public_key_bit = $public_key_info['bits'];
+ // 数据长度(数据长度=密钥字节数-11,11为OPENSSL_PKCS1_PADDING的填充长度)
+ $data_length = $public_key_bit / 8 - 11;
+
+ // 待加密数据转json
+ $pre_encrypt_data = json_encode($data, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
+ // 按密钥长度拆分数据
+ $pre_encrypt_data_arr = str_split($pre_encrypt_data, $data_length);
+ // 分段公钥加密
+ $crypted_data = '';
+ foreach($pre_encrypt_data_arr as $key=>$val)
+ {
+ $res = openssl_public_encrypt($val, $crypted_data_tmp, $public_key, OPENSSL_PKCS1_PADDING);
+ if($res === false)
+ {
+ $this->err_msg = openssl_error_string();
+ return false;
+ }
+ $crypted_data .= $crypted_data_tmp;
+ }
+ // 加密结果转Base64
+ $crypted_data = base64_encode($crypted_data);
+
+ return $crypted_data;
+ }
+
+
+ /**
+ * 解密交易报文
+ * @param string $data 加密的交易报文
+ * @return bool|array
+ */
+ public function decryptTradeData($data)
+ {
+ // 加密数据转二进制
+ $pre_decrypt_data = base64_decode($data);
+
+ // 读取私钥
+ $private_key = file_get_contents($this->config['private_key']);
+ $private_key = openssl_pkey_get_private($private_key);
+ // 私钥长度(bit)
+ $private_key_info = openssl_pkey_get_details($private_key);
+ $private_key_bit = $private_key_info['bits'];
+ // 数据长度(数据长度=密钥字节数,解密时无需考虑OPENSSL_PKCS1_PADDING的填充占位)
+ $data_length = $private_key_bit / 8;
+
+ // 按密钥长度拆分数据
+ $pre_decrypt_data_arr = str_split($pre_decrypt_data, $data_length);
+ // 分段私钥解密
+ $decrypted_data = '';
+ foreach($pre_decrypt_data_arr as $key=>$val)
+ {
+ $res = openssl_private_decrypt($val, $decrypted_data_tmp, $private_key, OPENSSL_PKCS1_PADDING);
+ if($res === false)
+ {
+ $this->err_msg = openssl_error_string();
+ return false;
+ }
+ $decrypted_data .= $decrypted_data_tmp;
+ }
+ // 解密结果编码转换(JAVA处理后的中文一般为GBK编码)
+ // echo "\r\n";
+ // var_dump($decrypted_data);
+ $charset = mb_detect_encoding($decrypted_data); // 这个东西有点问题 解析出来是false 先不用了
+ // echo "\r\n";
+ // var_dump($charset);
+ // echo "\r\n";
+
+ $decrypted_data = mb_convert_encoding($decrypted_data, 'UTF-8', 'GBK');
+ // echo "\r\n";
+ // var_dump($decrypted_data);
+ return $decrypted_data;
+ }
+
+
+}
+
+?>
diff --git a/mobile/source/helpers/dalianpay/library/Request.php b/mobile/source/helpers/dalianpay/library/Request.php
new file mode 100644
index 0000000..462be96
--- /dev/null
+++ b/mobile/source/helpers/dalianpay/library/Request.php
@@ -0,0 +1,156 @@
+config = $config;
+ }
+
+
+ /**
+ * 发送curl请求
+ * @param string $url 要请求的URL
+ * @param string $method 请求方法[get|post]
+ * @param string|array $post_data 请求数据,模拟表单提交时为Array,提交JSON数据时为String
+ * @param string $data_type 数据类型[form|file|json|xml]
+ */
+ private function curlRequest($url, $method, $post_data='', $data_type='form')
+ {
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ // 请求端口,SSL为443
+ curl_setopt($ch, CURLOPT_PORT, 443);
+ // 为项目内调用设置专用的UA
+ curl_setopt($ch, CURLOPT_USERAGENT, 'Intract cURL');
+ // 设置为不自动输出
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ // 不输出头部
+ curl_setopt($ch, CURLOPT_HEADER, false);
+ // 跳过证书检查
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+
+ // 不从证书中检查SSL加密算法是否存在
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+ // // 设定SSL版本,1-3切换
+ // curl_setopt($ch, CURLOPT_SSLVERSION, 1);
+
+ // 根据$data_type,选择不同的HTTP Header
+ $data_type = strtolower($data_type);
+ // echo curl_errno($ch);
+ switch($data_type)
+ {
+ case 'form':
+ $header = 'application/x-www-form-urlencoded';
+ break;
+ case 'file':
+ $header = 'multipart/form-data';
+ break;
+ case 'json':
+ $header = 'application/json';
+ break;
+ case 'xml':
+ $header = 'text/xml';
+ break;
+ default:
+ // 默认为form
+ $header = 'application/x-www-form-urlencoded';
+ }
+ $header = array(
+ 'Content-type: ' . $header,
+ 'Content-length: ' . strlen($post_data)
+ );
+ // 根据不同的提交方式,设置头部和数据
+ $method = strtolower($method);
+ switch($method)
+ {
+ case 'get':
+ break;
+ case 'post':
+ // 设置头部
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+ // 设置POST提交
+ curl_setopt($ch, CURLOPT_POST, true);
+ // 设置POST数据
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
+ break;
+ default:
+ ;
+ }
+ // 执行请求
+ $response = curl_exec($ch);
+ // 返回数据
+ $res = array(
+ 'status' => 0,
+ 'err_msg' => '',
+ 'http_code' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
+ 'data' => null
+ );
+ if($response === false)
+ {
+ $res['err_msg'] = curl_error($ch);
+ }
+ else
+ {
+ $res['status'] = 1;
+ $res['data'] = $response;
+ }
+ // 关闭连接
+ curl_close($ch);
+
+ return $res;
+ }
+
+
+ /**
+ * 发送报文
+ * @param string $url 接口URL
+ * @param string $data 加密后的数据
+ * @param string $sign 交易报文签名
+ * @return bool|string 成功时返回JSON字符串
+ */
+ public function send($url, $data, $sign)
+ {
+ // var_dump(gettype($url));
+ // echo "\r\n";
+ // if (!($url instanceof string))
+ // {
+ // var_dump("url is not a string");
+ // return false;
+ // }
+ // 组装通用参数
+ $post_data = array(
+ 'data' => $data,
+ // 'data' => urlencode($data),
+ 'orgid' => $this->config['org_num'],
+ 'signtype' => $this->config['signtype'],
+ 'sign' => $sign,
+ // 'sign' => urlencode($sign),
+ );
+ $post_data = json_encode($post_data);
+ // echo "\r\n";
+ // echo "[send message]: {$post_data}";
+
+ // 发送请求
+ $send_res = $this->curlRequest($url, 'post', $post_data, 'json');
+ if($send_res['status'] !== 1)
+ {
+ $this->err_msg = $send_res['err_msg'] . '(HTTP Code: ' . $send_res['http_code'] . ')';
+ return false;
+ }
+
+ return $send_res['data'];
+ }
+
+
+}
+
+?>