支付宝小程序支付代码

用支付宝的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 '成功'
        }

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

这个开发者的私钥
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GsjPlH7o-1589014863529)(https://upload-images.jianshu.io/upload_images/6095563-351e56180bafe967.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

这个是支付宝的公钥
alipayrsaPublicKey

个人博客

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值