参考支付宝官方的demo配置的方法,亲测可行.
public object GetPayInfo(string _amount)//_amount:付款金额
{
string orderInfo = OrderInfo(_amount);
// 对订单做RSA 签名
string sign = RSAFromPkcs8.sign(orderInfo, Config.Private_key, Config.Input_charset); //支付宝提供的Config.cs
//仅需对sign做URL编码
sign = HttpUtility.UrlEncode(sign, Encoding.UTF8);
string payInfo = orderInfo + "&sign=\"" + sign + "\"&"
+ getSignType();
return payInfo;
}
public string OrderInfo(string price)
{
Dictionary<string, string> payinfo = new Dictionary<string, string>();
payinfo.Add("service", "\"mobile.securitypay.pay\"");
payinfo.Add("partner", "\"" + Config.Partner + "\"");
payinfo.Add("seller_id", "\"" + Config.SELLER + "\"");
payinfo.Add("out_trade_no", "\"" + DateTime.Now.ToString("yyyyMMddHHmmssfff")+ "\"");
payinfo.Add("subject", "\"****\"");
payinfo.Add("body", "\"*****\"");
payinfo.Add("total_fee", "\"" + price.ToString() + "\"");
payinfo.Add("notify_url", "\"***********"");
payinfo.Add("payment_type", "\"1\"");
payinfo.Add("_input_charset", "\"UTF-8\"");
payinfo.Add("it_b_pay", "\"30m\"");
return Core.CreateLinkString(payinfo);
}
public String getSignType()
{
return "sign_type=\"RSA\"";
}
HB中的方法
function topay(rate) {
if (w) {
return;
}
//检查是否请求订单中
w = plus.nativeUI.showWaiting();
mui.getJSON("http://************/api/Pay", {
_amount: rate
}, function(data) {
w.close();
w = null;
if (data) {
plus.payment.request(pays["alipay"], data, function(result) {
plus.nativeUI.alert("支付成功:感谢您的支持。", function() {
mui.back();
}, "****");
}, function(error) {
if (error.code == 62001) {
mui.toast("您放弃支付.");
mui.back();
} else {
plus.nativeUI.alert("支付失败", null, "请前往会员中心再次对该订单尝试支付,支付失败:" + error.code);
}
});
}
});
}
22 个评论
要回复文章请先登录或注册
h***@126.com
阿鱼
3***@qq.com
木记 (作者)
4***@qq.com
4***@qq.com
4***@qq.com
游帝2015
4***@qq.com
书晨