微信支付 小程序 (v3)- PHP 完整后端代码_微信支付 api v3的php源码打包下载

本人从事网路安全工作12年,曾在2个大厂工作过,安全服务、售后服务、售前、攻防比赛、安全讲师、销售经理等职位都做过,对这个行业了解比较全面。

最近遍览了各种网络安全类的文章,内容参差不齐,其中不伐有大佬倾力教学,也有各种不良机构浑水摸鱼,在收到几条私信,发现大家对一套完整的系统的网络安全从学习路线到学习资料,甚至是工具有着不小的需求。

最后,我将这部分内容融会贯通成了一套282G的网络安全资料包,所有类目条理清晰,知识点层层递进,需要的小伙伴可以点击下方小卡片领取哦!下面就开始进入正题,如何从一个萌新一步一步进入网络安全行业。

学习路线图

其中最为瞩目也是最为基础的就是网络安全学习路线图,这里我给大家分享一份打磨了3个月,已经更新到4.0版本的网络安全学习路线图。

相比起繁琐的文字,还是生动的视频教程更加适合零基础的同学们学习,这里也是整理了一份与上述学习路线一一对应的网络安全视频教程。

网络安全工具箱

当然,当你入门之后,仅仅是视频教程已经不能满足你的需求了,你肯定需要学习各种工具的使用以及大量的实战项目,这里也分享一份我自己整理的网络安全入门工具以及使用教程和实战。

项目实战

最后就是项目实战,这里带来的是SRC资料&HW资料,毕竟实战是检验真理的唯一标准嘛~

面试题

归根结底,我们的最终目的都是为了就业,所以这份结合了多位朋友的亲身经验打磨的面试题合集你绝对不能错过!

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化资料的朋友,可以点击这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

//微信支付(小程序)签名
$str = getWechartSign($appid,$timeStamp,$noncestr,'prepay_id='.$ret);
$arr = array('appid'=>$appid,'timestamp'=>$timeStamp,'package'=>'prepay_id='.$ret,'paySign'=>$str);
exit(json_encode($arr));

}
$set_body = ‘支付测试’;//支付显示内容
$price = ‘1’;//支付金额
$out_trade_no = $data_s[‘out_trade_no’];//订单号
$timeStamp = $data_s[‘timeStamp’];//时间戳
$openid = $data_s[‘openid’];
$noncestr = $data_s[‘nonceStr’];

wechartAddOrder( s e t b o d y , set_body, setbody,out_trade_no, p r i c e , price, price,openid, t i m e S t a m p , timeStamp, timeStamp,noncestr);

