【第二十三篇】三步搞定支付宝单笔转账 alipay.fund.trans.uni.transfer

邮差的信 提交于 2020-08-10 09:52:48

先去看文档,看完之后我们来继续

https://opendocs.alipay.com/apis/api_28/alipay.fund.trans.uni.transfer/

准备工作

第一步,下载好证书,放在目录中

我用的config方式读取的

<add key="aliCertPublicKey" value="E:\\Project\\Cert\\alipayCertPublicKey_RSA2.crt"   />
<add key="aliRootCert" value="E:\\Project\\Cert\\alipayRootCert.crt"  />
<add key="aliAppCertPublicKey" value="E:\\Project\\Cert\\appCertPublicKey_202100.crt"  />
<add key="aliEncyptKey" value="V1LKCQTBLg=="/>

 

第二步,添加SDK

 

第三步

CertParams cert = new CertParams();
            cert.AlipayPublicCertPath = Configs.AppSettingsValue("aliCertPublicKey");
            cert.AppCertPath = Configs.AppSettingsValue("aliAppCertPublicKey");
            cert.RootCertPath = Configs.AppSettingsValue("aliRootCert");


            IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", mShop.AppId, mShop.MerchantPrivateKey, "json", "1.0", "RSA2", "GBK", Configs.AppSettingsValue("aliEncyptKey"), cert);

            AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
            request.BizContent = "{" +
              "\"out_biz_no\":\"" + with.BillCode + "\"," +
              "\"trans_amount\":" + with.TransAmount + "," +
              "\"biz_scene\":\"DIRECT_TRANSFER\"," +
              "\"product_code\":\"TRANS_ACCOUNT_NO_PWD\"," +
              "\"order_title\":\"主动提现:" + with.TransAmount + "元\"," +
              "\"payee_info\":{" +
                     "\"identity\":\"" + with.AlipayAccount + "\"," +
                     "\"identity_type\":\"ALIPAY_LOGON_ID\"," +
                     "\"name\":\"" + with.AlipayName + "\"" +
              "}}";
            AlipayFundTransUniTransferResponse response = client.CertificateExecute(request);
            if (response.Code == "10000")
            {
                json.msg = "提现成功,预计2小时内到账";
            }
            else
            {
                json.msg = "提现失败,请联系总部";
            }

 

--------------------------------------------------------------------------------------------------------- 

转载请记得说明作者和出处哦-.-
作者:KingDuDu
原文出处:https://www.cnblogs.com/kingdudu/articles/12673474.html

---------------------------------------------------------------------------------------------------------

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!