forked from mhcyong/TeePay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwxpay_notify_url.php
41 lines (37 loc) · 1.55 KB
/
wxpay_notify_url.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/*
* 付费阅读异步回调
*/
include '../../../config.inc.php';
require_once 'libs/payjs.php';
date_default_timezone_set('Asia/Shanghai');
$db = Typecho_Db::get();
$options = Typecho_Widget::widget('Widget_Options');
$option=$options->plugin('TeePay');
$data = $_POST;
if($data['return_code'] == 1){
$payjs = new Payjs("","",$option->payjs_wxpay_key,"");
$sign_verify = $data['sign'];
unset($data['sign']);
if($payjs->sign($data) == $sign_verify&&$data['total_fee']==$data['attach']*100){
$updateItem = $db->update('table.teepay_fees')->rows(array('feestatus'=>1))->where('feeid=?',$data["out_trade_no"]);
$updateItemRows= $db->query($updateItem);
$queryItem= $db->select()->from('table.teepay_fees')->where('feeid = ?', $data["out_trade_no"]);
$rowItem = $db->fetchRow($queryItem);
if($rowItem['feestatus']==1){
$queryContents= $db->select()->from('table.contents')->where('cid = ?', $rowItem['feecid']);
$rowContents = $db->fetchRow($queryContents);
$queryUser= $db->select()->from('table.users')->where('uid = ?', $rowContents['authorId']);
$rowUser = $db->fetchRow($queryUser);
$updateUser = $db->update('table.users')->rows(array('teepay_money'=>$rowUser['teepay_money']+$rowItem['feeprice']))->where('uid=?',$rowContents['authorId']);
$updateUserRows= $db->query($updateUser);
}
echo 'success';
}else{
$db = Typecho_Db::get();
$updateItem = $db->update('table.teepay_fees')->rows(array('feestatus'=>2))->where('feeid=?',$_POST['out_trade_no']);
$updateItemRows= $db->query($updateItem);
echo 'fail';exit();
}
}
?>