| | |
| | | package com.yeshi.buwan.controller; |
| | | |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.user.VipUtil; |
| | | import com.yeshi.buwan.util.vip.VIPOrderUtil; |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.slf4j.Logger; |
| | |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.entity.wx.WXAPPInfo; |
| | | import org.yeshi.utils.wx.WXPayV3Util; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.crypto.Cipher; |
| | | import javax.crypto.NoSuchPaddingException; |
| | | import javax.crypto.spec.GCMParameterSpec; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.security.GeneralSecurityException; |
| | | import java.security.InvalidAlgorithmParameterException; |
| | | import java.security.InvalidKeyException; |
| | |
| | | @RequestMapping("wx") |
| | | public class WXController { |
| | | Logger logger = LoggerFactory.getLogger(WXController.class); |
| | | |
| | | @Resource |
| | | private VIPService vipService; |
| | | |
| | | private static String decryptToString(String apiV3Key, String associatedData, String nonce, String ciphertext) |
| | | throws GeneralSecurityException, IOException { |
| | |
| | | * @throws Exception |
| | | */ |
| | | private void process(HttpServletRequest request) throws Exception { |
| | | WXAPPInfo wxappInfo = new WXAPPInfo(); |
| | | WXAPPInfo wxappInfo = VipUtil.getWXAPP(); |
| | | //验证证书序列号 |
| | | String mchSerialNo = request.getHeader("Wechatpay-Serial"); |
| | | if (!mchSerialNo.equalsIgnoreCase(wxappInfo.getMchSerialNo())) { |
| | |
| | | String tradeState = decript.optString("trade_state"); |
| | | //支付成功 |
| | | if (tradeState.equalsIgnoreCase("SUCCESS")) { |
| | | boolean isPaySuccess = WXPayV3Util.isPaySuccess(outTradeNo, wxappInfo); |
| | | if (isPaySuccess) { |
| | | //TODO 支付成功 |
| | | } |
| | | String id = VIPOrderUtil.getIdFromOutOrderNo(outTradeNo); |
| | | vipService.checkOrderPayState(id); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | } |
| | | |
| | | |