一.准备工作
1.沙箱应用:https://openhome.alipay.com/platform/appDaily.htm
2.签名专区:https://docs.open.alipay.com/291/105971/
3.DEMO下载:https://docs.open.alipay.com/270/106291/
4.商家中心:https://b.alipay.com/signing/authorizedProductSet.htm?navKey=all#/?_k=53rjub
5.电脑网站支付开发文档:https://docs.open.alipay.com/270/alipay.trade.page.pay
6.开发指南:https://docs.open.alipay.com/200/105310/
二.编写代码
1.发起PC支付
OrderPaymentTB orderPayment = this.BaseService.GetModel<OrderPaymentTB>(u => u.OrderPaymentNo == tradeNo); string app_id = CachedConfigContext.Current.AlipayConfig.app_id; string subject = CachedConfigContext.Current.AlipayConfig.subject; string merchant_private_key = CachedConfigContext.Current.AlipayConfig.private_key; string alipay_public_key = CachedConfigContext.Current.AlipayConfig.alipay_public_key; string server_url = CachedConfigContext.Current.AlipayConfig.server_url;//正式环境 https://openapi.alipay.com/gateway.do string format = CachedConfigContext.Current.AlipayConfig.format; string version = CachedConfigContext.Current.AlipayConfig.version; string sign_type = CachedConfigContext.Current.AlipayConfig.sign_type; string input_charset = CachedConfigContext.Current.AlipayConfig.input_charset; DefaultAopClient client = new DefaultAopClient(server_url, app_id, merchant_private_key, format, version, sign_type, alipay_public_key, input_charset, false); AlipayTradePagePayRequest request = new AlipayTradePagePayRequest(); request.BizContent = "{" + " \"body\":\"\"," + " \"subject\":\"" + subject + "\"," + " \"out_trade_no\":\"" + orderPayment.OrderPaymentNo + "\"," + " \"total_amount\":" + orderPayment .Amount+ "," + " \"product_code\":\"FAST_INSTANT_TRADE_PAY\"" + " }"; request.SetReturnUrl(CachedConfigContext.Current.AlipayConfig.return_url); request.SetNotifyUrl(CachedConfigContext.Current.AlipayConfig.notify_url); AlipayTradePagePayResponse response = client.pageExecute(request); string form = response.Body; return View();