@Test public void testCreateCardApiSignature() throws Exception { String[] param = {"123", this.cardId, "", this.code, this.openid, ""}; WxCardApiSignature cardApiSignature = this.wxService.getCardService().createCardApiSignature(param); assertNotNull(cardApiSignature); System.out.println(cardApiSignature); }
@Override public WxCardApiSignature createCardApiSignature(String... optionalSignParam) throws WxErrorException { long timestamp = System.currentTimeMillis() / 1000; String nonceStr = RandomUtils.getRandomStr(); String cardApiTicket = getCardApiTicket(false); String[] signParam = Arrays.copyOf(optionalSignParam, optionalSignParam.length + 3); signParam[optionalSignParam.length] = String.valueOf(timestamp); signParam[optionalSignParam.length + 1] = nonceStr; signParam[optionalSignParam.length + 2] = cardApiTicket; String signature = SHA1.gen(signParam); WxCardApiSignature cardApiSignature = new WxCardApiSignature(); cardApiSignature.setTimestamp(timestamp); cardApiSignature.setNonceStr(nonceStr); cardApiSignature.setSignature(signature); return cardApiSignature; }
WxMpCardServiceImpl implements WxMpCardService { @Override public WxCardApiSignature createCardApiSignature(String... optionalSignParam) throws WxErrorException { long timestamp = System.currentTimeMillis() / 1000; String nonceStr = RandomUtils.getRandomStr(); String cardApiTicket = getCardApiTicket(false); String[] signParam = Arrays.copyOf(optionalSignParam, optionalSignParam.length + 3); signParam[optionalSignParam.length] = String.valueOf(timestamp); signParam[optionalSignParam.length + 1] = nonceStr; signParam[optionalSignParam.length + 2] = cardApiTicket; String signature = SHA1.gen(signParam); WxCardApiSignature cardApiSignature = new WxCardApiSignature(); cardApiSignature.setTimestamp(timestamp); cardApiSignature.setNonceStr(nonceStr); cardApiSignature.setSignature(signature); return cardApiSignature; } }
WxMpCardServiceImpl implements WxMpCardService { @Override public WxCardApiSignature createCardApiSignature(String... optionalSignParam) throws WxErrorException { long timestamp = System.currentTimeMillis() / 1000; String nonceStr = RandomUtils.getRandomStr(); String cardApiTicket = getCardApiTicket(false); String[] signParam = Arrays.copyOf(optionalSignParam, optionalSignParam.length + 3); signParam[optionalSignParam.length] = String.valueOf(timestamp); signParam[optionalSignParam.length + 1] = nonceStr; signParam[optionalSignParam.length + 2] = cardApiTicket; String signature = SHA1.gen(signParam); WxCardApiSignature cardApiSignature = new WxCardApiSignature(); cardApiSignature.setTimestamp(timestamp); cardApiSignature.setNonceStr(nonceStr); cardApiSignature.setSignature(signature); return cardApiSignature; } WxMpCardServiceImpl(WxMpService wxMpService); }
WxMpCardServiceImpl implements WxMpCardService { @Override public WxCardApiSignature createCardApiSignature(String... optionalSignParam) throws WxErrorException { long timestamp = System.currentTimeMillis() / 1000; String nonceStr = RandomUtils.getRandomStr(); String cardApiTicket = getCardApiTicket(false); String[] signParam = Arrays.copyOf(optionalSignParam, optionalSignParam.length + 3); signParam[optionalSignParam.length] = String.valueOf(timestamp); signParam[optionalSignParam.length + 1] = nonceStr; signParam[optionalSignParam.length + 2] = cardApiTicket; String signature = SHA1.gen(signParam); WxCardApiSignature cardApiSignature = new WxCardApiSignature(); cardApiSignature.setTimestamp(timestamp); cardApiSignature.setNonceStr(nonceStr); cardApiSignature.setSignature(signature); return cardApiSignature; } WxMpCardServiceImpl(WxMpService wxMpService); @Override WxMpService getWxMpService(); @Override String getCardApiTicket(); @Override String getCardApiTicket(boolean forceRefresh); @Override WxCardApiSignature createCardApiSignature(String... optionalSignParam); @Override String decryptCardCode(String encryptCode); @Override WxMpCardResult queryCardCode(String cardId, String code, boolean checkConsume); @Override String consumeCardCode(String code); @Override String consumeCardCode(String code, String cardId); @Override void markCardCode(String code, String cardId, String openId, boolean isMark); @Override String getCardDetail(String cardId); @Override String addTestWhiteList(String openid); @Override WxMpCardCreateResult createCard(WxMpCardCreateMessage cardCreateMessage); @Override WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr); @Override WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr, int expiresIn); @Override WxMpCardLandingPageCreateResult createLandingPage(WxMpCardLandingPageCreateRequest request); @Override String unavailableCardCode(String cardId, String code, String reason); @Override WxMpCardDeleteResult deleteCard(String cardId); }
WxMpCardServiceImpl implements WxMpCardService { @Override public WxCardApiSignature createCardApiSignature(String... optionalSignParam) throws WxErrorException { long timestamp = System.currentTimeMillis() / 1000; String nonceStr = RandomUtils.getRandomStr(); String cardApiTicket = getCardApiTicket(false); String[] signParam = Arrays.copyOf(optionalSignParam, optionalSignParam.length + 3); signParam[optionalSignParam.length] = String.valueOf(timestamp); signParam[optionalSignParam.length + 1] = nonceStr; signParam[optionalSignParam.length + 2] = cardApiTicket; String signature = SHA1.gen(signParam); WxCardApiSignature cardApiSignature = new WxCardApiSignature(); cardApiSignature.setTimestamp(timestamp); cardApiSignature.setNonceStr(nonceStr); cardApiSignature.setSignature(signature); return cardApiSignature; } WxMpCardServiceImpl(WxMpService wxMpService); @Override WxMpService getWxMpService(); @Override String getCardApiTicket(); @Override String getCardApiTicket(boolean forceRefresh); @Override WxCardApiSignature createCardApiSignature(String... optionalSignParam); @Override String decryptCardCode(String encryptCode); @Override WxMpCardResult queryCardCode(String cardId, String code, boolean checkConsume); @Override String consumeCardCode(String code); @Override String consumeCardCode(String code, String cardId); @Override void markCardCode(String code, String cardId, String openId, boolean isMark); @Override String getCardDetail(String cardId); @Override String addTestWhiteList(String openid); @Override WxMpCardCreateResult createCard(WxMpCardCreateMessage cardCreateMessage); @Override WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr); @Override WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr, int expiresIn); @Override WxMpCardLandingPageCreateResult createLandingPage(WxMpCardLandingPageCreateRequest request); @Override String unavailableCardCode(String cardId, String code, String reason); @Override WxMpCardDeleteResult deleteCard(String cardId);  }