支付宝小程序支付

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cc2415/article/details/86063637

用支付宝的sdk
服务端SDK

$aop = new AopClient ();
            $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
            $aop->appId = '2018111962265438';
            $aop->rsaPrivateKey = 'thZJL2VT0PlgHCgYEAzwp';//开发者的私钥
            $aop->alipayrsaPublicKey='ZvpB';//支付宝的公钥
            $aop->apiVersion = '1.0';
            $aop->signType = 'RSA2';
            $aop->postCharset='UTF-8';
            $aop->format='json';
//支付必要参数
        $request = new AlipayTradeCreateRequest ();

        $content = array();
        $content['out_trade_no'] = $order;
        $content['total_amount'] = sprintf('%.2f',$allmoney);
        $content['subject'] = '外卖小吃';
        $content['buyer_id'] = '2088802486734682';
        $content=json_encode($content);
        $request->setBizContent($content);
        $result = $aop->execute($request);
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
        echo '成功'
        }

使用支付宝提供的密钥生成器,这个再创建公钥的时候有提供下载
密钥生成器下载地址

这个开发者的私钥
rsaPrivateKey

这个是支付宝的公钥
alipayrsaPublicKey

个人博客

猜你喜欢

转载自blog.csdn.net/cc2415/article/details/86063637