Skip to content

Commit

Permalink
* bugfix Notify.isReturnSuccess() .isErrorCodeSuccess() not perform c…
Browse files Browse the repository at this point in the history
…orrectly.

pervious version are all infected, do not use any more.
  • Loading branch information
cuter44 committed Mar 20, 2015
1 parent faa80f4 commit 7a3b2b9
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 18 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ SDK 中提供了一个工厂方法用于快速地创建请求. 这个工厂方

* 网页授权获取用户基本信息
[spec↗](http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html)
[doc↗](http://cuter44.github.io/wxpay-sdk/javadoc/0.2.0/com/github/cuter44/wxpay/servlet/SnsapiUserinfo.html)
& [doc↗](http://cuter44.github.io/wxpay-sdk/javadoc/0.2.0/com/github/cuter44/wxpay/servlet/SnsapiBase.html)
[doc↗](http://cuter44.github.io/wxpay-sdk/javadoc/0.3.0/com/github/cuter44/wxpay/servlet/SnsapiUserinfo.html)
& [doc↗](http://cuter44.github.io/wxpay-sdk/javadoc/0.3.0/com/github/cuter44/wxpay/servlet/SnsapiBase.html)
* 获取access token
[spec↗](http://mp.weixin.qq.com/wiki/11/0e4b294685f817b95cbed85ba5e82b8f.html)
[doc↗](http://cuter44.github.io/wxpay-sdk/javadoc/0.2.1/com/github/cuter44/wxpay/reqs/TokenClientCredential.html)
[doc↗](http://cuter44.github.io/wxpay-sdk/javadoc/0.3.0/com/github/cuter44/wxpay/reqs/TokenClientCredential.html)
* 微信JSSDK支持
[spec↗](http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html)
[doc↗](http://cuter44.github.io/wxpay-sdk/javadoc/0.2.1/com/github/cuter44/wxpay/servlet/JSSDKConfig.html)
[doc↗](http://cuter44.github.io/wxpay-sdk/javadoc/0.3.0/com/github/cuter44/wxpay/servlet/JSSDKConfig.html)



Expand Down
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<property name="rtlibdir" value="lib" />
<property name="javadocdir" value="javadoc" />
<property name="destdir" value="bin" />
<property name="version" value="0.3.0" />
<property name="version" value="0.3.3" />
<property name="wxpay-api-version" value="3.3.7" />

<property name="webdir" value="web" />
Expand Down
21 changes: 18 additions & 3 deletions src/com/github/cuter44/wxpay/resps/Notify.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class Notify extends ResponseBase
{
// CONSTANTS
//protected Boolean validity = null;
public static final String KEY_OPENID = "openid";
public static final String KEY_OUT_TRADE_NO = "out_trade_no";

public static final List<String> KEYS_PARAM_NAME = Arrays.asList(
"appid",
Expand All @@ -33,13 +35,11 @@ public class Notify extends ResponseBase
"out_trade_no",
"result_code",
"return_code",
"return_code",
"return_msg",
"return_msg",
"time_end",
"total_fee",
"transaction_id",
"trde_type"
"trade_type"
);


Expand Down Expand Up @@ -78,5 +78,20 @@ public String getProperty(String key)
}

// PROPERTY
public String getOpenid()
{
return(
this.getProperty(KEY_OPENID)
);
}

public String getOutTradeNo()
{
return(
this.getProperty(KEY_OUT_TRADE_NO)
);
}



}
2 changes: 1 addition & 1 deletion src/com/github/cuter44/wxpay/resps/ResponseBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ResponseBase
public static final String KEY_ERR_CODE = "err_code";
public static final String KEY_ERR_CODE_DES = "err_code_des";

public static final String VALUE_SUCCESS = "VALUE_SUCCESS";
public static final String VALUE_SUCCESS = "SUCCESS";
public static final String VALUE_FAIL = "FAIL";

protected static CryptoBase crypto = CryptoBase.getInstance();
Expand Down
2 changes: 1 addition & 1 deletion src/com/github/cuter44/wxpay/servlet/JSSDKConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/** JS-SDK config 签名 API
*
* 为 JS-SDK config 提供签名支持, 工作模式参见 {@link http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E6.AD.A5.E9.AA.A4.E4.B8.89.EF.BC.9A.E9.80.9A.E8.BF.87config.E6.8E.A5.E5.8F.A3.E6.B3.A8.E5.85.A5.E6.9D.83.E9.99.90.E9.AA.8C.E8.AF.81.E9.85.8D.E7.BD.AE 微信JSSDK说明文档↗}
* 为 JS-SDK config 提供签名支持, 工作模式参见 <a href="http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E6.AD.A5.E9.AA.A4.E4.B8.89.EF.BC.9A.E9.80.9A.E8.BF.87config.E6.8E.A5.E5.8F.A3.E6.B3.A8.E5.85.A5.E6.9D.83.E9.99.90.E9.AA.8C.E8.AF.81.E9.85.8D.E7.BD.AE">微信JSSDK说明文档↗</a>
*
* <pre style="font-size:12px">
Expand Down
2 changes: 1 addition & 1 deletion src/com/github/cuter44/wxpay/servlet/SnsapiBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/** 网页授权(snsapi_base)的基础实现, 为网页前端取得当前用户的 openid.
*
* 关于该 servlet 的工作流程请参见 {@link http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html 网页授权获取用户基本信息↗}
* 关于该 servlet 的工作流程请参见 {<a href="http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html">网页授权获取用户基本信息↗</a>
*
* 需要在微信客户端上执行
*
Expand Down
2 changes: 1 addition & 1 deletion src/com/github/cuter44/wxpay/servlet/SnsapiUserinfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/** 网页授权(snsapi_userinfo)的基础实现, 为网页前端取得当前用户的 openid 及其他信息.
*
* 关于该 servlet 的工作流程请参见 {@link http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html 网页授权获取用户基本信息↗}
* 关于该 servlet 的工作流程请参见 <a href="http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html">网页授权获取用户基本信息↗</a>
*
* 需要在微信客户端上执行
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@

public class WxpayNotifyGatewayServlet extends HttpServlet
{
protected WxpayNotifyPublisher gateway = WxpayNotifyPublisher.getDefaultInstance();
protected WxpayNotifyPublisher gateway;

// FOR TEST ONLY
// QUOTE ME ON PRODUCE ENVIRONMENT
/** 接收到通知时的回调方法
* 默认实现是调度 WxpayNotifyPublisher.getInstance(). 进行处理
* 覆盖此方法可以实现自己的通知处理逻辑.
*/
public boolean handle(Notify n)
{
return(
this.gateway.publish(n)
);
}

/** 默认初始化方法, 读取并配置调试开关
* 覆盖此方法可以删除对 web.xml 配置的访问, 以及删除对 WxpayNotifyPublisher 的访问(报告 NullPointerException)
*/
@Override
public void init(ServletConfig config)
{
Expand Down Expand Up @@ -57,6 +69,8 @@ public boolean handle(Notify n)
}
);
}

this.gateway = WxpayNotifyPublisher.getDefaultInstance();
}

@Override
Expand All @@ -73,9 +87,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp)
Properties parsedProp = parseXML(reqBody);
Notify n = new Notify(null, parsedProp);

System.out.println(parsedProp);

if (gateway.publish(n))
if (this.handle(n))
out.print("<xml><return_code>SUCCESS</return_code></xml>");
// else
out.print("<xml><return_code>FAIL</return_code><return_msg>NO_HANDLER_REPORTED</return_msg></xml>");
Expand Down

0 comments on commit 7a3b2b9

Please sign in to comment.