Пример #1
0
 /** ************MSDK API调用示例************* */
 public String callWGGetLoginRecord() {
   LoginRet ret = new LoginRet();
   int platform = WGPlatform.WGGetLoginRecord(ret);
   String result = "";
   if (platform == WeGame.WXPLATID) {
     result += "platform = " + ret.platform + " 微信登录 \n";
     result +=
         "accessToken = "
             + WeGame.getInstance().getLocalTokenByType(TokenType.eToken_WX_Access)
             + "\n";
     result +=
         "refreshToken = "
             + WeGame.getInstance().getLocalTokenByType(TokenType.eToken_WX_Refresh)
             + "\n";
   }
   result += "openid = " + ret.open_id + "\n";
   result += "flag = " + ret.flag + "\n";
   result += "desc = " + ret.desc + "\n";
   result += "pf = " + ret.pf + "\n";
   result += "pf_key = " + ret.pf_key + "\n";
   return result;
 }
Пример #2
0
  public void launchPaySample() {
    Intent i = new Intent("com.tencent.pay.sdksample.AndroidPaySample");

    LoginRet lr = new LoginRet();
    WGPlatform.WGGetLoginRecord(lr);
    if (lr.flag == CallbackFlag.eFlag_Succ) {
      i.putExtra("userId", lr.open_id);
      i.putExtra("offerId", WeGame.getInstance().offerId);
      if (lr.platform == WeGame.WXPLATID) {
        i.putExtra("userKey", lr.getTokenByType(TokenType.eToken_WX_Access));
        i.putExtra("sessionType", "wc_actoken");
        i.putExtra("sessionId", "hy_gameid");
      } else if (lr.platform == WeGame.QQPLATID) {
        i.putExtra("userKey", lr.getTokenByType(TokenType.eToken_QQ_Pay));
        i.putExtra("sessionType", "kp_actoken");
        i.putExtra("sessionId", "openid");
      }

      i.putExtra("pf", WGPlatform.WGGetPf(""));
      i.putExtra("zoneId", "1");
      i.putExtra("pfKey", WGPlatform.WGGetPfKey());
      i.putExtra("acctType", "common");
      i.putExtra("saveValue", "60");
      i.putExtra("msdk", true);
      try {
        mMainActivity.startActivity(i);
      } catch (ActivityNotFoundException e) {
        AlertDialog.Builder builder = new AlertDialog.Builder(mMainActivity);
        builder.setTitle("拉起支付失败说明");
        String msg =
            "1、支付接口具体调用方法请直接参照TencentMidasV2.3.9d_android_插件版_20150123.zip中进行接入\r\n"
                + "2、每个接口需要的相应参数请通过WGPlatform.WGGetLoginRecord进行获取";
        builder.setMessage(msg);
        builder.setNeutralButton(android.R.string.ok, null);
        builder.create().show();
      }
    }
  }