支付宝 配置 (举例 单笔转账给个人支付宝

好久不弄支付宝,有些环节模糊了。特写下来记一下

1、开放平台签约 (免费)

2、用RSA签名验签工具windows_V1.4生成(应用公钥2048、应用私钥2048),新加的应用都是 RSA2方式

     https://docs.open.alipay.com/291/105972

RSA(SHA256)密钥(推荐): 此处上传应用公钥, 得到支付宝公钥,备签名用

3、签名专区

通常由支付宝账户管理者登录开放平台上传商户应用公钥,并记录appid及支付宝公钥信息。
技术同学得到1).appid,2).商户私钥,3).支付宝公钥,放到代码里去签名和验签。

4、未使用开放平台SDK的自助排查流程

     https://docs.open.alipay.com/200/106122

5、

    public function tiXian()
    {
        vendor('Alipay.Corefunction');
        vendor('Alipay.Md5function');
        vendor('Alipay.Notify');
        vendor('Alipay.Submit');
        //加载支付宝sdk
        Vendor('AppAlipay.AopSdk');
        //log文件路径
        //$this->alipy_log="/data/web/web/Public/app_alipay_log.log";

        $payer_show_name = '用户红包提现';
        $remark = '红包提现到支付宝';

        $aop = new \AopClient2 ();
        $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
        $aop->appId = '201512120096xxx';  //单笔转账功能appid
        //应用私钥
        $aop->rsaPrivateKey =  "xxxxxxxxxxxxxxxxxxxxxxxxxD366qt67G3HcQK8Z4sbYJwIt008MrbZZnnU7wTvoMsR5Sy7Z8/rDjaaAhabWfICiyhD0QPLtIRN53yFniU8S7ERF6q7UjJJGpq89W1GriLRDaxZ4IweVr+/hmjf8X39SJS9NWjDOjhxCk7E3EyJsQZ8bPGGXs3yR+7rCagE59VZW6MK0ELNDCa7DW9K1dxeHakbnd72Ky6tyxGPQq7zIo36kmdcjvGXUAoEar2iTqnd14arnlfPPZlCSfTL8eoJ1luxUXFoVPKLC549hnWG6KQ2xyi+I4n+Z07lri9V1jyOPH9LUjpPe642QIDAQABAoIBAAuHXoS9iL7QJoqdGT4QMk1ZTQcofrwCdAYoAISC5TDNXToBYJgFnsOyTG4cXhVi6U8L3R936ccncDMzZTEc6PQ41/SkAPDpzA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bdo69+OWB1Bawa45W7zg46b61XnVBfHwa2Lw==";//C('app_alipay_config.rsaPrivate');
        //支付宝公钥
        $aop->alipayrsaPublicKey= "xxxxxxxxxxxxxxxxxxxxxxxAMIIBCgxKCAQEArfgKn7qGIm6/DJWb6AQ0HiXjcu/oI64h9kG4rIio1+qR3Uw/anyCHyX2NcrX64hrw/DoWs7YGmiDJsW1uTlQ6Sz+vM5nfnO/eHVHwt5OPHlsoB+Gm/nhJS8DPcPV1OwGX8lKDsIH6+59IlEvfMwyHlaQpRNf+OK9maG+doLvSBhY9LtScBftsmjEqQ8u/+S8z2D9cmVxmgW2U9RBpr3imvHXT/yD0KrXWTGPs6h/Pxb9CmAgyr9BCLA9WTBDAlomUmGAjo1d1kBSCzKiLo5WMBai8GHp7QirsEekF7hlQcZGNv7z1fSOWB6FJGXQb9uCem+MNz4YE/KY6lTQzkf/JwIDAQAB";//C('app_alipay_config.alipy_rsaPublic');

        $aop->apiVersion = '1.0';
        $aop->signType = 'RSA2';
        $aop->postCharset='UTF-8';
        $aop->format='json';

        $out_no = ordersn();
        $toUserAccount = '15300330000';
        $toUserName = '';
        $money = 0.01;

        $request = new \AlipayFundTransToaccountTransferRequest ();
        $request->setBizContent("{" .
            "\"out_biz_no\":\"$out_no\"," .
            "\"payee_type\":\"ALIPAY_LOGONID\"," .
            "\"payee_account\":\"15300330047\"," .
            "\"amount\":\"0.1\"," .
            "\"payer_show_name\":\"测试\"," .
            "\"payee_real_name\":\"\"," .
            "\"remark\":\"转账备注\"" .
            "}");
        $result = $aop->execute ( $request);

        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            echo "成功";
        } else {
            echo "失败";
        }

    }



你可能感兴趣的:(支付宝)