Refactor ahead!!
cuter44 opened this issue · 1 comments
Hello all,
Unfortunately, we are seeing a massive trend that mixing wxmp and wxpay will be dangerous. It may take in poor performance, confusion, etc.
So we decide to make a slight isolation. The main idea is, to seperate wxmp and wxpay reqs/resps, each of them should have own package hierarchy and super-class. Another thing is, explicitly defining one-api-one-req, and .build().sign().execute() workflow.
These changes are pushing version code to 0.4.z, which means backwards incompatiable. Meanwhile 0.3.z codebase is no longer maintained. Projects using 0.3 CANNOT upgrade without adapting code, I HAVE TOLD YOU.
Peace night!
After hard work, an evaluating snapshot is now available. Many thing changed, and we are approaching our propose mentioned above.
Errr, I am not listing changes now. These are jobs of the wiki pages, it's another story.
Just talk about how to "evaluate" it:
- Download the source, compile it like former we do.
- Adapt the configure file, sample is like this:
# wxpay-sdk configure file
# Config this to load certificate for https://api.weixin.qq.com or other alike.
# Usually it is the GeoTrustGlobalCA.crt, provided along with the source code or release.
# Wxpay-sdk does not load JDK's default, so unsetting this value may cause error.
# As the same reason, unless you know what you do, leave this default.
# Both colon(:) and semicolon(;) are seperators.
LOAD_TRUSTS=/GeoTrustGlobalCA.crt
# Config this to load certificate as your client certificate, which is only required for wxpay/refund and ...(forgotten).
# Usually it is the apilicent_cert.p12, acquired from your https://pay.weixin.qq.com/ console.
# If you are not going to use those two APIs, nor you don't have such a file, quote the line to skip.
# If you are using this for multi-accounts, you MUST quote the line then programatically config your cert. Read wiki or javadoc for detailed guide.
LOAD_IDENTIFICATION=/apicilent_cert.p12
appid=wxe457195f6397f916
SECRET=f9e22f##################
mch_id=1233151202
KEY=shi########################
-
Also prepare your credential cert(.p12), or comment the line as instructed.
-
Sample is provided in /src/.../SampleTokenClientCredential.java, consist of only 4 lines:
WxmpFactory factory = WxmpFactory.getDefaultInstance(); TokenClientCredential req = factory.newTokenClientCredential(); TokenClientCredentialResponse resp = req.build().execute(); System.out.println(resp.json);
-
Run it:
ant run -Drun.main=com.github.cuter44.wxmp.sample.SampleTokenClientCredential -s
Let's see the point 4. . Not even changed from before, right? Yes, we preserve the conciseness. But you must be surprised while reviewing the underlying code. They are completely rewritten to ensure better performance and flexibility. Reqs/resps are also standardized now.