提交修改
This commit is contained in:
parent
f79a76f13a
commit
42f8b98350
@ -86,7 +86,7 @@ public class JsapiPrepay {
|
||||
return doPay(request);
|
||||
}
|
||||
|
||||
private DirectAPIv3JsapiPrepayResponse doPay(DirectAPIv3JsapiPrepayRequest request) {
|
||||
public DirectAPIv3JsapiPrepayResponse doPay(DirectAPIv3JsapiPrepayRequest request) {
|
||||
String uri = PATH;
|
||||
String reqBody = WXPayUtility.toJson(request);
|
||||
|
||||
|
||||
@ -0,0 +1,80 @@
|
||||
package com.heyu.api.jsapi;
|
||||
// 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/v3/merchant/4014931831
|
||||
|
||||
import com.heyu.api.jsapi.dto.DirectAPIv3QueryResponse;
|
||||
import com.heyu.api.jsapi.dto.QueryByWxTradeNoRequest;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 微信支付订单号查询订单
|
||||
*/
|
||||
public class QueryByWxTradeNo {
|
||||
private static String HOST = "https://api.mch.weixin.qq.com";
|
||||
private static String METHOD = "GET";
|
||||
private static String PATH = "/v3/pay/transactions/id/{transaction_id}";
|
||||
|
||||
|
||||
private final String mchid;
|
||||
private final String certificateSerialNo;
|
||||
private final PrivateKey privateKey;
|
||||
private final String wechatPayPublicKeyId;
|
||||
private final PublicKey wechatPayPublicKey;
|
||||
|
||||
|
||||
public QueryByWxTradeNo(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) {
|
||||
this.mchid = mchid;
|
||||
this.certificateSerialNo = certificateSerialNo;
|
||||
this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath);
|
||||
this.wechatPayPublicKeyId = wechatPayPublicKeyId;
|
||||
this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath);
|
||||
}
|
||||
|
||||
|
||||
public DirectAPIv3QueryResponse run(QueryByWxTradeNoRequest request) {
|
||||
String uri = PATH;
|
||||
uri = uri.replace("{transaction_id}", WXPayUtility.urlEncode(request.transactionId));
|
||||
Map<String, Object> args = new HashMap<>();
|
||||
args.put("mchid", request.mchid);
|
||||
String queryString = WXPayUtility.urlEncode(args);
|
||||
if (!queryString.isEmpty()) {
|
||||
uri = uri + "?" + queryString;
|
||||
}
|
||||
|
||||
Request.Builder reqBuilder = new Request.Builder().url(HOST + uri);
|
||||
reqBuilder.addHeader("Accept", "application/json");
|
||||
reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId);
|
||||
reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null));
|
||||
reqBuilder.method(METHOD, null);
|
||||
Request httpRequest = reqBuilder.build();
|
||||
|
||||
// 发送HTTP请求
|
||||
OkHttpClient client = new OkHttpClient.Builder().build();
|
||||
try (Response httpResponse = client.newCall(httpRequest).execute()) {
|
||||
String respBody = WXPayUtility.extractBody(httpResponse);
|
||||
System.out.println("respBody = " + respBody);
|
||||
if (httpResponse.code() >= 200 && httpResponse.code() < 300) {
|
||||
// 2XX 成功,验证应答签名
|
||||
WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey,
|
||||
httpResponse.headers(), respBody);
|
||||
|
||||
// 从HTTP应答报文构建返回数据
|
||||
return WXPayUtility.fromJson(respBody, DirectAPIv3QueryResponse.class);
|
||||
} else {
|
||||
throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException("Sending request to " + uri + " failed.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CommRespAmountInfo {
|
||||
@SerializedName("total")
|
||||
public Long total;
|
||||
|
||||
@SerializedName("payer_total")
|
||||
public Long payerTotal;
|
||||
|
||||
@SerializedName("currency")
|
||||
public String currency;
|
||||
|
||||
@SerializedName("payer_currency")
|
||||
public String payerCurrency;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CommRespPayerInfo {
|
||||
@SerializedName("openid")
|
||||
public String openid;
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CommRespSceneInfo {
|
||||
@SerializedName("device_id")
|
||||
public String deviceId;
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DirectAPIv3QueryResponse {
|
||||
@SerializedName("appid")
|
||||
public String appid;
|
||||
|
||||
@SerializedName("mchid")
|
||||
public String mchid;
|
||||
|
||||
@SerializedName("out_trade_no")
|
||||
public String outTradeNo;
|
||||
|
||||
@SerializedName("transaction_id")
|
||||
public String transactionId;
|
||||
|
||||
@SerializedName("trade_type")
|
||||
public String tradeType;
|
||||
|
||||
@SerializedName("trade_state")
|
||||
public String tradeState;
|
||||
|
||||
@SerializedName("trade_state_desc")
|
||||
public String tradeStateDesc;
|
||||
|
||||
@SerializedName("bank_type")
|
||||
public String bankType;
|
||||
|
||||
@SerializedName("attach")
|
||||
public String attach;
|
||||
|
||||
@SerializedName("success_time")
|
||||
public String successTime;
|
||||
|
||||
@SerializedName("payer")
|
||||
public CommRespPayerInfo payer;
|
||||
|
||||
@SerializedName("amount")
|
||||
public CommRespAmountInfo amount;
|
||||
|
||||
@SerializedName("scene_info")
|
||||
public CommRespSceneInfo sceneInfo;
|
||||
|
||||
@SerializedName("promotion_detail")
|
||||
public List<PromotionDetail> promotionDetail;
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GoodsDetailInPromotion {
|
||||
@SerializedName("goods_id")
|
||||
public String goodsId;
|
||||
|
||||
@SerializedName("quantity")
|
||||
public Long quantity;
|
||||
|
||||
@SerializedName("unit_price")
|
||||
public Long unitPrice;
|
||||
|
||||
@SerializedName("discount_amount")
|
||||
public Long discountAmount;
|
||||
|
||||
@SerializedName("goods_remark")
|
||||
public String goodsRemark;
|
||||
}
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PromotionDetail {
|
||||
@SerializedName("coupon_id")
|
||||
public String couponId;
|
||||
|
||||
@SerializedName("name")
|
||||
public String name;
|
||||
|
||||
@SerializedName("scope")
|
||||
public String scope;
|
||||
|
||||
@SerializedName("type")
|
||||
public String type;
|
||||
|
||||
@SerializedName("amount")
|
||||
public Long amount;
|
||||
|
||||
@SerializedName("stock_id")
|
||||
public String stockId;
|
||||
|
||||
@SerializedName("wechatpay_contribute")
|
||||
public Long wechatpayContribute;
|
||||
|
||||
@SerializedName("merchant_contribute")
|
||||
public Long merchantContribute;
|
||||
|
||||
@SerializedName("other_contribute")
|
||||
public Long otherContribute;
|
||||
|
||||
@SerializedName("currency")
|
||||
public String currency;
|
||||
|
||||
@SerializedName("goods_detail")
|
||||
public List<GoodsDetailInPromotion> goodsDetail;
|
||||
}
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
package com.heyu.api.jsapi.dto;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QueryByWxTradeNoRequest {
|
||||
@SerializedName("mchid")
|
||||
@Expose(serialize = false)
|
||||
public String mchid;
|
||||
|
||||
@SerializedName("transaction_id")
|
||||
@Expose(serialize = false)
|
||||
public String transactionId;
|
||||
}
|
||||
@ -317,12 +317,14 @@ public class AppOrderController {
|
||||
BigDecimalUtil.multiply(vvTradeOrderEntity.getAllPrice(), new BigDecimal(100)).longValue(),
|
||||
vvBuyerEntity.getOpenid()
|
||||
);
|
||||
String prepay_id = jsapiPrepayResponse.getPrepayId();
|
||||
if (jsapiPrepayResponse != null && jsapiPrepayResponse.getPrepayId() != null) {
|
||||
List<VvTradeOrderLineEntity> vvTradeOrderLineEntities = vvTradeOrderLineDao.selectVvTradeOrderLineByTradeOrderId(vvTradeOrderEntity.getId());
|
||||
for (VvTradeOrderLineEntity vvTradeOrderLineEntity : vvTradeOrderLineEntities) {
|
||||
vvTradeOrderLineEntity.setPayType("weixin");
|
||||
vvTradeOrderLineEntity.setStatus(OrderStatusEnums.wait_pay.getStatus());
|
||||
vvTradeOrderLineEntity.setTransactionId(jsapiPrepayResponse.getPrepayId());
|
||||
|
||||
vvTradeOrderLineEntity.setGmtPrePay(new Date());
|
||||
vvTradeOrderLineDao.updateVvTradeOrderLineById(vvTradeOrderLineEntity);
|
||||
}
|
||||
@ -345,7 +347,10 @@ public class AppOrderController {
|
||||
});
|
||||
|
||||
}
|
||||
return R.ok("订单创建成功");
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("prepay_id",prepay_id);
|
||||
return R.ok().setData(map);
|
||||
|
||||
}
|
||||
|
||||
@Describe("删除订单")
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
package com.api.test;
|
||||
|
||||
import com.heyu.api.jsapi.QueryByWxTradeNo;
|
||||
import com.heyu.api.jsapi.WXPayUtility;
|
||||
import com.heyu.api.jsapi.dto.DirectAPIv3QueryResponse;
|
||||
import com.heyu.api.jsapi.dto.QueryByWxTradeNoRequest;
|
||||
|
||||
public class JSAPIQueryTest {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/merchant/4013070756
|
||||
QueryByWxTradeNo client = new QueryByWxTradeNo(
|
||||
TestJSAPI.mchid, // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756
|
||||
TestJSAPI.Certificate_serial_number, // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053
|
||||
TestJSAPI.privateKey, // 商户API证书私钥文件路径,本地文件路径
|
||||
TestJSAPI.PUB_KEY_ID, // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816
|
||||
TestJSAPI.wechatPayPublicKey // 微信支付公钥文件路径,本地文件路径
|
||||
);
|
||||
|
||||
QueryByWxTradeNoRequest request = new QueryByWxTradeNoRequest();
|
||||
request.transactionId = "wx07124718921276a55b1abd623f48690001";
|
||||
request.mchid = TestJSAPI.mchid;
|
||||
try {
|
||||
DirectAPIv3QueryResponse response = client.run(request);
|
||||
// TODO: 请求成功,继续业务逻辑
|
||||
System.out.println(response);
|
||||
} catch (WXPayUtility.ApiException e) {
|
||||
// TODO: 请求失败,根据状态码执行不同的逻辑
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -12,51 +12,64 @@ public class TestJSAPI {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public final static String privateKey = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCzn74aYlkoD1lO" +
|
||||
"rcbpqW9aI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
|
||||
"yEtY4XNR9zAf0aSgo+qSCAtgMqrWwyV+fKUjbzEbEjD7STPXLy+r1YC0g0Z7Wesz" +
|
||||
"LG0f4MYTzQKBgQCkCFW+7klwrzIKlmucE40jqYyfEmCXx8UUX3fbcw0OK0OoQo20" +
|
||||
"9tvwewyf+ZtNHW3onCf2t3Uy/SNFCaCiWVdEfpJPkPKfjQMuoARxhO2d5k1tqoU+" +
|
||||
"VnrtytwW371Og6EawHsOL5Yiie3ZyjRURdwu4+lRhmlMBZd8qtTjZitPpQKBgQCV" +
|
||||
"rMOLKWZzRxAJvOxahKpkkthYp//yOzHqzePNW95WIUrWco3uNDUVITFF/6mYXTu5" +
|
||||
"FePkcULqHFODi0LMNqHMCJc0GOVu1P33Bx3F/izPw/kht0v+itoYwusHk1xr7W8U" +
|
||||
"vCRpabi1cMeY6CBsJaCev9PQrHl8iJwNFruc3XeJTQKBgFt31iujP7W2FHaT6uyO" +
|
||||
"1gKSlqCcZILD2F15Q52OYQoV6I5Tq152ITyMyE4EiYPOqnqVWUc+ej1m+AuvYljR" +
|
||||
"qlvVCmp91QtYwLGguuHFYNVcE2V3WftKKbIIPT2qEFaS5eUb6hB+kl02E1EmjCtA" +
|
||||
"pwssCVJj81yu/DsBP0580zBL";
|
||||
|
||||
|
||||
|
||||
public final static String wechatPayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx/QqdSnkS8wd7xFH0LHV" +
|
||||
"pZTFVI+eWL383eAP7RaxHfRwXNDfZYrdi/Bt8Enko+1Wkr2FGY2kS4Hol5NCvuZ7" +
|
||||
"UY28/L4r95dBEgXtflkrxeVbiNbWHtiIdNXZSgkrpUkZEFoh7ks5Ou3pAlpG+94/" +
|
||||
"Nnc//D/yckM7AuD85G1foZMSO5niyVeFAed6z7CeBMAhRVdnOIDUqsI/NaHruT4f" +
|
||||
"vWNzPnn5SQKoKum00vRHckxftUqMkZ1D/YxHiAycEc9H0hCgLW7ZM6UV88Loa6SP" +
|
||||
"vhM0fmXIuk6p277ldlxFl6Bcxd5jOcCTjdpWaB3CeSXnSIBl6KsZNcV3vPC3xey1" +
|
||||
"WwIDAQAB";
|
||||
|
||||
|
||||
|
||||
|
||||
public final static String mchid = "1731491745";
|
||||
public final static String Certificate_serial_number = "793D48CCEB62C6B227E0A4F46AD90279B149A7BE"; // 证书序列号
|
||||
public final static String PUB_KEY_ID = "PUB_KEY_ID_0117314917452025110400382304001401"; // 证书序列号
|
||||
public final static String appid = "wx75fa59c097bd3dfd"; // 证书序列号
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String wechatPayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx/QqdSnkS8wd7xFH0LHV" +
|
||||
"pZTFVI+eWL383eAP7RaxHfRwXNDfZYrdi/Bt8Enko+1Wkr2FGY2kS4Hol5NCvuZ7" +
|
||||
"UY28/L4r95dBEgXtflkrxeVbiNbWHtiIdNXZSgkrpUkZEFoh7ks5Ou3pAlpG+94/" +
|
||||
"Nnc//D/yckM7AuD85G1foZMSO5niyVeFAed6z7CeBMAhRVdnOIDUqsI/NaHruT4f" +
|
||||
"vWNzPnn5SQKoKum00vRHckxftUqMkZ1D/YxHiAycEc9H0hCgLW7ZM6UV88Loa6SP" +
|
||||
"vhM0fmXIuk6p277ldlxFl6Bcxd5jOcCTjdpWaB3CeSXnSIBl6KsZNcV3vPC3xey1" +
|
||||
"WwIDAQAB";
|
||||
|
||||
|
||||
|
||||
String privateKey = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCzn74aYlkoD1lO" +
|
||||
"rcbpqW9aIE/IiH/lAea+nFmmmao5ggxrXhnvkGDQ3e+59Cf59jTikKxmMc+aj36m" +
|
||||
"axrd/OYDM27j0q5b7t8fWPD4qqyMR2uqiImc622BpQIxaPUeLeDHwsHq4C6g0UzZ" +
|
||||
"6DXJppHpb6xn0gEFHS87Na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9tvwewyf+ZtNHW3onCf2t3Uy/SNFCaCiWVdEfpJPkPKfjQMuoARxhO2d5k1tqoU+" +
|
||||
"VnrtytwW371Og6EawHsOL5Yiie3ZyjRURdwu4+lRhmlMBZd8qtTjZitPpQKBgQCV" +
|
||||
"rMOLKWZzRxAJvOxahKpkkthYp//yOzHqzePNW95WIUrWco3uNDUVITFF/6mYXTu5" +
|
||||
"FePkcULqHFODi0LMNqHMCJc0GOVu1P33Bx3F/izPw/kht0v+itoYwusHk1xr7W8U" +
|
||||
"vCRpabi1cMeY6CBsJaCev9PQrHl8iJwNFruc3XeJTQKBgFt31iujP7W2FHaT6uyO" +
|
||||
"1gKSlqCcZILD2F15Q52OYQoV6I5Tq152ITyMyE4EiYPOqnqVWUc+ej1m+AuvYljR" +
|
||||
"qlvVCmp91QtYwLGguuHFYNVcE2V3WftKKbIIPT2qEFaS5eUb6hB+kl02E1EmjCtA" +
|
||||
"pwssCVJj81yu/DsBP0580zBL";
|
||||
|
||||
// TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/merchant/4013070756
|
||||
JsapiPrepay client = new JsapiPrepay(
|
||||
"1731491745", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756
|
||||
"793D48CCEB62C6B227E0A4F46AD90279B149A7BE", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053
|
||||
mchid, // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756
|
||||
Certificate_serial_number, // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053
|
||||
privateKey, // 商户API证书私钥文件路径,本地文件路径
|
||||
"PUB_KEY_ID_0117314917452025110400382304001401", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816
|
||||
PUB_KEY_ID, // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816
|
||||
wechatPayPublicKey // 微信支付公钥文件路径,本地文件路径
|
||||
);
|
||||
|
||||
@ -64,19 +77,15 @@ public class TestJSAPI {
|
||||
System.out.println("privateKey:"+privateKey);
|
||||
System.out.println("wechatPayPublicKey:" +wechatPayPublicKey);
|
||||
|
||||
|
||||
|
||||
DirectAPIv3JsapiPrepayRequest request = new DirectAPIv3JsapiPrepayRequest();
|
||||
request.setAppid("wx75fa59c097bd3dfd");
|
||||
request.setMchid("1731491745");
|
||||
request.setAppid(appid);
|
||||
request.setMchid(mchid);
|
||||
|
||||
request.setNotifyUrl("https://api.1024api.com/api-interface/app/weixin/payNotify");
|
||||
|
||||
request.setDescription("Image形象店-深圳腾大-QQ公仔");
|
||||
|
||||
|
||||
|
||||
|
||||
request.setOutTradeNo("12177525011");
|
||||
request.setOutTradeNo("121775xx");
|
||||
request.setTimeExpire(WXPayUtility.generateExpireTime()); // 2025-11-05T21:02:16+08:00
|
||||
request.setAttach("自定义数据说明");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user