diff --git a/common/build.gradle b/common/build.gradle index 931e41955..f20b49dc9 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -229,7 +229,7 @@ dependencies { api project(':lib_google') //samsung插件包 - api project(':IAP6Helper') + //api project(':IAP6Helper') //時間選擇器 api 'com.contrarywind:Android-PickerView:4.1.9' diff --git a/common/libs/samsung-iap-6.1.1.aar b/common/libs/samsung-iap-6.1.1.aar new file mode 100644 index 000000000..4195da69d Binary files /dev/null and b/common/libs/samsung-iap-6.1.1.aar differ diff --git a/common/src/main/java/com/yunbao/common/pay/samsung/SamsungUtil.java b/common/src/main/java/com/yunbao/common/pay/samsung/SamsungUtil.java index 0cacbf03e..d4b4080e2 100644 --- a/common/src/main/java/com/yunbao/common/pay/samsung/SamsungUtil.java +++ b/common/src/main/java/com/yunbao/common/pay/samsung/SamsungUtil.java @@ -3,14 +3,16 @@ package com.yunbao.common.pay.samsung; import android.content.Context; import com.google.gson.Gson; -import com.samsung.android.sdk.iap.lib2.helper.HelperDefine; -import com.samsung.android.sdk.iap.lib2.helper.IapHelper; -import com.samsung.android.sdk.iap.lib2.listener.OnConsumePurchasedItemsListener; -import com.samsung.android.sdk.iap.lib2.listener.OnGetOwnedListListener; -import com.samsung.android.sdk.iap.lib2.listener.OnPaymentListener; -import com.samsung.android.sdk.iap.lib2.vo.ConsumeVo; -import com.samsung.android.sdk.iap.lib2.vo.ErrorVo; -import com.samsung.android.sdk.iap.lib2.vo.OwnedProductVo; +import com.samsung.android.sdk.iap.lib.constants.HelperDefine; +import com.samsung.android.sdk.iap.lib.helper.IapHelper; +import com.samsung.android.sdk.iap.lib.listener.OnConsumePurchasedItemsListener; +import com.samsung.android.sdk.iap.lib.listener.OnGetOwnedListListener; +import com.samsung.android.sdk.iap.lib.listener.OnPaymentListener; +import com.samsung.android.sdk.iap.lib.vo.ConsumeVo; +import com.samsung.android.sdk.iap.lib.vo.ErrorVo; +import com.samsung.android.sdk.iap.lib.vo.OwnedProductVo; +import com.samsung.android.sdk.iap.lib.vo.PurchaseVo; +import com.yunbao.common.R; import com.yunbao.common.utils.L; import java.util.ArrayList; @@ -57,9 +59,27 @@ public class SamsungUtil { */ public void buy(String skuId, OnPaymentListener onPaymentListener) { //购买 - iapHelper.startPayment(skuId, "", onPaymentListener); + iapHelper.startPayment(skuId, "", (errorVo, purchaseVo) -> { + if (purchaseVo != null) { + onPaymentListener.onPaymentSuccess(purchaseVo.getPurchaseId()); + } else { + if (errorVo.getErrorCode() == HelperDefine.IAP_PAYMENT_IS_CANCELED) { + onPaymentListener.onPaymentFailed(mContext.getString(R.string.pay_cancel)); + } else { + onPaymentListener.onPaymentFailed(errorVo.getErrorString()); + } + } + + }); } + public interface OnPaymentListener { + void onPaymentSuccess(String purchaseVo); + + void onPaymentFailed(String errorVo); + } + + /** * 消耗指定商品 * diff --git a/config.gradle b/config.gradle index 31994f1d9..87f2c9b5a 100644 --- a/config.gradle +++ b/config.gradle @@ -22,7 +22,7 @@ ext { // true表示谷歌支付 false // isGooglePlay : false, // true表示谷歌支付 false 0 链接包 1 谷歌包 2华为包 - isGooglePlay : 1, + isGooglePlay : 3, //是否上报异常日志 isUploadLog : true, diff --git a/main/src/main/java/com/yunbao/main/activity/SamsungFragment.java b/main/src/main/java/com/yunbao/main/activity/SamsungFragment.java index 32b02eaba..8fa0a3d02 100644 --- a/main/src/main/java/com/yunbao/main/activity/SamsungFragment.java +++ b/main/src/main/java/com/yunbao/main/activity/SamsungFragment.java @@ -14,10 +14,6 @@ import android.webkit.WebView; import androidx.fragment.app.Fragment; -import com.samsung.android.sdk.iap.lib2.helper.HelperDefine; -import com.samsung.android.sdk.iap.lib2.listener.OnPaymentListener; -import com.samsung.android.sdk.iap.lib2.vo.ErrorVo; -import com.samsung.android.sdk.iap.lib2.vo.PurchaseVo; import com.yunbao.common.pay.samsung.SamsungUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; @@ -99,15 +95,13 @@ public class SamsungFragment extends Fragment { mProductId = ProductId; mOrderid = OrderNumber; MoneyUsds = MoneyUsd; - - SamsungUtil.newInstance(getActivity()).buy(mProductId, new OnPaymentListener() { + SamsungUtil.newInstance(getActivity()).buy(mProductId, new SamsungUtil.OnPaymentListener() { @Override - public void onPayment(ErrorVo _errorVO, PurchaseVo _purchaseVO) { - if (_purchaseVO != null) { - SamsungUtil.newInstance(getActivity()).consume(_purchaseVO.getPurchaseId()); - payHandler.post(new Runnable() { - @Override - public void run() { + public void onPaymentSuccess(String purchaseVo) { + SamsungUtil.newInstance(getActivity()).consume(purchaseVo); + payHandler.post(new Runnable() { + @Override + public void run() { // CommonHttpUtil.notifySamsung(_purchaseVO.getPurchaseId(), mOrderid, new HttpCallback() { // @Override // public void onSuccess(int code, String msg, String[] info) { @@ -117,23 +111,22 @@ public class SamsungFragment extends Fragment { // } // } // }); - } - }); - } else { - payHandler.post(new Runnable() { - @Override - public void run() { - if (_errorVO.getErrorCode() == HelperDefine.IAP_PAYMENT_IS_CANCELED) { - ToastUtil.show(getString(R.string.pay_cancel)); - } else { - ToastUtil.show(_errorVO.getErrorString()); - } - } - }); - } + } + }); + } + + @Override + public void onPaymentFailed(String errorVo) { + payHandler.post(new Runnable() { + @Override + public void run() { + ToastUtil.show(errorVo); + } + }); } }); } + lastClickTime = currentTime; Log.e(TAG, "ProductId" + ProductId + "OrderNumber" + OrderNumber + "MoneyUsd" + MoneyUsd); @@ -149,6 +142,7 @@ public class SamsungFragment extends Fragment { public void androidGoBack() { getActivity().onBackPressed(); } + } diff --git a/settings.gradle b/settings.gradle index b391e1573..c0913d2fb 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,4 +6,4 @@ include ':Share' include ':pluginsForAnchor' //include ':lib_huawei' include ':lib_google' -include ':IAP6Helper' +//include ':IAP6Helper'