美文网首页
支付宝支付

支付宝支付

作者: liuboxx1 | 来源:发表于2017-12-07 18:07 被阅读38次
     public function androidEnctype() {
    
            $orderId    = I('post.order_id');
            $payMoney   = I('post.payMoney');
            $name       = I('post.name');
            $redid      = urlencode('redid='.I('post.redid'));   //urlencode一下
    //        $orderId  = '2222234rffvvfghb';
    //        $payMoney = '0.01';
    //        $name     = '鹅和鸭';
    
            require_once 'Alipay/aop/AopClient.php';
            require_once 'Alipay/aop/request/AlipayTradeAppPayRequest.php';
    
            $aop = new \Alipay\aop\AopClient();
            $aop->gatewayUrl = "https://openapi.alipay.com/gateway.do";
            $aop->appId = "2017056";
            $aop->rsaPrivateKey = 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCJA/cfwxtcMNbF0GP82UTI96uq21a8gzPDy9SsezpGpH0+c7seJPPJPULSKhCQlGEUgYxL/pLCNw9Fba4pSvN08g2u3HcHBd0w6TH9VjVE7ZSOkh7B5oolcXBhQ3RhrnE1CDJsDmbgUQkPlw1pf4Oh7gwdIGsHc7fbQbFmQ09rPqDEmhzPqasGJw02KXEcu8otOwE6jDntdw+htwNA1yh2mp9e2rCjk9s4lnOpOubmFMaRxH3mBzqXMMTlohtDy0ktffpdc+6YdlU+gahgqYREdprlLtEBRWRoCvMCNUb5MYcp98K0rawwXMfBzjmcvnGEGbHrb5FxlLGpwQKBgC6IgqIUjd9mAk4E6RFX/bo4MFY3Ai5oLYYBAG4k85MY5f43BTl6K1JsJ6AsmaqfG4W9kmX/gMZswqHk+TJhAgaf9TvtpNzadxOIqyzIK2h6gBTs45zIlHISqK6gd+6LqHYZVJ+ZbSCwH6M3Isqjuc1LGIt+9bTfL2VZqtW+8DbxAoGAczpT3cN3k2MmuHxVYB/CzB7wpRT71OFlxvhZhDLcHjkY9GN3qH16aQ3DlCio21Wi/M0gnP3bS0tNwf0zNw1nh0BcmL/gHnQlh5vNwbAisaeg+V0QWFlnNzu04Ue/hjiMOaBjmhIe4ACt9RpPE7rMk2Wo5KuO2rWI7OGQ/gYb4T4=';
    
            $aop->format   = "json";
            $aop->charset  = "UTF-8";
            $aop->signType = "RSA2";
            $aop->alipayrsaPublicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjKBkbh/HDTt3+RhQy/4AQ2fLeabaxBvXav5hn4uIlwlmIXOhDL1n2/cG/2Hrg/JwyOu9pzJOIafSsL+cSUHfCBR+DWwGgY25WHieBRrYKwci1jeJ4TBqFrrWjAjvapRGoAAY5q7E5GkIce/wsFXtj3P+gTB+jOuluKIj5nlF0VcmPFPXAAQEY8PWPoXyaj78iOJAaDL4eCl4/JWohgstZW6gYqln4suLo3A9oAE8aoYPge7mTxPGqRASPwIDAQAB';
    
    //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
            $request = new \Alipay\aop\request\AlipayTradeAppPayRequest();
    
    //SDK已经封装掉了公共参数,这里只需要传入业务参数
            $bizcontent =
                 "{\"body\":\"" . $name . "\","
                . "\"subject\": \"" . $name . "\","
                . "\"out_trade_no\": \"" . $orderId . "\","
                . "\"timeout_express\": \"30m\","
                . "\"total_amount\": \"" . $payMoney . "\","
                . "\"passback_params\": \"" . $redid . "\","
                . "\"product_code\":\"QUICK_MSECURITY_PAY\""
                . "}";
            $request->setNotifyUrl("https://www.coucouchina.com/Api/PayRsa/demoNotify_url");
            $request->setBizContent($bizcontent);
    //这里和普通的接口调用不同,使用的是sdkExecute
            $response = $aop->sdkExecute($request);
    
    //        $aaa      = $aop->rsaSign($request, 'RSA2');
    //htmlspecialchars是为了输出到页面时防止被浏览器将关键参数html转义,实际打印到日志以及http传输不会有这个问题
    
    //        echo htmlspecialchars($response);//就是orderString 可以直接给客户端请求,无需再做处理。
    
            $return_info['orderString'] = $response;
    //
            $this->ajaxReturn($return_info);
    
        }
    
    

    相关文章

      网友评论

          本文标题:支付宝支付

          本文链接:https://www.haomeiwen.com/subject/ftjjixtx.html