官方文檔
下載支付寶sdk後解壓放到extend目錄下
在public/index.php中定義常量
參考文檔
define('ALI_PATH',__DIR__.'/../extend/alipay/aop/');
創建控制器並寫入代碼
<?php
namespace app\api\controller;
use think\Controller;
use think\Session;
use think\DB;
require ALI_PATH.'AopClient.php';
require ALI_PATH.'request/AlipayFundAuthOperationDetailQueryRequest.php';
class Ali extends Controller{
public static $appid = ''; //appid
public static $pub_key = ''; //應用公鑰
public static $prikey = ''; //應用私鑰
public static $alipubkey = '';//支付寶公鑰
public function queryorder()
{
$aop = new \AopClient ();
$aop->appId = self::$appid;
//應用私鑰:使用密鑰生成工具生成的較長的那個密鑰
$aop->rsaPrivateKey = self::$prikey;
//支付寶公鑰:應用公鑰上傳後自動生成的
$aop->alipayrsaPublicKey=self::$alipubkey;
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='utf-8';
$aop->format='json';
$request = new \AlipayFundAuthOperationDetailQueryRequest ();
$request->setBizContent("{" .
// "\"auth_no\":\"2014021601002000640012345678\"," . //支付寶授權號
"\"out_order_no\":\"15856459848767orderid\"," . //商戶訂單號
// "\"operation_id\":\"20140216010020006400\"," . //支付寶流水號
"\"out_request_no\":\"15856459849166395liushui\"" . //商戶流水號
"}");
$result = $aop->execute ( $request);
var_dump($result) ;
}
}