use of com.alipay.sdk.app.PayTask in project expression by happy-yuxuan.
the class PayDemoActivity method getSDKVersion.
/**
* get the sdk version. 获取SDK版本号
*/
public void getSDKVersion() {
PayTask payTask = new PayTask(this);
String version = payTask.getVersion();
Toast.makeText(this, version, Toast.LENGTH_SHORT).show();
}
use of com.alipay.sdk.app.PayTask in project JustAndroid by chinaltz.
the class AliPayUtils method payV2.
// subject 商品名称 body 商品详情 price 商品价格
public void payV2(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, Map<String, String>> asyncTask = new AsyncTask<Void, Void, Map<String, String>>() {
@Override
protected Map<String, String> doInBackground(Void... params) {
Map<String, String> mapParams = OrderInfoUtil2_0.buildOrderParamMap(taskTradeNo, taskProductName, taskProductbody, taskProductPrice, taskNotifyUrl, taskoutTradeNo);
String orderParam = OrderInfoUtil2_0.buildOrderParam(mapParams);
String sign = OrderInfoUtil2_0.getSign(mapParams, Constants.RSA_PRIVATE, true);
final String orderInfo = orderParam + "&" + sign;
// EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX);
PayTask alipay = new PayTask((Activity) mContex);
// 调用支付接口,获取支付结果
Map<String, String> result = alipay.payV2(orderInfo, true);
return result;
}
@Override
protected void onPostExecute(Map<String, String> s) {
super.onPostExecute(s);
PayResultV2 payResult = new PayResultV2(s);
//
// 支付宝返回此次支付结果及加签,建议对支付宝签名信息拿签约时支付宝提供的公钥做验签
String resultInfo = payResult.getResult();
if (callBackV2 != null) {
callBackV2.onAliPayResultCallBack(payResult);
}
//
}
};
asyncTask.execute();
}
use of com.alipay.sdk.app.PayTask in project RxTools by vondear.
the class AliPayTools method aliPay.
public static void aliPay(final Activity activity, String appid, boolean isRsa2, String alipay_rsa_private, AliPayModel aliPayModel, OnRequestListener onRxHttp1) {
sOnRequestListener = onRxHttp1;
Map<String, String> params = AliPayOrderInfoUtil.buildOrderParamMap(appid, isRsa2, aliPayModel.getOut_trade_no(), aliPayModel.getName(), aliPayModel.getMoney(), aliPayModel.getDetail());
String orderParam = AliPayOrderInfoUtil.buildOrderParam(params);
String privateKey = alipay_rsa_private;
String sign = AliPayOrderInfoUtil.getSign(params, privateKey, isRsa2);
final String orderInfo = orderParam + "&" + sign;
Runnable payRunnable = new Runnable() {
@Override
public void run() {
PayTask alipay = new PayTask(activity);
Map<String, String> result = alipay.payV2(orderInfo, true);
Log.i("msp", result.toString());
Message msg = new Message();
msg.what = SDK_PAY_FLAG;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
Thread payThread = new Thread(payRunnable);
payThread.start();
}
use of com.alipay.sdk.app.PayTask in project ttdj by soonphe.
the class BCPay method reqAliPaymentViaAPP.
/**
* 与服务器交互后下一步进入支付宝app支付
*
* @param responseMap 服务端返回参数
*/
private void reqAliPaymentViaAPP(final Map<String, Object> responseMap) {
String orderString = (String) responseMap.get("order_string");
PayTask aliPay = new PayTask(mContextActivity);
String aliResult = aliPay.pay(orderString, false);
// 解析ali返回结果
Pattern pattern = Pattern.compile("resultStatus=\\{(\\d+?)\\}");
Matcher matcher = pattern.matcher(aliResult);
String resCode = "";
if (matcher.find())
resCode = matcher.group(1);
String result;
int errCode;
String errMsg;
// 9000-订单支付成功, 8000-正在处理中, 4000-订单支付失败, 6001-用户中途取消, 6002-网络连接出错
String errDetail;
if (resCode.equals("9000")) {
result = BCPayResult.RESULT_SUCCESS;
errCode = BCPayResult.APP_PAY_SUCC_CODE;
errMsg = BCPayResult.RESULT_SUCCESS;
errDetail = errMsg;
} else if (resCode.equals("6001")) {
result = BCPayResult.RESULT_CANCEL;
errCode = BCPayResult.APP_PAY_CANCEL_CODE;
errMsg = BCPayResult.RESULT_CANCEL;
errDetail = errMsg;
} else if (resCode.equals("8000")) {
result = BCPayResult.RESULT_UNKNOWN;
errCode = BCPayResult.APP_INTERNAL_THIRD_CHANNEL_ERR_CODE;
errMsg = BCPayResult.RESULT_PAYING_UNCONFIRMED;
errDetail = "订单正在处理中,无法获取成功确认信息";
} else {
result = BCPayResult.RESULT_FAIL;
errCode = BCPayResult.APP_INTERNAL_THIRD_CHANNEL_ERR_CODE;
errMsg = BCPayResult.FAIL_ERR_FROM_CHANNEL;
if (resCode.equals("4000"))
errDetail = "订单支付失败";
else
errDetail = "网络连接出错";
}
if (payCallback != null) {
payCallback.done(new BCPayResult(result, errCode, errMsg, errDetail, BCCache.getInstance().billID));
}
}
use of com.alipay.sdk.app.PayTask in project RxTools by vondear.
the class AliPayTool method aliPay.
public static void aliPay(final Activity activity, String appid, boolean isRsa2, String alipay_rsa_private, AliPayModel aliPayModel, OnSuccessAndErrorListener onRxHttp1) {
sOnSuccessAndErrorListener = onRxHttp1;
Map<String, String> params = AliPayOrderTool.buildOrderParamMap(appid, isRsa2, aliPayModel.getOutTradeNo(), aliPayModel.getName(), aliPayModel.getMoney(), aliPayModel.getDetail());
String orderParam = AliPayOrderTool.buildOrderParam(params);
String privateKey = alipay_rsa_private;
String sign = AliPayOrderTool.getSign(params, privateKey, isRsa2);
final String orderInfo = orderParam + "&" + sign;
Runnable payRunnable = new Runnable() {
@Override
public void run() {
PayTask alipay = new PayTask(activity);
Map<String, String> result = alipay.payV2(orderInfo, true);
TLog.i("msp", result.toString());
Message msg = new Message();
msg.what = SDK_PAY_FLAG;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
Thread payThread = new Thread(payRunnable);
payThread.start();
}
Aggregations