支付宝提现接口

官方接口文档:https://opendocs.alipay.com/pre-apis/api_pre/alipay.fund.trans.uni.transfer


支付宝提现接口_第1张图片
需要引入sdk

//司机提现功能https://opendocs.alipay.com/apis/api_28/alipay.fund.trans.uni.transfer

public function test(){

  $api_param = db('api_param')->where('id',3)->find();

    //var_dump($api_param['alipay_private_key']);die;

    $aop = new AopCertClient;

    $appCertPath = "./appCertPublicKey_2021001193637052.crt";//"应用证书路径(要确保证书文件可读),.crt";      //商户提现给个人必须用证书加密

    $alipayCertPath = "./alipayCertPublicKey_RSA2.crt";//"支付宝公钥证书路径(要确保证书文件可读),

    $rootCertPath = "./alipayRootCert.crt";//"支付宝根证书路径(要确保证书文件可读),

    $aop->gatewayUrl = "https://openapi.alipay.com/gateway.do";

    $aop->appId = '4556193645652';

    $aop->rsaPrivateKey = $api_param['alipay_private_key'];//秘钥

    $aop->format = "json";

    $aop->charset= "GBK";

    $aop->signType= "RSA2";

    //var_dump($appCertPath);die;

    //调用getPublicKey从支付宝公钥证书中提取公钥

    $aop->alipayrsaPublicKey = $aop->getPublicKey($alipayCertPath);//$api_param['alipay_public_key'];//

    //是否校验自动下载的支付宝公钥证书,如果开启校验要保证支付宝根证书在有效期内

    $aop->isCheckAlipayPublicCert = true;

    //调用getCertSN获取证书序列号

    $aop->appCertSN = $aop->getCertSN($appCertPath);

    //调用getRootCertSN获取支付宝根证书序列号

    $aop->alipayRootCertSN = $aop->getRootCertSN($rootCertPath);

    $request = new AlipayFundTransUniTransferRequest();

    $order_no = time();

    $request->setBizContent("{" .

        "\"out_biz_no\":\"$order_no\"," .

        "\"trans_amount\":0.1," .

        "\"product_code\":\"TRANS_ACCOUNT_NO_PWD\"," .

        "\"biz_scene\":\"DIRECT_TRANSFER\"," .

      /* "\"mutiple_currency_detail\":{" .

"\"payment_amount\":\"100.00\"," .

"\"payment_currency\":\"CNY\"," .

"\"trans_amount\":\"10.00\"," .

"\"trans_currency\":\"CNY\"," .

"\"settlement_amount\":\"10.00\"," .

"\"settlement_currency\":\"CNY\"," .

"\"ext_info\":\"key=value\"" .

"    }," .*/

        "\"order_title\":\"转账标题\"," .

        //"\"original_order_id\":\"20190620110075000006640000063057\"," .

        "\"payee_info\":{" .

        "\"identity\":\"1545454869\"," .

        "\"identity_type\":\"ALIPAY_LOGON_ID\"," .

        "\"name\":\"麦小迪\"" .

        "    }," .

        "\"remark\":\"单笔转账\"," .

        //"\"business_params\":\"{\\\"sub_biz_scene\\\":\\\"REDPACKET\\\"}\"," .

//"\"passback_params\":\"{\\\"merchantBizType\\\":\\\"peerPay\\\"}\"" .

        "  }");

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

    //$result = $aop->certificateExecute($request);

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

    $resultCode = $result->$responseNode->code;

    var_dump($result);die;

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

        echo "成功";

    } else {

        echo "失败";

    }


}


支付宝提现接口_第2张图片
支付宝提现接口_第3张图片

你可能感兴趣的:(支付宝提现接口)