app、扫码、wap支付新增场景信息参数

This commit is contained in:
jinyu 2018-04-14 22:05:39 +08:00
parent a71facbf8b
commit 6382fe6195
7 changed files with 1712 additions and 1434 deletions

View File

@ -168,4 +168,8 @@
* 2016-08-22 * 2016-08-22
+ 删除`Weixin4jSettings`配置类 + 删除`Weixin4jSettings`配置类
* 2018-04-14
+ app、扫码、wap支付新增场景信息参数

View File

@ -71,6 +71,12 @@ public class MchPayPackage extends PayPackage {
@XmlElement(name = "sub_openid") @XmlElement(name = "sub_openid")
@JSONField(name = "sub_openid") @JSONField(name = "sub_openid")
private String subOpenId; private String subOpenId;
/**
* 场景信息
*/
@XmlElement(name = "scene_info")
@JSONField(name = "scene_info")
private String sceneInfo;
protected MchPayPackage() { protected MchPayPackage() {
// jaxb required // jaxb required
@ -200,11 +206,20 @@ public class MchPayPackage extends PayPackage {
this.subOpenId = subOpenId; this.subOpenId = subOpenId;
} }
public String getSceneInfo() {
return sceneInfo;
}
public void setSceneInfo(String sceneInfo) {
this.sceneInfo = sceneInfo;
}
@Override @Override
public String toString() { public String toString() {
return "MchPayPackage [tradeType=" + tradeType + ",feeType=" + feeType return "MchPayPackage [tradeType=" + tradeType + ",feeType=" + feeType
+ ", openId=" + openId + ", productId=" + productId + ", openId=" + openId + ", productId=" + productId
+ ", authCode=" + authCode + ", limitPay=" + limitPay + ", authCode=" + authCode + ", limitPay=" + limitPay
+ ", subOpenId=" + subOpenId + ", " + super.toString() + "]"; + ", subOpenId=" + subOpenId + ", sceneInfo=" + sceneInfo
+ ", " + super.toString() + "]";
} }
} }

View File

@ -0,0 +1,99 @@
package com.foxinmy.weixin4j.payment.mch;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class SceneInfoApp {
/**
* 终端类型
*/
private String type;
/**
* 应用名称
*/
private String name;
/**
* 应用路径
*/
private String path;
private String sceneInfo;
private SceneInfoApp(String type, String name, String path) {
this.type = type;
this.name = name;
this.path = path;
}
public String getType() {
return type;
}
public String getName() {
return name;
}
public String getPath() {
return path;
}
public String getSceneInfo() {
return sceneInfo;
}
public void setSceneInfo(String sceneInfo) {
this.sceneInfo = sceneInfo;
}
/**
* IOS应用
*
* @param appName 应用名
* @param bundleId 模块ID
* @return
*/
public static SceneInfoApp createIOSAPP(String appName, String bundleId) {
SceneInfoApp app = new SceneInfoApp("IOS", appName, bundleId);
String sceneInfo = String
.format("{\"type\": \"%s\",\"app_name\": \"%s\",\"bundle_id\": \"%s\"}",
app.getType(), app.getName(), app.getPath());
app.setSceneInfo(sceneInfo);
return app;
}
/**
* Android应用
*
* @param appName 应用名
* @param packageName 包名
* @return
*/
public static SceneInfoApp createAndroidAPP(String appName, String packageName) {
SceneInfoApp app = new SceneInfoApp("IOS", appName, packageName);
String sceneInfo = String
.format("{\"type\": \"%s\",\"app_name\": \"%s\",\"package_name\": \"%s\"}",
app.getType(), app.getName(), app.getPath());
app.setSceneInfo(sceneInfo);
return app;
}
/**
* Wap应用
*
* @param name
* 网站名
* @param url
* 网站URL地址
* @return
*/
public static SceneInfoApp createWapAPP(String name, String url) {
SceneInfoApp app = new SceneInfoApp("Wap", name, url);
String sceneInfo = String.format(
"{\"type\": \"%s\",\"wap_name\": \"%s\",\"wap_url\": \"%s\"}",
app.getType(), app.getName(), app.getPath());
app.setSceneInfo(sceneInfo);
return app;
}
}

View File

@ -0,0 +1,75 @@
package com.foxinmy.weixin4j.payment.mch;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class SceneInfoStore {
/**
* SZTX001 门店唯一标识
*/
private String id;
/**
* 腾讯大厦腾大餐厅 门店名称
*/
private String name;
/**
* 门店所在地行政区划码详细见最新县及县以上行政区划代码
*/
@XmlElement(name = "area_code")
@JSONField(name = "area_code")
private String areaCode;
/**
* 科技园中一路腾讯大厦 门店详细地址
*/
private String address;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAreaCode() {
return areaCode;
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public SceneInfoStore(String id, String name) {
super();
this.id = id;
this.name = name;
}
@Override
public String toString() {
return "SceneInfoStore [id=" + id + ", name=" + name + ", areaCode="
+ areaCode + ", address=" + address + "]";
}
}

View File

@ -45,11 +45,7 @@ public class PayTest {
protected final static WeixinPayProxy PAY; protected final static WeixinPayProxy PAY;
static { static {
ACCOUNT = new WeixinPayAccount( ACCOUNT = new WeixinPayAccount("id", "支付秘钥", "商户号", "加载证书的密码,默认为商户号",
"id",
"支付秘钥",
"商户号",
"加载证书的密码,默认为商户号",
"证书文件路径"); "证书文件路径");
SIGNATURE = new WeixinPaymentSignature(ACCOUNT.getPaySignKey()); SIGNATURE = new WeixinPaymentSignature(ACCOUNT.getPaySignKey());
PAY = new WeixinPayProxy(ACCOUNT); PAY = new WeixinPayProxy(ACCOUNT);
@ -171,7 +167,7 @@ public class PayTest {
double totalFee = 1d; double totalFee = 1d;
String createIp = "127.0.0.1"; String createIp = "127.0.0.1";
MchPayRequest request = PAY.createMicroPayRequest(authCode, body, MchPayRequest request = PAY.createMicroPayRequest(authCode, body,
outTradeNo, totalFee, createIp, null); outTradeNo, totalFee, createIp, null, null);
System.err.println(request); System.err.println(request);
} }
} }