| | |
| | | package com.panzhihua.applets.unionpay; |
| | | |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | * 测试环境:http://58.247.0.18:29015/v1/netpay/trade/create |
| | | * 生产环境:https://api-mop.chinaums.com/v1/netpay/trade/create |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class UnifiedOrder { |
| | | |
| | |
| | | // static String url = "https://test-api-open.chinaums.com/v1/netpay/wx/unified-order"; |
| | | static String url = "https://api-mop.chinaums.com/v1/netpay/wx/unified-order"; |
| | | |
| | | public static String sendOrder(String totalAmount,String orderDesc,String productId) |
| | | public static String sendOrder(String totalAmount,String orderDesc,String productId,String OpenId) |
| | | { |
| | | //1. 组建请求报文 |
| | | LocalDateTime time=DateUtils.getCurrentDate(); |
| | |
| | | reqBody.tid = UnionpayContent.TID; |
| | | reqBody.instMid = UnionpayContent.INSTMID; |
| | | reqBody.totalAmount = totalAmount; |
| | | reqBody.secureTransaction = "true"; |
| | | reqBody.secureTransaction = "false"; |
| | | reqBody.orderDesc = orderDesc; |
| | | reqBody.productId = productId; |
| | | reqBody.notifyUrl = NOTIFYURL; |
| | | System.out.println("request body:\n"+reqBody); |
| | | reqBody.tradeType = "MINI"; |
| | | reqBody.subOpenId = OpenId; |
| | | |
| | | log.info("银联支付参数:\n"+reqBody); |
| | | |
| | | //2. 获取认证报文,timestamp为当前日期,老旧日期无法请求成功 |
| | | String authorization = null; |