|
@@ -0,0 +1,66 @@
|
|
|
|
|
+package com.modular.apputils.utils.playsdk;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import android.content.Context;
|
|
|
|
|
+
|
|
|
|
|
+import com.modular.apputils.R;
|
|
|
|
|
+import com.tencent.mm.opensdk.constants.ConstantsAPI;
|
|
|
|
|
+import com.tencent.mm.opensdk.modelbase.BaseResp;
|
|
|
|
|
+import com.tencent.mm.opensdk.modelmsg.WXTextObject;
|
|
|
|
|
+import com.tencent.mm.opensdk.modelpay.PayReq;
|
|
|
|
|
+import com.tencent.mm.opensdk.openapi.IWXAPI;
|
|
|
|
|
+import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Created by Bitlike on 2017/12/25.
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+public class WxPlay {
|
|
|
|
|
+ private static final String APP_ID = "";
|
|
|
|
|
+ private IWXAPI wxApi;
|
|
|
|
|
+ private static WxPlay api;
|
|
|
|
|
+
|
|
|
|
|
+ public static WxPlay api() {
|
|
|
|
|
+ if (api == null) {
|
|
|
|
|
+ synchronized (WxPlay.class) {
|
|
|
|
|
+ if (api == null) {
|
|
|
|
|
+ api = new WxPlay();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return api;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private WxPlay() {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public void init(Context context) {
|
|
|
|
|
+ wxApi = WXAPIFactory.createWXAPI(context, null);
|
|
|
|
|
+ wxApi.registerApp(APP_ID);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public void ss(){
|
|
|
|
|
+ PayReq request = new PayReq();
|
|
|
|
|
+ request.appId = "wxd930ea5d5a258f4f";
|
|
|
|
|
+ request.partnerId = "1900000109";
|
|
|
|
|
+ request.prepayId= "1101000000140415649af9fc314aa427";
|
|
|
|
|
+ request.packageValue = "Sign=WXPay";
|
|
|
|
|
+ request.nonceStr= "1101000000140429eb40476f8896f4c9";
|
|
|
|
|
+ request.timeStamp= "1398746574";
|
|
|
|
|
+ request.sign= "7FFECB600D7157C5AA49810D2D8F28BC2811827B";
|
|
|
|
|
+ wxApi.sendReq(request);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ public void onResp(BaseResp resp){
|
|
|
|
|
+ if(resp.getType()== ConstantsAPI.COMMAND_PAY_BY_WX){
|
|
|
|
|
+// Log.d(TAG,"onPayFinish,errCode="+resp.errCode);
|
|
|
|
|
+// AlertDialog.Builderbuilder=newAlertDialog.Builder(this);
|
|
|
|
|
+// builder.setTitle(R.string.app_tip);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|