淘宝双向接口简单修改

  1. 配置alipay.config.php,

    只配置$alipay_config['partner'](16位)  /  $alipay_config['key'](32位).

?
1
2
3
4
//合作身份者id,以2088开头的16位纯数字
$alipay_config [ 'partner' ]       =  '2088************' ; //安全检验码,以数字和字母组成的32位字符
$alipay_config [ 'key' ]           =  'vw******************************' ;

2.配置alipayapi.php

?
1
2
require_once ( "alipay.config.php" ); require_once ( "lib/alipay_submit.class.php" );

保证参数数组信息完整!$parameter

?
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
//构造要请求的参数数组,无需改动
$parameter  array (
         "service"  =>  "trade_create_by_buyer" ,
         "partner"  => trim( $alipay_config [ 'partner' ]),
         "payment_type"  =>  $payment_type ,
         "notify_url"    =>  $notify_url ,
         "return_url"    =>  $return_url ,
         "seller_email"  =>  $seller_email ,
         "out_trade_no"  =>  $out_trade_no ,
         "subject"   =>  $subject ,
         "price" =>  $price ,
         "quantity"  =>  $quantity ,
         "logistics_fee" =>  $logistics_fee ,
         "logistics_type"    =>  $logistics_type ,
         "logistics_payment" =>  $logistics_payment ,
         "body"  =>  $body ,
         "show_url"  =>  $show_url ,
         "receive_name"  =>  $receive_name ,
         "receive_address"   =>  $receive_address ,
         "receive_zip"   =>  $receive_zip ,
         "receive_phone" =>  $receive_phone ,
         "receive_mobile"    =>  $receive_mobile ,
         "_input_charset"    => trim( strtolower ( $alipay_config [ 'input_charset' ]))
); //建立请求
$alipaySubmit  new  AlipaySubmit( $alipay_config ); $html_text  $alipaySubmit ->buildRequestForm( $parameter , "get" "确认" ); echo  $html_text ;

3.配置alipay_submit.class.php修改订单确认界面修改 function buildRequestForm.

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function  buildRequestForm( $para_temp $method $button_name ) {
         //待请求参数数组        $para  $this ->buildRequestPara( $para_temp );
          
         $sHtml  "<form id='alipaysubmit' name='alipaysubmit' action='" . $this ->alipay_gateway_new. "_input_charset=" .trim( strtolower ( $this ->alipay_config['input_charset ']))."'  method= '".$method."' >";
         while  (list ( $key $val ) = each ( $para )) {
             $sHtml .=  $key . ":<input type='text' name='" . $key . "' value='" . $val . "'/><br/>" ;
         }
  
         //submit按钮控件请不要含有name属性         $sHtml  $sHtml . "<input type='submit' value='" . $button_name . "'></form>" ;
          
         $sHtml  $sHtml . "<script>document.forms['alipaysubmit'].submit();</script>" ;
          
         return  $sHtml ;
     }

4.修改return_url.php,支付返回信息处理

?
1
2
require_once ( "alipay.config.php" ); require_once ( "lib/alipay_notify.class.php" );

//商户订单号$out_trade_no = $_GET['out_trade_no'];

//支付宝交易号$trade_no = $_GET['trade_no'];

//交易状态$trade_status = $_GET['trade_status'];

?
1
2
3
4
5
6
7
8
9
10
11
12
13
     if ( $_GET [ 'trade_status' ] ==  'WAIT_SELLER_SEND_GOODS' ) {
  //判断该笔订单是否在商户网站中已经做过处理  //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序  //如果有做过处理,不执行商户的业务程序     }
  else  if ( $_GET [ 'trade_status' ] ==  'TRADE_FINISHED' ) {
  //判断该笔订单是否在商户网站中已经做过处理  //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序  //如果有做过处理,不执行商户的业务程序     }
     else  {
       echo  "trade_status=" . $_GET [ 'trade_status' ];
     }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值