128 lines
4.1 KiB
Java
128 lines
4.1 KiB
Java
package com.sl.house_property;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.app.AlertDialog;
|
|
import android.app.ProgressDialog;
|
|
import android.content.DialogInterface;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.os.Message;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import android.view.View;
|
|
import android.widget.Toast;
|
|
|
|
import com.alipay.sdk.app.PayTask;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.internal.LinkedTreeMap;
|
|
import com.sl.house_property.databinding.ActivityCarrageBinding;
|
|
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Random;
|
|
|
|
import entity.RegisterUser;
|
|
import entity.RentEntity;
|
|
import http.ApiConfig;
|
|
import my_loader.Loader;
|
|
import my_loader.Resultcode;
|
|
import my_view.ConfirmCarmoneyDialog;
|
|
import pay.alipay.AliPayManager;
|
|
import rx.Subscription;
|
|
import rx.functions.Action1;
|
|
import tools.Config;
|
|
import pay.alipay.AuthResult;
|
|
import utils.Md5;
|
|
import pay.alipay.OrderInfoUtil2_0;
|
|
import pay.alipay.PayResult;
|
|
|
|
|
|
public class AliPayTestActivity extends BaseActivity<ActivityCarrageBinding> {
|
|
|
|
private static final int SDK_PAY_FLAG = 1;
|
|
private static final int SDK_AUTH_FLAG = 2;
|
|
|
|
private ProgressDialog progressDialog;
|
|
private Loader mGankLoader;
|
|
|
|
|
|
private void getAliPayConfigData() {
|
|
RegisterUser user =
|
|
Config.getInstance(AliPayTestActivity.this).getUser();
|
|
Map<String, String> map = new HashMap<>();
|
|
if (user != null) {
|
|
map.put("userid", user.getUserid());
|
|
} else {
|
|
map.put("userid", 0 + "");
|
|
}
|
|
map.put("app", "System");
|
|
map.put("class", "System_an_ALiPayment");
|
|
map.put("sign", Md5.md5("System" + "System_an_ALiPayment" + Md5.secret));
|
|
|
|
getTempGarageData(ApiConfig.BASE_URL, map, getResources().getString(R.string.requsting));
|
|
}
|
|
|
|
private void getTempGarageData(String myurl, Map<String, String> map, String msg) {
|
|
progressDialog.setMessage(msg);
|
|
progressDialog.setCancelable(false);
|
|
progressDialog.show();
|
|
mGankLoader = new Loader();
|
|
Subscription subscription = mGankLoader.getMovie(myurl, map).subscribe(new Action1<Resultcode>() {
|
|
@Override
|
|
public void call(Resultcode resultcode) {
|
|
progressDialog.dismiss();
|
|
if (!(resultcode.status == 0)) {
|
|
setToast(1, resultcode.msg);
|
|
}
|
|
if (resultcode.status == 0) {
|
|
Gson gs = new Gson();
|
|
LinkedTreeMap adta = (LinkedTreeMap) resultcode.data;
|
|
String s = gs.toJson(adta);
|
|
ArrayList<RentEntity> list = null;
|
|
try {
|
|
JSONObject jsonObject = new JSONObject(s);
|
|
JSONObject playmentJsonObj = jsonObject.getJSONObject("payment");
|
|
String APPID = playmentJsonObj.getString("partner");
|
|
String PID = playmentJsonObj.getString("seller");
|
|
String RSA2_PRIVATE = playmentJsonObj.getString("privateKey");
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|
|
}, new Action1<Throwable>() {
|
|
@Override
|
|
public void call(Throwable throwable) {
|
|
progressDialog.dismiss();
|
|
|
|
setToast(2, getString(R.string.getdatafailure));
|
|
throwable.printStackTrace();
|
|
}
|
|
});
|
|
|
|
addSubscription(subscription);
|
|
}
|
|
|
|
|
|
@Override
|
|
protected int getLayoutResId() {
|
|
return R.layout.alipay_demo;
|
|
}
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
progressDialog = new ProgressDialog(this);
|
|
getAliPayConfigData();
|
|
}
|
|
|
|
public void testAlipay(View view) {
|
|
AliPayManager aliPayManager = new AliPayManager(this);
|
|
aliPayManager.startPay("充值", "个人", Math.abs(new Random().nextLong()) + "", "0.01", "http://www.baidu.com");
|
|
}
|
|
} |