@Test public void testGetActivateUrl() throws Exception { WxMpMemberCardService memberCardService = this.wxService.getMemberCardService(); ActivatePluginParam response = memberCardService.getActivatePluginParam(cardId, "test"); System.out.println(response); }
@Override public ActivatePluginParam getActivatePluginParam(String cardId, String outStr) throws WxErrorException { JsonObject params = new JsonObject(); params.addProperty("card_id", cardId); params.addProperty("outer_str", outStr); String response = this.wxMpService.post(MEMBER_CARD_ACTIVATE_URL, GSON.toJson(params)); ActivatePluginParamResult result = GSON.fromJson(response, ActivatePluginParamResult.class); if (0 == result.getErrcode()) { String url = result.getUrl(); try { String decodedUrl = URLDecoder.decode(url, "UTF-8"); Map<String, String> resultMap = parseRequestUrl(decodedUrl); ActivatePluginParam activatePluginParam = new ActivatePluginParam(); activatePluginParam.setEncryptCardId(resultMap.get("encrypt_card_id")); activatePluginParam.setOuterStr(resultMap.get("outer_str")); activatePluginParam.setBiz(resultMap.get("biz") + "=="); return activatePluginParam; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } return null; }
WxMpMemberCardServiceImpl implements WxMpMemberCardService { @Override public ActivatePluginParam getActivatePluginParam(String cardId, String outStr) throws WxErrorException { JsonObject params = new JsonObject(); params.addProperty("card_id", cardId); params.addProperty("outer_str", outStr); String response = this.wxMpService.post(MEMBER_CARD_ACTIVATE_URL, GSON.toJson(params)); ActivatePluginParamResult result = GSON.fromJson(response, ActivatePluginParamResult.class); if (0 == result.getErrcode()) { String url = result.getUrl(); try { String decodedUrl = URLDecoder.decode(url, "UTF-8"); Map<String, String> resultMap = parseRequestUrl(decodedUrl); ActivatePluginParam activatePluginParam = new ActivatePluginParam(); activatePluginParam.setEncryptCardId(resultMap.get("encrypt_card_id")); activatePluginParam.setOuterStr(resultMap.get("outer_str")); activatePluginParam.setBiz(resultMap.get("biz") + "=="); return activatePluginParam; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } return null; } }
WxMpMemberCardServiceImpl implements WxMpMemberCardService { @Override public ActivatePluginParam getActivatePluginParam(String cardId, String outStr) throws WxErrorException { JsonObject params = new JsonObject(); params.addProperty("card_id", cardId); params.addProperty("outer_str", outStr); String response = this.wxMpService.post(MEMBER_CARD_ACTIVATE_URL, GSON.toJson(params)); ActivatePluginParamResult result = GSON.fromJson(response, ActivatePluginParamResult.class); if (0 == result.getErrcode()) { String url = result.getUrl(); try { String decodedUrl = URLDecoder.decode(url, "UTF-8"); Map<String, String> resultMap = parseRequestUrl(decodedUrl); ActivatePluginParam activatePluginParam = new ActivatePluginParam(); activatePluginParam.setEncryptCardId(resultMap.get("encrypt_card_id")); activatePluginParam.setOuterStr(resultMap.get("outer_str")); activatePluginParam.setBiz(resultMap.get("biz") + "=="); return activatePluginParam; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } return null; } WxMpMemberCardServiceImpl(WxMpService wxMpService); }
WxMpMemberCardServiceImpl implements WxMpMemberCardService { @Override public ActivatePluginParam getActivatePluginParam(String cardId, String outStr) throws WxErrorException { JsonObject params = new JsonObject(); params.addProperty("card_id", cardId); params.addProperty("outer_str", outStr); String response = this.wxMpService.post(MEMBER_CARD_ACTIVATE_URL, GSON.toJson(params)); ActivatePluginParamResult result = GSON.fromJson(response, ActivatePluginParamResult.class); if (0 == result.getErrcode()) { String url = result.getUrl(); try { String decodedUrl = URLDecoder.decode(url, "UTF-8"); Map<String, String> resultMap = parseRequestUrl(decodedUrl); ActivatePluginParam activatePluginParam = new ActivatePluginParam(); activatePluginParam.setEncryptCardId(resultMap.get("encrypt_card_id")); activatePluginParam.setOuterStr(resultMap.get("outer_str")); activatePluginParam.setBiz(resultMap.get("biz") + "=="); return activatePluginParam; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } return null; } WxMpMemberCardServiceImpl(WxMpService wxMpService); @Override WxMpService getWxMpService(); @Override WxMpCardCreateResult createMemberCard(String createJson); @Override WxMpCardCreateResult createMemberCard(WxMpMemberCardCreateMessage createMessageMessage); @Override String activateMemberCard(WxMpMemberCardActivatedMessage activatedMessage); @Override WxMpMemberCardUserInfoResult getUserInfo(String cardId, String code); @Override WxMpMemberCardUpdateResult updateUserMemberCard(WxMpMemberCardUpdateMessage updateUserMessage); @Override MemberCardActivateUserFormResult setActivateUserForm(MemberCardActivateUserFormRequest userFormRequest); @Override ActivatePluginParam getActivatePluginParam(String cardId, String outStr); @Override CardUpdateResult updateCardInfo(MemberCardUpdateRequest memberCardUpdateRequest); @Override WxMpMemberCardActivateTempInfoResult getActivateTempInfo(String activateTicket); static Map<String, String> parseRequestUrl(String url); }
WxMpMemberCardServiceImpl implements WxMpMemberCardService { @Override public ActivatePluginParam getActivatePluginParam(String cardId, String outStr) throws WxErrorException { JsonObject params = new JsonObject(); params.addProperty("card_id", cardId); params.addProperty("outer_str", outStr); String response = this.wxMpService.post(MEMBER_CARD_ACTIVATE_URL, GSON.toJson(params)); ActivatePluginParamResult result = GSON.fromJson(response, ActivatePluginParamResult.class); if (0 == result.getErrcode()) { String url = result.getUrl(); try { String decodedUrl = URLDecoder.decode(url, "UTF-8"); Map<String, String> resultMap = parseRequestUrl(decodedUrl); ActivatePluginParam activatePluginParam = new ActivatePluginParam(); activatePluginParam.setEncryptCardId(resultMap.get("encrypt_card_id")); activatePluginParam.setOuterStr(resultMap.get("outer_str")); activatePluginParam.setBiz(resultMap.get("biz") + "=="); return activatePluginParam; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } return null; } WxMpMemberCardServiceImpl(WxMpService wxMpService); @Override WxMpService getWxMpService(); @Override WxMpCardCreateResult createMemberCard(String createJson); @Override WxMpCardCreateResult createMemberCard(WxMpMemberCardCreateMessage createMessageMessage); @Override String activateMemberCard(WxMpMemberCardActivatedMessage activatedMessage); @Override WxMpMemberCardUserInfoResult getUserInfo(String cardId, String code); @Override WxMpMemberCardUpdateResult updateUserMemberCard(WxMpMemberCardUpdateMessage updateUserMessage); @Override MemberCardActivateUserFormResult setActivateUserForm(MemberCardActivateUserFormRequest userFormRequest); @Override ActivatePluginParam getActivatePluginParam(String cardId, String outStr); @Override CardUpdateResult updateCardInfo(MemberCardUpdateRequest memberCardUpdateRequest); @Override WxMpMemberCardActivateTempInfoResult getActivateTempInfo(String activateTicket); static Map<String, String> parseRequestUrl(String url);  }