添加小游戏道具直购(present_goods)API支持
Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
This commit is contained in:
@@ -71,6 +71,16 @@ public interface WxMaXPayService {
|
|||||||
*/
|
*/
|
||||||
WxMaXPayPresentCurrencyResponse presentCurrency(WxMaXPayPresentCurrencyRequest request, WxMaXPaySigParams sigParams) throws WxErrorException;
|
WxMaXPayPresentCurrencyResponse presentCurrency(WxMaXPayPresentCurrencyRequest request, WxMaXPaySigParams sigParams) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 道具直购。
|
||||||
|
*
|
||||||
|
* @param request 道具直购请求对象
|
||||||
|
* @param sigParams 签名参数对象
|
||||||
|
* @return 道具直购结果
|
||||||
|
* @throws WxErrorException 直购失败时抛出
|
||||||
|
*/
|
||||||
|
WxMaXPayPresentGoodsResponse presentGoods(WxMaXPayPresentGoodsRequest request, WxMaXPaySigParams sigParams) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载对账单。
|
* 下载对账单。
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -108,6 +108,22 @@ public class WxMaXPayServiceImpl implements WxMaXPayService {
|
|||||||
return getDetailResponse;
|
return getDetailResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WxMaXPayPresentGoodsResponse presentGoods(WxMaXPayPresentGoodsRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
|
||||||
|
final String postBody = request.toJson();
|
||||||
|
final String uri = sigParams.signUriWithPay(PRESENT_GOODS_URL, postBody);
|
||||||
|
String responseContent = this.service.post(uri, postBody);
|
||||||
|
WxMaXPayPresentGoodsResponse getDetailResponse = WxMaGsonBuilder.create()
|
||||||
|
.fromJson(responseContent, WxMaXPayPresentGoodsResponse.class);
|
||||||
|
|
||||||
|
if (getDetailResponse.getErrcode() != 0) {
|
||||||
|
throw new WxErrorException(
|
||||||
|
new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return getDetailResponse;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxMaXPayDownloadBillResponse downloadBill(WxMaXPayDownloadBillRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
|
public WxMaXPayDownloadBillResponse downloadBill(WxMaXPayDownloadBillRequest request, WxMaXPaySigParams sigParams) throws WxErrorException {
|
||||||
final String postBody = request.toJson();
|
final String postBody = request.toJson();
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package cn.binarywang.wx.miniapp.bean.xpay;
|
||||||
|
|
||||||
|
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小游戏道具直购请求.
|
||||||
|
*
|
||||||
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class WxMaXPayPresentGoodsRequest implements Serializable {
|
||||||
|
private static final long serialVersionUID = 7495157056049312109L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户的openid.
|
||||||
|
*/
|
||||||
|
@SerializedName("openid")
|
||||||
|
private String openid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 环境。0-正式环境;1-沙箱环境.
|
||||||
|
*/
|
||||||
|
@SerializedName("env")
|
||||||
|
private Integer env;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商户订单号.
|
||||||
|
*/
|
||||||
|
@SerializedName("order_id")
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备类型。0-安卓;1-iOS.
|
||||||
|
*/
|
||||||
|
@SerializedName("device_type")
|
||||||
|
private Integer deviceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 道具id.
|
||||||
|
*/
|
||||||
|
@SerializedName("goods_id")
|
||||||
|
private String goodsId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 道具数量.
|
||||||
|
*/
|
||||||
|
@SerializedName("goods_number")
|
||||||
|
private Integer goodsNumber;
|
||||||
|
|
||||||
|
public String toJson() {
|
||||||
|
return WxMaGsonBuilder.create().toJson(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package cn.binarywang.wx.miniapp.bean.xpay;
|
||||||
|
|
||||||
|
import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse;
|
||||||
|
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小游戏道具直购响应.
|
||||||
|
*
|
||||||
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class WxMaXPayPresentGoodsResponse extends WxMaBaseResponse implements Serializable {
|
||||||
|
private static final long serialVersionUID = 7495157056049312110L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商户订单号.
|
||||||
|
*/
|
||||||
|
@SerializedName("order_id")
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
public String toJson() {
|
||||||
|
return WxMaGsonBuilder.create().toJson(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -875,6 +875,7 @@ public class WxMaApiUrlConstants {
|
|||||||
String NOTIFY_PROVIDE_GOODS_URL =
|
String NOTIFY_PROVIDE_GOODS_URL =
|
||||||
"https://api.weixin.qq.com/xpay/notify_provide_goods?pay_sig=%s";
|
"https://api.weixin.qq.com/xpay/notify_provide_goods?pay_sig=%s";
|
||||||
String PRESENT_CURRENCY_URL = "https://api.weixin.qq.com/xpay/present_currency?pay_sig=%s";
|
String PRESENT_CURRENCY_URL = "https://api.weixin.qq.com/xpay/present_currency?pay_sig=%s";
|
||||||
|
String PRESENT_GOODS_URL = "https://api.weixin.qq.com/xpay/present_goods?pay_sig=%s";
|
||||||
String DOWNLOAD_BILL_URL = "https://api.weixin.qq.com/xpay/download_bill?pay_sig=%s";
|
String DOWNLOAD_BILL_URL = "https://api.weixin.qq.com/xpay/download_bill?pay_sig=%s";
|
||||||
String REFUND_ORDER_URL = "https://api.weixin.qq.com/xpay/refund_order?pay_sig=%s";
|
String REFUND_ORDER_URL = "https://api.weixin.qq.com/xpay/refund_order?pay_sig=%s";
|
||||||
String CREATE_WITHDRAW_ORDER_URL =
|
String CREATE_WITHDRAW_ORDER_URL =
|
||||||
|
|||||||
Reference in New Issue
Block a user