php實現(xiàn)單筆轉(zhuǎn)賬到支付寶功能_第1頁
php實現(xiàn)單筆轉(zhuǎn)賬到支付寶功能_第2頁
php實現(xiàn)單筆轉(zhuǎn)賬到支付寶功能_第3頁
php實現(xiàn)單筆轉(zhuǎn)賬到支付寶功能_第4頁
php實現(xiàn)單筆轉(zhuǎn)賬到支付寶功能_第5頁
已閱讀5頁,還剩2頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

第php實現(xiàn)單筆轉(zhuǎn)賬到支付寶功能本文實例為大家分享了php實現(xiàn)單筆轉(zhuǎn)賬到支付寶的具體代碼,供大家參考,具體內(nèi)容如下

1.首先去螞蟻金服簽約單筆轉(zhuǎn)賬到支付寶

官方api文檔

2.需要的配置信息

1).應(yīng)用appid

2).生成密鑰

文檔地址

根據(jù)文檔步驟生成

上傳這里的應(yīng)用公鑰

3.下載官方sdk然后集成到自己項目

服務(wù)端SDK

官方實例

//實例化客戶端

AlipayClientalipayClient=newDefaultAlipayClient("/gateway.do",APP_ID,APP_PRIVATE_KEY,"json",CHARSET,ALIPAY_PUBLIC_KEY,"RSA2");

//實例化具體API對應(yīng)的request類,類名稱和接口名稱對應(yīng),當前調(diào)用接口名稱:alipay.open.public.template.message.industry.modify

AlipayOpenPublicTemplateMessageIndustryModifyRequestrequest=newAlipayOpenPublicTemplateMessageIndustryModifyRequest();

//SDK已經(jīng)封裝掉了公共參數(shù),這里只需要傳入業(yè)務(wù)參數(shù)

//此次只是參數(shù)展示,未進行字符串轉(zhuǎn)義,實際情況下請轉(zhuǎn)義

request.setBizContent("{"+

"\"primary_industry_name\":\"IT科技/IT軟件與服務(wù)\","+

"\"primary_industry_code\":\"10001/20102\","+

"\"secondary_industry_code\":\"10001/20102\","+

"\"secondary_industry_name\":\"IT科技/IT軟件與服務(wù)\""+

"}");

AlipayOpenPublicTemplateMessageIndustryModifyResponseresponse=alipayClient.execute(request);

//調(diào)用成功,則處理業(yè)務(wù)邏輯

if(response.isSuccess()){

//.....

}

效果如下

我的代碼

*createby適可而止

*createtime2025/4/8

namespaceOrg\Util;

classAlipayTransfer{

private$appId='appid';

private$rsaPrivateKey='私鑰';

private$alipayrsaPublicKey="支付寶公鑰";

private$payer_name="xx科技";

private$aop;

publicfunction__construct()

$g_alipay=C('ALIPAY_CONFIG');

$this-appId=$g_alipay['APPID'];//appid

$this-rsaPrivateKey=$g_alipay['rsaPrivateKey'];//私鑰

$this-alipayrsaPublicKey=$g_alipay['rsaPublicKey'];//支付寶公鑰

//引入單筆轉(zhuǎn)賬sdk

Vendor('Alipayaop.AopSdk');

publicfunctioninit_aop_config()

$this-aop-gatewayUrl='/gateway.do';

$this-aop-appId=$this-appId;

$this-aop-rsaPrivateKey=$this-rsaPrivateKey;

$this-aop-alipayrsaPublicKey=$this-alipayrsaPublicKey;

$this-aop-apiVersion='1.0';

$this-aop-signType='RSA2';

$this-aop-postCharset='UTF-8';

$this-aop-format='json';

*單筆轉(zhuǎn)賬接口

*@param$order_number訂單號

*@param$pay_no轉(zhuǎn)賬賬號

*@param$pay_name轉(zhuǎn)賬用戶名

*@param$amount轉(zhuǎn)賬金額

*@param$memo備注

publicfunctiontransfer($order_number,$pay_no,$pay_name,$amount,$memo)

//存入轉(zhuǎn)賬日志

$this-transferLog($order_number,$pay_no,$pay_name,$amount);

$this-aop=new\AopClient();

//配置參數(shù)

$this-init_aop_config();

//導入請求

$request=new\AlipayFundTransToaccountTransferRequest();

$request-setBizContent("{".

"\"out_biz_no\":\"".$order_number."\",".//商戶生成訂單號

"\"payee_type\":\"ALIPAY_LOGONID\",".//收款方支付寶賬號類型

"\"payee_account\":\"".$pay_no."\",".//收款方賬號

"\"amount\":\"".$amount."\",".//總金額

"\"payer_show_name\":\"".$this-payer_name."\",".//付款方賬戶

"\"payee_real_name\":\"".$pay_name."\",".//收款方姓名

"\"remark\":\"".$memo."\"".//轉(zhuǎn)賬備注

"}");

$result=$this-aop-execute($request);

$responseNode=str_replace(".","_",$request-getApiMethodName())."_response";

$resultCode=$result-$responseNode-code;

$resultSubMsg=$result-$responseNode-sub_msg;

//修改轉(zhuǎn)賬日志

$this-edit_transferLog($order_number,$resultCode,$resultSubMsg);

if(!empty($resultCode)$resultCode==10000){

returntrue;

}else{

returnfalse;

*存取日志

privatefunctiontransferLog($order_number,$pay_no,$pay_name,$amount)

$data['order_number']=$order_number;

$data['pay_no']=$pay_no;

$data['pay_name']=$pay_name;

$data['amount']=$amount;

$data['create_time']=time();

M('AlipayTransferLog')-add($data);

*修改日志

privatefunctionedit_transferLog($order_number,$result_code,$sub_msg)

$model=D("AlipayTransferLog");

$where['order_number']=$order_number;

$result=$model-where($where)-order('create_timedesc')-find();

if($result_code==10000)

$result['status']=1;

$sub_msg='success';

else

$result['status']=2;

$result['memo']=$sub_msg;

$result['update_time']=time();

M('AlipayTransferLog')-save($result);

*查單接口

publicfunctionquery($order_number)

$this-aop=new\AopClient();

//配置參數(shù)

$this-init_aop_config();

$request=new\AlipayFundTransOrderQueryRequest();

$request-setBizContent("{".

"\"out_biz_no\":\"".$order_number."\"".

"}");

$result=$this-aop-execute($request);

$responseNode=str_replace(".","_",$request-getApiMethodName())."_response";

$resultCode=$result-

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論