use of com.litingzhe.justandroid.pay.utils.AliPayUtils.v1.PayResult in project JustAndroid by chinaltz.
the class AliPayUtils method pay.
//subject 商品名称 body 商品详情 price 商品价格
public void pay(String OrderNo, String subject, String body, String price, String notifyUrl, String out_trade_no) {
if (TextUtils.isEmpty(Constants.AliAppId) || TextUtils.isEmpty(Constants.RSA_PRIVATE) || TextUtils.isEmpty(Constants.RSA_PRIVATE)) {
new AlertDialog.Builder(mContex).setTitle("警告").setMessage("需要配置PARTNER | RSA_PRIVATE| SELLER").setPositiveButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialoginterface, int i) {
//
((Activity) mContex).finish();
}
}).show();
return;
}
// 订单
final String taskProductName = subject;
final String taskProductbody = body;
final String taskProductPrice = "" + price;
final String taskNotifyUrl = notifyUrl;
final String taskoutTradeNo = "" + out_trade_no;
final String taskTradeNo = OrderNo;
AsyncTask<Void, Void, String> asyncTask = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
String orderInfo = getOrderInfo(taskTradeNo, taskProductName, taskProductbody, taskProductPrice, taskNotifyUrl, taskoutTradeNo);
Log.e("GFH", "订单信息=" + orderInfo);
// 对订单做RSA 签名
String sign = sign(orderInfo);
try {
// 仅需对sign 做URL编码
Log.e("GFH", "00=" + sign);
sign = URLEncoder.encode(sign, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
// 完整的符合支付宝参数规范的订单信息
final String payInfo = orderInfo + "&sign=\"" + sign + "\"&" + getSignType();
PayTask alipay = new PayTask((Activity) mContex);
// 调用支付接口,获取支付结果
String result = alipay.pay(payInfo, true);
return result;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
PayResult payResult = new PayResult(result);
//
//
// 支付宝返回此次支付结果及加签,建议对支付宝签名信息拿签约时支付宝提供的公钥做验签
String resultInfo = payResult.getResult();
if (callBack != null) {
callBack.onAliPayResultCallBack(payResult);
}
//
}
};
asyncTask.execute();
}
Aggregations