@Test public void testUnifiedOrder(){ UnifiedOrderRequest unifiedOrderRequest = new UnifiedOrderRequest(); unifiedOrderRequest.setBody("牛奶 小号"); unifiedOrderRequest.setDetail("小号牛奶 鲜奶"); unifiedOrderRequest.setTradeNumber("1292063901201605160012300016"); unifiedOrderRequest.setTotalFee(100); unifiedOrderRequest.setBillCreatedIp("192.168.1.103"); unifiedOrderRequest.setNotifyUrl("http: unifiedOrderRequest.setTradeType("JSAPI"); unifiedOrderRequest.setOpenId("oELhlt7Q-lRmLbRsPsaKeVX6pqjg"); UnifiedOrderResponse response = Payments.defaultPayments().unifiedOrder(unifiedOrderRequest); Assert.assertNotNull(response); }
public UnifiedOrderResponse unifiedOrder(UnifiedOrderRequest unifiedOrderRequest) { UnifiedOrderRequestWrapper wrapper = new UnifiedOrderRequestWrapper(); wrapper.setRequest(unifiedOrderRequest); setBaseSettings(wrapper); SortedMap<String, Object> unifiedOrderRequestMap = JsonMapper.nonEmptyMapper().getMapper().convertValue(wrapper, SortedMap.class); sign(wrapper, unifiedOrderRequestMap); String url = WxEndpoint.get("url.pay.payment.order.unified"); try { String xml = XmlObjectMapper.nonEmptyMapper().toXml(wrapper); logger.info("支付 unified order request: {}", xml); String response = wxSslClient.post(url, xml); logger.info("支付 unified order response: {}", response); UnifiedOrderResponseWrapper responseWrapper = XmlObjectMapper.defaultMapper().fromXml(response, UnifiedOrderResponseWrapper.class); return responseWrapper.getResponse(); } catch (Exception e) { throw new WxRuntimeException(999, "pre order failed:" + e.getMessage()); } }
Payments { public UnifiedOrderResponse unifiedOrder(UnifiedOrderRequest unifiedOrderRequest) { UnifiedOrderRequestWrapper wrapper = new UnifiedOrderRequestWrapper(); wrapper.setRequest(unifiedOrderRequest); setBaseSettings(wrapper); SortedMap<String, Object> unifiedOrderRequestMap = JsonMapper.nonEmptyMapper().getMapper().convertValue(wrapper, SortedMap.class); sign(wrapper, unifiedOrderRequestMap); String url = WxEndpoint.get("url.pay.payment.order.unified"); try { String xml = XmlObjectMapper.nonEmptyMapper().toXml(wrapper); logger.info("支付 unified order request: {}", xml); String response = wxSslClient.post(url, xml); logger.info("支付 unified order response: {}", response); UnifiedOrderResponseWrapper responseWrapper = XmlObjectMapper.defaultMapper().fromXml(response, UnifiedOrderResponseWrapper.class); return responseWrapper.getResponse(); } catch (Exception e) { throw new WxRuntimeException(999, "pre order failed:" + e.getMessage()); } } }
Payments { public UnifiedOrderResponse unifiedOrder(UnifiedOrderRequest unifiedOrderRequest) { UnifiedOrderRequestWrapper wrapper = new UnifiedOrderRequestWrapper(); wrapper.setRequest(unifiedOrderRequest); setBaseSettings(wrapper); SortedMap<String, Object> unifiedOrderRequestMap = JsonMapper.nonEmptyMapper().getMapper().convertValue(wrapper, SortedMap.class); sign(wrapper, unifiedOrderRequestMap); String url = WxEndpoint.get("url.pay.payment.order.unified"); try { String xml = XmlObjectMapper.nonEmptyMapper().toXml(wrapper); logger.info("支付 unified order request: {}", xml); String response = wxSslClient.post(url, xml); logger.info("支付 unified order response: {}", response); UnifiedOrderResponseWrapper responseWrapper = XmlObjectMapper.defaultMapper().fromXml(response, UnifiedOrderResponseWrapper.class); return responseWrapper.getResponse(); } catch (Exception e) { throw new WxRuntimeException(999, "pre order failed:" + e.getMessage()); } }  }
Payments { public UnifiedOrderResponse unifiedOrder(UnifiedOrderRequest unifiedOrderRequest) { UnifiedOrderRequestWrapper wrapper = new UnifiedOrderRequestWrapper(); wrapper.setRequest(unifiedOrderRequest); setBaseSettings(wrapper); SortedMap<String, Object> unifiedOrderRequestMap = JsonMapper.nonEmptyMapper().getMapper().convertValue(wrapper, SortedMap.class); sign(wrapper, unifiedOrderRequestMap); String url = WxEndpoint.get("url.pay.payment.order.unified"); try { String xml = XmlObjectMapper.nonEmptyMapper().toXml(wrapper); logger.info("支付 unified order request: {}", xml); String response = wxSslClient.post(url, xml); logger.info("支付 unified order response: {}", response); UnifiedOrderResponseWrapper responseWrapper = XmlObjectMapper.defaultMapper().fromXml(response, UnifiedOrderResponseWrapper.class); return responseWrapper.getResponse(); } catch (Exception e) { throw new WxRuntimeException(999, "pre order failed:" + e.getMessage()); } }  void setPaySetting(PaySetting paySetting); static Payments defaultPayments(); static Payments with(PaySetting paySetting); void setWxSslClient(WxSslClient wxSslClient); UnifiedOrderResponse unifiedOrder(UnifiedOrderRequest unifiedOrderRequest); com.riversoft.weixin.pay.payment.bean.OrderQueryResponse query(com.riversoft.weixin.pay.payment.bean.OrderQueryRequest orderQueryRequest); BaseResponse close(String tradeNumber); boolean checkSignature(PaymentNotification notification); RefundResponse refund(RefundRequest refundRequest); RefundQuery refundQueryByTransactionId(String transactionId); RefundQuery refundQueryByTradeNumber(String tradeNumber); RefundQuery refundQueryByRefundNumber(String refundNumber); RefundQuery refundQueryByRefundId(String refundId); RefundQuery refundQuery(RefundQueryRequestWrapper refundQueryRequestWrapper); String downloadAllBill(Date date); String downloadRefundBill(Date date); String downloadSuccessBill(Date date); }
Payments { public UnifiedOrderResponse unifiedOrder(UnifiedOrderRequest unifiedOrderRequest) { UnifiedOrderRequestWrapper wrapper = new UnifiedOrderRequestWrapper(); wrapper.setRequest(unifiedOrderRequest); setBaseSettings(wrapper); SortedMap<String, Object> unifiedOrderRequestMap = JsonMapper.nonEmptyMapper().getMapper().convertValue(wrapper, SortedMap.class); sign(wrapper, unifiedOrderRequestMap); String url = WxEndpoint.get("url.pay.payment.order.unified"); try { String xml = XmlObjectMapper.nonEmptyMapper().toXml(wrapper); logger.info("支付 unified order request: {}", xml); String response = wxSslClient.post(url, xml); logger.info("支付 unified order response: {}", response); UnifiedOrderResponseWrapper responseWrapper = XmlObjectMapper.defaultMapper().fromXml(response, UnifiedOrderResponseWrapper.class); return responseWrapper.getResponse(); } catch (Exception e) { throw new WxRuntimeException(999, "pre order failed:" + e.getMessage()); } }  void setPaySetting(PaySetting paySetting); static Payments defaultPayments(); static Payments with(PaySetting paySetting); void setWxSslClient(WxSslClient wxSslClient); UnifiedOrderResponse unifiedOrder(UnifiedOrderRequest unifiedOrderRequest); com.riversoft.weixin.pay.payment.bean.OrderQueryResponse query(com.riversoft.weixin.pay.payment.bean.OrderQueryRequest orderQueryRequest); BaseResponse close(String tradeNumber); boolean checkSignature(PaymentNotification notification); RefundResponse refund(RefundRequest refundRequest); RefundQuery refundQueryByTransactionId(String transactionId); RefundQuery refundQueryByTradeNumber(String tradeNumber); RefundQuery refundQueryByRefundNumber(String refundNumber); RefundQuery refundQueryByRefundId(String refundId); RefundQuery refundQuery(RefundQueryRequestWrapper refundQueryRequestWrapper); String downloadAllBill(Date date); String downloadRefundBill(Date date); String downloadSuccessBill(Date date);  }