三星内购调用
This commit is contained in:
parent
c723e14182
commit
a21352302b
@ -402,6 +402,14 @@ public class CommonHttpUtil {
|
|||||||
HttpClient.getInstance().get("Charge.Google_sec_pay", "Charge.Google_sec_pay").params("purchaseToken", purchaseToken).params("orderno", orderNo).params("trade_no", tradeNo).params("package_name", "com.pdlive.shayu").execute(callback);
|
HttpClient.getInstance().get("Charge.Google_sec_pay", "Charge.Google_sec_pay").params("purchaseToken", purchaseToken).params("orderno", orderNo).params("trade_no", tradeNo).params("package_name", "com.pdlive.shayu").execute(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void notifySamsung(String purchaseId, String selfOrderId,HttpCallback callback) {
|
||||||
|
HttpClient.getInstance().get("Charge.SamsungNotify", "Charge.SamsungNotify")
|
||||||
|
.params("purchaseID", purchaseId)
|
||||||
|
.params("SelfOrderId", selfOrderId)
|
||||||
|
.params("PackageName", "pd")
|
||||||
|
.execute(callback);
|
||||||
|
}
|
||||||
|
|
||||||
//不做任何操作的HttpCallback
|
//不做任何操作的HttpCallback
|
||||||
public static final HttpCallback NO_CALLBACK = new HttpCallback() {
|
public static final HttpCallback NO_CALLBACK = new HttpCallback() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,6 +2,7 @@ package com.yunbao.common.pay.samsung;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.samsung.android.sdk.iap.lib.helper.HelperDefine;
|
import com.samsung.android.sdk.iap.lib.helper.HelperDefine;
|
||||||
import com.samsung.android.sdk.iap.lib.helper.IapHelper;
|
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.OnConsumePurchasedItemsListener;
|
||||||
@ -48,14 +49,9 @@ public class SamsungUtil {
|
|||||||
*
|
*
|
||||||
* @param skuId
|
* @param skuId
|
||||||
*/
|
*/
|
||||||
public void buy(String skuId) {
|
public void buy(String skuId, OnPaymentListener onPaymentListener) {
|
||||||
//购买
|
//购买
|
||||||
iapHelper.startPayment(skuId, "", new OnPaymentListener() {
|
iapHelper.startPayment(skuId, "", onPaymentListener);
|
||||||
@Override
|
|
||||||
public void onPayment(ErrorVo _errorVO, PurchaseVo _purchaseVO) {
|
|
||||||
L.e(_errorVO.getErrorString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,11 +64,31 @@ public class SamsungUtil {
|
|||||||
iapHelper.consumePurchasedItems(skuId, new OnConsumePurchasedItemsListener() {
|
iapHelper.consumePurchasedItems(skuId, new OnConsumePurchasedItemsListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onConsumePurchasedItems(ErrorVo _errorVO, ArrayList<ConsumeVo> _consumeList) {
|
public void onConsumePurchasedItems(ErrorVo _errorVO, ArrayList<ConsumeVo> _consumeList) {
|
||||||
|
if (_consumeList != null) {
|
||||||
|
L.e("消耗:" + new Gson().toJson(_consumeList));
|
||||||
|
L.e("ErrorVo:" + _errorVO.dump());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void consumeAll(ArrayList<OwnedProductVo> _ownedList) {
|
||||||
|
if (_ownedList.size() > 0) {
|
||||||
|
iapHelper.consumePurchasedItems(_ownedList.get(0).getPurchaseId(), new OnConsumePurchasedItemsListener() {
|
||||||
|
@Override
|
||||||
|
public void onConsumePurchasedItems(ErrorVo _errorVO, ArrayList<ConsumeVo> _consumeList1) {
|
||||||
|
if (_errorVO.getErrorCode() == IapHelper.IAP_ERROR_NONE) {
|
||||||
|
L.e("消耗:" + new Gson().toJson(_consumeList1));
|
||||||
|
L.e("ErrorVo:" + _errorVO.dump());
|
||||||
|
_ownedList.remove(0);
|
||||||
|
consumeAll(_ownedList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消耗所有未消耗的消耗品
|
* 消耗所有未消耗的消耗品
|
||||||
*/
|
*/
|
||||||
@ -84,17 +100,10 @@ public class SamsungUtil {
|
|||||||
if (_errorVo != null) {
|
if (_errorVo != null) {
|
||||||
if (_errorVo.getErrorCode() == IapHelper.IAP_ERROR_NONE) {
|
if (_errorVo.getErrorCode() == IapHelper.IAP_ERROR_NONE) {
|
||||||
if (_ownedList != null) {
|
if (_ownedList != null) {
|
||||||
for (OwnedProductVo item : _ownedList) {
|
consumeAll(_ownedList);
|
||||||
if (item.getIsConsumable()) {
|
|
||||||
// TODO: 消耗尚未消耗的消耗品
|
|
||||||
consume(item.getPurchaseId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// TODO: Handle the error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,9 @@ ext {
|
|||||||
]
|
]
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
//正式、
|
//正式、
|
||||||
serverHost : "https://napi.yaoulive.com",
|
//serverHost : "https://napi.yaoulive.com",
|
||||||
// 测试
|
// 测试
|
||||||
//serverHost : " https://ceshi.yaoulive.com",
|
serverHost : " https://ceshi.yaoulive.com",
|
||||||
|
|
||||||
//百度语音识别
|
//百度语音识别
|
||||||
|
|
||||||
|
@ -147,8 +147,12 @@ public class MyWalletActivity extends AbsActivity {
|
|||||||
googleUtils.queryPurchasesAsync();
|
googleUtils.queryPurchasesAsync();
|
||||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||||
hwBuilder.consume();
|
hwBuilder.consume();
|
||||||
payHandler.postDelayed(runnable1, 1000);
|
payHandler.post(runnable1);
|
||||||
payHandler.postDelayed(runnable2, 1000);
|
payHandler.postDelayed(runnable2, 1000);
|
||||||
|
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||||
|
samsungUtil.query();
|
||||||
|
payHandler.post(runnable1);
|
||||||
|
payHandler.postDelayed(runnable2, 2000);
|
||||||
} else {
|
} else {
|
||||||
payHandler.post(runnable1);
|
payHandler.post(runnable1);
|
||||||
payHandler.postDelayed(runnable2, 1000);
|
payHandler.postDelayed(runnable2, 1000);
|
||||||
@ -213,12 +217,12 @@ public class MyWalletActivity extends AbsActivity {
|
|||||||
|
|
||||||
samsungFragment1 = new SamsungFragment();
|
samsungFragment1 = new SamsungFragment();
|
||||||
Bundle bundle1 = new Bundle();
|
Bundle bundle1 = new Bundle();
|
||||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||||
samsungFragment1.setArguments(bundle1);
|
samsungFragment1.setArguments(bundle1);
|
||||||
|
|
||||||
samsungFragment2 = new SamsungFragment();
|
samsungFragment2 = new SamsungFragment();
|
||||||
Bundle bundle2 = new Bundle();
|
Bundle bundle2 = new Bundle();
|
||||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||||
samsungFragment2.setArguments(bundle2);
|
samsungFragment2.setArguments(bundle2);
|
||||||
} else {
|
} else {
|
||||||
walletFragment = new WalletFragment();
|
walletFragment = new WalletFragment();
|
||||||
@ -272,6 +276,7 @@ public class MyWalletActivity extends AbsActivity {
|
|||||||
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||||
huaWeiFragment2.setArguments(bundle2);
|
huaWeiFragment2.setArguments(bundle2);
|
||||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||||
|
rView.setVisibility(View.VISIBLE);
|
||||||
walletFragment = new WalletFragment();
|
walletFragment = new WalletFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||||
@ -279,12 +284,12 @@ public class MyWalletActivity extends AbsActivity {
|
|||||||
|
|
||||||
samsungFragment1 = new SamsungFragment();
|
samsungFragment1 = new SamsungFragment();
|
||||||
Bundle bundle1 = new Bundle();
|
Bundle bundle1 = new Bundle();
|
||||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||||
samsungFragment1.setArguments(bundle1);
|
samsungFragment1.setArguments(bundle1);
|
||||||
|
|
||||||
samsungFragment2 = new SamsungFragment();
|
samsungFragment2 = new SamsungFragment();
|
||||||
Bundle bundle2 = new Bundle();
|
Bundle bundle2 = new Bundle();
|
||||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||||
samsungFragment2.setArguments(bundle2);
|
samsungFragment2.setArguments(bundle2);
|
||||||
} else {
|
} else {
|
||||||
Log.i("tss", "不是首充");
|
Log.i("tss", "不是首充");
|
||||||
@ -389,6 +394,11 @@ public class MyWalletActivity extends AbsActivity {
|
|||||||
hwBuilder.consume();
|
hwBuilder.consume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||||
|
if (samsungUtil != null) {
|
||||||
|
samsungUtil.query();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Runnable runnable1 = new Runnable() {
|
private Runnable runnable1 = new Runnable() {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.yunbao.main.activity;
|
package com.yunbao.main.activity;
|
||||||
|
|
||||||
|
|
||||||
|
import static com.yunbao.main.activity.MyWalletActivity.dis;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@ -14,8 +16,15 @@ import android.webkit.WebView;
|
|||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.facebook.appevents.AppEventsConstants;
|
||||||
|
import com.samsung.android.sdk.iap.lib.listener.OnPaymentListener;
|
||||||
|
import com.samsung.android.sdk.iap.lib.vo.ErrorVo;
|
||||||
|
import com.samsung.android.sdk.iap.lib.vo.PurchaseVo;
|
||||||
|
import com.yunbao.common.http.CommonHttpUtil;
|
||||||
|
import com.yunbao.common.http.HttpCallback;
|
||||||
import com.yunbao.common.pay.samsung.SamsungUtil;
|
import com.yunbao.common.pay.samsung.SamsungUtil;
|
||||||
import com.yunbao.common.utils.StringUtil;
|
import com.yunbao.common.utils.StringUtil;
|
||||||
|
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;
|
||||||
|
|
||||||
@ -94,7 +103,35 @@ public class SamsungFragment extends Fragment {
|
|||||||
mOrderid = OrderNumber;
|
mOrderid = OrderNumber;
|
||||||
MoneyUsds = MoneyUsd;
|
MoneyUsds = MoneyUsd;
|
||||||
|
|
||||||
SamsungUtil.newInstance(getActivity()).buy(mProductId);
|
SamsungUtil.newInstance(getActivity()).buy(mProductId, new 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() {
|
||||||
|
CommonHttpUtil.notifySamsung(_purchaseVO.getPurchaseId(), mOrderid, new HttpCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(int code, String msg, String[] info) {
|
||||||
|
if (code == 0) {
|
||||||
|
ToastUtil.show("支付成功");
|
||||||
|
dis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
payHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ToastUtil.show(_errorVO.getErrorString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
lastClickTime = currentTime;
|
lastClickTime = currentTime;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user