三星SDK升级

This commit is contained in:
hch 2024-03-26 16:20:24 +08:00
parent 9d528524be
commit 80fd2a1bbc
6 changed files with 52 additions and 38 deletions

View File

@ -229,7 +229,7 @@ dependencies {
api project(':lib_google')
//samsung插件包
api project(':IAP6Helper')
//api project(':IAP6Helper')
//
api 'com.contrarywind:Android-PickerView:4.1.9'

Binary file not shown.

View File

@ -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);
}
/**
* 消耗指定商品
*

View File

@ -22,7 +22,7 @@ ext {
// true表示谷歌支付 false
// isGooglePlay : false,
// true表示谷歌支付 false 0 1 2
isGooglePlay : 1,
isGooglePlay : 3,
//
isUploadLog : true,

View File

@ -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();
}
}

View File

@ -6,4 +6,4 @@ include ':Share'
include ':pluginsForAnchor'
//include ':lib_huawei'
include ':lib_google'
include ':IAP6Helper'
//include ':IAP6Helper'