浏览代码

wx pay get app_id from payload json

billyyoyo 6 年之前
父节点
当前提交
4698fcc052

+ 1 - 2
app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java

@@ -420,8 +420,7 @@ public class KFZSJs {
                 G.showToast(R.string.please_contact_customer_service);
                 return;
             }
-            String attach = jsonObject.getString("attach").split("_")[1];
-            CommonUtil.getInstance().wxpay(SheepApp.getInstance().getWxApi(activity, attach), jsonObject);
+            CommonUtil.getInstance().wxpay(SheepApp.getInstance().getWxApi(activity, jsonObject.getString("appid")), jsonObject);
         }
     }
 

+ 1 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/ActPay.java

@@ -189,8 +189,7 @@ public class ActPay extends BaseActivity {
                             QQUtil.saveWxPayOrderNo(SheepApp.getInstance(), jsonObject.getString("prepayid"), order_no);
                             QQUtil.saveWxPayOrient(SheepApp.getInstance(), jsonObject.getString("prepayid"), from_orient);
                         }
-                        String attach = jsonObject.getString("attach").split("_")[1];
-                        CommonUtil.getInstance().wxpay(SheepApp.getInstance().getWxApi(ActPay.this, attach), jsonObject);
+                        CommonUtil.getInstance().wxpay(SheepApp.getInstance().getWxApi(ActPay.this, jsonObject.getString("appid")), jsonObject);
                         finish();
                     }
                 });

+ 1 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/RechargeAct.java

@@ -331,11 +331,10 @@ public class RechargeAct extends BaseActivity {
             G.showToast(R.string.please_contact_customer_service);
             return;
         }
-        String attach = jsonObject.getString("attach").split("_")[1];
         QQUtil.saveWxPayFrom(SheepApp.getInstance(), jsonObject.getString("prepayid"), fromPackage);
         QQUtil.saveWxPayOrderNo(SheepApp.getInstance(), jsonObject.getString("prepayid"), "");
         QQUtil.saveWxPayOrient(SheepApp.getInstance(), jsonObject.getString("prepayid"), fromOrient);
-        CommonUtil.getInstance().wxpay(SheepApp.getInstance().getWxApi(this, attach), jsonObject);
+        CommonUtil.getInstance().wxpay(SheepApp.getInstance().getWxApi(this, jsonObject.getString("appid")), jsonObject);
         finish();
     }
 

+ 0 - 4
app/src/main/java/com/sheep/jiuyan/samllsheep/Config.java

@@ -132,10 +132,6 @@ public class Config {
         return url;
     }
 
-    //微信支付app_id
-    public static final String WX_PAY_APP_ID = "wx427e8e74e8dd27a6";
-    public static final String WX_PAY_APP_ID2 = "wx6ec1ec1732a9cfc0";
-
     public static final String WX_AUTH_APP_ID = "wx2be7f59bb7bb963f";
     public static final String QQ_APP_ID = "101461115";
 

+ 2 - 3
app/src/main/java/com/sheep/jiuyan/samllsheep/SheepApp.java

@@ -325,11 +325,10 @@ public class SheepApp extends MultiDexApplication {
         return wxApi;
     }
 
-    public IWXAPI getWxApi(Context context, String flag) {
-        String appid = "1".equals(flag) ? Config.WX_PAY_APP_ID : Config.WX_PAY_APP_ID2;
+    public IWXAPI getWxApi(Context context, String wxAppId) {
         wxApi = WXAPIFactory.createWXAPI(context, null);
         // 将该app注册到微信
-        wxApi.registerApp(appid);
+        wxApi.registerApp(wxAppId);
         return wxApi;
     }
 

+ 3 - 3
app/src/main/java/com/sheep/jiuyan/samllsheep/utils/G.java

@@ -82,7 +82,7 @@ public class G {
     public static void shortToast(BaseMessage msg) {
         if (TextUtils.isEmpty(msg.getMsg())) {
             G.shortToast(SheepApp.getInstance().getString(R.string.unknown_error));
-        } else if(msg.getCode() == 404 || msg.getCode() == 503) {
+        } else if (msg.getCode() == 404 || msg.getCode() == 503) {
             G.shortToast("错误: " + msg.getCode());
         } else {
             G.shortToast(msg.getMsg() + (BuildConfig.DEBUG ? "[" + msg.getCode() + "]" : ""));
@@ -104,10 +104,10 @@ public class G {
     public static void showToast(BaseMessage baseMessage) {
         if (TextUtils.isEmpty(baseMessage.getMsg())) {
             G.showToast(R.string.unknown_error);
-        } else if(baseMessage.getCode() == 404 || baseMessage.getCode() == 503) {
+        } else if (baseMessage.getCode() == 404 || baseMessage.getCode() == 503) {
             G.shortToast("错误: " + baseMessage.getCode());
         } else {
-            G.showToast(baseMessage.getMsg() + (BuildConfig.DEBUG ? "[" + baseMessage.getCode() + "]" : ""));
+            G.showToast(baseMessage.getMsg() + "[" + baseMessage.getCode() + "]");
         }
     }