微信支付 - 向支付中心发送商户订单

    科技2025-01-30  28

    @Autowired private RestTemplate restTemplate; @Configuration public class WebMvcConfig implements WebMvcConfigurer { @Bean public RestTemplate restTemplate(RestTemplateBuilder builder) { return builder.build(); } } public void setContentType(@Nullable MediaType mediaType) { if (mediaType != null) { Assert.isTrue(!mediaType.isWildcardType(), "Content-Type cannot contain wildcard type '*'"); Assert.isTrue(!mediaType.isWildcardSubtype(), "Content-Type cannot contain wildcard subtype '*'"); this.set("Content-Type", mediaType.toString()); } else { this.remove("Content-Type"); } } public static final MediaType APPLICATION_JSON; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.add("imoocUserId","imooc"); headers.add("password","imooc"); HttpEntity<MerchantOrdersVO> entity = new HttpEntity<>(merchantOrdersVO, headers); ResponseEntity<JSONResult> responseEntity = restTemplate.postForEntity(paymentUrl, entity, JSONResult.class); JSONResult paymentResult = responseEntity.getBody(); // 支付中心的调用地址 String paymentUrl = "http://payment.t.xuexi.com/payment/payment/createMerchantOrder"; // produce

     

    Processed: 0.016, SQL: 8