| | |
| | | import com.java110.core.factory.CommunitySettingFactory; |
| | | import com.java110.core.factory.PlutusFactory; |
| | | import com.java110.core.factory.WechatFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.owner.OwnerAppUserDto; |
| | | import com.java110.dto.smallWeChat.SmallWeChatDto; |
| | | import com.java110.utils.cache.MappingCache; |
| | |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.bouncycastle.util.encoders.Base64; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.client.RestTemplate; |
| | |
| | | |
| | | //微信支付 |
| | | public static final String PAY_UNIFIED_ORDER_URL = "https://api.plutuspay.com/open/v2/jsPay"; |
| | | public static final String PAY_UNIFIED_ORDER_NATIVE_URL = "https://api.plutuspay.com/open/v2/preCreate"; |
| | | |
| | | |
| | | private static final String VERSION = "1.0"; |
| | |
| | | |
| | | logger.debug("调用支付统一下单接口" + paramMap.toJSONString()); |
| | | String privateKey = CommunitySettingFactory.getRemark(smallWeChatDto.getObjId(), "PLUTUS_PRIVATE_KEY"); |
| | | String param = PlutusFactory.Encryption(paramMap.toJSONString(), privateKey, smallWeChatDto.getPayPassword()); |
| | | System.out.println(param); |
| | | String devId = CommunitySettingFactory.getValue(smallWeChatDto.getObjId(), "PLUTUS_DEV_ID"); |
| | | |
| | | String str = PlutusFactory.post(wechatAuthProperties.getWxPayUnifiedOrder(), param); |
| | | String param = PlutusFactory.Encryption(paramMap.toJSONString(), privateKey, smallWeChatDto.getPayPassword(), devId); |
| | | System.out.println(param); |
| | | String str = ""; |
| | | if (WechatAuthProperties.TRADE_TYPE_NATIVE.equals(tradeType)) { |
| | | str = PlutusFactory.post(PAY_UNIFIED_ORDER_NATIVE_URL, param); |
| | | } else { |
| | | str = PlutusFactory.post(PAY_UNIFIED_ORDER_URL, param); |
| | | } |
| | | System.out.println(str); |
| | | |
| | | JSONObject json = JSON.parseObject(str); |
| | |
| | | throw new IllegalArgumentException("支付失败签名失败"); |
| | | } |
| | | //解密 |
| | | byte[] bb = PlutusFactory.decrypt(Base64.decode(content), PlutusFactory.SECRET_KEY); |
| | | byte[] bb = PlutusFactory.decrypt(Base64.decode(content), smallWeChatDto.getPayPassword()); |
| | | //服务器返回内容 |
| | | String paramOut = new String(bb); |
| | | |
| | | JSONObject paramObj = JSONObject.parseObject(paramOut); |
| | | logger.debug("统一下单返回" + paramOut); |
| | | |
| | | if (paramObj.getString("paramObj") != "00") { |
| | | if (!"00".equals(paramObj.getString("status"))) { |
| | | throw new IllegalArgumentException("支付失败" + paramObj.getString("error")); |
| | | } |
| | | |
| | | return paramObj.getJSONObject("payInfo"); |
| | | if (WechatAuthProperties.TRADE_TYPE_NATIVE.equals(tradeType)) { |
| | | paramObj.put("code", 0); |
| | | return paramObj; |
| | | } else { |
| | | return paramObj.getJSONObject("payInfo"); |
| | | } |
| | | } |
| | | |
| | | |