I see the source code from alipay, direct pay and escrow pay have some difference:
first, direct pay:
protected void BtnAlipay_Click(object sender, EventArgs e)
{
////////////////////////////////////////////请求参数////////////////////////////////////////////
//支付类型
string payment_type = "1";
//必填,不能修改
//服务器异步通知页面路径
string notify_url = "http://商户网关地址/create_direct_pay_by_user-CSHARP-UTF-8/notify_url.aspx";
//需http://格式的完整路径,不能加?id=123这类自定义参数
//页面跳转同步通知页面路径
string return_url = "http://商户网关地址/create_direct_pay_by_user-CSHARP-UTF-8/return_url.aspx";
//需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/
//商户订单号
string out_trade_no = WIDout_trade_no.Text.Trim();
//商户网站订单系统中唯一订单号,必填
//订单名称
string subject = WIDsubject.Text.Trim();
//必填
//付款金额
string total_fee = WIDtotal_fee.Text.Trim();
//必填
//订单描述
string body = WIDbody.Text.Trim();
//商品展示地址
string show_url = WIDshow_url.Text.Trim();
//需以http://开头的完整路径,例如:http://www.商户网址.com/myorder.html
//防钓鱼时间戳
string anti_phishing_key = "";
//若要使用请调用类文件submit中的query_timestamp函数
//客户端的IP地址
string exter_invoke_ip = "";
//非局域网的外网IP地址,如:221.0.0.1
////////////////////////////////////////////////////////////////////////////////////////////////
//把请求参数打包成数组
SortedDictionary<string, string> sParaTemp = new SortedDictionary<string, string>();
sParaTemp.Add("partner", Config.Partner);
sParaTemp.Add("seller_email", Config.Seller_email);
sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
sParaTemp.Add("service", "create_direct_pay_by_user");
sParaTemp.Add("payment_type", payment_type);
sParaTemp.Add("notify_url", notify_url);
sParaTemp.Add("return_url", return_url);
sParaTemp.Add("out_trade_no", out_trade_no);
sParaTemp.Add("subject", subject);
sParaTemp.Add("total_fee", total_fee);
sParaTemp.Add("body", body);
sParaTemp.Add("show_url", show_url);
sParaTemp.Add("anti_phishing_key", anti_phishing_key);
sParaTemp.Add("exter_invoke_ip", exter_invoke_ip);
//建立请求
string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");
Response.Write(sHtmlText);
escrow pay:
protected void BtnAlipay_Click(object sender, EventArgs e)
{
////////////////////////////////////////////请求参数////////////////////////////////////////////
//支付类型
string payment_type = "1";
//必填,不能修改
//服务器异步通知页面路径
string notify_url = "http://商户网关地址/create_partner_trade_by_buyer-CSHARP-UTF-8/notify_url.aspx";
//需http://格式的完整路径,不能加?id=123这类自定义参数
//页面跳转同步通知页面路径
string return_url = "http://商户网关地址/create_partner_trade_by_buyer-CSHARP-UTF-8/return_url.aspx";
//需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/
//商户订单号
string out_trade_no = WIDout_trade_no.Text.Trim();
//商户网站订单系统中唯一订单号,必填
//订单名称
string subject = WIDsubject.Text.Trim();
//必填
//付款金额
string price = WIDprice.Text.Trim();
//必填
//商品数量
string quantity = "1";
//必填,建议默认为1,不改变值,把一次交易看成是一次下订单而非购买一件商品
//物流费用
string logistics_fee = "0.00";
//必填,即运费
//物流类型
string logistics_type = "EXPRESS";
//必填,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS)
//物流支付方式
string logistics_payment = "SELLER_PAY";
//必填,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费)
//订单描述
string body = WIDbody.Text.Trim();
//商品展示地址
string show_url = WIDshow_url.Text.Trim();
//需以http://开头的完整路径,如:http://www.商户网站.com/myorder.html
//收货人姓名
string receive_name = WIDreceive_name.Text.Trim();
//如:张三
//收货人地址
string receive_address = WIDreceive_address.Text.Trim();
//如:XX省XXX市XXX区XXX路XXX小区XXX栋XXX单元XXX号
//收货人邮编
string receive_zip = WIDreceive_zip.Text.Trim();
//如:123456
//收货人电话号码
string receive_phone = WIDreceive_phone.Text.Trim();
//如:0571-88158090
//收货人手机号码
string receive_mobile = WIDreceive_mobile.Text.Trim();
//如:13312341234
////////////////////////////////////////////////////////////////////////////////////////////////
//把请求参数打包成数组
SortedDictionary<string, string> sParaTemp = new SortedDictionary<string, string>();
sParaTemp.Add("partner", Config.Partner);1
sParaTemp.Add("seller_email", Config.Seller_email);1
sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());1
sParaTemp.Add("service", "create_partner_trade_by_buyer");1
sParaTemp.Add("payment_type", payment_type);1
sParaTemp.Add("notify_url", notify_url);1
sParaTemp.Add("return_url", return_url);1
sParaTemp.Add("out_trade_no", out_trade_no);1
sParaTemp.Add("subject", subject);1
sParaTemp.Add("price", price);
sParaTemp.Add("quantity", quantity);
sParaTemp.Add("logistics_fee", logistics_fee);
sParaTemp.Add("logistics_type", logistics_type);
sParaTemp.Add("logistics_payment", logistics_payment);
sParaTemp.Add("body", body);1
sParaTemp.Add("show_url", show_url);1
sParaTemp.Add("receive_name", receive_name);
sParaTemp.Add("receive_address", receive_address);
sParaTemp.Add("receive_zip", receive_zip);
sParaTemp.Add("receive_phone", receive_phone);
sParaTemp.Add("receive_mobile", receive_mobile);
//建立请求
string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");
Response.Write(sHtmlText);
I check the file AliPayEscrowPaymentProcessor.cs in alipay plugin ,in Methods the source code
public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
{
//string gateway = "https://www.alipay.com/cooperate/gateway.do?";
string service = "create_direct_pay_by_user";
string seller_email = _aliPayPaymentSettings.SellerEmail;
string sign_type = "MD5";
string key = _aliPayPaymentSettings.Key;
string partner = _aliPayPaymentSettings.Partner;
string input_charset = "utf-8";
string show_url = "http://www.alipay.com/";
string out_trade_no = postProcessPaymentRequest.Order.Id.ToString();
string subject = _storeContext.CurrentStore.Name;
string body = "Order from " + _storeContext.CurrentStore.Name;
string total_fee = postProcessPaymentRequest.Order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture);
string notify_url = _webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Notify";
string return_url = _webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Return";
string[] para ={
"service="+service,
"partner=" + partner,
"seller_email=" + seller_email,
"out_trade_no=" + out_trade_no,
"subject=" + subject,
"body=" + body,
"total_fee=" + total_fee,
"show_url=" + show_url,
"payment_type=1",
"notify_url=" + notify_url,
"return_url=" + return_url,
"_input_charset=" + input_charset
};
string aliay_url = CreatUrl(
para,
input_charset,
key
);
var post = new RemotePost();
post.FormName = "alipaysubmit";
post.Url = "https://www.alipay.com/cooperate/gateway.do?_input_charset=utf-8";
post.Method = "POST";
post.Add("service", service);
post.Add("partner", partner);
post.Add("seller_email", seller_email);
post.Add("out_trade_no", out_trade_no);
post.Add("subject", subject);
post.Add("body", body);
post.Add("total_fee", total_fee);
post.Add("show_url", show_url);
post.Add("return_url", return_url);
post.Add("notify_url", notify_url);
post.Add("payment_type", "1");
post.Add("sign", aliay_url);
post.Add("sign_type", sign_type);
post.Post();
}
/// <summary>
/// Returns a value indicating whether payment method should be hidden during checkout
/// </summary>
/// <param name="cart">Shoping cart</param>
/// <returns>true - hide; false - display.</returns>
public bool HidePaymentMethod(IList<ShoppingCartItem> cart)
{
//you can put any logic here
//for example, hide this payment method if all products in the cart are downloadable
//or hide this payment method if current customer is from certain country
return false;
}
I know change the "create_direct_pay_by_user" to "create_partner_trade_by_buyer", direct pay"total_fee" is escrow pay "price"
string quantity = "1";
string logistics_fee = "0.00";
string logistics_type = "EXPRESS";
string logistics_payment = "SELLER_PAY";
but the
string receive_name =
string receive_address =
string receive_zip =
string receive_mobile =
string receive_phone =
I don't know how to define them, please give me some advice, thanks