aop = new \AopCertClient; $this->aop->appId = self::APPID; $this->aop->signType = self::SIGN_TYPE; $this->aop->gatewayUrl = self::GATE_WAY_URL; $this->aop->format = self::FORMAT; $this->aop->charset = self::CHARST; $this->aop->isCheckAlipayPublicCert = true; $this->aop->rsaPrivateKey = self::RSAPRIVATEKEY; $this->aop->alipayrsaPublicKey = $this->aop->getPublicKey(dirname(__FILE__) . "/../cert/huomaoxiaoshuohui/alipayCertPublicKey_RSA2.crt"); //证书序列号 $this->aop->appCertSN = $this->aop->getCertSN(dirname(__FILE__) . "/../cert/huomaoxiaoshuohui/appCertPublicKey_2021003192638805.crt"); //支付宝根证书序列号 $this->aop->alipayRootCertSN = $this->aop->getRootCertSN(dirname(__FILE__) . "/../cert/huomaoxiaoshuohui/alipayRootCert.crt"); // \Log::info('$this->aop->alipayRootCertSN');\Log::info(dirname(__FILE__) . "/../cert/huomaoxiaoshuohui/alipayRootCert.crt"); } public function notify(array $data) { if (isset($data['sign']) && isset($data['trade_status']) && $data['trade_status'] == 'TRADE_SUCCESS') { return $this->aop->rsaCheckV1($data, $this->rsaPublicKeyFilePath, self::SIGN_TYPE); } else { return false; } } public function queryFundAccount() { /** 设置业务参数,具体接口参数传值以文档说明为准:https://opendocs.alipay.com/apis/api_28/alipay.fund.account.query **/ $request = new \AlipayFundAccountQueryRequest; $request->setBizContent("{" . "\"alipay_user_id\":\"2088641232029876\"," . "\"account_type\":\"ACCTRANS_ACCOUNT\"" . "}"); $result= $this->aop->execute($request); \Log::info('queryFundAccount:'.json_encode($result)); return $result; } public function transFund($trans_param) { $request = new \AlipayFundTransUniTransferRequest; $bizContent = [ 'out_biz_no'=>$trans_param['out_biz_no'], 'remark'=>$trans_param['remark'], 'business_params'=>[ 'payer_show_name_use_alias'=>true, ], 'biz_scene'=>'DIRECT_TRANSFER', 'out_biz_no'=>$trans_param['out_biz_no'], 'payee_info'=>[ 'identity'=>$trans_param['account'], 'identity_type'=>'ALIPAY_LOGON_ID', 'name'=>$trans_param['account_name'], ], 'trans_amount'=>$trans_param['trans_amount'], 'product_code'=>'TRANS_ACCOUNT_NO_PWD', 'order_title'=>$trans_param['order_title'], ]; $bizContent_json = json_encode($bizContent); // $bizContent = "{". // "\"out_biz_no\":\".$trans_param['out_biz_no'].\",". // "\"remark\":\".$trans_param['remark'].\",". // "\"business_params\":\"{\\\"payer_show_name_use_alias\\\":\\\"true\\\"}\",". // "\"biz_scene\":\"DIRECT_TRANSFER\",". // "\"payee_info\":{". // "\"identity\":\".$trans_param['account'].\",". // "\"identity_type\":\"ALIPAY_LOGON_ID\",". // "\"name\":\".$trans_param['account_name'].\"". // "},". // "\"trans_amount\":\".$trans_param['trans_amount'].\",". // "\"product_code\":\"TRANS_ACCOUNT_NO_PWD\",". // "\"order_title\":\".$trans_param['order_title'].\"". // "}"; \Log::info('$bizContent:'.$bizContent_json); \Log::info($bizContent); $request->setBizContent($bizContent_json); // {"out_biz_no":"tf-2023052917264016853524006173129", // "remark":"\u6536\u76ca\u63d0\u73b0", // "business_params":{"payer_show_name_use_alias":true}, // "biz_scene":"DIRECT_TRANSFER", // "payee_info":{"identity":"18668420256","identity_type":"ALIPAY_LOGON_ID","name":"\u5468\u7075\u6770"}, // "trans_amount":0.01,"product_code":"TRANS_ACCOUNT_NO_PWD","order_title":"\u706b\u732b\u5c0f\u8bf4"} // $request->setBizContent("{". // "\"out_biz_no\":\"hmxs201806300003\",". // "\"remark\":\"火猫小说\",". // "\"business_params\":\"{\\\"payer_show_name_use_alias\\\":\\\"true\\\"}\",". // "\"biz_scene\":\"DIRECT_TRANSFER\",". // "\"payee_info\":{". // "\"identity\":\"18668420256\",". // "\"identity_type\":\"ALIPAY_LOGON_ID\",". // "\"name\":\"周灵杰\"". // "},". // "\"trans_amount\":\"0.1\",". // "\"product_code\":\"TRANS_ACCOUNT_NO_PWD\",". // "\"order_title\":\"测试转账\"". // "}"); $result = $this->aop->execute($request); echo json_encode($result,JSON_UNESCAPED_UNICODE); \Log::info('transFund:'.json_encode($result,JSON_UNESCAPED_UNICODE)); return $result; } }