1.把支付宝的adk下载下来,放在vendor文件下
2.把AopClient.php里的$alipayrsaPublicKey 填写公钥
1 public $alipayrsaPublicKey = '***************************************************************';//此处为公钥
3.引用adk文件
1 vendor('zhifubao.aop.AopClient'); 2 3 vendor('zhifubao.aop.request.AlipayFundTransToaccountTransferRequest'); 4 5 vendor('zhifubao.aop.request.AlipayOpenPublicTemplateMessageIndustryModifyRequest'); 6 7 8 9 $c = new \AopClient;10 11 $c->gatewayUrl = "https://openapi.alipay.com/gateway.do";12 13 $c->appId = "*******";填写id14 15 $c->rsaPrivateKey = '************************************************' ;填写私钥16 17 $c->format = "json";18 19 $c->charset= "GBK";20 21 $c->signType= "RSA2";22 23 $c->alipayrsaPublicKey = '*********************************'; 填写公钥24 25 //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.open.public.template.message.industry.modify26 27 $request = new \AlipayFundTransToaccountTransferRequest();28 29 //SDK已经封装掉了公共参数,这里只需要传入业务参数30 31 //此次只是参数展示,未进行字符串转义,实际情况下请转义32 33 $request->setBizContent("{" .34 35 "\"out_biz_no\":\"3125232132343211\"," . 生产的订单id ,不能重复的随机数36 37 "\"payee_type\":\"ALIPAY_LOGONID\"," .38 39 "\"payee_account\":\"834206519@qq.com\"," . 收款人账号40 41 "\"amount\":\"0.1\"," .钱42 43 "\"payer_show_name\":\"123\"," . 名称44 45 "\"payee_real_name\":\"何为鹏\"," .46 47 "\"remark\":\"转账1备注\"" .48 49 "}");50 51 52 53 $response= $c->execute($request);54 55 $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";56 57 $resultCode = $response->$responseNode->code;58 59 // dump($response->$responseNode->code);die;60 61 if(!empty($resultCode)&&$resultCode == 10000){62 63 echo "成功";64 65 } else {66 67 echo "失败";68 69 }