|
|
|
|
<?php
|
|
|
|
|
namespace Org\SqpaySDK;
|
|
|
|
|
|
|
|
|
|
use Think\Exception;
|
|
|
|
|
use Qiniu\json_decode;
|
|
|
|
|
use Think\Log;
|
|
|
|
|
|
|
|
|
|
class Sqpay
|
|
|
|
|
{
|
|
|
|
|
// H5 支付 双乾 PaymentType "UNION","ZFBZF"
|
|
|
|
|
public function sq_pay($data){
|
|
|
|
|
/* $returnurl = empty($returnurl)?"http://".$_SERVER['HTTP_HOST']:$returnurl;//成功跳转
|
|
|
|
|
|
|
|
|
|
$notifyurl = "http://".$_SERVER['HTTP_HOST']."/callback.php/Notify/sq_callback";//通知
|
|
|
|
|
$ordertime =date("Ymdhms",time());
|
|
|
|
|
// 168885 12345678 */
|
|
|
|
|
$sign = md5("Amount={$data['amount']}&BillNo={$data['order_no']}&MerNo={$data['merno']}&PayType=SMZF&".strtoupper(md5($data['secret'])));
|
|
|
|
|
$sign = strtoupper($sign);
|
|
|
|
|
$params=[
|
|
|
|
|
'MerNo' => $data['merno'],
|
|
|
|
|
'Amount'=>$data['amount'],
|
|
|
|
|
'BillNo'=>$data['order_no'],
|
|
|
|
|
'TranCode'=>"SMZF012",
|
|
|
|
|
'PayType'=> "SMZF",
|
|
|
|
|
'PaymentType'=> $data['paymenttype'],//"UNION","ZFBZF",
|
|
|
|
|
'MerRemark' => $data['MerRemark'],
|
|
|
|
|
'subject' => $data['subject'],
|
|
|
|
|
'NotifyURL' => $data['notifyurl'],
|
|
|
|
|
'ReturnURL' => $data['returnurl'],
|
|
|
|
|
'mchAppId' => $data['mchAppId'],
|
|
|
|
|
'mchAppName' => $data['mchAppName'],
|
|
|
|
|
'deviceInfo' => $data['deviceInfo'],
|
|
|
|
|
'clientIp' => $data['clientIp'],
|
|
|
|
|
'MD5info' => $sign,
|
|
|
|
|
];
|
|
|
|
|
var_dump($params);
|
|
|
|
|
$ret = curl_post("https://scan.95epay.cn/ScanCodePayment.action", $params);
|
|
|
|
|
|
|
|
|
|
return $ret;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 小程序支付 双乾
|
|
|
|
|
public function sq_wxsmallpay($data){
|
|
|
|
|
Log::write("wxpay:".serialize($_REQUEST), Log::DEBUG);
|
|
|
|
|
|
|
|
|
|
$returnurl = empty($data['returnurl'])?"http://".$_SERVER['HTTP_HOST']:$data['returnurl'];//成功跳转
|
|
|
|
|
|
|
|
|
|
$notifyurl = "http://".$_SERVER['HTTP_HOST']."/callback.php/Notify/sq_callback"; //通知
|
|
|
|
|
$ordertime =date("Ymdhms",time());
|
|
|
|
|
// 168885 12345678
|
|
|
|
|
$sign = md5("Amount={$data['amount']}&BillNo={$data['order_no']}&MerNo={$data['merno']}&PayType=SMZF&".strtoupper(md5($data['secret'])));
|
|
|
|
|
$sign = strtoupper($sign);
|
|
|
|
|
$params=[
|
|
|
|
|
'MerNo' => $data['merno'],
|
|
|
|
|
'isSubMerPay' => 0,
|
|
|
|
|
// 'subMerNo' => $data['merno'],
|
|
|
|
|
'appId' => $data['appId'],//'wx0ba5be5c8bb9f1b7',
|
|
|
|
|
'Amount'=> $data['amount'],
|
|
|
|
|
'BillNo'=> $data['order_no'],
|
|
|
|
|
'TranCode'=>"SMZF010",
|
|
|
|
|
'PayType'=> "SMZF",
|
|
|
|
|
'PaymentType'=> "WXZF",
|
|
|
|
|
'MerRemark' => $data['MerRemark'],
|
|
|
|
|
'subject' => $data['subject'],
|
|
|
|
|
'userId' => $data['userId']?$data['userId']:'oqFwC5TRQX1wpM8KfBQHy5FI6yJM',//'oqFwC5TRQX1wpM8KfBQHy5FI6yJM',
|
|
|
|
|
'NotifyURL' => $notifyurl,
|
|
|
|
|
'MD5info' => $sign,
|
|
|
|
|
];
|
|
|
|
|
$ret = curl_post("https://scan.95epay.cn/ScanCodePayment.action", $params);
|
|
|
|
|
|
|
|
|
|
return json_decode($ret, true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 'cardType' => string 'CC' (length=2) DC为储蓄卡,CC为信用卡
|
|
|
|
|
'bank' => string 'CMB' (length=3)
|
|
|
|
|
'key' => string '1567737106107-2456-11.34.191.208-899687252' (length=42)
|
|
|
|
|
'messages' =>
|
|
|
|
|
array (size=0)
|
|
|
|
|
empty
|
|
|
|
|
'validated' => boolean true
|
|
|
|
|
'stat' => string 'ok' (length=2)
|
|
|
|
|
*/
|
|
|
|
|
private function getbankinfo($cardNo) {
|
|
|
|
|
$url = "https://ccdcapi.alipay.com/validateAndCacheCardInfo.json";
|
|
|
|
|
$r = curl_post($url, array('cardNo' => $cardNo, 'cardBinCheck' => 'true', '_input_charset' => 'utf-8'));
|
|
|
|
|
$r = (json_decode($r, true));
|
|
|
|
|
|
|
|
|
|
return $r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 查询用户银行卡信息的签约状态
|
|
|
|
|
*/
|
|
|
|
|
public function contract_status($data) {
|
|
|
|
|
$url = "https://fastpay.95epay.cn/pay/querySignResult.action";
|
|
|
|
|
// $url = "http://218.4.234.150:9600/pay/querySignResult.action";
|
|
|
|
|
|
|
|
|
|
$sign = md5("cardNo={$data['cardNo']}&custName={$data['custName']}&idNo={$data['idNo']}&merNo={$data['merNo']}&payType=XYPAY&phoneNo={$data['phoneNo']}&".strtoupper(md5($data['secret'])));
|
|
|
|
|
$sign = strtoupper($sign);
|
|
|
|
|
$param = array(
|
|
|
|
|
'merNo' => $data['merNo'],
|
|
|
|
|
'custName' => $data['custName'],
|
|
|
|
|
'phoneNo' => $data['phoneNo'],
|
|
|
|
|
'cardNo' => $data['cardNo'],
|
|
|
|
|
'idNo' => $data['idNo'],
|
|
|
|
|
'payType' => 'XYPAY',
|
|
|
|
|
'payAmount' => $data['payAmount'],
|
|
|
|
|
'MD5Info' => $sign,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$ret = curl_post($url, $param);
|
|
|
|
|
return json_decode($ret, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 协议支付发送短信
|
|
|
|
|
*/
|
|
|
|
|
public function protocol_pay_send_sms($data) {
|
|
|
|
|
$url = "https://fastpay.95epay.cn/pay/realnameAuth.action";
|
|
|
|
|
/* $url = "http://218.4.234.150:9600 /realnameAuth.action";
|
|
|
|
|
$data['merNo'] = 168885;
|
|
|
|
|
$data['secret'] = 12345678; */
|
|
|
|
|
|
|
|
|
|
$data['transDate'] = date('Ymd');
|
|
|
|
|
$data['transTime'] = date('His');
|
|
|
|
|
|
|
|
|
|
$bankInfo = $this->getbankinfo($data['cardNo']);
|
|
|
|
|
$data['cardType'] = $bankInfo['cardType'] == 'CC' ? 2: 1;
|
|
|
|
|
// pp($bankInfo);
|
|
|
|
|
$sign = md5("merNo={$data['merNo']}&custName={$data['custName']}&phone={$data['phoneNo']}&cardNo={$data['cardNo']}&idNo={$data['idNo']}&idType=0&payAmount={$data['payAmount']}&merOrderNo={$data['merOrderNo']}&cardType={$data['cardType']}&year=&month=&CVV2=&transDate={$data['transDate']}&transTime={$data['transTime']}&".strtoupper(md5($data['secret'])));
|
|
|
|
|
$sign = strtoupper($sign);
|
|
|
|
|
$param = array(
|
|
|
|
|
'merNo' => $data['merNo'],
|
|
|
|
|
'custName' => $data['custName'],
|
|
|
|
|
'cardNo' => $data['cardNo'],
|
|
|
|
|
'phone' => $data['phoneNo'],
|
|
|
|
|
'idNo' => $data['idNo'],
|
|
|
|
|
'idType' => '0',
|
|
|
|
|
'payAmount' => $data['payAmount'],
|
|
|
|
|
'merOrderNo' => $data['merOrderNo'],
|
|
|
|
|
'bankCode' => $bankInfo['bank'],
|
|
|
|
|
'payType' => 'XYPAY',
|
|
|
|
|
'cardType' => $data['cardType'],
|
|
|
|
|
'NotifyURL' => $data['NotifyURL'],
|
|
|
|
|
'transDate' => $data['transDate'],
|
|
|
|
|
'transTime' => $data['transTime'],
|
|
|
|
|
'purpose' => $data['purpose'],
|
|
|
|
|
'MD5Info' => $sign,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$ret = curl_post($url, $param);
|
|
|
|
|
|
|
|
|
|
return json_decode($ret, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 交易
|
|
|
|
|
*/
|
|
|
|
|
// 快捷支付 双乾
|
|
|
|
|
public function shortcut_pay($data){
|
|
|
|
|
$url = "https://fastpay.95epay.cn/pay/hfDaikouTrade.action";
|
|
|
|
|
/* $url = "http://218.4.234.150:9600 /realnameAuth.action";
|
|
|
|
|
$data['merNo'] = 168885;
|
|
|
|
|
$data['secret'] = 12345678; */
|
|
|
|
|
|
|
|
|
|
$notifyurl = "http://".'api.wmtxkj.com'."/callback.php/Notify/sq_callback";//通知
|
|
|
|
|
$data['NotifyURL'] = $notifyurl;
|
|
|
|
|
$bankInfo = $this->getbankinfo($data['cardNo']);
|
|
|
|
|
$data['cardType'] = $bankInfo['cardType'] == 'CC' ? 2: 1;
|
|
|
|
|
// pp($bankInfo);
|
|
|
|
|
$sign = md5("merNo={$data['merNo']}&merOrderNo={$data['merOrderNo']}&custName={$data['custName']}&phone={$data['phoneNo']}&cardNo={$data['cardNo']}&idType=0&idNo={$data['idNo']}&payAmount={$data['payAmount']}&bankCode={$bankInfo['bank']}&NotifyURL={$data['NotifyURL']}&".strtoupper(md5($data['secret'])));
|
|
|
|
|
$sign = strtoupper($sign);
|
|
|
|
|
$param = array(
|
|
|
|
|
'merNo' => $data['merNo'],
|
|
|
|
|
'merOrderNo' => $data['merOrderNo'],
|
|
|
|
|
'cardNo' => $data['cardNo'],
|
|
|
|
|
'custName' => $data['custName'],
|
|
|
|
|
'idType' => '0',
|
|
|
|
|
'idNo' => $data['idNo'],
|
|
|
|
|
'phone' => $data['phoneNo'],
|
|
|
|
|
'purpose' => $data['purpose'],
|
|
|
|
|
'payAmount' => $data['payAmount'],
|
|
|
|
|
'bankCode' => $bankInfo['bank'],
|
|
|
|
|
'payType' => 'XYPAY',
|
|
|
|
|
'NotifyURL' => $data['NotifyURL'],
|
|
|
|
|
'txnTime' => $data['txnTime'],
|
|
|
|
|
'smsCode' => $data['smsCode'],
|
|
|
|
|
'MD5Info' => $sign,
|
|
|
|
|
);
|
|
|
|
|
$ret = curl_post($url, $param);
|
|
|
|
|
return json_decode($ret, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 认证/签约
|
|
|
|
|
*/
|
|
|
|
|
public function sign_contract($data) {
|
|
|
|
|
$url = "https://fastpay.95epay.cn/pay/identifyAuthAndSign.action";
|
|
|
|
|
/* $url = "http://218.4.234.150:9600/pay/identifyAuthAndSign.action";
|
|
|
|
|
$data['merNo'] = 168885;
|
|
|
|
|
$data['secret'] = 12345678; */
|
|
|
|
|
|
|
|
|
|
$data['transDate'] = date('Ymd');
|
|
|
|
|
$data['transTime'] = date('His');
|
|
|
|
|
|
|
|
|
|
$bankInfo = $this->getbankinfo($data['cardNo']);
|
|
|
|
|
$data['cardType'] = $bankInfo['cardType'] == 'CC' ? 2: 1;
|
|
|
|
|
|
|
|
|
|
$sign = md5("authMsg=&bankCode={$bankInfo['bank']}&cardNo={$data['cardNo']}&cardType={$data['cardType']}&custName={$data['custName']}&custType={$data['custType']}&idNo={$data['idNo']}&idType=0&merNo={$data['merNo']}&payType=XYPAY&phoneNo={$data['phoneNo']}&reqMsgId={$data['reqMsgId']}&".strtoupper(md5($data['secret'])));
|
|
|
|
|
$sign = strtoupper($sign);
|
|
|
|
|
$param = array(
|
|
|
|
|
'merNo' => $data['merNo'],
|
|
|
|
|
'custName' => $data['custName'],
|
|
|
|
|
'phoneNo' => $data['phoneNo'],
|
|
|
|
|
'cardNo' => $data['cardNo'],
|
|
|
|
|
'bankCode' => $bankInfo['bank'],
|
|
|
|
|
'idNo' => $data['idNo'],
|
|
|
|
|
'idType' => 0,
|
|
|
|
|
'reqMsgId' => $data['reqMsgId'],
|
|
|
|
|
'cardType' => $data['cardType'],
|
|
|
|
|
'authMsg' => $data['authMsg'],
|
|
|
|
|
'custType' => $data['custType'], // 01:认证,02:签约
|
|
|
|
|
'payType' => 'XYPAY',
|
|
|
|
|
'MD5Info' => $sign,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$ret = curl_post($url, $param);
|
|
|
|
|
pp($ret);
|
|
|
|
|
return json_decode($ret, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|