| <?php
|
|
|
| class aliold_plugin
|
| {
|
| static public $info = [
|
| 'name' => 'aliold',
|
| 'showname' => '支付宝旧版接口',
|
| 'author' => '支付宝',
|
| 'link' => 'https://b.alipay.com/signing/productSetV2.htm',
|
| 'types' => ['alipay'],
|
| 'inputs' => [
|
| 'appid' => [
|
| 'name' => '合作者身份(PID)',
|
| 'type' => 'input',
|
| 'note' => '',
|
| ],
|
| 'appkey' => [
|
| 'name' => '安全校验码(Key)',
|
| 'type' => 'input',
|
| 'note' => '',
|
| ],
|
| ],
|
| 'select' => [
|
| '1' => '电脑网站支付',
|
| '2' => '手机网站支付',
|
| ],
|
| 'note' => '选择可用的接口,只能选择已经签约的产品,否则会无法支付。',
|
| 'bindwxmp' => false,
|
| 'bindwxa' => false,
|
| ];
|
|
|
| static public function submit(){
|
| global $siteurl, $channel, $order, $ordername, $sitename, $submit2, $conf;
|
|
|
| if(strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')!==false){
|
| if(!$submit2){
|
| return ['type'=>'jump','url'=>'/pay/submit/'.TRADE_NO.'/'];
|
| }
|
| return ['type'=>'page','page'=>'wxopen'];
|
| }
|
| if(!empty($conf['localurl_alipay']) && !strpos($conf['localurl_alipay'],$_SERVER['HTTP_HOST'])){
|
| return ['type'=>'jump','url'=>$conf['localurl_alipay'].'pay/submit/'.TRADE_NO.'/'];
|
| }
|
|
|
| require(PAY_ROOT."inc/alipay.config.php");
|
| require(PAY_ROOT."inc/alipay_submit.class.php");
|
|
|
| if(checkmobile()==true && in_array('2',$channel['apptype'])){
|
| $alipay_service = "alipay.wap.create.direct.pay.by.user";
|
| }else{
|
| $alipay_service = "create_direct_pay_by_user";
|
| }
|
| $parameter = array(
|
| "service" => $alipay_service,
|
| "partner" => trim($alipay_config['partner']),
|
| "seller_id" => trim($alipay_config['partner']),
|
| "payment_type" => "1",
|
| "notify_url" => $conf['localurl'].'pay/notify/'.TRADE_NO.'/',
|
| "return_url" => $siteurl.'pay/return/'.TRADE_NO.'/',
|
| "out_trade_no" => TRADE_NO,
|
| "subject" => $ordername,
|
| "total_fee" => $order['realmoney'],
|
| "_input_charset" => strtolower('utf-8')
|
| );
|
| if($alipay_service=="alipay.wap.create.direct.pay.by.user"){
|
| $parameter['app_pay'] = "Y";
|
| }
|
|
|
|
|
| $alipaySubmit = new AlipaySubmit($alipay_config);
|
| $html_text = $alipaySubmit->buildRequestForm($parameter,"get", "正在跳转");
|
| return ['type'=>'html','data'=>$html_text];
|
| }
|
|
|
|
|
| static public function notify(){
|
| global $channel, $order;
|
|
|
| require(PAY_ROOT."inc/alipay.config.php");
|
| require(PAY_ROOT."inc/alipay_notify.class.php");
|
|
|
|
|
| $alipayNotify = new AlipayNotify($alipay_config);
|
| $verify_result = $alipayNotify->verifyNotify();
|
|
|
| if($verify_result) {
|
|
|
| $out_trade_no = daddslashes($_POST['out_trade_no']);
|
|
|
|
|
| $trade_no = daddslashes($_POST['trade_no']);
|
|
|
|
|
| $buyer_id = daddslashes($_POST['buyer_id']);
|
|
|
|
|
| $total_fee = $_POST['total_fee'];
|
|
|
| if ($_POST['trade_status'] == 'TRADE_FINISHED' || $_POST['trade_status'] == 'TRADE_SUCCESS') {
|
|
|
| if($out_trade_no == TRADE_NO && round($total_fee,2)==round($order['realmoney'],2)){
|
| processNotify($order, $trade_no, $buyer_id);
|
| }
|
| }
|
| return ['type'=>'html','data'=>'success'];
|
| }
|
| else {
|
|
|
| return ['type'=>'html','data'=>'fail'];
|
| }
|
| }
|
|
|
|
|
| static public function return(){
|
| global $channel, $order;
|
|
|
| require(PAY_ROOT."inc/alipay.config.php");
|
| require(PAY_ROOT."inc/alipay_notify.class.php");
|
|
|
|
|
| $alipayNotify = new AlipayNotify($alipay_config);
|
| $verify_result = $alipayNotify->verifyReturn();
|
| if($verify_result) {
|
|
|
| $out_trade_no = daddslashes($_GET['out_trade_no']);
|
|
|
|
|
| $trade_no = daddslashes($_GET['trade_no']);
|
|
|
|
|
| $buyer_id = daddslashes($_GET['buyer_id']);
|
|
|
|
|
| $total_fee = $_GET['total_fee'];
|
|
|
| if($_GET['trade_status'] == 'TRADE_FINISHED' || $_GET['trade_status'] == 'TRADE_SUCCESS') {
|
| if($out_trade_no == TRADE_NO && round($total_fee,2)==round($order['realmoney'],2)){
|
| processReturn($order, $trade_no, $buyer_id);
|
| }else{
|
| return ['type'=>'error','msg'=>'订单信息校验失败'];
|
| }
|
| }else{
|
| return ['type'=>'error','msg'=>'trade_status='.$_GET['trade_status']];
|
| }
|
| }
|
| else {
|
|
|
| return ['type'=>'error','msg'=>'支付宝返回验证失败!'];
|
| }
|
| }
|
|
|
| } |