//微信支付签名
function getSign( d a t a = a r r a y ( ) , data=array(), data=array(),url, r a n d s t r , randstr, randstr,time){
KaTeX parse error: Undefined control sequence: \n at position 15: str = "POST"."\̲n̲".url.“\n”.KaTeX parse error: Undefined control sequence: \n at position 7: time."\̲n̲".randstr.“\n”.$data.“\n”;
$key = file_get_contents(‘apiclient_key.pem’);//在商户平台下载的秘钥
s t r = g e t S h a 256 W i t h R S A ( str = getSha256WithRSA( str=getSha256WithRSA(str,$key);
return $str;
}

//调起支付的签名
function getWechartSign( a p p i d , appid, appid,timeStamp, n o n c e s t r , noncestr, noncestr,prepay_id){
$str = KaTeX parse error: Undefined control sequence: \n at position 8: appid."\̲n̲".timeStamp.“\n”.KaTeX parse error: Undefined control sequence: \n at position 11: noncestr."\̲n̲".prepay_id.“\n”;
$key = file_get_contents(‘apiclient_key.pem’);
s t r = g e t S h a 256 W i t h R S A ( str = getSha256WithRSA( str=getSha256WithRSA(str,$key);
return $str;
}

function getSha256WithRSA($content, $privateKey){
$binary_signature = “”;
a l g o = " S H A 256 " ; o p e n s s l s i g n ( algo = "SHA256"; openssl_sign( algo="SHA256";opensslsign(content, $binary_signature, $privateKey, $algo);
s i g n = b a s e 6 4 e n c o d e ( sign = base64_encode( sign=base64encode(binary_signature);
return $sign;
}

/* PHP CURL HTTPS POST */
function curl_post_https( u r l , url, url,data,$header){ // 模拟提交数据函数
c u r l = c u r l i n i t ( ) ; / / 启动一个 C U R L 会话 c u r l s e t o p t ( curl = curl_init(); // 启动一个CURL会话 curl_setopt( curl=curlinit();//启动一个CURL会话curlsetopt(curl, CURLOPT_URL, u r l ) ; / / 要访问的地址 c u r l s e t o p t ( url); // 要访问的地址 curl_setopt( url);//要访问的地址curlsetopt(curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt( c u r l , C U R L O P T S S L V E R I F Y H O S T , 1 ) ; / / 从证书中检查 S S L 加密算法是否存在 c u r l s e t o p t ( curl, CURLOPT_SSL_VERIFYHOST, 1); // 从证书中检查SSL加密算法是否存在 curl_setopt( curl,CURLOPTSSLVERIFYHOST,1);//从证书中检查SSL加密算法是否存在curlsetopt(curl, CURLOPT_USERAGENT, S E R V E R [ ′ H T T P U S E R A G E N T ′ ] ) ; / / 模拟用户使用的浏览器 c u r l s e t o p t ( _SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器 curl_setopt( SERVER[HTTPUSERAGENT]);//模拟用户使用的浏览器curlsetopt(curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
curl_setopt( c u r l , C U R L O P T A U T O R E F E R E R , 1 ) ; / / 自动设置 R e f e r e r c u r l s e t o p t ( curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer curl_setopt( curl,CURLOPTAUTOREFERER,1);//自动设置Referercurlsetopt(curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, d a t a ) ; / / P o s t 提交的数据包 c u r l s e t o p t ( data); // Post提交的数据包 curl_setopt( data);//Post提交的数据包curlsetopt(curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
curl_setopt( c u r l , C U R L O P T H E A D E R , 0 ) ; / / 显示返回的 H e a d e r 区域内容 c u r l s e t o p t ( curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容 curl_setopt( curl,CURLOPTHEADER,0);//显示返回的Header区域内容curlsetopt(curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回

curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
$tmpInfo = curl_exec($curl); // 执行操作
if (curl_errno($curl)) {
    echo 'Errno'.curl_error($curl);//捕抓异常
}
curl_close($curl); // 关闭CURL会话
return $tmpInfo; // 返回数据,json格式

}


## 查询订单是否支付完成



header(‘Content-type:text/html; Charset=utf-8’);
ini_set(‘date.timezone’,‘Asia/Shanghai’);
$data_s = file_get_contents(‘php://input’);
d a t a s = j s o n d e c o d e ( data_s = json_decode( datas=jsondecode(data_s,true);
if(empty($data_s[‘out_trade_no’])){
exit;
}

$out_trade_no = $data_s[‘out_trade_no’];//订单号
$merchant_id = ‘商户ID’;//商户ID
$mch_private_key = file_get_contents(‘apiclient_key.pem’);//在商户平台下载的秘钥
$xlid = ‘微信支付公钥序列号’;//秘钥序列号 可在这个网址中查询 https://myssl.com/cert_decode.html

u r l = ′ h t t p s : / / a p i . m c h . w e i x i n . q q . c o m / v 3 / p a y / t r a n s a c t i o n s / o u t − t r a d e − n o / ′ . url = 'https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/'. url=https://api.mch.weixin.qq.com/v3/pay/transactions/outtradeno/.out_trade_no.‘?mchid=’.$merchant_id;
u r l p a r t s = p a r s e u r l ( url_parts = parse_url( urlparts=parseurl(url);
$http_method = ‘GET’;
$timestamp = time();
n o n c e = m d 5 ( t i m e ( ) . nonce = md5(time(). nonce=md5(time().out_trade_no);
$body = ‘’;
c a n o n i c a l u r l = ( canonical_url = ( canonicalurl=(url_parts[‘path’] . (!empty( u r l p a r t s [ ′ q u e r y ′ ] ) ? " ? url_parts['query']) ? "? urlparts[query])?"?{url_parts[‘query’]}" : “”));
$message = $http_method.“\n”.
$canonical_url.“\n”.
$timestamp.“\n”.
$nonce.“\n”.
KaTeX parse error: Undefined control sequence: \n at position 7: body."\̲n̲"; openssl_sign…message, $raw_sign, $mch_private_key, ‘sha256WithRSAEncryption’);
s i g n = b a s e 6 4 e n c o d e ( sign = base64_encode( sign=base64encode(raw_sign);

$schema = ‘WECHATPAY2-SHA256-RSA2048’;
t o k e n = s p r i n t f ( ′ m c h i d = " token = sprintf('mchid="%s",nonce_str="%s",timestamp="%d",serial_no="%s",signature="%s"', token=sprintf(mchid="merchant_id, $nonce, $timestamp, $xlid, $sign);
h e a d e r = a r r a y ( ′ C o n t e n t − T y p e : ′ . ′ a p p l i c a t i o n / j s o n ; c h a r s e t = U T F − 8 ′ , ′ A c c e p t : a p p l i c a t i o n / j s o n ′ , ′ U s e r − A g e n t : ∗ / ∗ ′ , ′ A u t h o r i z a t i o n : W E C H A T P A Y 2 − S H A 256 − R S A 204 8 ′ . header = array( 'Content-Type:'.'application/json; charset=UTF-8', 'Accept:application/json', 'User-Agent:*/*', 'Authorization: WECHATPAY2-SHA256-RSA2048 '. header=array(ContentType:.application/json;charset=UTF8,Accept:application/json,UserAgent:/,Authorization:WECHATPAY2SHA256RSA2048.token
);
r e t = c u r l g e t h t t p s ( ret = curl_get_https( ret=curlgethttps(url, d a t a , data, data,header);

r e t u r n o u t t r a d e n o = g e t b e t w e e n ( return_out_trade_no = get_between( returnouttradeno=getbetween(ret,‘“out_trade_no”:"’,‘",“payer”’);
r e t u r n t r a d e s t a t e = g e t b e t w e e n ( return_trade_state = get_between( returntradestate=getbetween(ret,‘trade_state":"’,‘",“trade_state_desc”’);

a r r = a r r a y ( ′ t y p e ′ = > ′ s u c c e s s ′ , ′ t r a d e s t a t e ′ = > arr = array('type'=>'success','trade_state'=> arr=array(type=>success,tradestate=>return_trade_state,‘out_trade_no’=> r e t u r n o u t t r a d e n o ) ; e x i t ( j s o n e n c o d e ( return_out_trade_no); exit(json_encode( returnouttradeno);exit(jsonencode(arr));

给大家的福利

零基础入门

对于从来没有接触过网络安全的同学,我们帮你准备了详细的学习成长路线图。可以说是最科学最系统的学习路线,大家跟着这个大的方向学习准没问题。

同时每个成长路线对应的板块都有配套的视频提供:

在这里插入图片描述

因篇幅有限,仅展示部分资料

网络安全面试题

绿盟护网行动

还有大家最喜欢的黑客技术

网络安全源码合集+工具包

所有资料共282G,朋友们如果有需要全套《网络安全入门+黑客进阶学习资源包》,可以扫描下方二维码领取(如遇扫码问题,可以在评论区留言领取哦)~

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化资料的朋友,可以点击这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 24
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值