1
This commit is contained in:
parent
8d98c6b5cc
commit
45d9b914a9
@ -25,6 +25,7 @@ import com.tencent.imsdk.v2.V2TIMManager;
|
|||||||
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
|
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
|
||||||
import com.tencent.imsdk.v2.V2TIMUserInfo;
|
import com.tencent.imsdk.v2.V2TIMUserInfo;
|
||||||
import com.yunbao.common.BuildConfig;
|
import com.yunbao.common.BuildConfig;
|
||||||
|
import com.yunbao.common.CommonAppConfig;
|
||||||
import com.yunbao.common.CommonAppContext;
|
import com.yunbao.common.CommonAppContext;
|
||||||
import com.yunbao.common.Constants;
|
import com.yunbao.common.Constants;
|
||||||
import com.yunbao.common.http.CommonHttpUtil;
|
import com.yunbao.common.http.CommonHttpUtil;
|
||||||
@ -140,6 +141,9 @@ public class AppContext extends CommonAppContext {
|
|||||||
|
|
||||||
String environment = AdjustConfig.ENVIRONMENT_PRODUCTION;
|
String environment = AdjustConfig.ENVIRONMENT_PRODUCTION;
|
||||||
AdjustConfig config = new AdjustConfig(this, "3om5fbglyqdc", environment);
|
AdjustConfig config = new AdjustConfig(this, "3om5fbglyqdc", environment);
|
||||||
|
if (CommonAppConfig.IS_GOOGLE_PLAY == true) {
|
||||||
|
config.setDefaultTracker("{xa7k5ut}");
|
||||||
|
}
|
||||||
Adjust.onCreate(config);
|
Adjust.onCreate(config);
|
||||||
registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks());
|
registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks());
|
||||||
config.setLogLevel(LogLevel.WARN);
|
config.setLogLevel(LogLevel.WARN);
|
||||||
|
@ -337,6 +337,7 @@ public class CommonHttpUtil {
|
|||||||
.params("purchaseToken", purchaseToken)
|
.params("purchaseToken", purchaseToken)
|
||||||
.params("productId", productId)
|
.params("productId", productId)
|
||||||
.params("orderno", orderno)
|
.params("orderno", orderno)
|
||||||
|
.params("package_name", "com.pdlive.shayu")
|
||||||
.execute(callback);
|
.execute(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,6 +348,7 @@ public class CommonHttpUtil {
|
|||||||
.params("trade_no", tradeNo)
|
.params("trade_no", tradeNo)
|
||||||
.params("allData", allData)
|
.params("allData", allData)
|
||||||
.params("gps_adid", gps_adid)
|
.params("gps_adid", gps_adid)
|
||||||
|
.params("package_name", "com.pdlive.shayu")
|
||||||
.execute(callback);
|
.execute(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,6 +357,7 @@ public class CommonHttpUtil {
|
|||||||
.params("purchaseToken", purchaseToken)
|
.params("purchaseToken", purchaseToken)
|
||||||
.params("orderno", orderNo)
|
.params("orderno", orderNo)
|
||||||
.params("trade_no", tradeNo)
|
.params("trade_no", tradeNo)
|
||||||
|
.params("package_name", "com.pdlive.shayu")
|
||||||
.execute(callback);
|
.execute(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,10 +2,13 @@ package com.yunbao.main.activity;
|
|||||||
|
|
||||||
|
|
||||||
import static com.yunbao.common.CommonAppContext.logger;
|
import static com.yunbao.common.CommonAppContext.logger;
|
||||||
|
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
|
||||||
|
import static com.yunbao.main.activity.MyWalletActivity.dis;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -16,12 +19,18 @@ import android.webkit.WebView;
|
|||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.adjust.sdk.Adjust;
|
||||||
|
import com.adjust.sdk.AdjustEvent;
|
||||||
import com.android.billingclient.api.Purchase;
|
import com.android.billingclient.api.Purchase;
|
||||||
import com.facebook.appevents.AppEventsConstants;
|
import com.facebook.appevents.AppEventsConstants;
|
||||||
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
|
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
|
||||||
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
|
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
|
||||||
import com.google.android.gms.common.GooglePlayServicesRepairableException;
|
import com.google.android.gms.common.GooglePlayServicesRepairableException;
|
||||||
|
import com.yunbao.common.CommonAppConfig;
|
||||||
|
import com.yunbao.common.http.CommonHttpUtil;
|
||||||
|
import com.yunbao.common.http.HttpCallback;
|
||||||
import com.yunbao.common.utils.GoogleBillingUtilNew;
|
import com.yunbao.common.utils.GoogleBillingUtilNew;
|
||||||
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.main.R;
|
import com.yunbao.main.R;
|
||||||
import com.yunbao.main.views.TestWebViewClient;
|
import com.yunbao.main.views.TestWebViewClient;
|
||||||
|
|
||||||
@ -79,37 +88,6 @@ public class GoogleFragment extends Fragment {
|
|||||||
|
|
||||||
webSettings.setJavaScriptEnabled(true); // 是否开启JS支持
|
webSettings.setJavaScriptEnabled(true); // 是否开启JS支持
|
||||||
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||||
//
|
|
||||||
// webSettings.setUseWideViewPort(true); // 缩放至屏幕大小
|
|
||||||
// webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕大小
|
|
||||||
// webSettings.setSupportZoom(true); // 是否支持缩放
|
|
||||||
// webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦,前提是支持缩放
|
|
||||||
// webSettings.setDisplayZoomControls(false); // 是否隐藏缩放控件
|
|
||||||
//
|
|
||||||
// webSettings.setAllowFileAccess(true); // 是否允许访问文件
|
|
||||||
// webSettings.setDomStorageEnabled(false); // 是否节点缓存
|
|
||||||
// webSettings.setDatabaseEnabled(false); // 是否数据缓存
|
|
||||||
// webSettings.setAppCacheEnabled(false); // 是否应用缓存
|
|
||||||
//
|
|
||||||
// webSettings.setMediaPlaybackRequiresUserGesture(false); // 是否要手势触发媒体
|
|
||||||
// webSettings.setStandardFontFamily("sans-serif"); // 设置字体库格式
|
|
||||||
// webSettings.setFixedFontFamily("monospace"); // 设置字体库格式
|
|
||||||
// webSettings.setSansSerifFontFamily("sans-serif"); // 设置字体库格式
|
|
||||||
// webSettings.setSerifFontFamily("sans-serif"); // 设置字体库格式
|
|
||||||
// webSettings.setCursiveFontFamily("cursive"); // 设置字体库格式
|
|
||||||
// webSettings.setFantasyFontFamily("fantasy"); // 设置字体库格式
|
|
||||||
// webSettings.setTextZoom(100); // 设置文本缩放的百分比
|
|
||||||
// webSettings.setMinimumFontSize(8); // 设置文本字体的最小值(1~72)
|
|
||||||
// webSettings.setDefaultFontSize(16); // 设置文本字体默认的大小
|
|
||||||
//
|
|
||||||
// webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); // 按规则重新布局
|
|
||||||
// webSettings.setLoadsImagesAutomatically(true); // 是否自动加载图片
|
|
||||||
// webSettings.setDefaultTextEncodingName("UTF-8"); // 设置编码格式
|
|
||||||
// webSettings.setNeedInitialFocus(true); // 是否需要获取焦点
|
|
||||||
// webSettings.setGeolocationEnabled(false); // 设置开启定位功能
|
|
||||||
// webSettings.setBlockNetworkLoads(false); // 是否从网络获取资源
|
|
||||||
// rlWebview.addJavascriptInterface(new JsInteration(), "androidObject");
|
|
||||||
// rlWebview.setWebContentsDebuggingEnabled(true);
|
|
||||||
|
|
||||||
|
|
||||||
rlWebview.addJavascriptInterface(new JsInteration(), "androidObject");
|
rlWebview.addJavascriptInterface(new JsInteration(), "androidObject");
|
||||||
@ -123,180 +101,14 @@ public class GoogleFragment extends Fragment {
|
|||||||
|
|
||||||
|
|
||||||
String TAG = "GooglePay";
|
String TAG = "GooglePay";
|
||||||
//我们自己的订单号
|
|
||||||
ProgressDialog progressDialog;
|
|
||||||
|
|
||||||
private void initGooglePay() {
|
private void initGooglePay() {
|
||||||
// GoogleBillingUtil.isDebug(true);
|
|
||||||
// GoogleBillingUtil.setIsAutoAcknowledgePurchase(true);//设置自动确认购买
|
|
||||||
// googleBillingUtil = GoogleBillingUtil.getInstance()
|
|
||||||
// .addOnGoogleBillingListener(getActivity(), mOnMyGoogleBillingListener)
|
|
||||||
// .build(getActivity());
|
|
||||||
GoogleBillingUtilNew.getInstance().initGooglePay(getActivity());
|
GoogleBillingUtilNew.getInstance().initGooglePay(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// private OnGoogleBillingListener mOnMyGoogleBillingListener = new OnGoogleBillingListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onSetupSuccess(boolean isSelf) {
|
|
||||||
// super.onSetupSuccess(isSelf);
|
|
||||||
// Log.d(TAG, "内购服务初始化完成");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onQuerySuccess(@NonNull String skuType, @NonNull List<SkuDetails> list, boolean isSelf) {
|
|
||||||
//
|
|
||||||
// googleBillingUtil.purchaseInApp(getActivity(), mProductId);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean onPurchaseSuccess(@NonNull Purchase purchase, boolean isSelf) {
|
|
||||||
// StringBuffer tempBuffer = new StringBuffer();
|
|
||||||
//
|
|
||||||
// if (progressDialog != null && progressDialog.isShowing()) {
|
|
||||||
// progressDialog.dismiss();
|
|
||||||
// }
|
|
||||||
// if (purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED) {
|
|
||||||
// tempBuffer.append("购买成功:");
|
|
||||||
// Log.e(TAG, purchase.getOrderId() + "ProductId" + mProductId + "OrderNumber" + mOrderid);
|
|
||||||
//
|
|
||||||
// //通知自己服务器
|
|
||||||
//// if (mOrderid == null || purchase.getOrderId() == null){
|
|
||||||
//// return false;
|
|
||||||
//// }
|
|
||||||
//// googleBillingUtil.consumeAsync(GooglePayActivity.this,purchase.getPurchaseToken());
|
|
||||||
// CommonHttpUtil.notifyGoogle(purchase.getPurchaseToken(), purchase.getOrderId(), mProductId, mOrderid, adid, new HttpCallback() {
|
|
||||||
// @Override
|
|
||||||
// public void onSuccess(int code, String msg, String[] info) {
|
|
||||||
// if (code == 0) {
|
|
||||||
// try {
|
|
||||||
//// String r_url = CommonAppConfig.HOST +"?g=Appapi&m=Mall&a=paysuss&status=1";
|
|
||||||
//// rlWebview.loadUrl(r_url);
|
|
||||||
// Bundle params = new Bundle();
|
|
||||||
// params.putString("currency", "HKD");
|
|
||||||
// params.putString("money", MoneyUsds);
|
|
||||||
// logger.logEvent("FB_iap_Play", params);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Bundle fb_params = new Bundle();
|
|
||||||
// fb_params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD");
|
|
||||||
// fb_params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId);
|
|
||||||
//
|
|
||||||
// //fb官方事件记录充值
|
|
||||||
// logger.logEvent(AppEventsConstants.EVENT_NAME_PURCHASED,
|
|
||||||
// Double.parseDouble(MoneyUsds),
|
|
||||||
// fb_params);
|
|
||||||
//
|
|
||||||
// //Google官方充值通知
|
|
||||||
// Bundle google_params = new Bundle();
|
|
||||||
// google_params.putString("currency", "HKD");
|
|
||||||
// google_params.putString("product_id", mProductId);
|
|
||||||
// google_params.putString("transaction_id", mOrderid);
|
|
||||||
// google_params.putString("value", MoneyUsds);
|
|
||||||
// google_params.putString("price", MoneyUsds);
|
|
||||||
// google_params.putString("quantity", "1");
|
|
||||||
//
|
|
||||||
// mFirebaseAnalytics.logEvent("FS_iap_Play", google_params);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// AdjustEvent adjustEvent1 = new AdjustEvent("cgssol");
|
|
||||||
// Adjust.trackEvent(adjustEvent1);
|
|
||||||
// CommonHttpUtil.setAdvertisingChannels("cgssol", new HttpCallback() {
|
|
||||||
// @Override
|
|
||||||
// public void onSuccess(int code, String msg, String[] info) {
|
|
||||||
// if (code == 0) {
|
|
||||||
// logger.logEvent("FB_iap_users", null);
|
|
||||||
// mFirebaseAnalytics.logEvent("FS_iap_users", null);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
//// AdjustEvent adjustEvent2 = new AdjustEvent("tr8lb9");
|
|
||||||
//// adjustEvent2.setRevenue(Double.parseDouble(MoneyUsds),"HKD");
|
|
||||||
//// adjustEvent2.addCallbackParameter("GOrderid",purchase.getOrderId());
|
|
||||||
//// adjustEvent2.addCallbackParameter("POrderid",mOrderid);
|
|
||||||
//// adjustEvent2.addCallbackParameter("Uid",CommonAppConfig.getInstance().getUid());
|
|
||||||
//// adjustEvent2.addCallbackParameter("GADid",adid);
|
|
||||||
//// adjustEvent2.setOrderId(mOrderid);
|
|
||||||
//// Adjust.trackEvent(adjustEvent2);
|
|
||||||
//
|
|
||||||
// ToastUtil.show("购买成功");
|
|
||||||
// getActivity().onBackPressed();
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
//// String r_url = CommonAppConfig.HOST +"?g=Appapi&m=Mall&a=paysuss&status=0";
|
|
||||||
//// rlWebview.loadUrl(r_url);
|
|
||||||
// ToastUtil.show("购买失败,请联系客服");
|
|
||||||
// getActivity().onBackPressed();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
//
|
|
||||||
// progressDialog.setTitle("正在處理");
|
|
||||||
// progressDialog.setMessage("系統檢測到您的卡是慢速卡,正在處理您的訂單,大概需要一分鐘,請勿離開,若因離開此頁面導致支付失敗,請聯系在線客服");
|
|
||||||
// progressDialog.setCancelable(false);
|
|
||||||
// progressDialog.show();
|
|
||||||
// tempBuffer.append("暂未支付:");
|
|
||||||
// }
|
|
||||||
// String details = String.format(Locale.getDefault(), "%s \n", purchase.getSku());
|
|
||||||
// tempBuffer.append(details);
|
|
||||||
// Log.d(TAG, tempBuffer.toString());
|
|
||||||
// return true;//自动消耗(只有当isSelf为true,并且支付状态为PURCHASED时,该值才会生效)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean onRecheck(@NonNull String skuType, @NonNull Purchase purchase, boolean isSelf) {
|
|
||||||
// StringBuffer tempBuffer = new StringBuffer();
|
|
||||||
// tempBuffer.append("检测到未处理的订单($skuType):${purchase.sku}()");
|
|
||||||
// Log.d(TAG, tempBuffer.toString());
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onBillingServiceDisconnected() {
|
|
||||||
// super.onBillingServiceDisconnected();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onConsumeSuccess(@NonNull String purchaseToken, boolean isSelf) {
|
|
||||||
// Log.d(TAG, "消耗商品成功:$purchaseToken");
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onAcknowledgePurchaseSuccess(boolean isSelf) {
|
|
||||||
// Log.d(TAG, "确认购买商品成功");
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onFail(@NonNull GoogleBillingUtil.GoogleBillingListenerTag tag, int responseCode, boolean isSelf) {
|
|
||||||
// Log.d(TAG, "操作失败:tag=${" + tag.name() + "responseCode=" + responseCode);
|
|
||||||
//// String r_url = CommonAppConfig.HOST +"?g=Appapi&m=Mall&a=paysuss&status=0";
|
|
||||||
//// rlWebview.loadUrl(r_url);
|
|
||||||
//// ToastUtil.show("购买失败,请联系客服");
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onError(@NonNull GoogleBillingUtil.GoogleBillingListenerTag tag, boolean isSelf) {
|
|
||||||
// Log.d(TAG, "发生错误:tag=" + tag.name());
|
|
||||||
//// String r_url = CommonAppConfig.HOST +"?g=Appapi&m=Mall&a=paysuss&status=0";
|
|
||||||
//// rlWebview.loadUrl(r_url);
|
|
||||||
//// ToastUtil.show("购买失败,请联系客服");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
// private GoogleBillingUtil googleBillingUtil;
|
|
||||||
|
|
||||||
|
private Handler payHandler = new Handler();
|
||||||
//js调用原生
|
//js调用原生
|
||||||
public class JsInteration {
|
public class JsInteration {
|
||||||
|
|
||||||
@ -312,6 +124,71 @@ public class GoogleFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onPaySuccess(List<Purchase> list) {
|
public void onPaySuccess(List<Purchase> list) {
|
||||||
for (Purchase purchase : list) {
|
for (Purchase purchase : list) {
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
int finalI = i;
|
||||||
|
payHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
CommonHttpUtil.notifyGoogle(list.get(finalI).getPurchaseToken(), list.get(finalI).getOrderId(), mProductId, mOrderid, adid, new HttpCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(int code, String msg, String[] info) {
|
||||||
|
if (code == 0) {
|
||||||
|
Bundle params = new Bundle();
|
||||||
|
params.putString("currency", "HKD");
|
||||||
|
params.putString("money", MoneyUsds);
|
||||||
|
logger.logEvent("FB_iap_Play", params);
|
||||||
|
|
||||||
|
|
||||||
|
Bundle fb_params = new Bundle();
|
||||||
|
fb_params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD");
|
||||||
|
fb_params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId);
|
||||||
|
|
||||||
|
//fb官方事件记录充值
|
||||||
|
logger.logEvent(AppEventsConstants.EVENT_NAME_PURCHASED,
|
||||||
|
Double.parseDouble(MoneyUsds),
|
||||||
|
fb_params);
|
||||||
|
|
||||||
|
//Google官方充值通知
|
||||||
|
Bundle google_params = new Bundle();
|
||||||
|
google_params.putString("currency", "HKD");
|
||||||
|
google_params.putString("product_id", mProductId);
|
||||||
|
google_params.putString("transaction_id", mOrderid);
|
||||||
|
google_params.putString("value", MoneyUsds);
|
||||||
|
google_params.putString("price", MoneyUsds);
|
||||||
|
google_params.putString("quantity", "1");
|
||||||
|
|
||||||
|
mFirebaseAnalytics.logEvent("FS_iap_Play", google_params);
|
||||||
|
|
||||||
|
|
||||||
|
AdjustEvent adjustEvent1 = new AdjustEvent("cgssol");
|
||||||
|
Adjust.trackEvent(adjustEvent1);
|
||||||
|
CommonHttpUtil.setAdvertisingChannels("cgssol", new HttpCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(int code, String msg, String[] info) {
|
||||||
|
if (code == 0) {
|
||||||
|
logger.logEvent("FB_iap_users", null);
|
||||||
|
mFirebaseAnalytics.logEvent("FS_iap_users", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AdjustEvent adjustEvent2 = new AdjustEvent("tr8lb9");
|
||||||
|
adjustEvent2.setRevenue(Double.parseDouble(MoneyUsds),"HKD");
|
||||||
|
adjustEvent2.addCallbackParameter("GOrderid",purchase.getOrderId());
|
||||||
|
adjustEvent2.addCallbackParameter("POrderid",mOrderid);
|
||||||
|
adjustEvent2.addCallbackParameter("Uid", CommonAppConfig.getInstance().getUid());
|
||||||
|
adjustEvent2.addCallbackParameter("GADid",adid);
|
||||||
|
adjustEvent2.setOrderId(mOrderid);
|
||||||
|
Adjust.trackEvent(adjustEvent2);
|
||||||
|
|
||||||
|
dis();
|
||||||
|
ToastUtil.show("支付成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
Log.e("谷歌支付", purchase.toString());
|
Log.e("谷歌支付", purchase.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -346,10 +223,5 @@ public class GoogleFragment extends Fragment {
|
|||||||
|
|
||||||
public void release() {
|
public void release() {
|
||||||
|
|
||||||
// if (googleBillingUtil != null) {
|
|
||||||
// googleBillingUtil.onDestroy(getActivity());
|
|
||||||
// //退出程序的时候可以调用(实验性)
|
|
||||||
// GoogleBillingUtil.endConnection();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,120 +188,11 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
return R.layout.activity_main;
|
return R.layout.activity_main;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GoogleBillingUtil googleBillingUtil;
|
|
||||||
|
|
||||||
private OnGoogleBillingListener mOnMyGoogleBillingListener = new OnGoogleBillingListener() {
|
|
||||||
@Override
|
|
||||||
public void onSetupSuccess(boolean isSelf) {
|
|
||||||
super.onSetupSuccess(isSelf);
|
|
||||||
Log.d(TAG, "内购服务初始化完成");
|
|
||||||
// googleBillingUtil.queryPurchaseHistoryAsyncInApp(new PurchaseHistoryResponseListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onPurchaseHistoryResponse(@NonNull BillingResult billingResult, @Nullable List<PurchaseHistoryRecord> list) {
|
|
||||||
// Log.e(TAG,list.get(0).getPurchaseToken());
|
|
||||||
// //谷歌掉单处理
|
|
||||||
//// CommonHttpUtil.Google_sec_pay(purchase.getPurchaseToken(), purchase.getOrderId(), purchase.getSku(), new HttpCallback() {
|
|
||||||
//// @Override
|
|
||||||
//// public void onSuccess(int code, String msg, String[] info) {
|
|
||||||
////
|
|
||||||
//// }
|
|
||||||
//// });
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
List<Purchase> data = googleBillingUtil.queryPurchasesInApp(MainActivity.this);
|
|
||||||
if(data!=null&&data.size()>0) {
|
|
||||||
Log.e(TAG," data.get(0).getSku()");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onQuerySuccess(@NonNull String skuType, @NonNull List<SkuDetails> list, boolean isSelf) {
|
|
||||||
|
|
||||||
Log.d(TAG, "1111");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPurchaseSuccess(@NonNull Purchase purchase, boolean isSelf) {
|
|
||||||
StringBuffer tempBuffer = new StringBuffer();
|
|
||||||
|
|
||||||
if (purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED) {
|
|
||||||
tempBuffer.append("购买成功:");
|
|
||||||
//通知自己服务器
|
|
||||||
if (purchase.getOrderId() == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
googleBillingUtil.consumeAsync(MainActivity.this, purchase.getPurchaseToken());
|
|
||||||
} else {
|
|
||||||
|
|
||||||
tempBuffer.append("暂未支付:");
|
|
||||||
}
|
|
||||||
String details = String.format(Locale.getDefault(), "%s \n", "purchase.getSku()");
|
|
||||||
tempBuffer.append(details);
|
|
||||||
Log.d(TAG, tempBuffer.toString());
|
|
||||||
return true;//自动消耗(只有当isSelf为true,并且支付状态为PURCHASED时,该值才会生效)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onRecheck(@NonNull String skuType, @NonNull Purchase purchase, boolean isSelf) {
|
|
||||||
Log.e(TAG, "purchase.getSku()" + "s" + purchase.getOrderId() + "sds" + purchase.getPurchaseToken());
|
|
||||||
//谷歌掉单处理
|
|
||||||
CommonHttpUtil.Google_sec_pay(purchase.getPurchaseToken(), purchase.getOrderId(), "purchase.getSku()", new HttpCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(int code, String msg, String[] info) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
StringBuffer tempBuffer = new StringBuffer();
|
|
||||||
tempBuffer.append("检测到未处理的订单($skuType):${purchase.sku}()");
|
|
||||||
Log.d(TAG, tempBuffer.toString());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBillingServiceDisconnected() {
|
|
||||||
super.onBillingServiceDisconnected();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConsumeSuccess(@NonNull String purchaseToken, boolean isSelf) {
|
|
||||||
Log.d(TAG, "消耗商品成功:$purchaseToken");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAcknowledgePurchaseSuccess(boolean isSelf) {
|
|
||||||
Log.d(TAG, "确认购买商品成功");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFail(@NonNull GoogleBillingUtil.GoogleBillingListenerTag tag, int responseCode, boolean isSelf) {
|
|
||||||
Log.d(TAG, "操作失败:tag=${" + tag.name() + "responseCode=" + responseCode);
|
|
||||||
String r_url = CommonAppConfig.HOST + "?g=Appapi&m=Mall&a=paysuss&status=0";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(@NonNull GoogleBillingUtil.GoogleBillingListenerTag tag, boolean isSelf) {
|
|
||||||
Log.d(TAG, "发生错误:tag=" + tag.name());
|
|
||||||
String r_url = CommonAppConfig.HOST + "?g=Appapi&m=Mall&a=paysuss&status=0";
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void main() {
|
protected void main() {
|
||||||
ConversationIMListManager.get(this);
|
ConversationIMListManager.get(this);
|
||||||
//谷歌支付
|
|
||||||
GoogleBillingUtil.setIsAutoAcknowledgePurchase(true);//设置自动确认购买
|
|
||||||
googleBillingUtil = GoogleBillingUtil.getInstance()
|
|
||||||
.addOnGoogleBillingListener(MainActivity.this, mOnMyGoogleBillingListener)
|
|
||||||
.build(MainActivity.this);
|
|
||||||
|
|
||||||
|
|
||||||
//在请求一下这个接口给我后台版本号
|
//在请求一下这个接口给我后台版本号
|
||||||
CommonHttpUtil.getConfig(mContext, new CommonCallback<ConfigBean>() {
|
CommonHttpUtil.getConfig(mContext, new CommonCallback<ConfigBean>() {
|
||||||
|
@ -30,6 +30,7 @@ import com.yunbao.common.http.CommonHttpUtil;
|
|||||||
import com.yunbao.common.http.HttpCallback;
|
import com.yunbao.common.http.HttpCallback;
|
||||||
import com.yunbao.common.utils.GoogleBillingUtilNew;
|
import com.yunbao.common.utils.GoogleBillingUtilNew;
|
||||||
import com.yunbao.common.utils.RouteUtil;
|
import com.yunbao.common.utils.RouteUtil;
|
||||||
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
import com.yunbao.main.R;
|
import com.yunbao.main.R;
|
||||||
import com.yunbao.main.utils.HXLinePagerIndicator;
|
import com.yunbao.main.utils.HXLinePagerIndicator;
|
||||||
@ -94,14 +95,16 @@ public class MyWalletActivity extends AbsActivity {
|
|||||||
CommonHttpUtil
|
CommonHttpUtil
|
||||||
.Google_sec_pay(list.get(finalI).getPurchaseToken(),
|
.Google_sec_pay(list.get(finalI).getPurchaseToken(),
|
||||||
list.get(finalI).getOrderId(),
|
list.get(finalI).getOrderId(),
|
||||||
list.get(finalI).getProducts().toString(),
|
list.get(finalI).getProducts().get(0),
|
||||||
new HttpCallback() {
|
new HttpCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(int code, String msg, String[] info) {
|
public void onSuccess(int code, String msg, String[] info) {
|
||||||
if (finalI == list.size() - 1) {
|
if (finalI == list.size() - 1) {
|
||||||
loadingDialog.setShowText(getString(R.string.order_query_success));
|
loadingDialog.setShowText(getString(R.string.order_query_success));
|
||||||
payHandler.postDelayed(() -> loadingDialog.dismiss(), 2000);
|
loadingDialog.dismiss();
|
||||||
}
|
}
|
||||||
|
ToastUtil.show("充值已到账");
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@ public class MainHttpUtil {
|
|||||||
HttpClient.getInstance().get("Login.userLoginByThird", MainHttpConsts.LOGIN_BY_THIRD)
|
HttpClient.getInstance().get("Login.userLoginByThird", MainHttpConsts.LOGIN_BY_THIRD)
|
||||||
.params("openid", openid)
|
.params("openid", openid)
|
||||||
.params("nicename", nicename)
|
.params("nicename", nicename)
|
||||||
|
.params("app_project", "1")
|
||||||
.params("avatar", avatar)
|
.params("avatar", avatar)
|
||||||
.params("type", type)
|
.params("type", type)
|
||||||
.params("source", DEVICE)
|
.params("source", DEVICE)
|
||||||
@ -79,6 +80,7 @@ public class MainHttpUtil {
|
|||||||
String sign = MD5Util.getMD5("openid=" + openid + "&" + SALT);
|
String sign = MD5Util.getMD5("openid=" + openid + "&" + SALT);
|
||||||
HttpClient.getInstance().get("Login.userLoginByThird", MainHttpConsts.LOGIN_BY_THIRD)
|
HttpClient.getInstance().get("Login.userLoginByThird", MainHttpConsts.LOGIN_BY_THIRD)
|
||||||
.params("openid", openid)
|
.params("openid", openid)
|
||||||
|
.params("app_project", "1")
|
||||||
.params("admin_id", promoCode)
|
.params("admin_id", promoCode)
|
||||||
.params("uuid_Device", uuidDevice)
|
.params("uuid_Device", uuidDevice)
|
||||||
.params("nicename", nicename)
|
.params("nicename", nicename)
|
||||||
@ -550,6 +552,7 @@ public class MainHttpUtil {
|
|||||||
public static void register(String invitecode, String user_login, String promo_code, String uuidDevice, int countryCode, String pass, String pass2, String code, HttpCallback callback) {
|
public static void register(String invitecode, String user_login, String promo_code, String uuidDevice, int countryCode, String pass, String pass2, String code, HttpCallback callback) {
|
||||||
HttpClient.getInstance().get("Login.userReg", MainHttpConsts.REGISTER)
|
HttpClient.getInstance().get("Login.userReg", MainHttpConsts.REGISTER)
|
||||||
.params("user_login", user_login)
|
.params("user_login", user_login)
|
||||||
|
.params("app_project", "1")
|
||||||
//增加参数:推广码
|
//增加参数:推广码
|
||||||
.params("user_activation_key", promo_code)
|
.params("user_activation_key", promo_code)
|
||||||
.params("admin_id", promo_code)
|
.params("admin_id", promo_code)
|
||||||
|
Loading…
Reference in New Issue
Block a user