public class AliPayController : Controller { // GET: AliPay public ActionResult Index() { return RedirectToAction("PayRequest"); } public static string merchant_private_key = "/BUD4N8Y6Nh9sL4o4KfoMM+/+uoHFQn+/M++++//“/// <summary> /// //支付宝的公钥,查看地址:https://b.alipay.com/order/pidAndKey.htm /// </summary> public static string alipay_public_key = "/FCEa3/cNMW0QIDAQAB"; /// <summary> /// RSA2私钥 /// </summary> //public static string private_key = "+++++/Ms20n4l/+///on/Vm4R2/GMS+B0JHrgjrC6uw=="; /// <summary> /// RSA2公钥 /// </summary> //public static string alipay_public_key = "///fQIDAQAB"; //[HttpPost] public ActionResult PayRequest() { IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", "2018999999999999", merchant_private_key, "json", "1.0", "RSA", alipay_public_key, "GBK", false); AlipayFundTransToaccountTransferRequest request = new AlipayFundTransToaccountTransferRequest(); request.BizContent = "{" + ""out_biz_no":"1888888899999"," + ""payee_type":"ALIPAY_LOGONID"," + ""payee_account":"999@foxmail.com"," + ""amount":"0.1"," + ""remark":"转账备注"" + "}"; //Execute 执行服务端返回结果 SDKExecute执行 请求信息 返回到客户端 AlipayFundTransToaccountTransferResponse response = client.Execute(request); Console.WriteLine(response.Body); return View(); } }