|
@@ -39,15 +39,26 @@ public class WeixinPayController extends Controller {
|
|
|
String asString = this.getPara("out_trade_no");
|
|
|
String bbString = this.getPara("appId");
|
|
|
|
|
|
- WeixinService wService = ServiceFactory.getService(WeixinService.class);
|
|
|
String codeString = "";
|
|
|
+ WeixinService wService = ServiceFactory.getService(WeixinService.class);
|
|
|
ApiConfigKit.setThreadLocalAppId(bbString);
|
|
|
- try {
|
|
|
- String url = wService.getCodeUrl(ApiConfigKit.getApiConfig().getAppId(), getRequest().getRequestURL().toString() + "?appId=" + ApiConfigKit.getApiConfig().getAppId());
|
|
|
- codeString = getParamByUrl(url, "code");
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
+ String code = this.getPara("code");
|
|
|
+ if (code == null) {
|
|
|
+ System.out.println(ApiConfigKit.getApiConfig().getAppId());
|
|
|
+ System.out.println(getRequest().getRequestURL().toString());
|
|
|
+
|
|
|
+ String url;
|
|
|
+ try {
|
|
|
+ url = wService.getCodeUrl(ApiConfigKit.getApiConfig().getAppId(), getRequest().getRequestURL().toString() + "?appId=" + ApiConfigKit.getApiConfig().getAppId());
|
|
|
+ this.redirect(url);
|
|
|
+
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }else {
|
|
|
+ codeString = this.getPara("code");
|
|
|
}
|
|
|
SnsAccessToken snsAccessToken = wService.getWebAccessToken(ApiConfigKit.getApiConfig().getAppId(), ApiConfigKit.getApiConfig().getAppSecret(), codeString);
|
|
|
|