use of com.baidu.android.pay.PayCallBack in project ttdj by soonphe.
the class BCPay method reqBaiduPaymentViaAPP.
/**
* 与服务器交互后下一步进入百度app支付
*
* @param responseMap 服务端返回参数
*/
private void reqBaiduPaymentViaAPP(final Map<String, Object> responseMap) {
String orderInfo = (String) responseMap.get("orderInfo");
// Log.w(TAG, orderInfo);
Map<String, String> map = new HashMap<String, String>();
baiduPay = BaiduPay.getInstance();
baiduPay.doPay(mContextActivity, orderInfo, new PayCallBack() {
public void onPayResult(int stateCode, String payDesc) {
// Log.w(TAG, "rsult=" + stateCode + "#desc=" + payDesc);
String result;
int errCode;
String errMsg;
String errDetail;
switch(stateCode) {
case // 需要到服务端验证支付结果
PayCallBackManager.PayStateModle.PAY_STATUS_SUCCESS:
result = BCPayResult.RESULT_SUCCESS;
errCode = BCPayResult.APP_PAY_SUCC_CODE;
errMsg = BCPayResult.RESULT_SUCCESS;
errDetail = errMsg;
break;
case // 需要到服务端验证支付结果
PayCallBackManager.PayStateModle.PAY_STATUS_PAYING:
result = BCPayResult.RESULT_UNKNOWN;
errCode = BCPayResult.APP_INTERNAL_THIRD_CHANNEL_ERR_CODE;
errMsg = BCPayResult.RESULT_PAYING_UNCONFIRMED;
errDetail = "订单正在处理中,无法获取成功确认信息";
break;
case PayCallBackManager.PayStateModle.PAY_STATUS_CANCEL:
result = BCPayResult.RESULT_CANCEL;
errCode = BCPayResult.APP_PAY_CANCEL_CODE;
errDetail = errMsg = BCPayResult.RESULT_CANCEL;
break;
case PayCallBackManager.PayStateModle.PAY_STATUS_NOSUPPORT:
result = BCPayResult.RESULT_FAIL;
errCode = BCPayResult.APP_INTERNAL_THIRD_CHANNEL_ERR_CODE;
errMsg = BCPayResult.FAIL_ERR_FROM_CHANNEL;
errDetail = "不支持该种支付方式";
break;
case PayCallBackManager.PayStateModle.PAY_STATUS_TOKEN_INVALID:
result = BCPayResult.RESULT_FAIL;
errCode = BCPayResult.APP_INTERNAL_THIRD_CHANNEL_ERR_CODE;
errMsg = BCPayResult.FAIL_ERR_FROM_CHANNEL;
errDetail = "无效的登陆状态";
break;
case PayCallBackManager.PayStateModle.PAY_STATUS_LOGIN_ERROR:
result = BCPayResult.RESULT_FAIL;
errCode = BCPayResult.APP_INTERNAL_THIRD_CHANNEL_ERR_CODE;
errMsg = BCPayResult.FAIL_ERR_FROM_CHANNEL;
errDetail = "登陆失败";
break;
case PayCallBackManager.PayStateModle.PAY_STATUS_ERROR:
result = BCPayResult.RESULT_FAIL;
errCode = BCPayResult.APP_INTERNAL_THIRD_CHANNEL_ERR_CODE;
errMsg = BCPayResult.FAIL_ERR_FROM_CHANNEL;
errDetail = "支付失败";
break;
case PayCallBackManager.PayStateModle.PAY_STATUS_LOGIN_OUT:
result = BCPayResult.RESULT_FAIL;
errCode = BCPayResult.APP_INTERNAL_THIRD_CHANNEL_ERR_CODE;
errMsg = BCPayResult.FAIL_ERR_FROM_CHANNEL;
errDetail = "退出登录";
break;
default:
result = BCPayResult.RESULT_FAIL;
errCode = BCPayResult.APP_INTERNAL_THIRD_CHANNEL_ERR_CODE;
errMsg = BCPayResult.FAIL_ERR_FROM_CHANNEL;
errDetail = "支付失败";
break;
}
if (payCallback != null) {
payCallback.done(new BCPayResult(result, errCode, errMsg, errDetail + "#result=" + stateCode + "#desc=" + payDesc, BCCache.getInstance().billID));
}
}
public boolean isHideLoadingDialog() {
return true;
}
}, map);
}
Aggregations