三星内购
This commit is contained in:
@@ -216,4 +216,8 @@ dependencies {
|
||||
//google插件包
|
||||
api project(':lib_google')
|
||||
|
||||
//samsung插件包
|
||||
api project(':IAP6Helper')
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.yunbao.common.pay.samsung;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
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.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 java.util.ArrayList;
|
||||
|
||||
public class SamsungUtil {
|
||||
|
||||
public void init(Context context) {
|
||||
//初始化
|
||||
IapHelper iapHelper = IapHelper.getInstance(context);
|
||||
|
||||
//设置支付模式 OPERATION_MODE_TEST 测试模式
|
||||
iapHelper.setOperationMode(HelperDefine.OperationMode.OPERATION_MODE_TEST);
|
||||
|
||||
//查询商品 PRODUCT_TYPE_ITEM 消耗品&非消耗品
|
||||
iapHelper.getOwnedList(HelperDefine.PRODUCT_TYPE_ITEM, new OnGetOwnedListListener() {
|
||||
@Override
|
||||
public void onGetOwnedProducts(ErrorVo _errorVo, ArrayList<OwnedProductVo> _ownedList) {
|
||||
if (_errorVo != null) {
|
||||
if (_errorVo.getErrorCode() == IapHelper.IAP_ERROR_NONE) {
|
||||
if (_ownedList != null) {
|
||||
for (OwnedProductVo item : _ownedList) {
|
||||
if (item.getIsConsumable()) {
|
||||
// TODO: 消耗尚未消耗的消耗品
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// TODO: Handle the error
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//购买
|
||||
iapHelper.startPayment("zs640", "", new OnPaymentListener() {
|
||||
@Override
|
||||
public void onPayment(ErrorVo _errorVO, PurchaseVo _purchaseVO) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
//消耗
|
||||
iapHelper.consumePurchasedItems("zs640", new OnConsumePurchasedItemsListener() {
|
||||
@Override
|
||||
public void onConsumePurchasedItems(ErrorVo _errorVO, ArrayList<ConsumeVo> _consumeList) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user