新增Google内购相关代码
This commit is contained in:
@@ -91,6 +91,15 @@ dependencies {
|
||||
|
||||
api 'com.tencent.bugly:crashreport:4.1.9'
|
||||
|
||||
//firebase推送、统计
|
||||
implementation 'com.google.firebase:firebase-messaging:22.0.0'
|
||||
implementation 'com.google.android.gms:play-services-base:17.6.0'
|
||||
implementation 'com.google.firebase:firebase-core:19.0.0'
|
||||
|
||||
//googleplay内购
|
||||
api 'com.google.android.gms:play-services-wallet:18.1.3'
|
||||
api 'com.android.billingclient:billing:4.0.0'
|
||||
|
||||
api project(':nim_uikit')
|
||||
api project(':library')
|
||||
api project(':trtc_release')
|
||||
|
@@ -265,4 +265,6 @@ public class XChatConstants {
|
||||
(byte) 0x33, (byte) 0x3f, (byte) 0x33, (byte) 0x90, (byte) 0x07, (byte) 0x53, (byte) 0xeb, (byte) 0xd2, (byte) 0xd2,
|
||||
(byte) 0x4e, (byte) 0xc5, (byte) 0xed, (byte) 0xfd, (byte) 0x43
|
||||
};
|
||||
|
||||
public static final int CODE_IGNORE_TOAST = 5263;
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.bean.response.result.ChargeListResult;
|
||||
import com.yizhuan.xchat_android_core.pay.bean.FirstChargeGoods;
|
||||
import com.yizhuan.xchat_android_core.pay.bean.NewUserChargeInfo;
|
||||
import com.yizhuan.xchat_android_core.pay.bean.PayRecordId;
|
||||
import com.yizhuan.xchat_android_core.pay.bean.WalletInfo;
|
||||
import com.yizhuan.xchat_android_core.pay.bean.WxPayType;
|
||||
|
||||
@@ -101,4 +102,12 @@ public interface IPayModel extends IModel {
|
||||
Single<List<FirstChargeGoods>> getFirstChargeList();
|
||||
|
||||
Single<NewUserChargeInfo> getNewUserChargeInfo();
|
||||
|
||||
Single<String> verifyOrder(String chargeRecordId,
|
||||
String googlePlayProdId,
|
||||
String packageName,
|
||||
String purchaseToken);
|
||||
|
||||
Single<PayRecordId> placeOrder(String googlePlayProdId);
|
||||
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import android.content.Context;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.yizhuan.xchat_android_constants.XChatConstants;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.base.BaseModel;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
@@ -15,6 +16,7 @@ import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
||||
import com.yizhuan.xchat_android_core.manager.RoomEvent;
|
||||
import com.yizhuan.xchat_android_core.pay.bean.FirstChargeGoods;
|
||||
import com.yizhuan.xchat_android_core.pay.bean.NewUserChargeInfo;
|
||||
import com.yizhuan.xchat_android_core.pay.bean.PayRecordId;
|
||||
import com.yizhuan.xchat_android_core.pay.bean.WalletInfo;
|
||||
import com.yizhuan.xchat_android_core.pay.bean.WxPayType;
|
||||
import com.yizhuan.xchat_android_core.pay.event.ChargeCustomNotificationEvent;
|
||||
@@ -22,6 +24,7 @@ import com.yizhuan.xchat_android_core.pay.event.FirstRechargeEvent;
|
||||
import com.yizhuan.xchat_android_core.pay.event.GetWalletInfoEvent;
|
||||
import com.yizhuan.xchat_android_core.pay.event.UpdateWalletInfoEvent;
|
||||
import com.yizhuan.xchat_android_core.user.event.LoginUserInfoUpdateEvent;
|
||||
import com.yizhuan.xchat_android_core.utils.net.IgnoreException;
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper;
|
||||
import com.yizhuan.xchat_android_library.net.rxnet.RxNet;
|
||||
import com.yizhuan.xchat_android_library.utils.NetworkUtils;
|
||||
@@ -447,6 +450,32 @@ public class PayModel extends BaseModel implements IPayModel {
|
||||
.compose(RxHelper.handleSchAndExce());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<String> verifyOrder(String chargeRecordId,
|
||||
String googlePlayProdId,
|
||||
String packageName,
|
||||
String purchaseToken) {
|
||||
return api.verifyOrder(chargeRecordId, googlePlayProdId, packageName, purchaseToken)
|
||||
.compose(RxHelper.handleException())
|
||||
.flatMap(result -> {
|
||||
if (result.isSuccess()) {
|
||||
return Single.just(result.getData() == null ? "" : result.getData());
|
||||
}
|
||||
if (result.getCode() == XChatConstants.CODE_IGNORE_TOAST) {
|
||||
return Single.error(new IgnoreException("不需要toast提示的错误"));
|
||||
}
|
||||
return Single.error(new Throwable(result.getMessage()));
|
||||
})
|
||||
.compose(RxHelper.handleSchedulers());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<PayRecordId> placeOrder(String googlePlayProdId) {
|
||||
return api.placeOrder(googlePlayProdId)
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchedulers());
|
||||
}
|
||||
|
||||
|
||||
public interface Api {
|
||||
|
||||
@@ -616,6 +645,27 @@ public class PayModel extends BaseModel implements IPayModel {
|
||||
*/
|
||||
@GET("/first/charge/limit/list")
|
||||
Single<ServiceResult<NewUserChargeInfo>> getNewUserChargeInfo();
|
||||
|
||||
/**
|
||||
* 验证googlePlay订单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/googlePlayBilling/verifyOrder")
|
||||
Single<ServiceResult<String>> verifyOrder(@Field("chargeRecordId") String chargeRecordId,
|
||||
@Field("googlePlayProdId") String googlePlayProdId,
|
||||
@Field("packageName") String packageName,
|
||||
@Field("purchaseToken") String purchaseToken);
|
||||
|
||||
/**
|
||||
* googlePlay预下单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/googlePlayBilling/placeOrder")
|
||||
Single<ServiceResult<PayRecordId>> placeOrder(@Field("chargeProdId") String chargeProdId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package com.yizhuan.xchat_android_core.pay.bean;
|
||||
|
||||
import com.android.billingclient.api.SkuDetails;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@@ -23,6 +25,7 @@ public class ChargeBean implements Serializable{
|
||||
public int giftGoldNum;
|
||||
public int channel;
|
||||
public String prodDesc;
|
||||
private SkuDetails skuDetails;
|
||||
|
||||
public boolean isSelected;
|
||||
|
||||
@@ -30,17 +33,6 @@ public class ChargeBean implements Serializable{
|
||||
public ChargeBean(int money) {
|
||||
this.money = money;
|
||||
}
|
||||
// public int seqNo;
|
||||
//
|
||||
//
|
||||
// public int getSeqNo() {
|
||||
// return seqNo;
|
||||
// }
|
||||
//
|
||||
// public void setSeqNo(int seqNo) {
|
||||
// this.seqNo = seqNo;
|
||||
// }
|
||||
|
||||
|
||||
public String getChargeProdId() {
|
||||
return chargeProdId;
|
||||
@@ -82,15 +74,40 @@ public class ChargeBean implements Serializable{
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public String getProdDesc() {
|
||||
return prodDesc;
|
||||
}
|
||||
|
||||
public void setProdDesc(String prodDesc) {
|
||||
this.prodDesc = prodDesc;
|
||||
}
|
||||
|
||||
public SkuDetails getSkuDetails() {
|
||||
return skuDetails;
|
||||
}
|
||||
|
||||
public void setSkuDetails(SkuDetails skuDetails) {
|
||||
this.skuDetails = skuDetails;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return isSelected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
isSelected = selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChargeBean{" +
|
||||
"chargeProdId=" + chargeProdId +
|
||||
"chargeProdId='" + chargeProdId + '\'' +
|
||||
", prodName='" + prodName + '\'' +
|
||||
", money=" + money +
|
||||
", giftGoldNum=" + giftGoldNum +
|
||||
", channel=" + channel +
|
||||
", prodDesc='" + prodDesc + '\'' +
|
||||
", skuDetails=" + skuDetails +
|
||||
", isSelected=" + isSelected +
|
||||
'}';
|
||||
}
|
||||
|
@@ -0,0 +1,14 @@
|
||||
package com.yizhuan.xchat_android_core.pay.bean;
|
||||
|
||||
public class PayRecordId {
|
||||
|
||||
private String recordId;
|
||||
|
||||
public String getRecordId() {
|
||||
return recordId;
|
||||
}
|
||||
|
||||
public void setRecordId(String recordId) {
|
||||
this.recordId = recordId;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package com.yizhuan.xchat_android_core.utils.net;
|
||||
|
||||
/**
|
||||
* 可以忽略的异常,比如不弹toast
|
||||
*/
|
||||
|
||||
public class IgnoreException extends Exception {
|
||||
public IgnoreException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user